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.
refactor: move apk upstream logic to apk metadata (anchore#1619)
* refactor: move apk upstream logic to apk metadata Export the logic for parsing upstream APK package names so it can be accessed from apk metadata objects directly. This also tightens the upstream regex pattern as several edge cases were being missed. Signed-off-by: Weston Steimel <[email protected]> * fix: ensure correct handling for apk packages beginning with digits Signed-off-by: Weston Steimel <[email protected]> * fix: upstream generation for ruby Signed-off-by: Weston Steimel <[email protected]> --------- Signed-off-by: Weston Steimel <[email protected]>
- Loading branch information
1 parent
ddfb8ec
commit 4ddfff9
Showing
4 changed files
with
226 additions
and
31 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
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 |
---|---|---|
|
@@ -208,6 +208,34 @@ func Test_PackageURL(t *testing.T) { | |
}, | ||
expected: "pkg:apk/alpine/[email protected]?arch=a&upstream=abc&distro=alpine-3.4.6", | ||
}, | ||
{ | ||
name: "abc101-12345-1045 upstream abc101-12345", | ||
metadata: pkg.ApkMetadata{ | ||
Package: "abc101-12345-1045", | ||
Version: "101.191.23456", | ||
Architecture: "a", | ||
OriginPackage: "abc101-12345-1045", | ||
}, | ||
distro: linux.Release{ | ||
ID: "alpine", | ||
VersionID: "3.4.6", | ||
}, | ||
expected: "pkg:apk/alpine/[email protected]?arch=a&upstream=abc101-12345&distro=alpine-3.4.6", | ||
}, | ||
{ | ||
name: "abc101-a12345-1045 upstream abc101-a12345", | ||
metadata: pkg.ApkMetadata{ | ||
Package: "abc101-a12345-1045", | ||
Version: "101.191.23456", | ||
Architecture: "a", | ||
OriginPackage: "abc101-a12345-1045", | ||
}, | ||
distro: linux.Release{ | ||
ID: "alpine", | ||
VersionID: "3.4.6", | ||
}, | ||
expected: "pkg:apk/alpine/[email protected]?arch=a&upstream=abc101-a12345&distro=alpine-3.4.6", | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
|