Commit graph

3315 commits

Author SHA1 Message Date
Renata Ravanelli
ca25b07c5c CODEOWNERS: Assign ownership for CoreOS-related files
- Introduce a CODEOWNERS file to designate the CoreOS team as responsible for maintaining files related to CoreOS.
- This change ensures collaborative support, alleviating the burden solely on the osbuild team.
- By assigning ownership, we aim to enhance code quality and responsiveness to issues affecting CoreOS.

Signed-off-by: Renata Ravanelli <rravanel@redhat.com>
2024-12-05 09:28:59 +01:00
Michael Vogt
25d3656068 util,test: add test for new shlex based os-release parsing
This commit adds a tiny unit test for the new `shlex` based
os-release parsing and tweaks the error message in a small
and non-functional way (just because it's slightly nicer
for a user). The test checks for three keys NAME which is
quoted with `"`, ID which is not quoted and OSTREE_VERSION
which is quoted with `'`.
2024-12-04 14:54:00 -05:00
Renata Ravanelli
07d4f6955d util/osrelease.py: Replaced string stripping with shlex.split()
- Replaced string stripping with `shlex.split()` to properly
handle values in the os-release file;
- This ensures cleaner and more accurate key-value assignments,
follwing a broader set of shell-like parsing rules;
- Add os-release file for Fedora CoreOS 40 for testing.

Signed-off-by: Renata Ravanelli <rravanel@redhat.com>
2024-12-04 14:54:00 -05:00
Dusty Mabe
f4b899873b osbuild/remoteloop: add more loop device options
This adds lock, partscan, read_only, sector_size to _create_device()
similar to make_loop() from devices/org.osbuild.loopback.
2024-12-04 16:30:55 +01:00
schutzbot
b1f16e9ab4 Post release version bump
[skip ci]
2024-12-04 08:32:12 +00:00
Ondřej Budai
b3123a1c19 github: prevent script injections via PR branch names
Prior this commit, ${{ github.event.workflow_run.head_branch }} got
expanded in the bash script. A malicious actor could inject
an arbitrary shell script. Since this action has access to a token
with write rights the malicious actor can easily steal this token.

This commit moves the expansion into an env block where such an
injection cannot happen. This is the preferred way according to the
github docs:
https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
2024-12-03 18:40:04 +01:00
Renata Ravanelli
458df8695f util/chroot: Add support for custom directory bind mounts
- Add optional bind_mounts parameter to __init__ method;
 - Enhanced methods to accept an optional `bind_mounts`.
This allows for more flexible for configurations when setting
up bind mounts.

Signed-off-by: Renata Ravanelli <rravanel@redhat.com>
2024-12-03 15:22:40 +01:00
Tomáš Hozza
f1c43ae5bd util/sbom/spdx: rename {,s}bom_pkgset_to_spdx2_doc()
Rename the function for consistency reason. The parent package is named
SBOM (originally BOM).

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-12-02 23:24:39 +01:00
Tomáš Hozza
562a30ce93 osbuild-depsolve-dnf: add SBOM support for DNF5
Enable generating SBOM documents for depsolved transactions when using
DNF5. Enable SBOM testing with DNF5 in unit tests.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-12-02 23:24:39 +01:00
Tomáš Hozza
def6a9fabd util/sbom: add support for DNF5
Add functions for transforming package sets depsolved using libdnf5 to
the SBOM standard-agnostic model. Cover the function with unit tests.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-12-02 23:24:39 +01:00
Tomáš Hozza
c3f3588419 test_util_sbom_spdx: fix imported module name
There was a typo in the imported module name, which caused the test to
be always skipped.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-12-02 23:24:39 +01:00
Tomáš Hozza
0a64f08f08 test_util_sbom_dnf: fix imported module name
There was a typo in the imported module name, which caused the test to
be always skipped.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-12-02 23:24:39 +01:00
Tomáš Hozza
7993b78e7c Testutil: add DNF5 helper function for depsolving
This will be used for testing the SBOM implementation with DNF5.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-12-02 23:24:39 +01:00
Achilleas Koutsou
3bf6ca399f test: add new containers.unit.create options in test 2024-12-02 12:55:30 +01:00
Pierre-Yves Chibon
17fda9e318 Expand the options available in containers.unit.create
Add the option to specify the SELinux type label and file type label for
the process.
Add the option to specify a tmpfs mount to create into the container.

Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
2024-12-02 12:55:30 +01:00
Tom Koscielniak
9b66ad8123 Bump RHEL 10 from beta to nightly
Bumping Rhel 10 runners from beta to nightly, running manifests on 9.6 nightly and also removing the Rhel 9.5 nightly runners altogether.
2024-11-29 14:47:45 +01:00
Michael Vogt
add78e7f47 sources: skip ostree tests if no ostree binary if found
This commit skips the ostree tests if no ostree binary is available.
2024-11-28 20:06:51 +01:00
Michael Vogt
bca7fb1418 workflow: install python3-pytest too to workaround test_host.py
The test_host.py:test_signals_on_separate_fd (and more)  runs
itself but that run will happen without the tox env so a pip/tox
installed pytest will not be found, install the pytest package
as a workaround.
2024-11-28 20:06:51 +01:00
Michael Vogt
b3b639517a workflow: add smoke test that runs unit tests as user
This commit adds a tiny smoke test that runs the unit tests as
a normal user on a regular github runner. This should ensure that
we catch issues like in osbuild#1936.
2024-11-28 20:06:51 +01:00
Tomáš Hozza
a6c7b56d98 Tests/tox: latest Fedora uses Python 3.13, so use it
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-11-28 13:29:12 +01:00
Tomáš Hozza
81cc279074 GH actions: use the latest build of osbuild-ci* containers
This will bring the latest image builds with new dependencies for unit
tests.

