From 64f92ac7ce6f27bc95f277327c7553c02d533c9c Mon Sep 17 00:00:00 2001 From: Adam Cmiel Date: Thu, 19 Dec 2024 14:07:54 +0100 Subject: [PATCH] merge_cachi2_sboms: rename to merge_sboms Handles syft SBOMs as well now. Signed-off-by: Adam Cmiel --- sbom-utility-scripts/Dockerfile | 8 +++++--- .../merge_sboms.py} | 0 .../requirements-test.in | 0 .../requirements-test.txt | 0 .../requirements.in | 0 .../requirements.txt | 0 .../test_data/assemble-input-sboms.sh | 4 ++-- .../test_data/cachi2.bom.json | 0 .../test_data/merged.bom.json | 0 .../test_data/syft-sboms/gomod-pandemonium.bom.json | 0 .../test_data/syft-sboms/npm-cachi2-smoketest.bom.json | 0 .../test_data/syft-sboms/pip-e2e-test.bom.json | 0 .../test_data/syft-sboms/ubi-micro.bom.json | 0 .../test_data/syft.merged-by-syft.bom.json | 0 .../test_data/syft.merged-by-us.bom.json | 0 .../test_merge_sboms.py} | 2 +- .../tox.ini | 4 ++-- 17 files changed, 10 insertions(+), 8 deletions(-) rename sbom-utility-scripts/scripts/{merge-cachi2-sboms-script/merge_cachi2_sboms.py => merge-sboms-script/merge_sboms.py} (100%) rename sbom-utility-scripts/scripts/{merge-cachi2-sboms-script => merge-sboms-script}/requirements-test.in (100%) rename sbom-utility-scripts/scripts/{merge-cachi2-sboms-script => merge-sboms-script}/requirements-test.txt (100%) rename sbom-utility-scripts/scripts/{merge-cachi2-sboms-script => merge-sboms-script}/requirements.in (100%) rename sbom-utility-scripts/scripts/{merge-cachi2-sboms-script => merge-sboms-script}/requirements.txt (100%) rename sbom-utility-scripts/scripts/{merge-cachi2-sboms-script => merge-sboms-script}/test_data/assemble-input-sboms.sh (94%) rename sbom-utility-scripts/scripts/{merge-cachi2-sboms-script => merge-sboms-script}/test_data/cachi2.bom.json (100%) rename sbom-utility-scripts/scripts/{merge-cachi2-sboms-script => merge-sboms-script}/test_data/merged.bom.json (100%) rename sbom-utility-scripts/scripts/{merge-cachi2-sboms-script => merge-sboms-script}/test_data/syft-sboms/gomod-pandemonium.bom.json (100%) rename sbom-utility-scripts/scripts/{merge-cachi2-sboms-script => merge-sboms-script}/test_data/syft-sboms/npm-cachi2-smoketest.bom.json (100%) rename sbom-utility-scripts/scripts/{merge-cachi2-sboms-script => merge-sboms-script}/test_data/syft-sboms/pip-e2e-test.bom.json (100%) rename sbom-utility-scripts/scripts/{merge-cachi2-sboms-script => merge-sboms-script}/test_data/syft-sboms/ubi-micro.bom.json (100%) rename sbom-utility-scripts/scripts/{merge-cachi2-sboms-script => merge-sboms-script}/test_data/syft.merged-by-syft.bom.json (100%) rename sbom-utility-scripts/scripts/{merge-cachi2-sboms-script => merge-sboms-script}/test_data/syft.merged-by-us.bom.json (100%) rename sbom-utility-scripts/scripts/{merge-cachi2-sboms-script/test_merge_cachi2_sboms.py => merge-sboms-script/test_merge_sboms.py} (98%) rename sbom-utility-scripts/scripts/{merge-cachi2-sboms-script => merge-sboms-script}/tox.ini (72%) diff --git a/sbom-utility-scripts/Dockerfile b/sbom-utility-scripts/Dockerfile index e29d07e..f01b4d7 100644 --- a/sbom-utility-scripts/Dockerfile +++ b/sbom-utility-scripts/Dockerfile @@ -3,8 +3,10 @@ FROM registry.access.redhat.com/ubi9/python-312:9.5@sha256:88ea2d10c741f16968110 WORKDIR /scripts COPY scripts/merge_syft_sboms.py /scripts -COPY scripts/merge-cachi2-sboms-script/merge_cachi2_sboms.py /scripts -COPY scripts/merge-cachi2-sboms-script/requirements.txt /scripts/merge-cachi2-sboms-script-requirements.txt +COPY scripts/merge-sboms-script/merge_sboms.py /scripts +# for backwards compatibility, also ship the script at the original location +COPY scripts/merge-sboms-script/merge_sboms.py /scripts/merge_cachi2_sboms.py +COPY scripts/merge-sboms-script/requirements.txt /scripts/merge-sboms-script-requirements.txt COPY scripts/base-images-sbom-script/app/base_images_sbom_script.py /scripts COPY scripts/base-images-sbom-script/app/requirements.txt /scripts/base-images-sbom-script-requirements.txt COPY scripts/index-image-sbom-script/requirements.txt /scripts/index-image-sbom-script-requirements.txt @@ -14,7 +16,7 @@ COPY scripts/add-image-reference-script/add_image_reference.py /scripts COPY scripts/add-image-reference-script/requirements.txt /scripts/add-image-reference-requirements.txt RUN pip3 install --no-cache-dir \ - -r merge-cachi2-sboms-script-requirements.txt \ + -r merge-sboms-script-requirements.txt \ -r base-images-sbom-script-requirements.txt \ -r index-image-sbom-script-requirements.txt \ -r add-image-reference-requirements.txt diff --git a/sbom-utility-scripts/scripts/merge-cachi2-sboms-script/merge_cachi2_sboms.py b/sbom-utility-scripts/scripts/merge-sboms-script/merge_sboms.py similarity index 100% rename from sbom-utility-scripts/scripts/merge-cachi2-sboms-script/merge_cachi2_sboms.py rename to sbom-utility-scripts/scripts/merge-sboms-script/merge_sboms.py diff --git a/sbom-utility-scripts/scripts/merge-cachi2-sboms-script/requirements-test.in b/sbom-utility-scripts/scripts/merge-sboms-script/requirements-test.in similarity index 100% rename from sbom-utility-scripts/scripts/merge-cachi2-sboms-script/requirements-test.in rename to sbom-utility-scripts/scripts/merge-sboms-script/requirements-test.in diff --git a/sbom-utility-scripts/scripts/merge-cachi2-sboms-script/requirements-test.txt b/sbom-utility-scripts/scripts/merge-sboms-script/requirements-test.txt similarity index 100% rename from sbom-utility-scripts/scripts/merge-cachi2-sboms-script/requirements-test.txt rename to sbom-utility-scripts/scripts/merge-sboms-script/requirements-test.txt diff --git a/sbom-utility-scripts/scripts/merge-cachi2-sboms-script/requirements.in b/sbom-utility-scripts/scripts/merge-sboms-script/requirements.in similarity index 100% rename from sbom-utility-scripts/scripts/merge-cachi2-sboms-script/requirements.in rename to sbom-utility-scripts/scripts/merge-sboms-script/requirements.in diff --git a/sbom-utility-scripts/scripts/merge-cachi2-sboms-script/requirements.txt b/sbom-utility-scripts/scripts/merge-sboms-script/requirements.txt similarity index 100% rename from sbom-utility-scripts/scripts/merge-cachi2-sboms-script/requirements.txt rename to sbom-utility-scripts/scripts/merge-sboms-script/requirements.txt diff --git a/sbom-utility-scripts/scripts/merge-cachi2-sboms-script/test_data/assemble-input-sboms.sh b/sbom-utility-scripts/scripts/merge-sboms-script/test_data/assemble-input-sboms.sh similarity index 94% rename from sbom-utility-scripts/scripts/merge-cachi2-sboms-script/test_data/assemble-input-sboms.sh rename to sbom-utility-scripts/scripts/merge-sboms-script/test_data/assemble-input-sboms.sh index 5e787fd..c4f9380 100755 --- a/sbom-utility-scripts/scripts/merge-cachi2-sboms-script/test_data/assemble-input-sboms.sh +++ b/sbom-utility-scripts/scripts/merge-sboms-script/test_data/assemble-input-sboms.sh @@ -12,7 +12,7 @@ set -o errexit -o nounset -o pipefail -o xtrace # # It will generate cachi2 and syft SBOMs for a few sample repositories (and one # container image, for syft) and assemble them into a merged cachi2 SBOM and a -# merged syft SBOM. You can then test the merge_cachi2_sboms.py script by merging +# merged syft SBOM. You can then test the merge_sboms.py script by merging # the cachi2 SBOM with the syft SBOM. testdata_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd) @@ -90,4 +90,4 @@ syft ./syft-sboms --select-catalogers=+sbom-cataloger -o cyclonedx-json@1.5 | postprocess_syft_cyclonedx > "$testdata_dir/syft.merged-by-syft.bom.json" printf "syft:%s\n" "$testdata_dir/syft-sboms"/* | - xargs python "$testdata_dir/../merge_cachi2_sboms.py" > "$testdata_dir/syft.merged-by-us.bom.json" + xargs python "$testdata_dir/../merge_sboms.py" > "$testdata_dir/syft.merged-by-us.bom.json" diff --git a/sbom-utility-scripts/scripts/merge-cachi2-sboms-script/test_data/cachi2.bom.json b/sbom-utility-scripts/scripts/merge-sboms-script/test_data/cachi2.bom.json similarity index 100% rename from sbom-utility-scripts/scripts/merge-cachi2-sboms-script/test_data/cachi2.bom.json rename to sbom-utility-scripts/scripts/merge-sboms-script/test_data/cachi2.bom.json diff --git a/sbom-utility-scripts/scripts/merge-cachi2-sboms-script/test_data/merged.bom.json b/sbom-utility-scripts/scripts/merge-sboms-script/test_data/merged.bom.json similarity index 100% rename from sbom-utility-scripts/scripts/merge-cachi2-sboms-script/test_data/merged.bom.json rename to sbom-utility-scripts/scripts/merge-sboms-script/test_data/merged.bom.json diff --git a/sbom-utility-scripts/scripts/merge-cachi2-sboms-script/test_data/syft-sboms/gomod-pandemonium.bom.json b/sbom-utility-scripts/scripts/merge-sboms-script/test_data/syft-sboms/gomod-pandemonium.bom.json similarity index 100% rename from sbom-utility-scripts/scripts/merge-cachi2-sboms-script/test_data/syft-sboms/gomod-pandemonium.bom.json rename to sbom-utility-scripts/scripts/merge-sboms-script/test_data/syft-sboms/gomod-pandemonium.bom.json diff --git a/sbom-utility-scripts/scripts/merge-cachi2-sboms-script/test_data/syft-sboms/npm-cachi2-smoketest.bom.json b/sbom-utility-scripts/scripts/merge-sboms-script/test_data/syft-sboms/npm-cachi2-smoketest.bom.json similarity index 100% rename from sbom-utility-scripts/scripts/merge-cachi2-sboms-script/test_data/syft-sboms/npm-cachi2-smoketest.bom.json rename to sbom-utility-scripts/scripts/merge-sboms-script/test_data/syft-sboms/npm-cachi2-smoketest.bom.json diff --git a/sbom-utility-scripts/scripts/merge-cachi2-sboms-script/test_data/syft-sboms/pip-e2e-test.bom.json b/sbom-utility-scripts/scripts/merge-sboms-script/test_data/syft-sboms/pip-e2e-test.bom.json similarity index 100% rename from sbom-utility-scripts/scripts/merge-cachi2-sboms-script/test_data/syft-sboms/pip-e2e-test.bom.json rename to sbom-utility-scripts/scripts/merge-sboms-script/test_data/syft-sboms/pip-e2e-test.bom.json diff --git a/sbom-utility-scripts/scripts/merge-cachi2-sboms-script/test_data/syft-sboms/ubi-micro.bom.json b/sbom-utility-scripts/scripts/merge-sboms-script/test_data/syft-sboms/ubi-micro.bom.json similarity index 100% rename from sbom-utility-scripts/scripts/merge-cachi2-sboms-script/test_data/syft-sboms/ubi-micro.bom.json rename to sbom-utility-scripts/scripts/merge-sboms-script/test_data/syft-sboms/ubi-micro.bom.json diff --git a/sbom-utility-scripts/scripts/merge-cachi2-sboms-script/test_data/syft.merged-by-syft.bom.json b/sbom-utility-scripts/scripts/merge-sboms-script/test_data/syft.merged-by-syft.bom.json similarity index 100% rename from sbom-utility-scripts/scripts/merge-cachi2-sboms-script/test_data/syft.merged-by-syft.bom.json rename to sbom-utility-scripts/scripts/merge-sboms-script/test_data/syft.merged-by-syft.bom.json diff --git a/sbom-utility-scripts/scripts/merge-cachi2-sboms-script/test_data/syft.merged-by-us.bom.json b/sbom-utility-scripts/scripts/merge-sboms-script/test_data/syft.merged-by-us.bom.json similarity index 100% rename from sbom-utility-scripts/scripts/merge-cachi2-sboms-script/test_data/syft.merged-by-us.bom.json rename to sbom-utility-scripts/scripts/merge-sboms-script/test_data/syft.merged-by-us.bom.json diff --git a/sbom-utility-scripts/scripts/merge-cachi2-sboms-script/test_merge_cachi2_sboms.py b/sbom-utility-scripts/scripts/merge-sboms-script/test_merge_sboms.py similarity index 98% rename from sbom-utility-scripts/scripts/merge-cachi2-sboms-script/test_merge_cachi2_sboms.py rename to sbom-utility-scripts/scripts/merge-sboms-script/test_merge_sboms.py index 9a841fc..ea3e52f 100644 --- a/sbom-utility-scripts/scripts/merge-cachi2-sboms-script/test_merge_cachi2_sboms.py +++ b/sbom-utility-scripts/scripts/merge-sboms-script/test_merge_sboms.py @@ -6,7 +6,7 @@ import pytest -from merge_cachi2_sboms import SBOMItem, main, merge_by_apparent_sameness, merge_cyclonedx_sboms, wrap_as_cdx +from merge_sboms import SBOMItem, main, merge_by_apparent_sameness, merge_cyclonedx_sboms, wrap_as_cdx TOOLS_METADATA = { "syft-cyclonedx-1.4": { diff --git a/sbom-utility-scripts/scripts/merge-cachi2-sboms-script/tox.ini b/sbom-utility-scripts/scripts/merge-sboms-script/tox.ini similarity index 72% rename from sbom-utility-scripts/scripts/merge-cachi2-sboms-script/tox.ini rename to sbom-utility-scripts/scripts/merge-sboms-script/tox.ini index 65eb41c..9aca6bd 100644 --- a/sbom-utility-scripts/scripts/merge-cachi2-sboms-script/tox.ini +++ b/sbom-utility-scripts/scripts/merge-sboms-script/tox.ini @@ -6,12 +6,12 @@ basepython = 3.12 deps = -r requirements.txt -r requirements-test.txt -commands = pytest test_merge_cachi2_sboms.py +commands = pytest test_merge_sboms.py [testenv:flake8] basepython = 3.12 deps = flake8 -commands = flake8 --max-line-length 120 merge_cachi2_sboms.py test_merge_cachi2_sboms.py +commands = flake8 --max-line-length 120 merge_sboms.py test_merge_sboms.py [testenv:black] deps = black