Commit Graph

21049 Commits

Author SHA1 Message Date
Martin Pitt dd272d2b0c sosreport: Fix command injection with crafted report names [CVE-2024-2947]
Files in /var/tmp/ are controllable by any user. In particular, an
unprivileged user could create an sosreport* file containing a `'` and a
shell command, which would then run with root privileges when the
admin Cockpit user tried to delete the report.

Use the `cockpit.file()` API instead, which entirely avoids shell. The
main motivation for using shell and the glob was to ensure that the
auxiliary files like *.gpg and *.sha256 get cleaned up -- do that
explicitly (which is much safer anyway), and let our tests make sure
that we don't leave files behind.

https://bugzilla.redhat.com/show_bug.cgi?id=2271614
https://bugzilla.redhat.com/show_bug.cgi?id=2271815

Cherry-picked from main commit 9c4cc9b6df
2024-03-28 09:48:08 +01:00
Allison Karlitskaya c44296cf47 test/static-code: quiet superfluous ruff messages
The `All checks passed!` output in the latest version of ruff is being
interpreted by test/static-code as an error.  Fortunately, `--quiet`
helps.
2024-03-19 22:01:11 +01:00
Allison Karlitskaya e75da57d62 test/browser: run tests in the tasks container 2024-03-19 22:01:11 +01:00
Allison Karlitskaya c262afbbd4 misc: move to new tasks container location 2024-03-18 13:26:34 +01:00
Allison Karlitskaya e693028f5c workflows: run unit-tests in the correct container
This is a backport of da22d7a749.
2024-03-18 13:26:34 +01:00
Allison Karlitskaya 212d807578 .cockpit-ci: pin our container version 2024-03-18 13:26:34 +01:00
Allison Karlitskaya 82c7972f3f test-router: use a different username
The bridge will suppress the username if it is equal to the current
account name.  "user" is a bad choice, then — that's the name of the
default user in our tasks container.

Change it to something less likely.
2024-03-18 13:26:34 +01:00
Martin Pitt 76f30e40d0 test: Convert .format() to f-strings
ruff 0.3.1, which now runs in our "tox" test, and which we will get with
the next tasks container refresh), starts complaining about some
.format() usages.

This is a backport of 6b3fbba882.
2024-03-18 13:26:34 +01:00
Martin Pitt 505bd88496 base1: Hack test-stream failure due to glibc resolver bug
Fedora glibc's resolver hardcodes `getent hosts localhost` to `::1`,
even if there is no IPv6 configured whatsoever (interface addresses or
/etc/hosts) [1][2].

This causes the C bridge to fail the http channel request with

    localhost:44191: couldn't connect: Cannot assign requested address

The Python bridge handles that better, due to not using that obsolete
resolver, so this isn't a problem on main. But we aren't going to fix
that in the C bridge at this point, so hack around it so that it can
pass in GitHub workflow's Fedora (cockpit/tasks) container environment.

[1] https://unix.stackexchange.com/questions/530976/why-does-localhost-resolve-to-1-but-not-127-0-0-1
[2] https://lists.opensuse.org/archives/list/factory@lists.opensuse.org/thread/CITDFVWNRTPZIHVJLA6R5BZ47UIU5RD3/
2024-02-20 11:29:02 +01:00
Martin Pitt d4d347b616 workflows: Run unit tests in our tasks container
This reduces our tools like `ruff` to a single source of truth (as all
our other projects already run their unit tests and linting in the tasks
container). It also removes a lot of moving parts only relevant for CI.
In practice, us developers run the unit tests in toolbox or our own dev
machines anyway.

Move building the guide in the release workflow to the tasks container
as well.

Cherry-picked from main commit f16f1fc14b
2024-02-20 11:29:02 +01:00
Martin Pitt 6487eb1757 workflows: Drop clang unit test
It hasn't helped us in years, modern gcc has good static analysis (plus
of course CodeQL and Coverity), none of our supported downstream distros
care, and we are not going to add significant amounts of C code any
more.

