Skip to content

Conversation

willmurphyscode
Copy link
Contributor

The Mariner distro feed will start including version ranges in the OVAL XML. Update models and grype-db transformer to be able to handle this in version 5.

This is the other half of anchore/vunnel#585

The Mariner distro feed will start including version ranges in the OVAL
XML. Update models and grype-db transformer to be able to handle this in
version 5.

Signed-off-by: Will Murphy <[email protected]>
@willmurphyscode willmurphyscode marked this pull request as ready for review May 24, 2024 18:11
@willmurphyscode willmurphyscode self-assigned this May 24, 2024
constraint = common.CleanConstraint(constraint)
if len(constraint) == 0 {
func enforceConstraint(fixedVersion, vulnerableRange, format, vulnerabilityID string) string {
if len(vulnerableRange) > 0 && !strings.HasSuffix(vulnerabilityID, "ALASKERNEL") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like there is new special casing for ALASKERNEL, but I don't see how that relates to this (maybe I'm missing something)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ALASKERNEL generates it's own version range from a hard-coded lower bound for a given kernel:

if strings.HasPrefix(vulnerabilityID, "ALASKERNEL-") {

this special casing is to avoid skipping that if vunnel ends up emitting a version range.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an existing test that covers this? if not, can you add a new test for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests cover the behavior:

{
ID: "ALASKERNEL-5.4-2022-007",
PackageName: "kernel-headers",
PackageQualifiers: []qualifier.Qualifier{rpmmodularity.Qualifier{
Kind: "rpm-modularity",
Module: "",
}},
VersionConstraint: ">= 5.4, < 5.4.144-69.257.amzn2",
VersionFormat: "rpm",
Namespace: "amazon:distro:amazonlinux:2",
RelatedVulnerabilities: []grypeDB.VulnerabilityReference{
{
ID: "CVE-2021-3753",
Namespace: "nvd:cpe",
},
{
ID: "CVE-2021-40490",
Namespace: "nvd:cpe",
},
},
Fix: grypeDB.Fix{
Versions: []string{"5.4.144-69.257.amzn2"},
State: grypeDB.FixedState,
},
},
{
ID: "ALASKERNEL-5.4-2022-007",
PackageName: "kernel",
PackageQualifiers: []qualifier.Qualifier{rpmmodularity.Qualifier{
Kind: "rpm-modularity",
Module: "",
}},
VersionConstraint: ">= 5.4, < 5.4.144-69.257.amzn2",
VersionFormat: "rpm",
Namespace: "amazon:distro:amazonlinux:2",
RelatedVulnerabilities: []grypeDB.VulnerabilityReference{
{
ID: "CVE-2021-3753",
Namespace: "nvd:cpe",
},
{
ID: "CVE-2021-40490",
Namespace: "nvd:cpe",
},
},
Fix: grypeDB.Fix{
Versions: []string{"5.4.144-69.257.amzn2"},
State: grypeDB.FixedState,
},
},
{
ID: "ALASKERNEL-5.10-2022-005",
PackageName: "kernel-headers",
PackageQualifiers: []qualifier.Qualifier{rpmmodularity.Qualifier{
Kind: "rpm-modularity",
Module: "",
}},
VersionConstraint: ">= 5.10, < 5.10.62-55.141.amzn2",
VersionFormat: "rpm",
Namespace: "amazon:distro:amazonlinux:2",
RelatedVulnerabilities: []grypeDB.VulnerabilityReference{
{
ID: "CVE-2021-3753",
Namespace: "nvd:cpe",
},
{
ID: "CVE-2021-40490",
Namespace: "nvd:cpe",
},
},
Fix: grypeDB.Fix{
Versions: []string{"5.10.62-55.141.amzn2"},
State: grypeDB.FixedState,
},
},
{
ID: "ALASKERNEL-5.10-2022-005",
PackageName: "kernel",
PackageQualifiers: []qualifier.Qualifier{rpmmodularity.Qualifier{
Kind: "rpm-modularity",
Module: "",
}},
VersionConstraint: ">= 5.10, < 5.10.62-55.141.amzn2",
VersionFormat: "rpm",
Namespace: "amazon:distro:amazonlinux:2",
RelatedVulnerabilities: []grypeDB.VulnerabilityReference{
{
ID: "CVE-2021-3753",
Namespace: "nvd:cpe",
},
{
ID: "CVE-2021-40490",
Namespace: "nvd:cpe",
},
},
Fix: grypeDB.Fix{
Versions: []string{"5.10.62-55.141.amzn2"},
State: grypeDB.FixedState,
},
},
},

But they pass without the hard-coded prefix check, but that's because there's no vulnerable range on the test fixtures:

I think there's also no vulnerable range on the upstream data; it just felt like counting on a coincidence to leave out the ALASKERNEL- prefix check.

Then again, if upstream vunnel starts shipping version ranges on ALASKERNEL- vulnerabilities, why shouldn't grype-db believe vunnel? I think it might make sense to remove the check here.

If the ALAS provider starts emitting vulnerableRange for ALAS kernel
vulnerabilities, there's no reason grype-db shouldn't respect them.

Signed-off-by: Will Murphy <[email protected]>
@willmurphyscode willmurphyscode merged commit ab9a900 into main May 28, 2024
@willmurphyscode willmurphyscode deleted the feat-range-in-os-vuln branch May 28, 2024 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants