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

"No vulnerability database update available" when actually the check for an update was unsuccessful #310

Open
luhring opened this issue May 3, 2021 · 3 comments · May be fixed by #1247
Labels
bug Something isn't working good-first-issue Good for newcomers

Comments

@luhring
Copy link
Contributor

luhring commented May 3, 2021

What happened:

Grype shows "No vulnerability database update available" when it hasn't actually checked to see if a database update is available.

What you expected to happen:

If Grype is unable (for any reason) to check to see if a database update is available, it should report the failure to the user and exit non-zero.

How to reproduce it (as minimally and precisely as possible):

  1. For the sake of a clean environment, start a new container in which we'll run Grype: docker run --rm -it ubuntu:latest bash
  2. Install curl if it's not already present: apt-get update && apt-get install -y curl
  3. Install grype: curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b /usr/local/bin
  4. Edit /etc/resolv.conf so that the system relies on an incorrect address for its DNS server. For example: echo "nameserver 8.8.8.9" > /etc/resolv.conf
  5. Tell Grype to check for a database update: grype db update

Grype will show No vulnerability database update available, and its exit code will be 0.

But in fact, Grype doesn't even have a local database yet. The same behavior can be witnessed if Grype has an outdated database, too.

Anything else we need to know?:

There may exist other network-related failure modes that produce the same symptom, but this is the mode that I encountered today.

Also, this impacts the security of the user — because this output leads them to behave their Grype scans have considered the latest vulnerability data when this might not really be the case.

Environment:

  • Output of grype version:
Application:          grype
Version:              0.11.0
BuildDate:            2021-04-22T21:51:14Z
GitCommit:            0a46e54aae837135f73d2ff18a84061189ee6f28
GitTreeState:         clean
Platform:             linux/amd64
GoVersion:            go1.16.3
Compiler:             gc
Supported DB Schema:  2
  • OS (e.g: cat /etc/os-release or similar):
NAME="Ubuntu"
VERSION="20.04.2 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.2 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

(I've also seen this issue on macOS 11.2.3)

@luhring luhring added the bug Something isn't working label May 3, 2021
@tgerla tgerla added the good-first-issue Good for newcomers label Aug 4, 2022
@shanedell
Copy link
Contributor

I am not able to reproduce this. I test by doing the below:

docker run -d --name grype-test --rm -it ubuntu:latest tail -f /dev/null
docker exec -it grype-test apt update
docker exec -it grype-test apt install curl -y
docker exec -it grype-test bash -c 'curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b /usr/local/bin'
docker exec -it grype-test grype db update

The final command outputs

 ✔ Vulnerability DB        [updated]
Vulnerability database updated to latest version!

Maybe this was fixed already and this issue wasn't tagged to close?

Tagging @tgerla @wagoodman to see if this should be closed.

@luhring
Copy link
Contributor Author

luhring commented Apr 13, 2023

I'm still able to reproduce this. @shanedell a key step that looks like it's missing in your case was to intentionally break DNS resolution (as one example of how to cause a network issue for Grype) via editing /etc/resolv.conf.

I did have that step out of order in my original issue description, and I've just edited the description to be correct. If you run through those steps, you should still see this problem.

@shanedell
Copy link
Contributor

shanedell commented Apr 13, 2023

@luhring You are right. My apologies I must have looked past the part /etc/resolv.conf initially. I am able to reproduce with the below commands

docker run -d --name grype-test --rm -it ubuntu:latest tail -f /dev/null
docker exec -it grype-test apt update
docker exec -it grype-test apt install curl -y
docker exec -it grype-test bash -c 'curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b /usr/local/bin'
docker exec -it grype-test bash -c 'echo "nameserver 8.8.8.9" > /etc/resolv.conf'
docker exec -it grype-test grype db update

output:

 ✔ Vulnerability DB        [no update available]
No vulnerability database update available

shanedell added a commit to shanedell/grype that referenced this issue Apr 20, 2023
Closes anchore#310

Signed-off-by: Shane Dell <shanedell100@gmail.com>
@shanedell shanedell linked a pull request Apr 20, 2023 that will close this issue
shanedell added a commit to shanedell/grype that referenced this issue Apr 20, 2023
Closes anchore#310

Signed-off-by: Shane Dell <shanedell100@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good-first-issue Good for newcomers
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

3 participants