第 8 章 在断开连接的环境中的 Clair
Clair 支持 Red Hat Quay 部署无法直接访问互联网的环境。您可以使用 clairctl 工具将漏洞数据库更新从开放主机传送到隔离环境,使 Clair 能够在没有互联网连接的情况下扫描镜像。
Clair 使用一组名为 updaters 的组件来处理从各种漏洞数据库获取和解析数据。默认设置更新程序,以直接从互联网拉取漏洞数据,并可以立即使用。
目前,Clair 增强数据是 CVSS 数据。目前在断开连接的环境中不支持增强数据。
有关 Clair updaters 的更多信息,请参阅"Clair updaters"。
8.1. 在断开连接的 OpenShift Container Platform 集群中设置 Clair 复制链接链接已复制到粘贴板!
要为断开连接的 OpenShift Container Platform 部署安装 clairctl 命令行工具,您可以从正在运行的 Clair pod 中提取工具并设置其执行权限。这可让您使用 clairctl 在断开连接的环境中管理漏洞数据库更新。
流程
输入以下命令在 OpenShift Container Platform 集群中为 Clair 部署安装
clairctl程序:$ oc -n quay-enterprise exec example-registry-clair-app-64dd48f866-6ptgw -- cat /usr/bin/clairctl > clairctl注意未正式,可以下载
clairctl工具设置
clairctl文件的权限,以便用户可以由用户执行并运行,例如:$ chmod u+x ./clairctl
要为 OpenShift Container Platform 上的断开连接的环境配置 Clair,您可以检索并解码 Clair 配置 secret,然后更新 clair-config.yaml 文件,将 disable_updaters 和 airgap 参数设置为 True。这会准备 Clair 在不直接访问互联网的情况下工作。
先决条件
-
已安装
clairctl命令行工具工具。
流程
输入以下命令来检索和解码配置 secret,然后将其保存到 Clair 配置 YAML 中:
$ oc get secret -n quay-enterprise example-registry-clair-config-secret -o "jsonpath={$.data['config\.yaml']}" | base64 -d > clair-config.yaml更新
clair-config.yaml文件,使disable_updaters和airgap参数设置为True,例如:# ... indexer: airgap: true # ... matcher: disable_updaters: true # ...
8.1.2. 从连接的 Clair 实例导出更新程序捆绑包 复制链接链接已复制到粘贴板!
要从连接的 Clair 实例导出漏洞数据库更新,以便在断开连接的环境中使用 clairctl 工具,以导出更新程序捆绑包。这会创建一个可传送到隔离环境的捆绑包文件。
先决条件
-
已安装
clairctl命令行工具工具。 -
您已检索并解码了 Clair 配置 secret,并将其保存到 Clair
config.yaml文件中。 -
disable_updaters和airgap参数在 Clairconfig.yaml文件中被设置为True。
流程
从可访问互联网的 Clair 实例中,使用
clairctlCLI 工具和配置文件导出更新器捆绑包。例如:$ ./clairctl --config ./config.yaml export-updaters updates.gz
要在断开连接的 OpenShift Container Platform 集群中配置对 Clair 数据库的访问,您可以确定数据库服务,转发数据库端口,并更新 Clair config.yaml 文件以使用 localhost。这可让您使用 clairctl 工具将更新程序捆绑包导入到数据库中。
先决条件
-
已安装
clairctl命令行工具工具。 -
您已检索并解码了 Clair 配置 secret,并将其保存到 Clair
config.yaml文件中。 -
disable_updaters和airgap参数在 Clairconfig.yaml文件中被设置为True。 - 您已从可访问互联网的 Clair 实例导出 updaters 捆绑包。
流程
使用
ocCLI 工具确定 Clair 数据库服务,例如:$ oc get svc -n quay-enterprise输出示例
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE example-registry-clair-app ClusterIP 172.30.224.93 <none> 80/TCP,8089/TCP 4d21h example-registry-clair-postgres ClusterIP 172.30.246.88 <none> 5432/TCP 4d21h ...转发 Clair 数据库端口,使其可从本地机器访问。例如:
$ oc port-forward -n quay-enterprise service/example-registry-clair-postgres 5432:5432更新 Clair
config.yaml文件,例如:indexer: connstring: host=localhost port=5432 dbname=postgres user=postgres password=postgres sslmode=disable layer_scan_concurrency: 5 migrations: true scanlock_retry: 10 airgap: true scanner: repo: rhel-repository-scanner: repo2cpe_mapping_file: /data/repository-to-cpe.json package: rhel_containerscanner: name2repos_mapping_file: /data/container-name-repos-map.json其中:
connstring::指定数据库的连接字符串。rhel-repository-scanner::指定存储库扫描程序配置。rhel_containerscanner::指定容器扫描程序配置。
要将漏洞数据库更新导入到断开连接的 OpenShift Container Platform 集群中,您可以使用 clairctl 工具和 Clair 配置文件导入更新程序捆绑包。这会使用漏洞数据填充 Clair 数据库,以便 Clair 可以在没有互联网访问的情况下扫描镜像。
先决条件
-
已安装
clairctl命令行工具工具。 -
您已检索并解码了 Clair 配置 secret,并将其保存到 Clair
config.yaml文件中。 -
disable_updaters和airgap参数在 Clairconfig.yaml文件中被设置为True。 - 您已从可访问互联网的 Clair 实例导出 updaters 捆绑包。
- 您已将更新器捆绑包传送到断开连接的环境中。
流程
使用
clairctlCLI 工具将 updaters 捆绑包导入到 OpenShift Container Platform 部署的 Clair 数据库中。例如:$ ./clairctl --config ./clair-config.yaml import-updaters updates.gz