Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to parse constraint of CVE-2024-6345 which fails the scan #2048

Closed
tomersein opened this issue Aug 12, 2024 · 6 comments · Fixed by #2049
Closed

Failed to parse constraint of CVE-2024-6345 which fails the scan #2048

tomersein opened this issue Aug 12, 2024 · 6 comments · Fixed by #2049
Assignees
Labels
bug Something isn't working

Comments

@tomersein
Copy link
Contributor

tomersein commented Aug 12, 2024

What happened:
I have an image based on alpine 3.20 and the scan fails. The error is:
unable to find matches in DB: provider failed to inflate vulnerability record (namespace="alpine:distro:alpine:3.20" id="CVE-2024-6345" distro="alpine 3.20.2"): failed to parse constraint='< 70.3.0-rc0' format='Apk': unable to parse apk constraint phrase: failed to create comparator for '&{< 70.3.0-rc0}': unable to parse constraint version (70.3.0-rc0): invalid version
What you expected to happen:
Scan should pass
How to reproduce it (as minimally and precisely as possible):
Here is a Dockerfile to reproduce:

# Use the Alpine 3.20 image as the base image
FROM alpine:3.20

# Install the py3-setuptools package
RUN apk add --no-cache py3-setuptools

# Set a default command, you can replace this with the command you want the container to run
CMD ["sh"]

Anything else we need to know?:
I checked on alpine 3.19 and it works.
might it be related to the phrase "rc" inside the constraint?
Environment:

  • Output of grype version: 0.79.5
  • OS (e.g: cat /etc/os-release or similar): mac
@tomersein tomersein added the bug Something isn't working label Aug 12, 2024
@josh-alles
Copy link

I'm having the same issue with Alpine 3.20.2 The same scan worked last week.

One thing that sticks out to me was previously the Vulnerability field was not showing the GHSA instead of the CVE:

NAME INSTALLED FIXED-IN TYPE VULNERABILITY SEVERITY
setuptools 69.5.1 70.0.0 python GHSA-cx63-2mw6-8hw5 High

And now it looks like the error is complaining about the CVE tied to the same vulnerability as the GHSA. Not sure if that's related, but it was the first time I a vulnerability show up as the GHSA.

@wagoodman
Copy link
Contributor

There are multiple things happening here, one being upstream data changing... but aside from that this kind of error should not be fatal (the user should be able to get a grype report even if the data is problematic/unexpected upstream).

Today the vulnerability provider code can raise up errors when the constraint isn't parsed correctly

vulnObj, err := vulnerability.NewVulnerability(vuln)
if err != nil {
return nil, fmt.Errorf("provider failed to inflate vulnerability record (namespace=%q id=%q distro=%q): %w", vuln.Namespace, vuln.ID, d, err)
}
. This should change, specifically any GetBy* methods should not return errors for these cases (unable to inflate vulnerability record from DB), instead we should be logging warnings. Though the user cannot take action to fix this, the state of the vuln data does affect the vuln report (potentially missing results) so we should let the user know without requiring debug.

@wagoodman wagoodman moved this to Ready in OSS Aug 12, 2024
@spiffcs
Copy link
Contributor

spiffcs commented Aug 12, 2024

Here is a link to the secfix that's causing the headache - it looks like this was merged a day ago which is an incorrect version constraint for alpine

https://gitlab.alpinelinux.org/alpine/aports/-/blob/3.20-stable/main/py3-setuptools/APKBUILD?ref_type=heads#L39-41

I'll try and get a PR submitted to fix this in the data, but I agree with @wagoodman's statement above as well that we should protect more against this.

Change request filed:
https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/70435

@tomersein
Copy link
Contributor Author

hi, thanks for the fast investigation!
when do you think this fix will be merged?

@wagoodman
Copy link
Contributor

We'll put in a new release with the error handing in probably today (may even cut a release today), but it isn't clear when the upstream data will be addressed (thus this particular CVE will be omitted from grype results when this error processing fix lands).

@wagoodman wagoodman moved this from Ready to In Progress in OSS Aug 12, 2024
@wagoodman wagoodman self-assigned this Aug 12, 2024
@tomersein
Copy link
Contributor Author

sounds perfect 👍

@github-project-automation github-project-automation bot moved this from In Progress to Done in OSS Aug 12, 2024
@wagoodman wagoodman changed the title failed to parse constraint of CVE-2024-6345 which fails the scan Failed to parse constraint of CVE-2024-6345 which fails the scan Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants