-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #105 from paketo-buildpacks/sbom-deps
Adds support for DependencyLayerContributor and HelperLayerContributor to generate SBOMs
- Loading branch information
Showing
11 changed files
with
484 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ import ( | |
"github.com/sclevine/spec" | ||
|
||
"github.com/paketo-buildpacks/libpak" | ||
"github.com/paketo-buildpacks/libpak/sbom" | ||
) | ||
|
||
func testBuildpack(t *testing.T, context spec.G, it spec.S) { | ||
|
@@ -62,6 +63,37 @@ func testBuildpack(t *testing.T, context spec.G, it spec.S) { | |
})) | ||
}) | ||
|
||
it("renders dependency as a SyftArtifact", func() { | ||
dependency := libpak.BuildpackDependency{ | ||
ID: "test-id", | ||
Name: "test-name", | ||
Version: "1.1.1", | ||
URI: "test-uri", | ||
SHA256: "test-sha256", | ||
Stacks: []string{"test-stack"}, | ||
Licenses: []libpak.BuildpackDependencyLicense{ | ||
{ | ||
Type: "test-type", | ||
URI: "test-uri", | ||
}, | ||
}, | ||
CPEs: []string{"test-cpe1", "test-cpe2"}, | ||
PURL: "test-purl", | ||
} | ||
|
||
Expect(dependency.AsSyftArtifact()).To(Equal(sbom.SyftArtifact{ | ||
ID: "46713835f08d90b7", | ||
Name: "test-name", | ||
Version: "1.1.1", | ||
Type: "UnknownPackage", | ||
FoundBy: "libpak", | ||
Licenses: []string{"test-type"}, | ||
Locations: []sbom.SyftLocation{{Path: "buildpack.toml"}}, | ||
CPEs: []string{"test-cpe1", "test-cpe2"}, | ||
PURL: "test-purl", | ||
})) | ||
}) | ||
|
||
context("NewBuildpackMetadata", func() { | ||
it("deserializes metadata", func() { | ||
actual := map[string]interface{}{ | ||
|
@@ -86,6 +118,8 @@ func testBuildpack(t *testing.T, context spec.G, it spec.S) { | |
"uri": "test-uri", | ||
}, | ||
}, | ||
"cpes": []interface{}{"cpe:2.3:a:test-id:1.1.1"}, | ||
"purl": "pkg:generic:[email protected]", | ||
}, | ||
}, | ||
"include-files": []interface{}{"test-include-file"}, | ||
|
@@ -114,6 +148,8 @@ func testBuildpack(t *testing.T, context spec.G, it spec.S) { | |
URI: "test-uri", | ||
}, | ||
}, | ||
CPEs: []string{"cpe:2.3:a:test-id:1.1.1"}, | ||
PURL: "pkg:generic:[email protected]", | ||
}, | ||
}, | ||
IncludeFiles: []string{"test-include-file"}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,6 +153,8 @@ func testDependencyCache(t *testing.T, context spec.G, it spec.S) { | |
URI: "test-uri", | ||
}, | ||
}, | ||
CPEs: []string{"cpe:2.3:a:some:jre:11.0.2:*:*:*:*:*:*:*"}, | ||
PURL: "pkg:generic/[email protected]?arch=amd64", | ||
} | ||
|
||
dependencyCache = libpak.DependencyCache{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.