7.3. 使用 RHEL 镜像构建器自定义预先强化的镜像
您可以通过更改某些规则中的参数(如最小密码长度、删除以不同方式涵盖的规则以及选择附加规则)来自定义安全配置文件,以实施内部策略。您不能通过自定义配置文件来定义新规则。
当您从该蓝图构建镜像时,它会使用新的定制配置文件 ID 创建一个定制文件,并将其保存为 /usr/share/xml/osbuild-oscap-tailoring/tailoring.xml
镜像。新配置文件 ID 向基础 ID 添加了 _osbuild_tailoring
后缀。例如,如果您定制了 CIS (cis
)基础配置文件,配置集 ID 是 xccdf_org.ssgproject.content_profile_cis_osbuild_tailoring
。
前提条件
-
您以 root 用户身份,或者
weldr
组成员的用户身份登录。 -
openscap
和scap-security-guide
软件包已安装。
流程
从所选配置文件中以 TOML 格式创建强化蓝图:
oscap xccdf generate fix --profile=<profileID> --fix-type=blueprint /usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml > <profileID>-tailored.toml
# oscap xccdf generate fix --profile=<profileID> --fix-type=blueprint /usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml > <profileID>-tailored.toml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 将定制文件附加到蓝图。定制自定义仅影响自定义所基于的配置文件中的所选或未选规则的默认状态。它选择或未选择配置文件中的规则,但不会更改其他规则的状态。
Blueprint for CIS Red Hat Enterprise Linux 9 Benchmark for Level 2 - Server ...
# Blueprint for CIS Red Hat Enterprise Linux 9 Benchmark for Level 2 - Server # ... [customizations.openscap.tailoring] selected = [ "xccdf_org.ssgproject.content_bind_crypto_policy" ] unselected = [ "grub2_password" ]
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 使用
composer-cli
工具将蓝图推送到osbuild-composer
:composer-cli blueprints push <blueprintProfileID>-tailored.toml
# composer-cli blueprints push <blueprintProfileID>-tailored.toml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 启动强化镜像的构建:
composer-cli compose start <blueprintProfileID> <image_type>
# composer-cli compose start <blueprintProfileID> <image_type>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 将
<image_type>
替换为任何镜像类型,如qcow2
。镜像构建就绪后,在部署中使用预先强化的镜像。
验证
部署预先强化的镜像后,您可以执行配置合规性扫描,以验证镜像是否与所选安全配置文件一致。
执行配置合规性扫描不能保证系统是合规的。如需更多信息,请参阅配置合规性扫描。