Skip to content

feat!: dont "fix" licenses if not needed. #995

@jkowalleck

Description

@jkowalleck

currently, we "fix" licenses

"""
Per CycloneDX spec, there must be EITHER one license expression OR multiple license id/name.
If there is an expression, it is used and everything else is moved to evidences, so it is not lost.
"""
# hack for preventing expressions AND named licenses.
# see https://github.com/CycloneDX/cyclonedx-python/issues/826
# see https://github.com/CycloneDX/specification/issues/454

see

def licenses_fixup(component: 'Component') -> None:
"""
Per CycloneDX spec, there must be EITHER one license expression OR multiple license id/name.
If there is an expression, it is used and everything else is moved to evidences, so it is not lost.
"""
# hack for preventing expressions AND named licenses.
# see https://github.com/CycloneDX/cyclonedx-python/issues/826
# see https://github.com/CycloneDX/specification/issues/454
licenses = list(component.licenses)
lexp = find_LicenseExpression(licenses)
if lexp is None:
return
component.licenses = (lexp,)
licenses.remove(lexp)
if len(licenses) > 0:
if component.evidence is None:
component.evidence = ComponentEvidence()
component.evidence.licenses.update(licenses)

this is no longer needed since CycloneDX 1.7

feature request: dont "fix" licenses if not needed.

this might be considered a breaking change, since the output result might be different.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions