Skip to content
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

feat: creates an UUID object for the bomref in init-sbom #333

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions cdxev/initialize_sbom.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# SPDX-License-Identifier: GPL-3.0-or-later

import json
import uuid
from datetime import datetime
from typing import Any, Union

Expand Down Expand Up @@ -67,10 +68,7 @@ def initialize_sbom(
type=ExternalReferenceType.WEBSITE,
)

bom_ref = BomRef(
"An optional identifier which can be used "
"to reference the component elsewhere in the SBOM."
)
bom_ref = BomRef(str(uuid.uuid4()))

metadata_component = Component(
name=software_name,
Expand Down
10 changes: 10 additions & 0 deletions tests/integration/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,11 @@ def test(
# Verify that command completed successfully
assert exit_code == Status.OK

expected["metadata"]["component"]["bom-ref"] = actual["metadata"]["component"][
"bom-ref"
]
expected["dependencies"][0]["ref"] = actual["metadata"]["component"]["bom-ref"]

# Verify that output matches what is expected
assert actual == expected

Expand All @@ -318,6 +323,11 @@ def test_no_arguments(
# Verify that command completed successfully
assert exit_code == Status.OK

expected["metadata"]["component"]["bom-ref"] = actual["metadata"]["component"][
"bom-ref"
]
expected["dependencies"][0]["ref"] = actual["metadata"]["component"]["bom-ref"]

# Verify that output matches what is expected
assert actual == expected

Expand Down
Loading