7.4. 为断开连接的环境配置 Clair
Clair 利用一组称为 Updaters 的组件来处理从各种漏洞数据库获取和解析数据。默认情况下,这些更新器被设置为直接从互联网拉取漏洞数据,并开箱即用。对于没有直接访问互联网的断开连接的环境中的客户,这会产生问题。Clair 通过处理不同类型的更新工作流来支持这些环境,以考虑网络隔离。使用 clairctl
命令行工具,任何进程都可以通过开放主机从互联网轻松获取更新器数据,安全地将数据传送到隔离的主机,然后将隔离主机上的 Updater 数据导入到 Clair 本身。
这些步骤如下所示。
首先,确保您的 Clair 配置已在运行过程中禁用了自动更新器。
config.yaml
matcher: disable_updaters: true
matcher: disable_updaters: true
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 将最新的 Updater 数据导出到本地归档。这要求
clairctl
工具可以直接作为二进制文件运行,或者通过 Clair 容器镜像运行。假设 Clair 配置位于/etc/clairv4/config/config.yaml
中,以通过容器镜像运行:podman run -it --rm -v /etc/clairv4/config:/cfg:Z -v /path/to/output/directory:/updaters:Z --entrypoint /bin/clairctl registry.redhat.io/quay/clair-rhel8:v3.5.7 --config /cfg/config.yaml export-updaters /updaters/updaters.gz
$ podman run -it --rm -v /etc/clairv4/config:/cfg:Z -v /path/to/output/directory:/updaters:Z --entrypoint /bin/clairctl registry.redhat.io/quay/clair-rhel8:v3.5.7 --config /cfg/config.yaml export-updaters /updaters/updaters.gz
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 请注意,您需要显式引用 Clair 配置。这将在
/etc/clairv4/updaters/updaters.gz
中创建 Updater 归档。如果要确保从源数据库创建存档时没有错误,您可以为clairctl
提供--strict
标志。归档文件应复制到可以从运行 Clair 的断开连接的主机访问的卷。在断开连接的主机上,现在使用相同的步骤将存档导入到 Clair 中。podman run -it --rm -v /etc/clairv4/config:/cfg:Z -v /path/to/output/directory:/updaters:Z --entrypoint /bin/clairctl registry.redhat.io/quay/clair-rhel8:v3.5.7 --config /cfg/config.yaml import-updaters /updaters/updaters.gz
$ podman run -it --rm -v /etc/clairv4/config:/cfg:Z -v /path/to/output/directory:/updaters:Z --entrypoint /bin/clairctl registry.redhat.io/quay/clair-rhel8:v3.5.7 --config /cfg/config.yaml import-updaters /updaters/updaters.gz
Copy to Clipboard Copied! Toggle word wrap Toggle overflow