Skip to content
Closed
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
2 changes: 1 addition & 1 deletion syft/pkg/cataloger/apkdb/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func generateUpstream(m pkg.ApkMetadata) string {
}
}

pattern := regexp.MustCompile(`(?P<upstream>\w+?)\-?\d[\d\.]*`)
pattern := regexp.MustCompile(`^(?P<upstream>[\w-]+?)\-?\d[\d\.]*$`)
groups := internal.MatchNamedCaptureGroups(pattern, m.Package)

upstream, ok := groups["upstream"]
Expand Down
28 changes: 28 additions & 0 deletions syft/pkg/cataloger/apkdb/package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,34 @@ func Test_PackageURL(t *testing.T) {
},
expected: "pkg:apk/alpine/abc101.191.23456@101.191.23456?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/abc101-12345-1045@101.191.23456?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/abc101-a12345-1045@101.191.23456?arch=a&upstream=abc101-a12345&distro=alpine-3.4.6",
},
}

for _, test := range tests {
Expand Down