Skip to content

Commit

Permalink
ensure azurelinux ids get same version processing as mariner (#2499)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Goodman <[email protected]>
  • Loading branch information
wagoodman authored Mar 3, 2025
1 parent f6b81ba commit 152d04a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
10 changes: 7 additions & 3 deletions grype/db/v6/vulnerability.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,14 @@ func MimicV5Namespace(vuln *VulnerabilityHandle, affected *AffectedPackageHandle
switch affected.OperatingSystem.Name {
case "amazon":
family = "amazonlinux"
case "mariner":
major := strings.Split(ver, ".")[0]
if strings.Count(ver, ".") < 1 {
case "mariner", "azurelinux":
fields := strings.Split(ver, ".")
major := fields[0]
switch len(fields) {
case 1:
ver = fmt.Sprintf("%s.0", major)
default:
ver = fmt.Sprintf("%s.%s", major, fields[1])
}
switch major {
case "1", "2":
Expand Down
30 changes: 29 additions & 1 deletion grype/db/v6/vulnerability_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,12 +360,40 @@ func TestV5Namespace(t *testing.T) {
expected: "mariner:distro:azurelinux:3.0",
},
{
name: "mariner azure version",
name: "mariner azure version (missing version fields)",
provider: "mariner",
osName: "mariner",
osVersion: "3",
expected: "mariner:distro:azurelinux:3.0",
},
{
name: "azurelinux version (extra version fields)",
provider: "mariner",
osName: "azurelinux",
osVersion: "3.0.20240727",
expected: "mariner:distro:azurelinux:3.0",
},
{
name: "azurelinux version",
provider: "mariner",
osName: "azurelinux",
osVersion: "3.0",
expected: "mariner:distro:azurelinux:3.0",
},
{
name: "azurelinux version (missing version fields)",
provider: "mariner",
osName: "azurelinux",
osVersion: "3",
expected: "mariner:distro:azurelinux:3.0",
},
{
name: "mariner azure version (extra version fields)",
provider: "mariner",
osName: "mariner",
osVersion: "3.0.20240727",
expected: "mariner:distro:azurelinux:3.0",
},
{
name: "oracle linux distribution",
provider: "oracle",
Expand Down

0 comments on commit 152d04a

Please sign in to comment.