Skip to content

Commit

Permalink
test_base_images_sbom: add SPDX tests
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Cmiel <[email protected]>
  • Loading branch information
chmeliik committed Dec 10, 2024
1 parent 24147df commit 1bf21b1
Show file tree
Hide file tree
Showing 2 changed files with 478 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,11 @@ def detect_sbom_type(sbom: dict[str, Any]) -> Literal["cyclonedx", "spdx"]:
raise ValueError("Unknown SBOM format")


def _datetime_utc_now() -> datetime.datetime:
# a mockable datetime.datetime.now (just for tests):
return datetime.datetime.now(datetime.UTC)


def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(
description="Updates the sbom file with base images data based on the provided files"
Expand Down Expand Up @@ -337,7 +342,7 @@ def main() -> None:
if detect_sbom_type(sbom) == "cyclonedx":
update_cyclonedx_sbom(sbom, base_images_sbom_components)
else:
annotation_date = datetime.datetime.now(datetime.UTC)
annotation_date = _datetime_utc_now()
base_images_spdx = [cdx_to_spdx(c, annotation_date) for c in base_images_sbom_components]
update_spdx_sbom(sbom, base_images_spdx)

Expand Down
Loading

0 comments on commit 1bf21b1

Please sign in to comment.