Add declared-license encoding for root components - #12
Conversation
andrew
left a comment
There was a problem hiding this comment.
joinLicenseExpression should use AND, not OR. The three Component fields come from different declaration sources (normalized manifest expression, unrecognized manifest strings, license-file contents); when a project declares MIT in one manifest and points license-file at custom terms in another, both apply. OR grants a choice the project didn't offer. Any actual dual-licensing choice is already encoded inside LicenseExpression by the caller.
One-line change at encode.go:200. The existing parenthesization is correct for AND too. Please also tighten TestEncodeMixedComponentLicenses to assert the top-level conjunction, e.g. strings.Contains(root.LicenseDeclared, ") AND LicenseRef-"), so it's pinned.
Minor, non-blocking:
componentLicensesToSPDXemits duplicatehasExtractedLicensingInfosentries when inputs repeat; fine for the git-pkgs caller which dedupes, worth a follow-up.ExtractedLicense.IDis passed through without aLicenseRef-prefix check; document the constraint on the field or prefix it inextractedLicenseID.- The
xml:tags oncdxBOM/cdxMetadata/cdxComponentand theXMLName/XMLNSfields are dead now the mirror types handle XML encoding.
|
Resolved. Independent component license declarations are now joined with I also addressed the non-blocking notes in the same update:
|
andrew
left a comment
There was a problem hiding this comment.
The follow-up commit addresses the requested license conjunction, deduplication, ID normalization, and serializer cleanup.
Summary
Component.LicenseRefidentifiers for extracted licenses.This is required by git-pkgs/git-pkgs#310 to move root license serialization into the SBOM library.
Verification
go mod tidy -diffgo build ./...go test -race ./... -count=1golangci-lint run ./...