Skip to content

Commit

Permalink
fix(sbom): use NOASSERTION for licenses fields in SPDX formats (#7403)
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriyLewen authored Aug 29, 2024
1 parent 7aea79d commit c96dcdd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 27 deletions.
12 changes: 6 additions & 6 deletions integration/testdata/julia-spdx.json.golden
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"downloadLocation": "NONE",
"filesAnalyzed": false,
"sourceInfo": "package found in: Manifest.toml",
"licenseConcluded": "NONE",
"licenseDeclared": "NONE",
"licenseConcluded": "NOASSERTION",
"licenseDeclared": "NOASSERTION",
"externalRefs": [
{
"referenceCategory": "PACKAGE-MANAGER",
Expand All @@ -54,8 +54,8 @@
"downloadLocation": "NONE",
"filesAnalyzed": false,
"sourceInfo": "package found in: Manifest.toml",
"licenseConcluded": "NONE",
"licenseDeclared": "NONE",
"licenseConcluded": "NOASSERTION",
"licenseDeclared": "NOASSERTION",
"externalRefs": [
{
"referenceCategory": "PACKAGE-MANAGER",
Expand All @@ -77,8 +77,8 @@
"downloadLocation": "NONE",
"filesAnalyzed": false,
"sourceInfo": "package found in: Manifest.toml",
"licenseConcluded": "NONE",
"licenseDeclared": "NONE",
"licenseConcluded": "NOASSERTION",
"licenseDeclared": "NOASSERTION",
"externalRefs": [
{
"referenceCategory": "PACKAGE-MANAGER",
Expand Down
3 changes: 2 additions & 1 deletion pkg/sbom/spdx/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const (
CreatorOrganization = "aquasecurity"
CreatorTool = "trivy"
noneField = "NONE"
noAssertionField = "NOASSERTION"
)

const (
Expand Down Expand Up @@ -378,7 +379,7 @@ func (m *Marshaler) spdxAttributionTexts(c *core.Component) []string {

func (m *Marshaler) spdxLicense(c *core.Component) string {
if len(c.Licenses) == 0 {
return noneField
return noAssertionField
}
return NormalizeLicense(c.Licenses)
}
Expand Down
40 changes: 20 additions & 20 deletions pkg/sbom/spdx/marshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ func TestMarshaler_Marshal(t *testing.T) {
PackageDownloadLocation: "NONE",
PackageName: "actioncontroller",
PackageVersion: "7.0.1",
PackageLicenseConcluded: "NONE",
PackageLicenseDeclared: "NONE",
PackageLicenseConcluded: "NOASSERTION",
PackageLicenseDeclared: "NOASSERTION",
PackageAttributionTexts: []string{
"PkgType: bundler",
},
Expand All @@ -238,8 +238,8 @@ func TestMarshaler_Marshal(t *testing.T) {
PackageDownloadLocation: "NONE",
PackageName: "actionpack",
PackageVersion: "7.0.1",
PackageLicenseConcluded: "NONE",
PackageLicenseDeclared: "NONE",
PackageLicenseConcluded: "NOASSERTION",
PackageLicenseDeclared: "NOASSERTION",
PackageAttributionTexts: []string{
"PkgType: bundler",
},
Expand All @@ -259,8 +259,8 @@ func TestMarshaler_Marshal(t *testing.T) {
PackageDownloadLocation: "NONE",
PackageName: "actionpack",
PackageVersion: "7.0.1",
PackageLicenseConcluded: "NONE",
PackageLicenseDeclared: "NONE",
PackageLicenseConcluded: "NOASSERTION",
PackageLicenseDeclared: "NOASSERTION",
PackageAttributionTexts: []string{
"PkgType: bundler",
},
Expand Down Expand Up @@ -536,8 +536,8 @@ func TestMarshaler_Marshal(t *testing.T) {
PackageDownloadLocation: "NONE",
PackageName: "actionpack",
PackageVersion: "7.0.1",
PackageLicenseConcluded: "NONE",
PackageLicenseDeclared: "NONE",
PackageLicenseConcluded: "NOASSERTION",
PackageLicenseDeclared: "NOASSERTION",
PackageExternalReferences: []*spdx.PackageExternalReference{
{
Category: tspdx.CategoryPackageManager,
Expand All @@ -561,8 +561,8 @@ func TestMarshaler_Marshal(t *testing.T) {
PackageDownloadLocation: "NONE",
PackageName: "actionpack",
PackageVersion: "7.0.1",
PackageLicenseConcluded: "NONE",
PackageLicenseDeclared: "NONE",
PackageLicenseConcluded: "NOASSERTION",
PackageLicenseDeclared: "NOASSERTION",
PackageExternalReferences: []*spdx.PackageExternalReference{
{
Category: tspdx.CategoryPackageManager,
Expand Down Expand Up @@ -750,8 +750,8 @@ func TestMarshaler_Marshal(t *testing.T) {
PackageDownloadLocation: "NONE",
PackageName: "actioncable",
PackageVersion: "6.1.4.1",
PackageLicenseConcluded: "NONE",
PackageLicenseDeclared: "NONE",
PackageLicenseConcluded: "NOASSERTION",
PackageLicenseDeclared: "NOASSERTION",
PackageExternalReferences: []*spdx.PackageExternalReference{
{
Category: tspdx.CategoryPackageManager,
Expand All @@ -771,8 +771,8 @@ func TestMarshaler_Marshal(t *testing.T) {
PackageDownloadLocation: "NONE",
PackageName: "com.example:example",
PackageVersion: "1.0.0",
PackageLicenseConcluded: "NONE",
PackageLicenseDeclared: "NONE",
PackageLicenseConcluded: "NOASSERTION",
PackageLicenseDeclared: "NOASSERTION",
PackageExternalReferences: []*spdx.PackageExternalReference{
{
Category: tspdx.CategoryPackageManager,
Expand Down Expand Up @@ -889,8 +889,8 @@ func TestMarshaler_Marshal(t *testing.T) {
PackageDownloadLocation: "NONE",
PackageName: "org.apache.logging.log4j:log4j-core",
PackageVersion: "2.17.0",
PackageLicenseConcluded: "NONE",
PackageLicenseDeclared: "NONE",
PackageLicenseConcluded: "NOASSERTION",
PackageLicenseDeclared: "NOASSERTION",
PackageExternalReferences: []*spdx.PackageExternalReference{
{
Category: tspdx.CategoryPackageManager,
Expand Down Expand Up @@ -1229,8 +1229,8 @@ func TestMarshaler_Marshal(t *testing.T) {
PackageSPDXIdentifier: spdx.ElementID("Package-b1c3b9e2363f5ff7"),
PackageDownloadLocation: "NONE",
PackageName: "./private_repos/cnrm.googlesource.com/cnrm/",
PackageLicenseConcluded: "NONE",
PackageLicenseDeclared: "NONE",
PackageLicenseConcluded: "NOASSERTION",
PackageLicenseDeclared: "NOASSERTION",
PrimaryPackagePurpose: tspdx.PackagePurposeLibrary,
PackageSupplier: &spdx.Supplier{Supplier: tspdx.PackageSupplierNoAssertion},
PackageSourceInfo: "package found in: /usr/local/bin/test",
Expand All @@ -1243,8 +1243,8 @@ func TestMarshaler_Marshal(t *testing.T) {
PackageDownloadLocation: "NONE",
PackageName: "golang.org/x/crypto",
PackageVersion: "v0.0.1",
PackageLicenseConcluded: "NONE",
PackageLicenseDeclared: "NONE",
PackageLicenseConcluded: "NOASSERTION",
PackageLicenseDeclared: "NOASSERTION",
PackageExternalReferences: []*spdx.PackageExternalReference{
{
Category: tspdx.CategoryPackageManager,
Expand Down

0 comments on commit c96dcdd

Please sign in to comment.