Cherry-picked from main commit 15a98ff833
2024-02-20 11:29:02 +01:00
Martin Pitt 356a7fc0cb workflows: Drop i386 unit test/container
We won't add a lot of new C code any more, valgrinding Python code isn't
very useful (or architecture specific), and more and more distributions
drop i386 support. Also, we still run the unit tests during RPM package
build through packit/COPR, which cover even more architectures.

This paves the way for dropping the unit test container altogether in
favor of running the tests in the cockpit/tasks container, once we agree
on how to build a proper staging setup.

Drop tools/valgrind.supp which was only relevant for i386.

Cherry-picked from main commit 59e1df60b3.
2024-02-20 11:29:02 +01:00
Martin Pitt 040ece86e8 base1: Explicitly set a $TERM for the "pty window size" unit test
`tput` requires `$TERM`. The Debian-based unit test container sets this
by default, but the Fedora based cockpit/tasks container doesn't. Set it
explicitly to a known-good value to make sure the test passes there.

Cherry-picked from main commit b26df150cb
2024-02-20 11:29:02 +01:00
Martin Pitt ed9f3afc9e packit: Put back build job
Without this, the c8s test can't run.
2024-02-15 10:17:19 +01:00
Marius Vollmer f65423c7e4 test: Make our loopback device partitionable
The kernel in ubuntu-2204 has started to require this, while others
don't seem to care.

Cherry-picked from main commit 2aebbbf2c
2024-02-15 09:29:38 +01:00
Marius Vollmer e89d4919bc systemd: Prevent insights-client crash when stdout is closed
INsights-client produces a long backtrace in the journal when it tries
to log a warning or error to a closed stdout. This has started to
hapen recently and causes our tests to fail due to the unexpected
journal messages.

Cherry-picked from main commit afb76670ab
2024-02-14 17:26:26 +01:00
Jelle van der Waa ace15c7714 kdump: stop using obsolete cockpit.extend
This is an shim for Object.assign.

Cherry-picked from main commit 844bab4ec4
2024-02-14 17:26:26 +01:00
Jelle van der Waa d431605c4c lib: update patternfly url to the current version
Cherry-picked from main commit 8fe1defd4c
2024-02-14 17:26:26 +01:00
Marius Vollmer 1a691b6c57 storage: Explicitly round sizes for new partitions
The rest of the storage stack rounds the size down to full MiBs, but
it is better to round them to the nearest MiB for small partitions. So
let's instruct the size slider to do that.  Resizing partitions
already did that, so this change also makes creation consistent with
resizing in this regard.

For example, rounding to nearest will result in a 1 MiB partition when
the user asks for a 1 MB one, instead of the smallest possibe one.

A nice side effect of doing our own rounding is that we get consistent
partition sizes across different versions of UDisks2, which helps
clean up our tests a bit.
2024-02-14 14:17:21 +01:00
Marius Vollmer 0425b932d6 storage: Improve behavior of size slider text and unit inputs
Now the text and unit inputs stay constant when the user changes the
other, and the slider moves accordingly. Previously, the slider would
remain in place and the text input would change when the user changed
the unit input.

I believe this is more natural: When people interact with the text and
unit input, they very like start inputting the number and then they
adjust the unit to what that number should be interpreted in.  In the
old behavior, changing the unit would change the text so that the
resulting value would still be the same. (Changing the unit from GB to
MB would multiply the text by 1000.)

This was however masked by a bug: the text input did not actually
change, although the SizeSLider component would pretend that it had.
For example, when the unit was "GB", and the user typed in "1" into
the text input and then changed the unit to "MB", a dialog would still
receive 1 GB as the value of the slider.

