使用 conan audit
扫描依赖项¶
conan audit
命令提供了一种内置方法来扫描您的依赖项中已知的 CVE。
有关身份验证、使用示例、输出格式以及设置私有提供程序的演练指南,请参阅 检查软件包漏洞。简而言之
在 audit.conan.io 上注册。
通过您收到的确认电子邮件激活您的帐户。
保存您的令牌,该令牌在激活后显示在页面上。
配置 Conan 以使用您的令牌:
conan audit provider auth conancenter --token=<token>
运行扫描
# Check a specific reference
conan audit list zlib/1.2.13
# Scan the entire dependency graph
conan audit scan . # Path to the conanfile.py/txt
此命令还支持使用您自己的 JFrog Platform 作为私有提供程序进行漏洞扫描。有关更多详细信息,请参阅 添加私有提供程序 部分。
过滤查询的软件包¶
默认情况下,conan audit scan
命令将查询依赖项图中的所有软件包。您可以使用 --context
选项根据上下文过滤要查询的软件包,该选项接受 "host"
或 "build"
作为值,省略时默认为查询这两个上下文。
这使您可以跳过检查构建要求中的 CVE,因为它们不是最终产品的一部分,因此对于漏洞扫描而言相关性较低(但仍然很重要!)。
还可以通过利用 conan list
命令的软件包列表过滤功能,使用 conan audit list
命令执行此过滤。例如
# Generate the dependency graph in JSON format
$ conan graph info . --format=json > graph.json
# Create a packages list for the resolved dependency graph, filtering to only contain the `host` context packages
$ conan list --graph=graph.json --graph-context=host --format=json > pkglist.json
# Scan the filtered packages list for vulnerabilities
$ conan audit list --list=pkglist.json
另请参阅
JFrog Academy Conan 2 Essentials: 使用 Conan Audit 扫描 C++ 软件包的漏洞
有关所有
conan audit
子命令及其选项的详细参考文档,请参阅 conan audit 命令参考。在专用的博客文章中阅读更多。