8000 feat: add support for OSV schema by juan131 · Pull Request #217 · anchore/grype-db · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: add support for OSV schema #217

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

Merged
merged 12 commits into from
Mar 17, 2025

Conversation

juan131
Copy link
Contributor
@juan131 juan131 commented Jan 9, 2024

Summary

As described at anchore/grype#1609, Bitnami is providing vulnerability matching data for their containers via the Bitnami Vulnerability Database repository.

This database uses the Open Source Vulnerability format (AKA OSV) and it's currently part of the aggregated OSV vulnerability database.

This PR follows up anchore/vunnel#447, adding support to grype-db to aggregate data from CVE feeds using the OSV schema.

@juan131
Copy link
Contributor Author
juan131 commented Jan 15, 2024

cc @westonsteimel @wagoodman

wagoodman
wagoodman previously approved these changes Feb 2, 2024
Copy link
Contributor
@wagoodman wagoodman left a comment

Choose a reason for hiding this comment

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

This allows for ingesting OSV records, we can add individual DB transformer functions in a follow up PR

juan131 and others added 3 commits February 5, 2024 13:11
Signed-off-by: juan131 <jariza@vmware.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: juan131 <jariza@vmware.com>
@juan131 juan131 force-pushed the feat/osv-schema-support branch from f2b5170 to 3f96831 Compare February 5, 2024 12:14
@juan131 juan131 requested a review from wagoodman February 5, 2024 12:14
@juan131
Copy link
Contributor Author
juan131 commented Mar 12, 2024

@wagoodman sorry for the long delay on resuming this work, I've been involved in other projects these last weeks and I didn't find the time for this.

@wagoodman wagoodman added the enhancement New feature or request label Mar 26, 2024
@carrodher
Copy link

Hi @wagoodman, is there anything we can help with at this time?

@carrodher
Copy link

Hi @wagoodman,

I hope you’re doing well! We wanted to check in on the status of our recent contributions. We have some open PRs, and we’re unsure about the current progress or the next steps. Could you kindly provide an update? It would help us plan our work and understand how we can continue contributing effectively.

Here are a couple of the open PRs for reference:

We appreciate any details you can share. Thanks in advance for your help!

@willmurphyscode
Copy link
Contributor

Hi @carrodher!

I wanted to give an overview of what still needs to happen to get grype supporting the bitnami vulnerability provider. The list is at least mostly in the order things need to happen. The items don't say who's doing what or when; I'm trying to just get the scope of work remaining written down, and then we can figure that out. I am happy to help with the work but I want to clarify the remaining work first.

Step 1: Syft needs to find the right packages

Syft needs to find packages that can be compared to the data bitnami publishes. The best way to do this is probably to write a Syft cataloger that parses the SPDX SBOMs that bitnami puts at paths like /opt/bitnami/redis/.spdx-redis.spdx.

This work is tracked at anchore/syft#3065.

This issue is largely ready to pick up.

It's important that we do this first for two reasons:

  1. Syft finding bitnami packages in bitnami images is a useful feature all on its own
  2. When adding the data source to grype, we need to already know what we're trying to match against

Step 2: Make a test image

In order to test the new data provider end to end, there needs to be an image that grype can scan to find known vulnerabilities from the new provider.

Add a test image built from an old Bitnami (so it will have some vulns) image to our test images repo.

Step 3: Local end to end workflow working

The way to do that is to make a 3 repo local workspace with Vunnel, Grype, and Grype-DB all incorporating any necessary changes to scan a bitnami image.

To attempt and end to end run, you can go into the vunnel directory and run:

make dev provider=bitnami  # creates a subshell
make update-db 
grype "$image_from_ste_2" 

This will fail, because there are a few other things to do, but when it starts finding the known vulnerabilities that are present in the old Bitnami image, things are working and we can set up an end to end test and merge. There are a few changes that I know about, and we may discover more.

PR changes that I know about