With this change, the dialog would receive "1 MB" in this situation.
2024-02-14 14:17:21 +01:00
Martin Pitt eb2e4be2f9 Drop Python bridge
We only support the C bridge on RHEL 8. Drop `--enable-old-bridge` and
make it the default.
2024-02-14 09:23:36 +01:00
Martin Pitt ea4cc7297a workflows: Drop "guide" and "flathub" release jobs
We don't want these for this stable RHEL branch.
2024-02-14 09:23:36 +01:00
Martin Pitt 9902dd3ef5 pf5: Don't hide long dialog titles
A lot of our dialogs include parts which are not under our control (such
as VM or container names), which can be long. Also, the title templates
themselves may get longer in some translations.

Revert PF's `no-wrap` whitespace option (which partially hides the title
in conjunction with `overflow: hidden`) to `normal`.

This catches a few broken dialogs, update the pixel references.

Cherry-picked from main commit 8f2bed6f74
2024-02-13 11:09:09 +01:00
Martin Pitt b5b8ddf5ae common: Fix crash with unsupported HTTP methods
Commit 96335a440c introduced a crash: Requesting any HTTP method
other than "GET" or "HEAD" segfaulted cockpit_web_response_error() as
`self->method` is NULL. That could happen because
cockpit_web_response_set_method()` refused to set unsupported ones.

Improve the /web-response/head test to set the "HEAD" method right away
with `cockpit_web_response_new()`, instead of overwriting setup()'s
"GET" default.

That was the only consumer of `cockpit_web_response_set_method()`. This
method is rather dubious, as the method should only be set in the
constructor. So eliminate it and move the check into the constructor.

Keep the provided method value also for unknown ones.

Drop the critical, as it's not an internal program error.

Fixes #19997

Cherry-picked from main commit 4c75313ea1
2024-02-13 11:09:09 +01:00
Martin Pitt ce26d9c564 test: Drop obsolete expected "Returning error-response" message
Nothing actually sends this message any more. This gets in the way of
adding a new unit test which *actually* expects a message.

Cherry-picked from main commit eaee13a094.
2024-02-13 11:09:09 +01:00
Martin Pitt e9d2aa23fe workflows: Drop workflows not relevant for rhel-8 branch 2024-02-10 07:59:23 +01:00
Martin Pitt 53714076f1 packit: Restrict jobs to c8s tests
None of the other jobs are relevant for the stable rhel-8 branch.
2024-02-10 07:59:23 +01:00
Jelle van der Waa 0d42a93275 users: handle tab's in lastlog output
Sometimes for longer names lastlog inserts a tab for example for
`systemd-timesync`. This causes `passwd -S` to be unable to look up the
account name.
2024-02-09 15:41:25 +01:00
Marius Vollmer 9ef7bb2139 storage: Put "Edit mount point" into menu in Anaconda mode.
It is probably common that people want to change the mount point of
something from the overview without actually mounting it. Let's not
require them to dive into the details pages for that.
2024-02-09 12:40:18 +02:00
Marius Vollmer c5393f272b storage: No "mismounting" warnings in Anaconda mode
The Anaconda backend mounts and unmounts things as it wants and needs,
and we don't want to bother the user with that.
2024-02-09 12:40:18 +02:00
dependabot[bot] baf27b2e3b build(deps): bump github/codeql-action from 2 to 3
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2 to 3.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/v2...v3)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-09 08:22:47 +01:00
dependabot[bot] a7c62c52ab build(deps): bump redhat-plumbers-in-action/differential-shellcheck
Bumps [redhat-plumbers-in-action/differential-shellcheck](https://github.com/redhat-plumbers-in-action/differential-shellcheck) from 4 to 5.
- [Release notes](https://github.com/redhat-plumbers-in-action/differential-shellcheck/releases)
- [Changelog](https://github.com/redhat-plumbers-in-action/differential-shellcheck/blob/main/docs/CHANGELOG.md)
- [Commits](https://github.com/redhat-plumbers-in-action/differential-shellcheck/compare/v4...v5)

---
updated-dependencies:
- dependency-name: redhat-plumbers-in-action/differential-shellcheck
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-09 07:49:44 +01:00
Jelle van der Waa 56495b7247 .github: update workflow checkout actions to v4
Node.js 16 actions are deprecated. Please update the following actions
to use Node.js 20.
2024-02-09 07:45:44 +01:00
Marius Vollmer a354653a93 storage: Remove AnacondaAdvice scaffolding
It is not going to be used.
2024-02-09 08:37:34 +02:00
dependabot[bot] d8041942a4 Bump js-sha1 from 0.6.0 to 0.7.0
Bumps [js-sha1](https://github.com/emn178/js-sha1) from 0.6.0 to 0.7.0.
- [Changelog](https://github.com/emn178/js-sha1/blob/master/CHANGELOG.md)
- [Commits](https://github.com/emn178/js-sha1/compare/v0.6.0...v0.7.0)

---
updated-dependencies:
- dependency-name: js-sha1
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-09 07:23:41 +01:00
Jelle van der Waa 17165a227e
github: allow dependabot to update github workflow actions
Github usually updates their actions once a while and then warns about a
node env getting deprecated in runs. Which is not super easily spotted
by a developer until it's too late, so let's like npm let dependabot
handle updating.
2024-02-09 07:12:47 +01:00
Jelle van der Waa 6d54e4960c users: get rid of the mix of useEffect and useInit
With useFile the component had a two useEffect's for the same purpose,
reading a file. As we don't need to values available as a variable but
in state, prefer using the existing useInit.
2024-02-08 21:18:42 +01:00
Jelle van der Waa 644d57127d users: drop extraneous getLogins call
cockpit.file().watch() will always do an initial read() to obtain the
content-tag and therefore call setDetails. So in total `useInit` causes
three(!) re-renders.
2024-02-08 21:18:42 +01:00
Jelle van der Waa 5c06dbe40d users: don't fsread1 on file changes for /var/run/utmp
We don't do anything with the content of /var/run/utmp so the file does
not have to be read on file updates.
2024-02-08 21:18:42 +01:00
Marius Vollmer 35c80af69f storage: Navigate to parent after deleting a btrfs subvolume 2024-02-08 16:31:40 +02:00
GitHub Workflow 312fd65791 po: Update from Fedora Weblate
Closes #19969
2024-02-08 12:08:03 +01:00
dependabot[bot] 2f8edeecf4 Bump js-sha256 from 0.10.1 to 0.11.0
Bumps [js-sha256](https://github.com/emn178/js-sha256) from 0.10.1 to 0.11.0.
- [Changelog](https://github.com/emn178/js-sha256/blob/master/CHANGELOG.md)
- [Commits](https://github.com/emn178/js-sha256/compare/v0.10.1...v0.11.0)

---
updated-dependencies:
- dependency-name: js-sha256
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-08 05:07:56 +01:00
Marius Vollmer d2a0a971cd storage: Don't use o.fd.UDisk2.MDRaid.Running property
It is not fully reliably, unfortunately, and sometimes doesn't turn
True after starting the array.
2024-02-07 22:43:32 +01:00
Martin Pitt 1a28b31828 build: Drop ESLint from esbuild
Similar to what commit c9ac6736b3 did for stylelint, move
ESLint to static code checks as well. It already runs from there (and
actually correctly since the previous commit).
2024-02-07 18:35:09 +01:00
Martin Pitt 005cff4c95 test: Fix eslint invocation in static-code
`find_scripts()` previously only accepted two arguments, i.e. one glob.
Make it accept many, which will make test_eslint() *actually* cover
`*.jsx` files.
2024-02-07 18:35:09 +01:00
Martin Pitt 9b5becf16b lib: Fix ESLint error in DynamicListForm
The ESLint call from esbuild didn't catch this as we don't use this
component in Cockpit itself. But the one from test/static-code will
(once it gets fixed to actually work).
2024-02-07 18:35:09 +01:00
Martin Pitt e8967c5385 HACKING: Keep your PR!
We've seen contributors close their PRs after each review and open a new
one. Don't do that.
2024-02-07 17:58:11 +01:00
Martin Pitt 2a26eb407f guide: stylelint fixes
All these were done automatically with `stylelint --fix`. Start to cover
the guide in test/static-code runs.
2024-02-07 16:54:02 +01:00
dependabot[bot] 9dfa967481 Bump the stylelint group with 5 updates
Bumps the stylelint group with 5 updates:

| Package | From | To |
| --- | --- | --- |
| [stylelint](https://github.com/stylelint/stylelint) | `15.11.0` | `16.2.1` |
| [stylelint-config-standard](https://github.com/stylelint/stylelint-config-standard) | `34.0.0` | `36.0.0` |
| [stylelint-config-standard-scss](https://github.com/stylelint-scss/stylelint-config-standard-scss) | `11.1.0` | `13.0.0` |
| [stylelint-formatter-pretty](https://github.com/mrcgrtz/stylelint-formatter-pretty) | `3.2.1` | `4.0.0` |
| [stylelint-use-logical-spec](https://github.com/Jordan-Hall/stylelint-use-logical-spec) | `5.0.0` | `5.0.1` |

Updates `stylelint` from 15.11.0 to 16.2.1
- [Release notes](https://github.com/stylelint/stylelint/releases)
- [Changelog](https://github.com/stylelint/stylelint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/stylelint/stylelint/compare/15.11.0...16.2.1)

Updates `stylelint-config-standard` from 34.0.0 to 36.0.0
- [Release notes](https://github.com/stylelint/stylelint-config-standard/releases)
- [Changelog](https://github.com/stylelint/stylelint-config-standard/blob/main/CHANGELOG.md)
- [Commits](https://github.com/stylelint/stylelint-config-standard/compare/34.0.0...36.0.0)

Updates `stylelint-config-standard-scss` from 11.1.0 to 13.0.0
- [Release notes](https://github.com/stylelint-scss/stylelint-config-standard-scss/releases)
- [Changelog](https://github.com/stylelint-scss/stylelint-config-standard-scss/blob/main/CHANGELOG.md)
- [Commits](https://github.com/stylelint-scss/stylelint-config-standard-scss/compare/v11.1.0...v13.0.0)

Updates `stylelint-formatter-pretty` from 3.2.1 to 4.0.0
- [Release notes](https://github.com/mrcgrtz/stylelint-formatter-pretty/releases)
- [Commits](https://github.com/mrcgrtz/stylelint-formatter-pretty/compare/v3.2.1...v4.0.0)

Updates `stylelint-use-logical-spec` from 5.0.0 to 5.0.1
- [Release notes](https://github.com/Jordan-Hall/stylelint-use-logical-spec/releases)
- [Changelog](https://github.com/Jordan-Hall/stylelint-use-logical-spec/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Jordan-Hall/stylelint-use-logical-spec/commits)

---
updated-dependencies:
- dependency-name: stylelint
  dependency-type: direct:development
  update-type: version-update:semver-major
  dependency-group: stylelint
- dependency-name: stylelint-config-standard
  dependency-type: direct:development
  update-type: version-update:semver-major
  dependency-group: stylelint
- dependency-name: stylelint-config-standard-scss
  dependency-type: direct:development
  update-type: version-update:semver-major
  dependency-group: stylelint
- dependency-name: stylelint-formatter-pretty
  dependency-type: direct:development
  update-type: version-update:semver-major
  dependency-group: stylelint
- dependency-name: stylelint-use-logical-spec
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: stylelint
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-07 15:59:17 +01:00
Martin Pitt 129725da61 CSS: stylelint fixes
Use logical directions, drop obsolete vendor prefix, and various stylistic fixes.

Done automatically with `stylelint --fix`. Fixes e.g.
```
Expected "#EEEEEE" to be "#EEE"                          color-hex-length
Unexpected "min-height" property. Use "min-block-size".  liberty/use-logical-spec
Unexpected vendor-prefix "-moz-transform"        property-no-vendor-prefix
Expected empty line before rule  rule-empty-line-before
```

The only deliberate `moz-*` rule is our Firefox specific checkbox fix,
ignore property-no-vendor-prefix for that one.
2024-02-07 15:59:17 +01:00