7.5. 在蓝图中为配置集添加自定义定制选项
通过 OpenSCAP
和 RHEL 镜像构建器集成,您可以使用以下选项将配置集的自定义定制选项添加到蓝图自定义中:
-
selected
用于您要添加的规则的列表 -
unselected
用于您要删除的规则的列表
使用默认的 org.ssgproject.content
规则命名空间,您可以在此命名空间下省略规则的前缀。例如,org.ssgproject.content_grub2_password
和 grub2_password
的功能相当。
当您从该蓝图构建镜像时,它会使用新的定制配置文件 ID 创建一个定制文件,并将其保存为 /usr/share/xml/osbuild-oscap-tailoring/tailoring.xml
镜像。新配置文件 ID 将 _osbuild_tailoring
作为后缀附加到基本配置文件。例如,如果您使用 CIS (cis
)基础配置集,配置集 ID 为 xccdf_org.ssgproject.content_profile_cis_osbuild_tailoring
。
前提条件
-
您以 root 用户身份或
welder
组成员的用户身份登录。
流程
以 TOML 格式创建强化蓝图,使用
OpenSCAP
工具和scap-security-guide
内容,并根据需要进行修改:# oscap xccdf generate fix --profile=cis --fix-type=blueprint /usr/share/xml/scap/ssg/content/ssg-rhel{ProductNumber}-ds.xml > cis_tailored.toml
将 tailoring 部分的自定义规则集附加到蓝图中:
# Blueprint for CIS Red Hat Enterprise Linux {ProductNumber} Benchmark for Level 2 - Server # ... [customizations.openscap.tailoring] selected = [ "xccdf_org.ssgproject.content_bind_crypto_policy" ] unselected = [ "grub2_password" ]
使用
composer-cli
工具将蓝图推送到osbuild-composer
:# composer-cli blueprints push cis_tailored.toml
启动强化镜像的构建:
# composer-cli compose start hardened_xccdf_org.ssgproject.content_profile_cis qcow2
镜像构建就绪后,请在部署中使用预先强化的镜像来创建虚拟机。如需更多信息,请参阅 创建虚拟机。
在虚拟机中部署预先强化的镜像后,可以执行配置合规性扫描,以验证镜像是否与所选安全配置集一致。
重要执行配置合规性扫描不能保证系统是合规的。如需更多信息,请参阅配置合规性扫描。
验证
在部署预先强化的镜像的虚拟机中,请按照以下步骤执行:
-
使用
SSH
连接到虚拟机。 运行
oscap
扫描程序。# oscap xccdf eval --profile=cis --report=/tmp/compliance-report.html /usr/share/xml/scap/ssg/content/ssg-rhel{ProductNumber}-ds.xml
-
获取
compliance-report.html
并检查结果。
其他资源