osv-scanner README

The project's README from github.com/google/osv-scanner. As one markdown file: README.md.


OpenSSF Scorecard Checks codecov SLSA 3 GitHub Release

Use OSV-Scanner to find existing vulnerabilities affecting your project's dependencies. OSV-Scanner provides an officially supported frontend to the OSV database and CLI interface to OSV-Scalibr that connects a project’s list of dependencies with the vulnerabilities that affect them.

OSV-Scanner supports a wide range of project types, package managers and features, including but not limited to:

OSV-Scanner uses the extensible OSV-Scalibr library under the hood to provide this functionality. If a language or package manager is not supported currently, please file a feature request.

Underlying database

The underlying database, OSV.dev has several benefits in comparison with closed source advisory databases and scanners:

The above all results in accurate and actionable vulnerability notifications, which reduces the time needed to resolve them. Check out OSV.dev for more details!

Basic installation

To install OSV-Scanner, please refer to the installation section of our documentation. OSV-Scanner releases can be found on the releases page of the GitHub repository. The recommended method is to download a prebuilt binary for your platform. Alternatively, you can use go install github.com/google/osv-scanner/v2/cmd/osv-scanner@latest to build it from source.

Key Features

For more information, please read our detailed documentation to learn how to use OSV-Scanner. For detailed information about each feature, click their titles in this README.

Please note: These are the instructions for the latest OSV-Scanner V2 beta. If you are using V1, checkout the V1 README and documentation instead.

Scanning a source directory

$ osv-scanner scan source -r /path/to/your/dir

This command will recursively scan the specified directory for any supported package files, such as package.json, go.mod, pom.xml, etc. and output any discovered vulnerabilities.

OSV-Scanner has the option of using call analysis to determine if a vulnerable function is actually being used in the project, resulting in fewer false positives, and actionable alerts.

OSV-Scanner can also detect vendored C/C++ code for vulnerability scanning. See here for details.

Supported Lockfiles

OSV-Scanner supports 11+ language ecosystems and 19+ lockfile types. To check if your ecosystem is covered, please check out our detailed documentation.

Container Scanning

OSV-Scanner also supports comprehensive, layer-aware scanning for container images to detect vulnerabilities in the following operating system packages and language-specific dependencies.

Distro Support Language Artifacts Support
Alpine OS Go
Debian Java
Ubuntu Node
Python

See the full documentation for details on support.

Usage:

$ osv-scanner scan image my-image-name:tag

screencast of html output of container scanning

License Scanning

Check your dependencies' licenses using deps.dev data. For a summary:

osv-scanner --licenses path/to/repository

To check against an allowed license list (SPDX format):

osv-scanner --licenses="MIT,Apache-2.0" path/to/directory

Offline Scanning

Scan your project against a local OSV database. No network connection is required after the initial database download. The database can also be manually downloaded.

osv-scanner --offline --download-offline-databases ./path/to/your/dir

Guided Remediation (Experimental)

[!WARNING] Guided remediation (the fix command) can be risky when run on untrusted projects. It may trigger the package manager to execute scripts or follow external registries specified in the project. Please ensure you trust the source code and artifacts before proceeding.

OSV-Scanner provides guided remediation, a feature that suggests package version upgrades based on criteria such as dependency depth, minimum severity, fix strategy, and return on investment. We currently support remediating vulnerabilities in the following files:

Ecosystem File Format (Type) Supported Remediation Strategies
npm package-lock.json (lockfile) in-place
npm package.json (manifest) relock
Maven pom.xml (manifest) override

This is available as a headless CLI command, as well as an interactive mode.

Example (for npm)

$ osv-scanner fix \
    --max-depth=3 \
    --min-severity=5 \
    --ignore-dev  \
    --strategy=in-place \
    -L path/to/package-lock.json

Interactive mode (for npm)

$ osv-scanner fix \
    -M path/to/package.json \
    -L path/to/package-lock.json
Screenshot of the interactive relock results screen with some relaxation patches selected

Data Sources and Privacy

OSV-Scanner communicates with the following external services during operation:

