Skip to content

Commit

Permalink
feat: add LicenseComment field
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriyLewen committed Dec 12, 2024
1 parent f851f9b commit 041ab21
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions pkg/sbom/spdx/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ func (m *Marshaler) newOtherLicense(license string, text bool) *spdx.OtherLicens
}
if text {
otherLicense.ExtractedText = license
otherLicense.LicenseComment = "The license text represents text found in package metadata and may not represent the full text of the license"
} else {
otherLicense.LicenseName = license
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/sbom/spdx/marshal_private_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,18 @@ func TestMarshaler_normalizeLicenses(t *testing.T) {
"AFL 2.0",
"unknown-license",
},
wantLicenseName: "LicenseRef-c5e3a1aeaab71db AND AFL-2.0 AND LicenseRef-8960e1168859663e",
wantLicenseName: "LicenseRef-ffca10435cadded4 AND AFL-2.0 AND LicenseRef-8960e1168859663e",
wantOtherLicenses: []*spdx.OtherLicense{
{
LicenseIdentifier: "LicenseRef-8960e1168859663e",
LicenseName: "unknown-license",
ExtractedText: "NOASSERTION",
},
{
LicenseIdentifier: "LicenseRef-c5e3a1aeaab71db",
LicenseIdentifier: "LicenseRef-ffca10435cadded4",
LicenseName: "NOASSERTION",
ExtractedText: "unknown-license",
LicenseComment: "The license text represents text found in package metadata and may not represent the full text of the license",
},
},
},
Expand Down
2 changes: 2 additions & 0 deletions pkg/sbom/spdx/marshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -963,11 +963,13 @@ func TestMarshaler_Marshal(t *testing.T) {
LicenseIdentifier: "LicenseRef-14b1606fb243e2b6",
LicenseName: "NOASSERTION",
ExtractedText: "BSD-4-clause",
LicenseComment: "The license text represents text found in package metadata and may not represent the full text of the license",
},
{
LicenseIdentifier: "LicenseRef-229659393343e160",
LicenseName: "NOASSERTION",
ExtractedText: "UNKNOWN",
LicenseComment: "The license text represents text found in package metadata and may not represent the full text of the license",
},
{
LicenseIdentifier: "LicenseRef-73d50f1d1ecbdb3b",
Expand Down

0 comments on commit 041ab21

Please sign in to comment.