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=2271614https://bugzilla.redhat.com/show_bug.cgi?id=2271815
Cherry-picked from main commit 9c4cc9b6df
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.
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.
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
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
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.
`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
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
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.
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.
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
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
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.
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.
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.
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.
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.
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).
`find_scripts()` previously only accepted two arguments, i.e. one glob.
Make it accept many, which will make test_eslint() *actually* cover
`*.jsx` files.
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).
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.