Skip to content

feat: add support for component's evidences according to spec #810

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

OxPirates
Copy link

@OxPirates OxPirates commented May 3, 2025

fixes #737

@OxPirates OxPirates requested a review from a team as a code owner May 3, 2025 10:26
@OxPirates
Copy link
Author

@jkowalleck Thank you for your time, Will work on it and submit the changes.

@OxPirates
Copy link
Author

@jkowalleck Thank you for the detailed review. All comments have been addressed except the one regarding ToolReference

@tools.setter
def tools(self, tools: Iterable[Union[str, BomRef]]) -> None:
"""Convert all inputs to BomRef for consistent storage"""
self._tools = SortedSet(BomRef(str(t)) for t in tools)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, per specs, this is a list of (string or BomRef).
https://cyclonedx.org/docs/1.6/json/#components_items_evidence_identity_oneOf_i0_items_tools

so it seams like forcing everything to be a BomRef is not the intended solution, or is it?
FYI: We already have some code that might help validate BomLinks.

I need to think about this a bit more.
lets leave the "tools" topic open for a while :-)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I've pushed a minor update based on the feedback. Let me know if you have any final thoughts—happy to make further adjustments if needed.

@@ -1485,4 +1554,5 @@ def get_bom_for_issue540_duplicate_components() -> Bom:
get_bom_with_lifecycles,
get_bom_with_definitions_standards,
get_bom_with_definitions_and_detailed_standards,
get_bom_with_component_evidence,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please dont modify this existing model.

  • craft a new own data model, instead of reusing an existing one! Create an own function called get_bom_with_component_evidence() - it will be found and used automatically.

)
],
tools=[
BomRef('ref0'), # BomRef reference
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not how this should work.
instead of rafting a new BomRef for this single use,
the spec clearly says to reference an already defined one that was used in metadata.tools.
https://cyclonedx.org/docs/1.6/json/#components_items_evidence_identity_oneOf_i0_items_tools

The object in the BOM identified by its bom-ref. This is often a component or service but may be any object type supporting bom-refs. Tools used for analysis should already be defined in the BOM, either in the metadata/tools, components, or formulation.

offset=16,
symbol='exampleSymbol',
additional_context='Found in source code',
bom_ref=bom_ref,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the bom_ref used here? it seams to have no purpose - can it be removed?

Suggested change
bom_ref=bom_ref,

@@ -737,6 +773,55 @@ def get_component_setuptools_complete(include_pedigree: bool = True) -> Componen
return component


def get_component_evidence_basic(tool: BomRef, bom_ref: str) -> ComponentEvidence:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def get_component_evidence_basic(tool: BomRef, bom_ref: str) -> ComponentEvidence:
def get_component_evidence_basic(tools: Iterable[Tool]) -> ComponentEvidence:

confidence=Decimal('0.8'), value='analysis-tool'
)
],
tools=[tool]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
tools=[tool]
tools=[tool.bom_ref for tool in tools]

licenses=[DisjunctiveLicense(id='MIT')],
author='Test Author'
)
component.evidence = get_component_evidence_basic(tool=tool_component.bom_ref, bom_ref='ref:setuptools')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
component.evidence = get_component_evidence_basic(tool=tool_component.bom_ref, bom_ref='ref:setuptools')
component.evidence = get_component_evidence_basic(tools=[tool_component])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

implement component.evidence.identity
2 participants