osv-scanner: find existing vulnerabilities affecting your project’s dependencies
OSV-Scanner
Use OSV-Scanner to find existing vulnerabilities affecting your project’s dependencies.
OSV-Scanner provides an officially supported frontend to the OSV database that connects a project’s list of dependencies with the vulnerabilities that affect them. Since the OSV.dev database is open source and distributed, it has several benefits in comparison with closed-source advisory databases and scanners:
- Each advisory comes from an open and authoritative source (e.g. the RustSec Advisory Database)
- Anyone can suggest improvements to advisories, resulting in a very high-quality database
- The OSV format unambiguously stores information about affected versions in a machine-readable format that precisely maps onto a developer’s list of packages
The above all results in fewer, more actionable vulnerability notifications, which reduces the time needed to resolve them.
Usage
OSV-Scanner collects a list of dependencies and versions that are used in your project, before matching this list against the OSV database via the OSV.dev API. To build the list of dependencies, you can point OSV-Scanner at your project directory, or manually pass in the path to individual manifest files.
Scan a directory
Walks through a list of directories to find:
- Lockfiles
- SBOMs
- git directories for the latest commit hash
which is used to build the list of dependencies to be matched against OSV vulnerabilities.
Can be configured to recursively walk through subdirectories with the –recursive / -r flag.
Searching for git commit hash is intended to work with projects that use git submodules or a similar mechanism where dependencies are checked out as real git repositories.
Example
$ go run ./cmd/osv-scanner -r /path/to/your/dir
Input an SBOM
SPDX and CycloneDX SBOMs using Package URLs are supported. The format is auto-detected based on the input file contents.
Example
$ go run ./cmd/osv-scanner –sbom=/path/to/your/sbom.json
Input a lockfile
A wide range of lockfiles are supported by utilizing this lockfile package. This is the current list of supported lockfiles:
- Cargo.lock
- package-lock.json
- yarn.lock
- pnpm-lock.yaml
- composer.lock
- Gemfile.lock
- go.mod
- mix.lock
- poetry.lock
- pubspec.lock
- pom.xml*
- requirements.txt*
Example
$ go run ./cmd/osv-scanner –lockfile=/path/to/your/package-lock.json -L /path/to/another/Cargo.lock
Scanning a Debian-based docker image packages
This tool will scrape the list of installed packages in a Debian image and query for vulnerabilities on them.
Currently, only Debian-based docker image scanning is supported.
Requires docker to be installed and the tool to have permission calling it.
Example
$ go run ./cmd/osv-scanner –docker image_name:latest
Install
Copyright (C) 2022 Google