使用 conan audit 扫描依赖项

conan audit 命令提供了一种内置方法来扫描依赖项中的已知 CVE

有关身份验证、用法示例、输出格式以及设置私有提供程序的逐步指南,请参阅 检查软件包漏洞。简而言之:

  1. audit.conan.io 注册

  2. 通过收到的确认电子邮件激活您的帐户

  3. 保存您的令牌,该令牌将在激活后的页面上显示。

  4. 配置 Conan 以使用您的令牌:

conan audit provider auth conancenter --token=<token>
  1. 运行扫描

# 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 audit list 命令执行此过滤,方法是利用 conan 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

另请参阅