In addition, pin down the osbuild-ci-c*s container to a specific tag, to
ensure stability of the CI.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-11-28 13:29:12 +01:00
Tomáš Hozza
76a0d56690 Test/manifests: update fedora manifests to F41
Update the fedora manifest template to F41. This is a preparation for
testing a new `org.osbuild.dnf5.sbom.spdx` stage. In addition to that,
F39 is already EOL and unsupported, so moving to a newer version is
desirable.

Regenerate all testing manifests.

Notes about specific changes:
 - Remove `pcmciautils` package from ostree manifest, because it has
   been deprecated and it is not available on F41 any more.
 - Add `python3-dnf` package to the Fedora build pipeline. The reason
   is that DNF5 is installed by default since F41 and the module is
   needed to test e.g. `org.osbuild.dnf4.sbom.spdx` or
   `org.osbuild.dnf4.mark` stages.
 - Add `python3-libdnf5` package to the Fedora build pipeline. This is a
   preparation for testing a new `org.osbuild.dnf5.sbom.spdx` stage.
 - Install `pam` in `authselect` stage test manifest, because otherwise
   authselect fails on the nonexistence of /etc/pam.d.
 - Adjust the `dnf4.mark` test case to also accept `dnf5` as the marked
   package, because on F41, `dnf` is a virtual provide of it.
 - Adjust stage tests and their diffs as needed.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-11-28 13:29:12 +01:00
Tomáš Hozza
03f16e9a4c Schutzfile: use released repositories for F41
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-11-28 13:29:12 +01:00
Dusty Mabe
85f3bc1f09 test/data/manifests/fedora-coreos-container: fix CI
We updated the container in the registry so we need to update this
manifest to unbreak CI.
2024-11-28 11:53:57 +01:00
Alexander Larsson
9c3e5107aa osbuild-mpp: Fix error on python < 3.11
The change in commit ed33869430 to
use hashlib.file_digest breaks with older python, because
it was added in 3.11.

This change reverts back to hashing all the data in the case
where file_digest doesn't exist.
2024-11-27 00:06:08 +01:00
Achilleas Koutsou
af7b7db66f test: update users stage unit tests
Update the unit tests to match new calls and options.
2024-11-26 23:35:04 +01:00
Achilleas Koutsou
97007b9e3d stages: run useradd, usermod, and passwd with --root
The useradd, usermod, and passwd commands support a `--root` option that
handles chroot-ing for the command.  In general, we prefer using this
option for commands that provide it and relying on the utility itself to
know how to set up the chroot in the way it needs.

The option has been available for these commands since 2011 [1] and it's
unclear why they weren't used originally.

The `mkhomedir_helper` command is still run using our Chroot context, so
the fix introduced in 9071cd0abb is
unaffected.

