Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cmd/license.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,9 @@ func hashComponentLicense(bom *schema.BOM, policyConfig *schema.LicensePolicyCon

// Issue a warning that the component had no license; use "safe" BOMRef string value
warnInvalidResourceLicense(schema.RESOURCE_TYPE_COMPONENT, licenseInfo.BOMRef.String(), cdxComponent.Name, cdxComponent.Version)
// No actual licenses to process
return
if err != nil {
return
}
}

// Recursively hash licenses for all child components (i.e., hierarchical composition)
Expand Down
9 changes: 9 additions & 0 deletions cmd/license_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const (
TEST_LICENSE_LIST_CDX_1_3 = "test/cyclonedx/1.3/cdx-1-3-license-list.json"
TEST_LICENSE_LIST_CDX_1_3_NONE_FOUND = "test/cyclonedx/1.3/cdx-1-3-license-list-none-found.json"
TEST_LICENSE_LIST_CDX_1_4_NONE_FOUND = "test/cyclonedx/1.4/cdx-1-4-license-list-none-found.json"
TEST_LICENSE_LIST_CDX_1_4_PARENT_NO_LICENSE = "test/cyclonedx/1.4/cdx-1-4-license-list-parent-no-license.json"
TEST_LICENSE_LIST_CDX_1_5_LICENSE_CHOICE_VARIANTS = "test/cyclonedx/1.5/cdx-1-5-license-choice-variants.json"
TEST_LICENSE_LIST_CDX_1_5_MATURE_EXAMPLE_1 = TEST_CDX_1_5_MATURE_EXAMPLE_1_BASE

Expand Down Expand Up @@ -219,6 +220,14 @@ func TestLicenseListCdx14CsvNoneFound(t *testing.T) {
innerTestLicenseList(t, lti)
}

func TestLicenseListCdx14CsvParentNoLicense(t *testing.T) {
lti := NewLicenseTestInfo(TEST_LICENSE_LIST_CDX_1_4_PARENT_NO_LICENSE, FORMAT_CSV, false)
lti.ResultExpectedLineCount = 5 // title only + 2 UNDEFINED (metadata and parent) + 1 Apache 2.0 (child) + newline
lti.ResultLineContainsValues = []string{"Apache-2.0"}
lti.ResultLineContainsValuesAtLineNum = 1
innerTestLicenseList(t, lti)
}

func TestLicenseListCdx13MarkdownNoneFound(t *testing.T) {
// Test CDX 1.3 document
lti := NewLicenseTestInfo(TEST_LICENSE_LIST_CDX_1_3_NONE_FOUND, FORMAT_MARKDOWN, false)
Expand Down
32 changes: 32 additions & 0 deletions test/cyclonedx/1.4/cdx-1-4-license-list-parent-no-license.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"bomFormat": "CycloneDX",
"specVersion": "1.4",
"serialNumber": "urn:uuid:a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"version": 1,
"metadata": {
"timestamp": "2024-01-01T00:00:00Z",
"component": {
"type": "application",
"name": "ACME Application"
}
},
"components": [
{
"type": "library",
"name": "parent-no-license",
"components": [
{
"type": "library",
"name": "child-with-license",
"licenses": [
{
"license": {
"id": "Apache-2.0"
}
}
]
}
]
}
]
}
Loading