mirror of
https://github.com/anchore/grype
synced 2024-11-10 06:34:13 +00:00
feat: add strong distro type for wolfi (#996)
This commit is contained in:
parent
3e0af43383
commit
ef1934a5c1
7 changed files with 28 additions and 1 deletions
|
@ -71,6 +71,8 @@ func NamespaceForDistro(d *distro.Distro) string {
|
|||
return fmt.Sprintf("sles:%d.%d", versionSegments[0], versionSegments[1])
|
||||
case distro.Windows:
|
||||
return fmt.Sprintf("%s:%d", MSRCNamespacePrefix, versionSegments[0])
|
||||
case distro.Wolfi:
|
||||
return "wolfi:rolling"
|
||||
}
|
||||
}
|
||||
return fmt.Sprintf("%s:%s", strings.ToLower(d.Type.String()), d.FullVersion())
|
||||
|
|
|
@ -178,9 +178,14 @@ func Test_NamespaceForDistro(t *testing.T) {
|
|||
},
|
||||
{
|
||||
dist: distro.Gentoo,
|
||||
version: "", // Gentoo doesn't expose a version
|
||||
version: "", // Gentoo is a rolling release
|
||||
expected: "gentoo:",
|
||||
},
|
||||
{
|
||||
dist: distro.Wolfi,
|
||||
version: "2022yzblah", // Wolfi is a rolling release
|
||||
expected: "wolfi:rolling",
|
||||
},
|
||||
}
|
||||
|
||||
observedDistros := strset.New()
|
||||
|
|
|
@ -37,6 +37,10 @@ func TestFromString(t *testing.T) {
|
|||
namespaceString: "amazon:distro:amazonlinux:2",
|
||||
result: NewNamespace("amazon", grypeDistro.AmazonLinux, "2"),
|
||||
},
|
||||
{
|
||||
namespaceString: "wolfi:distro:wolfi:rolling",
|
||||
result: NewNamespace("wolfi", grypeDistro.Wolfi, "rolling"),
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range successTests {
|
||||
|
|
|
@ -37,6 +37,10 @@ func TestFromString(t *testing.T) {
|
|||
namespaceString: "amazon:distro:amazonlinux:2",
|
||||
result: NewNamespace("amazon", grypeDistro.AmazonLinux, "2"),
|
||||
},
|
||||
{
|
||||
namespaceString: "wolfi:distro:wolfi:rolling",
|
||||
result: NewNamespace("wolfi", grypeDistro.Wolfi, "rolling"),
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range successTests {
|
||||
|
|
|
@ -204,6 +204,10 @@ func Test_NewDistroFromRelease_Coverage(t *testing.T) {
|
|||
fixture: "test-fixtures/os/gentoo",
|
||||
Type: Gentoo,
|
||||
},
|
||||
{
|
||||
fixture: "test-fixtures/os/wolfi",
|
||||
Type: Wolfi,
|
||||
},
|
||||
}
|
||||
|
||||
observedDistros := internal.NewStringSet()
|
||||
|
|
5
grype/distro/test-fixtures/os/wolfi/etc/os-release
Normal file
5
grype/distro/test-fixtures/os/wolfi/etc/os-release
Normal file
|
@ -0,0 +1,5 @@
|
|||
ID=wolfi
|
||||
NAME="Wolfi"
|
||||
PRETTY_NAME="Wolfi"
|
||||
VERSION_ID="20220914"
|
||||
HOME_URL="https://wolfi.dev"
|
|
@ -28,6 +28,7 @@ const (
|
|||
RockyLinux Type = "rockylinux"
|
||||
AlmaLinux Type = "almalinux"
|
||||
Gentoo Type = "gentoo"
|
||||
Wolfi Type = "wolfi"
|
||||
)
|
||||
|
||||
// All contains all Linux distribution options
|
||||
|
@ -50,6 +51,7 @@ var All = []Type{
|
|||
RockyLinux,
|
||||
AlmaLinux,
|
||||
Gentoo,
|
||||
Wolfi,
|
||||
}
|
||||
|
||||
// IDMapping connects a distro ID like "ubuntu" to a Distro type
|
||||
|
@ -72,6 +74,7 @@ var IDMapping = map[string]Type{
|
|||
"rocky": RockyLinux,
|
||||
"almalinux": AlmaLinux,
|
||||
"gentoo": Gentoo,
|
||||
"wolfi": Wolfi,
|
||||
}
|
||||
|
||||
func TypeFromRelease(release linux.Release) Type {
|
||||
|
|
Loading…
Reference in a new issue