[1] 365279ea95/ChangeLog (L1339)
2024-11-26 23:35:04 +01:00
Achilleas Koutsou
b9efc1f9bf test/users: modify root's home directory in stage test
Since 9071cd0abb the commands in the
org.osbuild.users stage are run using the osbuild.util.chroot.Chroot
context manager.  This includes mounting /proc into the chroot.

The `usermod` command now fails with

  usermod: user root is currently used by process N

when modifying any property of the root user that requires the user to
not be logged in (like the home directory).

Change the home directory of the root user in the stage test to check
for this issue and catch regressions.
2024-11-26 23:35:04 +01:00
Achilleas Koutsou
8e3d054099 stages: use util.chroot in all stages that call "chroot"
Use the chroot utility module for all cases where we need to chroot
during a stage's execution.

The advantage is that all stages use the same tested code path for
setting up a chroot and all chrooted commands run in the same
environment, with the /proc, /dev, and /sys filesystems mounted.
2024-11-26 12:13:44 +01:00
Michael Vogt
2f892b20e7 sources: fix ostree_sources test to work without /var/empty
Not all distros ship `/var/empty` so just create an empty dir
on demand as needed.

This also tweaks `test_ostree_source_exists()` into calling
`make_repo()` instead of duplicating that code.
2024-11-26 10:26:52 +01:00
Tomáš Hozza
9071cd0abb Stages/users: use Chroot from osbuild.util.chroot
Use Chroot class from osbuild.util.chroot module, instead of calling
`chroot` directly. The class handles mounting of various paths in the
chroot to make us more usable. This resolves new failure when running
the stage test on F41 results in `mkhomedir_heper` failing with `6`
return code, meaning permissions denied.

Adjust the stage unit tests, because `chroot.Chroot` can't work with
`pathlib.Path`.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-11-25 18:05:54 +01:00
Tomáš Hozza
a8aa6361b1 Stages/tuned: handle changed profiles dir with new TuneD versions
Since v2.23.0, TuneD changed the default directory under which it
looks for profiles. The profiles are newly nested under `profiles/`
directory. More information in [1].

Modify the stage implementation to check if the default profile
directories contain `profiles/` directory. If yes, then look for
profiles in it. If not, use the original behavior.

[1] https://github.com/redhat-performance/tuned/releases/tag/v2.23.0

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-11-25 10:22:21 +01:00
Tomáš Hozza
062feda60a Stages/dnf-automatic.config: don't fail on non-existent config file
On Fedora 41 with DNF5, the dnf-automatic plugin by default does not
install any configuration file. This means that the stage would fail in
such case.

Previously, the full config file was placed in /etc and its purpose was
also to document all possible options. The example config file is now
installed only in /usr/share/dnf5/dnf5-plugins/automatic.conf.

Relax the stage implementation to not fail when the configuration file
does not exist. Just log a warning and create the configuration file.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-11-25 10:15:17 +01:00
Tomáš Hozza
a50795b627 osbuild/util/containers.py: disable pylint issue W0135
Disable the newly reported pylint issue W0135
(contextmanager-generator-missing-cleanup), because as far as I was able
to understand the motivation behind it, it should not apply to the code
and it should be a false positive. We do not use context manager inside
a generator, but inside another context manager. So the execution flow
should return sequentially through the stack and all context manager
cleanups should be executed as expected.

The reported issue:
osbuild/util/containers.py:184:4: W0135: The context used in function 'container_source' will not be exited. (contextmanager-generator-missing-cleanup)

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-11-25 10:09:18 +01:00
Tomáš Hozza
3ac6d405b5 Fix pylint issue E0606: possibly-used-before-assignment
Fix:
assemblers/org.osbuild.qemu:310:36: E0606: Possibly using variable 'prep_type' before assignment (possibly-used-before-assignment)
inputs/org.osbuild.tree:85:15: E0606: Possibly using variable 'path' before assignment (possibly-used-before-assignment)
stages/org.osbuild.sfdisk:58:36: E0606: Possibly using variable 'prep_type' before assignment (possibly-used-before-assignment)
stages/org.osbuild.systemd.unit:23:16: E0606: Possibly using variable 'unit_dropins_dir' before assignment (possibly-used-before-assignment)
test/mod/test_meta.py:219:29: E0606: Possibly using variable 'schema_part' before assignment (possibly-used-before-assignment)

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-11-25 10:09:18 +01:00
Tomáš Hozza
7f86ccc7fc Fix pylint issue R1737: use-yield-from
Fix:
osbuild/pipeline.py:101:12: R1737: Use 'yield from' directly instead of yielding each element one by one (use-yield-from)

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-11-25 10:09:18 +01:00
Tomáš Hozza
689ca5cfe5 Lint/pylint: disable too-many-positional-arguments check
The new version of Pylint reports this issue in too many places. It is
unlikely that we would change all occurrences of it just to make
Pylint happy. Disable the check.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-11-25 10:09:18 +01:00
Tomáš Hozza
c44657377e Lint/pylint: update to the latest upstream version v3.3.1
Update pylint to the latest upstream version, to fix a false positive
with Python 3.13, that was resolved in `astroid` dependency in version
`3.3.5`. In order to update the dependency, the `pylint` version itself
needs to be bumped to at least version `3.0.0`.

