Grype DB
Categories:
Getting started
Adding Data Sources
Grype DB is responsible for building the database used by Grype, aggregating data provided by Vunnel providers. If you’re interested in adding a data source, you probably want to start with the Vunnel documentation.This codebase is primarily Go, however, there are also Python scripts critical to the daily DB publishing process as well as acceptance testing. You will require the following:
- Python 3.11+ installed on your system (Python 3.11-3.13 supported). Consider using pyenv if you do not have a preference for managing python interpreter installations.
zstdbinary utility if you are packaging v6+ DB schemas- (optional)
xzbinary utility if you have specifically overridden the package command options - uv installed for Python package and virtualenv management
To download Go tooling used for static analysis, dependent Go modules, and Python dependencies run:
make bootstrap
Useful commands
Common commands for ongoing development:
make help- List all available commandsmake lint- Check code formatting and lintingmake lint-fix- Auto-fix formatting issuesmake unit- Run unit tests (Go and Python)make cli- Run CLI testsmake db-acceptance schema=<version>- Run DB acceptance tests for a schema versionmake snapshot- Build release snapshot with all binaries and packagesmake download-all-provider-cache- Download pre-built vulnerability data cache
Development workflows
Getting vulnerability data
In order to build a grype DB you will need a local cache of vulnerability data:
make download-all-provider-cache
This will populate the ./data directory locally with everything needed to run grype-db build (without needing to run grype-db pull).
This data being pulled down is the same data used in the daily DB publishing workflow, so it should be relatively fresh.
Creating a new DB schema
- Create a new
v#schema package in thegryperepo (withingrype/db) - Create a new
v#schema package in thegrype-dbrepo (use thebump-schema.pyhelper script) that uses the new changes fromgrype-db - Modify the
manager/src/grype_db_manager/data/schema-info.jsonto pin the last-latest version to a specific version of grype and add the new schema version pinned to the “main” branch of grype (or a development branch) - Update all references in
grypeto use the new schema - Use the Staging DB Publisher workflow to test your DB changes with grype in a flow similar to the daily DB publisher workflow
Testing with staging databases
While developing a new schema version it may be useful to get a DB built for you by the Staging DB Publisher GitHub Actions workflow. This code exercises the same code as the Daily DB Publisher, with the exception that only a single schema is built and is validated against a given development branch of grype. When these DBs are published you can point grype at the proper listing file like so:
GRYPE_DB_UPDATE_URL=https://toolbox-data.anchore.io/grype/staging-databases/listing.json grype centos:8 ...
Testing
Levels of testing
unit(make unit): Unit tests for both Go code in the main codebase and Python scripts in themanager/directory. These tests focus on correctness of individual functions and components. Coverage metrics track Go test coverage.cli(make cli): CLI tests for both Go and Python components. These validate that command-line interfaces work correctly with various inputs and configurations.db-acceptance(make db-acceptance schema=<version>): Acceptance tests that verify a specific DB schema version works correctly with Grype. These tests build a database, run Grype scans, and validate that vulnerability matches are correct and complete.
Running tests
To run unit tests for Go code and Python scripts:
make unit
To verify that a specific DB schema version interops with Grype:
make db-acceptance schema=<version>
# Note: this may take a while... go make some coffee.
Next Steps
Understanding the Codebase
Architecture - Learn about the ETL pipeline, schema support, and publishing workflow
Vunnel Documentation - Understand the vulnerability data provider system that feeds Grype DB Contributing Your Work
Pull Requests - Guidelines for submitting PRs and working with reviewers
Issues and Discussions - Where to get help and report issues
Related Projects
- Grype Contributing Guide - Understand how Grype uses the database
- Vunnel Contributing Guide - Learn about vulnerability data providers
Getting Help
- Anchore Discourse - Community discussions and questions
- Grype DB GitHub Issues - Report bugs or request features