OSV.dev API

The primary data source for vulnerability information. OSV-Scanner queries this API to check packages for known vulnerabilities and to identify vendored C/C++ dependencies. Data sent includes package names, versions, ecosystems, and file hashes. Use --offline mode to disable network requests and scan against a local database instead.

deps.dev API

Used for supplementary package information:

Data sent includes package names, versions, and ecosystems. No source code is transmitted.

Package Registries

When using native registry for dependency resolution (instead of deps.dev), OSV-Scanner may query:

Registry URL Used For
Maven Central repo.maven.apache.org/maven2 Maven package metadata and POM files
npm Registry registry.npmjs.org npm package metadata
PyPI pypi.org Python package metadata

Contribute

Report Problems

If you have what looks like a bug, please use the GitHub issue tracking system. Before you file an issue, please search existing issues to see if your issue is already covered.

Contributing code to osv-scanner

See CONTRIBUTING.md for documentation on how to contribute code.

Star History

Star History Chart

osv-scanner (google/osv-scanner)

Searching Database…

Что это такое?OSV-Scanner — это опенсорсный консольный сканер уязвимостей от Google: он сверяет зависимости вашего проекта с OSV.dev, открытой базой данных уязвимостей, и сообщает, какие из известных уязвимостей вас касаются.
Это библиотека, которую я добавляю в свой код, или отдельная утилита, которую я запускаю?Это самостоятельный CLI-инструмент, написанный на Go, а не библиотека для импорта — вы указываете ему на каталог проекта или образ контейнера, и он выдаёт результаты. Внутри для обнаружения зависимостей используется библиотека OSV-Scalibr.
Нужно ли мне что-то ещё установить, чтобы просканировать свой проект?Нет, достаточно самого бинарника сканера — он читает ваши существующие файлы пакетов вроде package.json, go.mod и pom.xml. Поддерживается 11+ языковых экосистем и 19+ типов lock-файлов: npm, pip, yarn, maven, go modules, cargo, gem, composer, nuget и другие, а также пакеты Linux-дистрибутивов.
Будет ли он показывать уязвимости, которые мой код на самом деле не использует?Возможно. Чтобы убрать такой шум, в OSV-Scanner есть опциональный call analysis — анализ вызовов, который проверяет, действительно ли уязвимая функция используется в вашем проекте. Это даёт меньше ложных срабатываний и более полезные предупреждения.
Могу ли я пользоваться им без доступа в интернет?Да. В офлайн-режиме сканер проверяет проект по локальной базе OSV: после первоначальной загрузки базы интернет-соединение не требуется, причём базу можно скачать и вручную.
Что он отправляет по сети, когда я запускаю сканирование?Он обращается к API OSV.dev, отправляя названия пакетов, версии, экосистемы и хэши файлов, а также к API deps.dev для дополнительных сведений о пакетах — исходный код не передаётся. Запустите его с флагом --offline, чтобы полностью отключить сетевые запросы.
Он умеет сканировать Docker-образы, а не только lock-файлы из исходников?Да — есть сканирование контейнеров с учётом слоёв: он находит уязвимые пакеты ОС в базовых образах Alpine, Debian и Ubuntu, а также языковые зависимости Go, Java, Node и Python внутри образа.
Насколько надёжны данные об уязвимостях, на которых он основан?OSV.dev собирает рекомендации из открытых и авторитетных источников, таких как GitHub Security Advisories, база RustSec Advisory Database и уведомления по безопасности Ubuntu. Предложить улучшения может любой желающий, а машиночитаемый формат OSV точно сопоставляет затронутые версии со списком ваших пакетов.
Он может ещё и проверить лицензии моих зависимостей?Да — есть режим сканирования лицензий на основе данных deps.dev: можно получить сводку или сверить лицензии с вашим собственным списком разрешённых в формате SPDX.
What are similar projects?grype, oss-scanner, semgrep, gitleaks, trivy, fscan, nuclei, clair
Creator
google
Size
44.6 MB
Stars
11.2K
Age
3y
Commits · 90 Days