The error was:
test/run/test_stages.py:21:0: E0611: No name 'Mapping' in module 'collections.abc' (no-name-in-module)

More details: https://github.com/pylint-dev/pylint/issues/10000

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-11-25 10:09:18 +01:00
Tomáš Hozza
8b62e9d901 Lint/autopep8: update to the latest upstream version v2.3.1
This is needed to resolve fialure to find `lib2to3` module on F41, which
was removed since Python 3.13 used by default there.

Update autopep8 and pycodestyle to the latest upstream releases.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-11-25 09:23:51 +01:00
Tomáš Hozza
36a60d1c29 Test/autotailor: fix Python 3.6 compatibility
The test case is skipped in the upstream CI, because the `autotailor`
executable is not installed in the `osbuild-ci` image. This will not
be the case in the future and the CI run will reveal a Python 3.6
incompatibility in the test implementation. Fix it.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-11-25 09:12:19 +01:00
schutzbot
4c2b8db0d7 Post release version bump
[skip ci]
2024-11-22 21:00:17 +00:00
Lukas Zapletal
32b1b91597 test: regenerate X509 test certs 2024-11-22 10:15:50 +01:00
schutzbot
349c192ca8 Post release version bump
[skip ci]
2024-11-20 08:29:18 +00:00
Nikita Dubrovskii
a8e8ebde44 org.osbuild.selinux: support for specifying where file_contexts comes from
file_context now can come from
- tree (current default)
- mount
- input

Example:
```
- type: org.osbuild.selinux
  inputs:
    tree:
      type: org.osbuild.tree
      origin: org.osbuild.pipeline
      references:
        - name:tree
  options:
    file_contexts: input://tree/etc/selinux/targeted/contexts/files/file_contexts
```
2024-11-14 17:49:26 +01:00
Nikita Dubrovskii
84d4de5770 org.osbuild.selinux: support operating on mounts
This adds support for specifying paths to operate on,
rather than just the root of the target:
```
- type: org.osbuild.selinux
  options:
    file_contexts: etc/selinux/targeted/contexts/files/file_contexts
    target: mount://root/path/to/dir
  mounts:
    - name: root
      source: disk
      target: /
```

or

```
- type: org.osbuild.selinux
  options:
    labels:
      mount://root/path/to/file: system_u:object_r:boot_t:s0
      mount://root/path/to/other/file: system_u:object_r:var_t:s0
  mounts:
    - name: root
      source: disk
      target: /

```
2024-11-14 17:49:26 +01:00
Nikita Dubrovskii
6a59e740e4 parsing: treat locations without scheme as belonging to 'tree://' 2024-11-14 17:49:26 +01:00
Nikita Dubrovskii
077244e3b9 parsing: add parse_location_into_parts
New fucntion returns tuple of 'root' and relative 'file path', which could be
useful in contexts, where knowing 'root' is required, for example setting
selinux labels.
2024-11-14 17:49:26 +01:00
Alexander Larsson
a699d05094 osbuild-mpp: Allow using formating in the mpp-resolve-images handling
This allows using e.g. mpp-eval in the resolve-image operation, similar
to how it is now possible in the mpp-depsolve handling.

We want this so we can inject the list of images from a list variable
(that can then be mpp-join:ed, etc).
2024-11-13 11:22:16 +01:00
Tom Koscielniak
ff0cd854c8 Build RPMs on 9.6 nightly 2024-11-12 12:46:56 +01:00
schutzbot
1809495fd6 schutzfile: Update snapshots to 20241107 2024-11-12 11:12:47 +01:00