-
Notifications
You must be signed in to change notification settings - Fork 40
chore: merge SBOM packages and remove old SBOM's #583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -256,6 +256,50 @@ printf "%s\n" "${INVENTORY_DATA}" >"${ROOT_MOUNT}/usr/share/bottlerocket/applica | |
| # can access the inventory without needed to dig into the generated image. | ||
| printf "%s\n" "${INVENTORY_DATA}" >"${OUTPUT_DIR}/application-inventory.json" | ||
|
|
||
| # Install SBOM subpackages for each installed RPM (only for EROFS images) | ||
| if [[ "${EROFS_ROOT_PARTITION}" == "yes" ]]; then | ||
| SBOM_RPMS=() | ||
| while IFS= read -r rpm_name; do | ||
| sbom_rpm="${rpm_name}-sbom" | ||
| if rpm -q --root "${ROOT_MOUNT}" "${sbom_rpm}" >/dev/null 2>&1; then | ||
| SBOM_RPMS+=("${sbom_rpm}") | ||
| else | ||
|
Comment on lines
+264
to
+266
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is to handle the case where someone adds |
||
| # Check if SBOM package file exists in local packages or external kits | ||
| sbom_file=$(find "${PACKAGE_DIR}" -maxdepth 1 -name "${sbom_rpm}*.rpm" -print -quit) | ||
| if [[ -z "${sbom_file}" && -n "${EXTERNAL_KITS_PATH}" ]]; then | ||
| sbom_file=$(find "${EXTERNAL_KITS_PATH}" -name "${sbom_rpm}*.rpm" -print -quit) | ||
|
Comment on lines
+267
to
+270
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems pretty hacky and I think we can do better:
That should give you a new temporary directory with only the SBOM files installed, which you can then concatenate together. |
||
| fi | ||
| if [[ -n "${sbom_file}" ]]; then | ||
| if rpm -iv --ignorearch --root "${ROOT_MOUNT}" "${sbom_file}" >/dev/null 2>&1; then | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We shouldn't install packages only to turn around and erase them. We can |
||
| SBOM_RPMS+=("${sbom_rpm}") | ||
| fi | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to fix your editor settings to not insert a mix of tabs/spaces. Please make sure this follows existing whitespace conventions. |
||
| fi | ||
| fi | ||
| done < <(rpm -qa --root "${ROOT_MOUNT}" --queryformat "%{NAME}\n") | ||
|
|
||
| # Merge SBOMs into a single json file | ||
| KIT_SBOMS_DIR="${ROOT_MOUNT}/usr/share/sboms" | ||
| if [ -d "${KIT_SBOMS_DIR}" ]; then | ||
| IMAGE_SBOM_DIR="${ROOT_MOUNT}/usr/share/bottlerocket" | ||
| mkdir -p "${IMAGE_SBOM_DIR}" | ||
| for format in "spdx" "cyclonedx"; do | ||
| image_sbom="${format}-sbom.json" | ||
| image_sbom_path="${IMAGE_SBOM_DIR}/${image_sbom}" | ||
| find "${KIT_SBOMS_DIR}" -name "*-${format}.json" -type f -exec sbomtool merge --output "${image_sbom_path}" {} \+ | ||
|
|
||
| # Write the inventory to a file in the local build output directory | ||
| cp "${image_sbom_path}" "${OUTPUT_DIR}/${image_sbom}" | ||
| done | ||
| # Clean up old SBOM packages | ||
| rm -rf "${KIT_SBOMS_DIR}" | ||
| fi | ||
|
|
||
| # Uninstall SBOM subpackages | ||
| for sbom_rpm in "${SBOM_RPMS[@]}"; do | ||
| rpm -e --root "${ROOT_MOUNT}" "${sbom_rpm}" >/dev/null 2>&1 || true | ||
| done | ||
| fi | ||
|
|
||
| # Regenerate module dependencies, if possible. | ||
| KMOD_DIR="${ROOT_MOUNT}/lib/modules" | ||
| # First decompress the kernel modules, so they can be recompressed by EROFS. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This restriction doesn't make much sense as build system policy - "we will only produce SBOM artifacts if you're using EROFS".
Options:
Not sure which is best, assuming you can't just always include SBOM artifacts.