These utilities consist of:
- AlmaLinux SBOM CLI (
alma-sbom): creates SBOM records for artifacts produced by the AlmaLinux Build System. It generates SBOMs for builds, individual RPM packages, and installer ISO images. - AlmaLinux Git Notarization Tool (
git_notarize.py): allows AlmaLinux developers to manually notarize AlmaLinux git sources using the ImmudbWrapper.
For a step-by-step walkthrough with example output, see the AlmaLinux SBOM User Guide.
- Linux with RPM's Python bindings (
python3-rpm). AlmaLinux installs them by default; on other distributions, installpython3-rpmfirst. Every subcommand uses them, and the iso subcommand also relies on Linux-only features (memfd_create,/proc), so macOS and Windows are not supported. Inside a virtual environment, the rpm shim package is installed and loads the system bindings. - Python >= 3.9
git, since alma-sbom and itsimmudb_wrapperdependency are installed from GitHub- An internet connection to reach the AlmaLinux Build System and the AlmaLinux immudb instance
All other dependencies are installed automatically; see setup.py for the full list.
pipx is a tool to install and run Python applications in isolated environments.
The pipx package is released in Fedora EPEL, so you can install it on AlmaLinux by running dnf install epel-release and then dnf install pipx.
To install alma-sbom with pipx you can either:
- Install alma-sbom directly from GitHub:
pipx install git+https://github.com/AlmaLinux/alma-sbom.git - Clone the alma-sbom git repository and run
pipx install .inside the cloned repository.
- Clone the repository:
git clone https://github.com/AlmaLinux/alma-sbom.git && cd alma-sbom - Create a Python virtual environment:
python3 -m venv env - Activate the virtual environment:
source env/bin/activate - Install alma-sbom and its dependencies:
pip install .
Either way, you get the alma-sbom command. Run alma-sbom --help to check the installation.
alma-sbom [global options] {build,package,iso} [subcommand options]
There are three subcommands, one for each kind of artifact:
| Subcommand | SBOM for | Required input |
|---|---|---|
build |
A build in the AlmaLinux Build System, with every package it produced | --build-id |
package |
A single RPM package | --rpm-package-hash or --rpm-package |
iso |
An AlmaLinux installer ISO image, with every RPM package on it | --iso-image |
Important
Global options must be given before the subcommand. For example, alma-sbom --file-format cyclonedx-json build --build-id 4372 works, but alma-sbom build --build-id 4372 --file-format cyclonedx-json fails with unrecognized arguments.
-
output-file: The file you want to save the generated SBOM to. If not provided, the resulting SBOM is printed to stdout
-
file-format: The SBOM standard and file format you want to generate. The default is
spdx-json. Supported combinations:SBOM standard Values SPDX 2.3 spdx-json,spdx-xml,spdx-yaml,spdx-tagvalue,spdx-rdfCycloneDX 1.6 cyclonedx-json,cyclonedx-xml -
albs-url: The URL of the AlmaLinux Build System, if different from the production one, https://build.almalinux.org
-
immudb-username, immudb-password, immudb-database, immudb-address: Connection settings for immudb. They can also be set with the
IMMUDB_USERNAME,IMMUDB_PASSWORD,IMMUDB_DATABASEandIMMUDB_ADDRESSenvironment variables. By default, the public read-only credentials and the AlmaLinux immudb instance from the ImmudbWrapper module are used, so you normally don't need to set them -
immudb-public-key-file: (Optional) Path of the public key to use for authenticating requests. Can also be set with the
IMMUDB_PUBLIC_KEY_FILEenvironment variable -
verbose or debug: Print verbose or debug output
You can get the SBOM of a Build using the build subcommand, and providing the following argument:
- build-id: The ID of the build in the AlmaLinux Build System, as shown in the build URL, e.g.
https://build.almalinux.org/build/4372
Example to make SBOM of a Build in cyclonedx-json format:
$ alma-sbom --file-format cyclonedx-json build --build-id 4372
You can get the SBOM of a Package using the package subcommand, and providing exactly one of the following arguments:
- rpm-package-hash: The immudb hash of the package. This is the SHA-256 checksum of the
.rpmfile, so you can get it from the build details page in the AlmaLinux Build System or withsha256sum package.rpm | cut -d' ' -f1 - rpm-package: The path to a local RPM package file
When using rpm-package, the package file's hash is looked up in immudb and the result is merged with the metadata from the RPM header. If the package is not found in immudb (for example, it was not built by the AlmaLinux Build System), a warning is printed and the SBOM is generated from the RPM header only.
Example to make SBOM of a Package with rpm-package-hash option in cyclonedx-xml format with verbose output:
$ alma-sbom --verbose --file-format cyclonedx-xml package --rpm-package-hash b00d871e204ca8cbcae72c37c53ab984fdadc3846c91fb35c315335adfe0699b
Example to make SBOM of a Package with rpm-package option in spdx-yaml format with debug output:
$ alma-sbom --debug --file-format spdx-yaml package --rpm-package /path/to/package.rpm
You can get the SBOM of an ISO image using the iso subcommand, and providing the following argument:
- iso-image: Path to the AlmaLinux DVD or Minimal installer ISO image that you want to generate the SBOM for. Boot images aren't supported, since they don't contain packages, and ISO images of other distributions are rejected
Every RPM package on the image is read and, like with rpm-package, enriched with immudb data when available. Large images such as the DVD contain thousands of packages, so this can take a while; use debug to see progress.
Example to make an SBOM of an ISO image in the default format (spdx-json):
$ alma-sbom --output-file iso.spdx.json iso --iso-image /path/to/isoimage
Error opening RPM package: public key not availablewith rpm-package or iso: the systemrpmlibrary verifies package signatures and the AlmaLinux GPG key for that package's major version isn't imported. This can happen on non-AlmaLinux hosts or when checking packages from a different major version than the host. Import the matching key,sudo rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux-<major version>(8,9or10), or get the hash withsha256sum package.rpm | cut -d' ' -f1and use rpm-package-hash instead.Failed to get data from immudb for hash value: ...with rpm-package-hash: the hash is not a notarized package hash. Make sure you are using the 64-character SHA-256 hash of the package, not a git commit hash.
When importing git sources from CentOS, these are notarized using Immudb, however, there are corner cases where these sources can't be notarized. For this reason, this tool has been created in order to allow AlmaLinux developers to manually notarize AlmaLinux sources that couldn't be notarized at import time.
To summarize what the tool does:
- It checks whether an AlmaLinux git source's commit has a git tag assigned according to the AlmaLinux tagging conventions
- If this tag is "modified" according to the AlmaLinux tagging conventions, then the tool will try to find a matching tag in a corresponding upstream tag
- If the matching tag is found, the tool will authenticate its commit and take its Immudb hash if found. This hash will be added as an attribute of an AlmaLinux source Immudb record
- If the matching tag/commit is not notarized, the tool can notarize it and then use that hash as an attribute when notarizing the AlmaLinux source
- If no upstream matching tag can be found, the tool allows notarizing the AlmaLinux source without having a notarized upstream corresponding tag
The AlmaLinux Git Notarization Tool accepts the following arguments:
- immudb-username: The immudb username, must be provided either by setting the environmental variable or by using this option to notarize sources
- immudb-password: The immudb password, must be provided either by setting the environmental variable or by using this option to notarize sources
- immudb-database: The immudb database name, could be provided either by setting the environmental variable or by using this option, by default uses value from ImmudbWrapper module
- immudb-address: The immudb host address, could be provided either by setting the environmental variable or by using this option, by default uses value from ImmudbWrapper module
- immudb-public-key-file: (Optional) Path of the public key to use for authenticating requests, must be provided either by setting the environmental variable or by using this option
- local-git-repo: The path to a local AlmaLinux git source repository. If not provided, uses the current working directory
- notarize-without-upstream-hash: Use this option if you want to force the notarization of an AlmaLinux commit even when there's no matched upstream tag
- notarize-upstream-tag: Use this option if you want to force the notarization of an upstream tag before notarizing an AlmaLinux source
- notarize-without-imported-source-notarization: Use this option if you want to force the notarization of an upstream tag without an imported source notarization
- debug: This option will make the tool to display debug information while running, which could be useful when diagnosing a problem in the tool
There are no mandatory arguments to pass (unless strictly required to force a notarization), if you are currently in a local clone of an AlmaLinux source, you can run python /path/to/git_notarize.py.
If you want to specify the folder, you should run python /path/to/git_notarize.py --local-git-repo <path to local copy of a git repo>.
Note that this tool is meant for AlmaLinux developers that have write permissions into git.almalinux.org and that have the AlmaLinux Immudb credentials required to notarize artifacts on behalf of AlmaLinux
Any question? Found a bug? File an issue. Do you want to contribute with source code?
- Fork the repository on GitHub
- Create a new feature branch
- Write your change
- Submit a pull request
To run the tests, install the development dependencies with pip install -e .[dev] and run pytest tests/pytest/.