-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(sbom): save digests for package/application when scanning SBOM fi…
…les (#5432) Signed-off-by: knqyf263 <[email protected]> Co-authored-by: knqyf263 <[email protected]>
- Loading branch information
1 parent
048150d
commit ca50b77
Showing
4 changed files
with
94 additions
and
0 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 |
---|---|---|
|
@@ -199,6 +199,88 @@ func TestApplyLayers(t *testing.T) { | |
}, | ||
}, | ||
}, | ||
{ | ||
name: "happy path with digests in libs/packages (as for SBOM)", | ||
inputLayers: []types.BlobInfo{ | ||
{ | ||
SchemaVersion: 2, | ||
OS: types.OS{ | ||
Family: "debian", | ||
Name: "11.8", | ||
}, | ||
PackageInfos: []types.PackageInfo{ | ||
{ | ||
Packages: types.Packages{ | ||
{ | ||
ID: "[email protected]+deb11u1", | ||
Name: "adduser", | ||
Version: "3.118+deb11u1", | ||
Arch: "all", | ||
SrcName: "adduser", | ||
SrcVersion: "3.118+deb11u1", | ||
Ref: "pkg:deb/debian/[email protected]%2Bdeb11u1?arch=all&distro=debian-11.8", | ||
Layer: types.Layer{ | ||
Digest: "sha256:e67fdae3559346105027c63e7fb032bba57e62b1fe9f2da23e6fdfb56384e00b", | ||
DiffID: "sha256:633f5bf471f7595b236a21e62dc60beef321db45916363a02ad5af02d794d497", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
Applications: []types.Application{ | ||
{ | ||
Type: types.PythonPkg, | ||
Libraries: types.Packages{ | ||
{ | ||
Name: "pip", | ||
Version: "23.0.1", | ||
Layer: types.Layer{ | ||
DiffID: "sha256:1def056a3160854c9395aa76282dd62172ec08c18a5fa03bb7d50a777c15ba99", | ||
}, | ||
FilePath: "usr/local/lib/python3.9/site-packages/pip-23.0.1.dist-info/METADATA", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
want: types.ArtifactDetail{ | ||
OS: types.OS{ | ||
Family: "debian", | ||
Name: "11.8", | ||
}, | ||
Packages: types.Packages{ | ||
{ | ||
ID: "[email protected]+deb11u1", | ||
Name: "adduser", | ||
Version: "3.118+deb11u1", | ||
Arch: "all", | ||
SrcName: "adduser", | ||
SrcVersion: "3.118+deb11u1", | ||
Ref: "pkg:deb/debian/[email protected]%2Bdeb11u1?arch=all&distro=debian-11.8", | ||
Layer: types.Layer{ | ||
Digest: "sha256:e67fdae3559346105027c63e7fb032bba57e62b1fe9f2da23e6fdfb56384e00b", | ||
DiffID: "sha256:633f5bf471f7595b236a21e62dc60beef321db45916363a02ad5af02d794d497", | ||
}, | ||
}, | ||
}, | ||
Applications: []types.Application{ | ||
{ | ||
Type: types.PythonPkg, | ||
Libraries: types.Packages{ | ||
{ | ||
Name: "pip", | ||
Version: "23.0.1", | ||
FilePath: "usr/local/lib/python3.9/site-packages/pip-23.0.1.dist-info/METADATA", | ||
Layer: types.Layer{ | ||
DiffID: "sha256:1def056a3160854c9395aa76282dd62172ec08c18a5fa03bb7d50a777c15ba99", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: "happy path with merging ubuntu version and ESM", | ||
inputLayers: []types.BlobInfo{ | ||
|
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 |
---|---|---|
|
@@ -221,6 +221,7 @@ func TestUnmarshaler_Unmarshal(t *testing.T) { | |
}, | ||
Ref: "pkg:deb/ubuntu/[email protected]?distro=ubuntu-22.04", | ||
Layer: ftypes.Layer{ | ||
Digest: "sha256:74ac377868f863e123f24c409f79709f7563fa464557c36a09cf6f85c8b92b7f", | ||
DiffID: "sha256:b93c1bd012ab8fda60f5b4f5906bf244586e0e3292d84571d3abb56472248466", | ||
}, | ||
}, | ||
|
@@ -235,6 +236,7 @@ func TestUnmarshaler_Unmarshal(t *testing.T) { | |
SrcEpoch: 1, | ||
Ref: "pkg:deb/ubuntu/[email protected]?epoch=1&distro=ubuntu-22.04", | ||
Layer: ftypes.Layer{ | ||
Digest: "sha256:74ac377868f863e123f24c409f79709f7563fa464557c36a09cf6f85c8b92b7f", | ||
DiffID: "sha256:b93c1bd012ab8fda60f5b4f5906bf244586e0e3292d84571d3abb56472248466", | ||
}, | ||
}, | ||
|