mirror of
https://github.com/anchore/grype
synced 2024-11-10 14:44:12 +00:00
Implement support for Chainguard Linux (#1198)
Signed-off-by: Dan Luhring <dluhring@chainguard.dev>
This commit is contained in:
parent
dfcce84cdb
commit
45c5f8c9c7
7 changed files with 33 additions and 2 deletions
|
@ -186,6 +186,10 @@ func Test_NamespaceForDistro(t *testing.T) {
|
|||
version: "2022yzblah", // Wolfi is a rolling release
|
||||
expected: "wolfi:rolling",
|
||||
},
|
||||
{
|
||||
dist: distro.Chainguard,
|
||||
expected: "chainguard:rolling",
|
||||
},
|
||||
}
|
||||
|
||||
observedDistros := strset.New()
|
||||
|
|
|
@ -133,6 +133,7 @@ func TestIndex_NamespacesForDistro(t *testing.T) {
|
|||
"ubuntu:distro:ubuntu:18.04",
|
||||
"oracle:distro:oraclelinux:8",
|
||||
"wolfi:distro:wolfi:rolling",
|
||||
"chainguard:distro:chainguard:rolling",
|
||||
"archlinux:distro:archlinux:rolling",
|
||||
})
|
||||
|
||||
|
@ -267,6 +268,12 @@ func TestIndex_NamespacesForDistro(t *testing.T) {
|
|||
distro.NewNamespace("wolfi", osDistro.Wolfi, "rolling"),
|
||||
},
|
||||
},
|
||||
{
|
||||
distro: newDistro(t, osDistro.Chainguard, "20230214", []string{}),
|
||||
namespaces: []*distro.Namespace{
|
||||
distro.NewNamespace("chainguard", osDistro.Chainguard, "rolling"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
|
|
@ -134,6 +134,7 @@ func TestIndex_NamespacesForDistro(t *testing.T) {
|
|||
"ubuntu:distro:ubuntu:18.04",
|
||||
"oracle:distro:oraclelinux:8",
|
||||
"wolfi:distro:wolfi:rolling",
|
||||
"chainguard:distro:chainguard:rolling",
|
||||
"archlinux:distro:archlinux:rolling",
|
||||
})
|
||||
|
||||
|
@ -310,6 +311,14 @@ func TestIndex_NamespacesForDistro(t *testing.T) {
|
|||
distro.NewNamespace("wolfi", osDistro.Wolfi, "rolling"),
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
name: "Chainguard matches chainguard rolling namespace",
|
||||
distro: newDistro(t, osDistro.Chainguard, "20230214", []string{}),
|
||||
namespaces: []*distro.Namespace{
|
||||
distro.NewNamespace("chainguard", osDistro.Chainguard, "rolling"),
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
name: "Gentoo doesn't match any namespace since the gentoo rolling namespace doesn't exist in index",
|
||||
|
|
|
@ -87,7 +87,7 @@ func (d Distro) String() string {
|
|||
}
|
||||
|
||||
func (d Distro) IsRolling() bool {
|
||||
return d.Type == Wolfi || d.Type == ArchLinux || d.Type == Gentoo
|
||||
return d.Type == Wolfi || d.Type == Chainguard || d.Type == ArchLinux || d.Type == Gentoo
|
||||
}
|
||||
|
||||
// Unsupported Linux distributions
|
||||
|
|
|
@ -208,6 +208,10 @@ func Test_NewDistroFromRelease_Coverage(t *testing.T) {
|
|||
fixture: "test-fixtures/os/wolfi",
|
||||
Type: Wolfi,
|
||||
},
|
||||
{
|
||||
fixture: "test-fixtures/os/chainguard",
|
||||
Type: Chainguard,
|
||||
},
|
||||
}
|
||||
|
||||
observedDistros := internal.NewStringSet()
|
||||
|
@ -243,7 +247,6 @@ func Test_NewDistroFromRelease_Coverage(t *testing.T) {
|
|||
if test.Version != "" {
|
||||
assert.Equal(t, d.Version.String(), test.Version)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
|
5
grype/distro/test-fixtures/os/chainguard/etc/os-release
Normal file
5
grype/distro/test-fixtures/os/chainguard/etc/os-release
Normal file
|
@ -0,0 +1,5 @@
|
|||
ID=chainguard
|
||||
NAME="Chainguard"
|
||||
PRETTY_NAME="Chainguard"
|
||||
VERSION_ID="20230214"
|
||||
HOME_URL="https://chainguard.dev/"
|
|
@ -29,6 +29,7 @@ const (
|
|||
AlmaLinux Type = "almalinux"
|
||||
Gentoo Type = "gentoo"
|
||||
Wolfi Type = "wolfi"
|
||||
Chainguard Type = "chainguard"
|
||||
)
|
||||
|
||||
// All contains all Linux distribution options
|
||||
|
@ -52,6 +53,7 @@ var All = []Type{
|
|||
AlmaLinux,
|
||||
Gentoo,
|
||||
Wolfi,
|
||||
Chainguard,
|
||||
}
|
||||
|
||||
// IDMapping connects a distro ID like "ubuntu" to a Distro type
|
||||
|
@ -75,6 +77,7 @@ var IDMapping = map[string]Type{
|
|||
"almalinux": AlmaLinux,
|
||||
"gentoo": Gentoo,
|
||||
"wolfi": Wolfi,
|
||||
"chainguard": Chainguard,
|
||||
}
|
||||
|
||||
func TypeFromRelease(release linux.Release) Type {
|
||||
|
|
Loading…
Reference in a new issue