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 是谷歌开源的命令行漏洞扫描工具:它把项目的依赖和 OSV.dev(一个开放漏洞数据库)进行比对,然后报告哪些已知漏洞会影响到你。
它是加到我代码里的库,还是一个单独运行的工具?它是一个用 Go 编写的独立命令行工具,不是需要导入的库——你把项目目录或容器镜像交给它,它就会报告扫描结果。内部它借助 OSV-Scalibr 库来检测依赖。
扫描项目前还需要装别的东西吗?不需要,只要有扫描器本身就行——它会直接读取你项目里已有的包文件,比如 package.json、go.mod 和 pom.xml。它支持 11 种以上的语言生态和 19 种以上的锁文件类型:npm、pip、yarn、maven、go modules、cargo、gem、composer、nuget 等等,还能扫描 Linux 系统包。
它会不会把代码里根本没实际用到的漏洞也报出来?有可能——为了减少这种噪音,OSV-Scanner 提供了可选的调用分析功能,检查有漏洞的函数是否真的在项目中被使用,从而减少误报,让警报更有参考价值。
没有网络也能用吗?可以。离线模式下它会对照本地的 OSV 数据库来扫描项目:首次下载数据库之后就不再需要网络连接,而且数据库也可以手动下载。
扫描时它会往网络上发送什么?它会查询 OSV.dev API,发送包名、版本、生态系统和文件哈希值,另外还会用 deps.dev API 获取补充的包信息——不会上传任何源代码。加上 --offline 参数运行就可以完全禁止网络请求。
它能扫描 Docker 镜像,而不只是源码的锁文件吗?能——它支持基于分层的容器扫描,可以找出 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