forked from anchore/syft
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: correct apk purls for other distros (anchore#1620)
The apk purl spec allows for vendor-specific namespace. I noticed in the embedded SBOMs from wolfi that the purls are of the form `pkg:apk/wolfi/[email protected]?arch=x86`, but the current logic in syft actually prevents purl generation entirely if the distro isn't alpine, so this corrects that behaviour. Signed-off-by: Weston Steimel <[email protected]>
- Loading branch information
1 parent
4ddfff9
commit 96e952b
Showing
2 changed files
with
17 additions
and
5 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 |
---|---|---|
|
@@ -20,7 +20,7 @@ func Test_PackageURL(t *testing.T) { | |
expected string | ||
}{ | ||
{ | ||
name: "bad distro", | ||
name: "non-alpine distro", | ||
metadata: pkg.ApkMetadata{ | ||
Package: "p", | ||
Version: "v", | ||
|
@@ -30,7 +30,7 @@ func Test_PackageURL(t *testing.T) { | |
ID: "something else", | ||
VersionID: "3.4.6", | ||
}, | ||
expected: "", | ||
expected: "pkg:apk/something%20else/p@v?arch=a&distro=something%20else-3.4.6", | ||
}, | ||
{ | ||
name: "gocase", | ||
|
@@ -236,6 +236,19 @@ func Test_PackageURL(t *testing.T) { | |
}, | ||
expected: "pkg:apk/alpine/[email protected]?arch=a&upstream=abc101-a12345&distro=alpine-3.4.6", | ||
}, | ||
{ | ||
name: "wolfi distro", | ||
metadata: pkg.ApkMetadata{ | ||
Package: "p", | ||
Version: "v", | ||
Architecture: "a", | ||
}, | ||
distro: linux.Release{ | ||
ID: "wolfi", | ||
VersionID: "20221230", | ||
}, | ||
expected: "pkg:apk/wolfi/p@v?arch=a&distro=wolfi-20221230", | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
|