This PR (#217) needs to have a transformer implemented. The transformer is a function that is responsible for mapping the OSV data that vunnel downloaded from Bitnami to the vulnerability and vulnerability metadata structures that grype uses in its SQLite database.

You can see a transformer here:

func Transform(vulnerability unmarshal.GitHubAdvisory) ([]data.Entry, error) {

Additionally, the vunnel pr will need to be changed so that it emits records in dictionaries shaped like OSV JSON, in other words this comment needs to be addressed.

It's also possible that Grype needs to have a new matcher added for the bitnami package type, but the stock matcher might work (it tries to compare semver for packages that don't have a more specific matcher type), but some package types need a specific match. You can see all the matchers here:

https://github.com/anchore/grype/blob/09fb54ee101fde621b38aa6223c7ca6e7881baa7/grype/matcher/matchers.go#L32-L46

After these changes, I think that we will be ready to add the end to end tests.

There are also some linting fixes and missing unit tests, but I think it makes sense to get the end to end flow working. If you prefer to add unit tests as you build the blocks of the system, that's fine too.

Adding labels and test cases

Vunnel, Grype, and Grype-DB are guarded by end-to-end test cases that basically have 3 inputs:

  1. a reference run of grype (latest with the last published database, for example)
  2. a candidate run of grype (latest with the database created by the current branch of vunnel, for example)
  3. a set of labeled test images

The test gate than asserts that for each test image, the candidate configuration is better, or at least no worse within some tolerance, than the reference configuration.

One grype in your workflow can match the test image, you can label matches grype finds against your test images.

Some details are at
https://github.com/anchore/vunnel/blob/main/tests/quality/README.md#getting-started. This is a step we can definitely help with.

That ended up being a bit longer post than I thought, but I wanted to get the remaining steps written down concretely to help get your hard work over the line.

@willmurphyscode
Copy link
Contributor

@carrodher and @juan131 I am pretty determined to see these changes land and will start picking up this work. I'd also be happy to sync up with you a 8000 ll if you'd like to provide any additional assistance - just let me know!

As an aside, we are striving to make this process easier - I realize from outside the team the process outlined in my last comment is probably a little daunting and hard to discover. I'd also be glad to sync with you on what might have made that easier.

@juan131
Copy link
Contributor Author
juan131 commented Sep 27, 2024

@willmurphyscode thanks so much for writing down the required steps and your determination to get this done. If that's fine to you, we could set up a sync meeting (@carrodher and myself from Bitnami side) so we can plan the action items and assign who'll be leading the development

@willmurphyscode
Copy link
Contributor

@juan131 a sync up meeting sounds great. Probably the easiest way to hash out the details is to DM me in our discourse (not discord) instance: https://anchorecommunity.discourse.group/ (@willmurphy). I'm traveling next week but we could plan to meet sometime 7 October or after.

We also have regularly scheduled community meetings. The next one is at Thursday, 10 October at noon Eastern.

@willmurphyscode
Copy link
Contributor

@juan131 here's the branch I mentioned during the meeting today: https://github.com/anchore/syft/compare/spike-bitnami-cataloger

It should help in creating a PR to resolve anchore/syft#3065.

Let us know if you have any questions, or when you want to set up the next meeting. Thanks!

@juan131
Copy link
Contributor Author
juan131 commented Feb 18, 2025

@willmurphyscode now that we completed the 1st step from #217 (comment), we can continue with the plan and add the test image at https://github.com/anchore/test-images, right?

@wagoodman
Copy link
Contributor

indeed -- or if you have an image that is public then we can use that directly without needing to make an explicitly image in the test_images repo

@juan131
Copy link
Contributor Author
juan131 commented Mar 11, 2025

@wagoodman I think we can use docker.io/bitnami/airflow:2.9.2-debian-12-r0. This image has several SPDX files, for instance:

  • /opt/bitnami/airflow/.spdx-airflow.spdx
  • /opt/bitnami/postgresql/.spdx-postgresql-client.spdx
  • /opt/bitnami/python/.spdx-python.spdx

There several "high" vulnerabilities affecting Airflow listed in Bitnami vulndb:

There are also several "high" vulnerabilities affecting python, setuptools and virtualenv listed in Bitnami vulndb:

What do you think?

@willmurphyscode
Copy link
Contributor

Hi @juan131, that's a reasonable image to start with. We always can change it later. I think this PR can be done in either order relative to anchore/vunnel#512, since vunnel#512 will make vunnel emit OSV compliant JSON, and this PR will transform OSV compliant JSON, so as long as both sides read the same spec the work can be concurrent. Would it be helpful if I picked up anchore/vunnel#512, at least long enough to get it going again?

@juan131
Copy link
Contributor Author
juan131 commented Mar 12, 2025

@willmurphyscode I just updated vunnel PR but I'd appreciate help with the CI errors

@willmurphyscode
Copy link
Contributor

Hi @juan131! The vunnel PR is merged - it was almost there, just some Python specific nonsense and a couple tests. Let me know if you need a hand with this PR - there has been a whole db schema released since it was opened, so the codebase has diverged quite a bit from where this branch branched off.

Thanks!

juan131 added 2 commits March 13, 2025 09:01
Signed-off-by: juan131 <juan.ariza@broadcom.com>
@juan131
Copy link
Contributor Author
juan131 commented Mar 13, 2025

Working on transformers for v5 and v6, I'll update the PR soon

@wagoodman
Copy link
Contributor

You only need to do the v6 transformers, since we don't even have a way to match bitnami packages for v5.

Signed-off-by: juan131 <juan.ariza@broadcom.com>
@juan131
Copy link
Contributor Author
juan131 commented Mar 13, 2025

I just added the transformer at 0a3cf9d but I'm missing more unit tests yet @willmurphyscode

Signed-off-by: Will Murphy <willmurphyscode@users.noreply.github.com>
@wagoodman wagoodman moved this from Stalled to In Progress in OSS Mar 13, 2025
@willmurphyscode willmurphyscode dismissed wagoodman’s stale review March 14, 2025 09:53

Some changes still needed to version range handling

@juan131 juan131 requested a review from willmurphyscode March 17, 2025 11:46
Signed-off-by: Will Murphy <willmurphyscode@users.noreply.github.com>
@willmurphyscode willmurphyscode merged commit d0ef16d into anchore:main Mar 17, 2025
11 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in OSS Mar 17, 2025
@juan131 juan131 deleted the feat/osv-schema-support branch March 17, 2025 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants
0