Skip to content
Merged
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
7 changes: 7 additions & 0 deletions grype/db/v5/namespace/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ func (i *Index) NamespacesForDistro(d *grypeDistro.Distro) []*distro.Namespace {
}
}

if versionSegments == nil && d.Type == grypeDistro.Debian && d.RawVersion == "unstable" {
distroKey := fmt.Sprintf("%s:%s", strings.ToLower(d.Type.String()), "unstable")
if v, ok := i.byDistroKey[distroKey]; ok {
return v
}
}

return nil
}

Expand Down
12 changes: 12 additions & 0 deletions grype/db/v5/namespace/index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ func TestIndex_NamespacesForDistro(t *testing.T) {
"alpine:distro:alpine:3.16",
"alpine:distro:alpine:edge",
"debian:distro:debian:8",
"debian:distro:debian:unstable",
"amazon:distro:amazonlinux:2",
"amazon:distro:amazonlinux:2022",
"abc.xyz:distro:unknown:123.456",
Expand Down Expand Up @@ -346,6 +347,17 @@ func TestIndex_NamespacesForDistro(t *testing.T) {
distro: newDistro(t, osDistro.Busybox, "20.1", []string{}),
namespaces: nil,
},
{
name: "debian unstable",
distro: &osDistro.Distro{
Type: osDistro.Debian,
RawVersion: "unstable",
Version: nil,
},
namespaces: []*distro.Namespace{
distro.NewNamespace("debian", osDistro.Debian, "unstable"),
},
},
}

for _, test := range tests {
Expand Down
8 changes: 8 additions & 0 deletions grype/distro/distro.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ func NewFromRelease(release linux.Release) (*Distro, error) {
}
}

if t == Debian && release.VersionID == "" && release.Version == "" && strings.Contains(release.PrettyName, "sid") {
return &Distro{
Type: t,
RawVersion: "unstable",
IDLike: release.IDLike,
}, nil
}

return New(t, selectedVersion, release.IDLike...)
}

Expand Down
15 changes: 15 additions & 0 deletions grype/distro/distro_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,21 @@ func Test_NewDistroFromRelease(t *testing.T) {
},
expectErr: true,
},
{
// syft -o json debian:testing | jq .distro
name: "unstable debian",
release: linux.Release{
ID: "debian",
VersionID: "",
Version: "",
PrettyName: "Debian GNU/Linux trixie/sid",
VersionCodename: "trixie",
Name: "Debian GNU/Linux",
},
expectedType: Debian,
expectedRawVersion: "unstable",
expectedVersion: "",
},
}

for _, test := range tests {
Expand Down