5.3. 配置合规补救
要自动使您的系统与特定配置集保持一致,您可以执行补救。您可以修复系统,使其与 SCAP 安全指南提供的任何配置文件保持一致。
5.3.1. 修复系统,使其与特定基准一致
您可以修正 RHEL 系统,使其与特定基准一致。您可以修复系统,使其与 SCAP 安全指南提供的任何配置文件保持一致。
有关列出可用的配置集的详情,请查看 Viewing profiles for configuration compliance 部分。
如果不小心使用,在启用了 Remediate
选项的情况下运行系统评估可能会导致系统无法正常工作。红帽不提供任何自动的方法来恢复由安全补救补救所做的更改。默认配置的 RHEL 系统支持自动安全补救功能。如果在安装后更改了您的系统,运行补救可能无法使其与所需安全配置兼容。
先决条件
-
scap-security-guide
软件包已安装。
步骤
使用
oscap
命令和--remediate
选项修复系统:oscap xccdf eval --profile <profile_ID> --remediate /usr/share/xml/scap/ssg/content/ssg-rhel10-ds.xml
# oscap xccdf eval --profile <profile_ID> --remediate /usr/share/xml/scap/ssg/content/ssg-rhel10-ds.xml
Copy to Clipboard Copied! 将
<profile_ID
> 替换为系统应该遵守的配置集 ID,例如hipaa
。- 重启您的系统。
验证
使用配置文件评估系统合规性,并将扫描结果保存到一个文件中:
oscap xccdf eval --report <scan_report.html> --profile <profile_ID> /usr/share/xml/scap/ssg/content/ssg-rhel10-ds.xml
$ oscap xccdf eval --report <scan_report.html> --profile <profile_ID> /usr/share/xml/scap/ssg/content/ssg-rhel10-ds.xml
Copy to Clipboard Copied! 替换:
-
<scan_report.html
>,带有oscap
保存扫描结果的文件名。 -
<profile_
id> 带有系统应该遵守的配置集 ID,例如hipaa
。
-
5.3.2. 使用 SSG Ansible Playbook 修复系统,使其与特定基准一致
您可以使用 SCAP 安全指南项目中的 Ansible Playbook 文件修复您的系统,使其与特定基准一致。您可以修复,使其与 SCAP 安全指南提供的任何配置集保持一致。
如果不小心使用,在启用了 Remediate
选项的情况下运行系统评估可能会导致系统无法正常工作。红帽不提供任何自动的方法来恢复由安全补救补救所做的更改。默认配置的 RHEL 系统支持自动安全补救功能。如果在安装后更改了您的系统,运行补救可能无法使其与所需安全配置兼容。
先决条件
-
scap-security-guide
软件包已安装。 -
ansible-core
软件包已安装。如需更多信息,请参阅 Ansible 安装指南。 -
rhc-worker-playbook
软件包已安装。 - 您知道要修复系统的配置文件的 ID。详情请参阅 查看配置文件以了解配置合规性。
流程
使用 Ansible 修复您的系统,使其与所选配置文件一致:
ANSIBLE_COLLECTIONS_PATH=/usr/share/rhc-worker-playbook/ansible/collections/ansible_collections/ ansible-playbook -i "localhost," -c local /usr/share/scap-security-guide/ansible/rhel10-playbook-<profile_ID>.yml
# ANSIBLE_COLLECTIONS_PATH=/usr/share/rhc-worker-playbook/ansible/collections/ansible_collections/ ansible-playbook -i "localhost," -c local /usr/share/scap-security-guide/ansible/rhel10-playbook-<profile_ID>.yml
Copy to Clipboard Copied! ANSIBLE_COLLECTIONS_PATH
环境变量是运行命令才能运行 playbook 所必需的。将
<profile_ID
> 替换为所选配置集的配置集 ID。- 重新启动系统。
验证
使用所选配置集评估系统的合规性,并将扫描结果保存到文件中:
oscap xccdf eval --profile <profile_ID> --report <scan_report.html> /usr/share/xml/scap/ssg/content/ssg-rhel10-ds.xml
# oscap xccdf eval --profile <profile_ID> --report <scan_report.html> /usr/share/xml/scap/ssg/content/ssg-rhel10-ds.xml
Copy to Clipboard Copied! 将
<scan_report.html
> 替换为oscap
保存扫描结果的文件名。
5.3.3. 创建修复 Ansible Playbook,使系统与特定基准保持一致
您可以创建一个 Ansible Playbook,它只包含使您的系统与特定基准保持一致所需的补救。此 playbook 很小,因为它没有涵盖已满足的要求。创建 playbook 不会以任何方式修改您的系统,您只需为后续应用程序准备一个文件。
先决条件
-
scap-security-guide
软件包已安装。 -
ansible-core
软件包已安装。如需更多信息,请参阅 Ansible 安装指南。 -
rhc-worker-playbook
软件包已安装。 - 您知道要修复系统的配置文件的 ID。详情请参阅 查看配置文件以了解配置合规性。
流程
扫描系统并保存结果:
oscap xccdf eval --profile <profile_ID> --results <profile_results.xml> /usr/share/xml/scap/ssg/content/ssg-rhel10-ds.xml
# oscap xccdf eval --profile <profile_ID> --results <profile_results.xml> /usr/share/xml/scap/ssg/content/ssg-rhel10-ds.xml
Copy to Clipboard Copied! 在带有结果的文件中找到结果 ID 的值:
oscap info <profile_results.xml>
# oscap info <profile_results.xml>
Copy to Clipboard Copied! 根据第 1 步中生成的文件生成 Ansible Playbook:
oscap xccdf generate fix --fix-type ansible --result-id xccdf_org.open-scap_testresult_xccdf_org.ssgproject.content_profile_<profile_ID> --output <profile_remediations.yml> <profile_results.xml>
# oscap xccdf generate fix --fix-type ansible --result-id xccdf_org.open-scap_testresult_xccdf_org.ssgproject.content_profile_<profile_ID> --output <profile_remediations.yml> <profile_results.xml>
Copy to Clipboard Copied! -
检查生成的 <
;profile_remediations.yml
> 文件是否包含在第 1 步中执行的扫描中失败的规则的 Ansible 修复。 使用 Ansible 修复您的系统,使其与所选配置文件一致:
ANSIBLE_COLLECTIONS_PATH=/usr/share/rhc-worker-playbook/ansible/collections/ansible_collections/ ansible-playbook -i "localhost," -c local <profile_remediations.yml>`
# ANSIBLE_COLLECTIONS_PATH=/usr/share/rhc-worker-playbook/ansible/collections/ansible_collections/ ansible-playbook -i "localhost," -c local <profile_remediations.yml>`
Copy to Clipboard Copied! ANSIBLE_COLLECTIONS_PATH
环境变量是运行命令才能运行 playbook 所必需的。警告如果不小心使用,在启用了
Remediate
选项的情况下运行系统评估可能会导致系统无法正常工作。红帽不提供任何自动的方法来恢复由安全补救补救所做的更改。默认配置的 RHEL 系统支持自动安全补救功能。如果在安装后更改了您的系统,运行修复可能无法使其遵守所需的安全配置文件。
验证
使用所选配置集评估系统的合规性,并将扫描结果保存到文件中:
oscap xccdf eval --profile <profile_ID> --report <scan_report.html> /usr/share/xml/scap/ssg/content/ssg-rhel10-ds.xml
# oscap xccdf eval --profile <profile_ID> --report <scan_report.html> /usr/share/xml/scap/ssg/content/ssg-rhel10-ds.xml
Copy to Clipboard Copied! 将
<scan_report.html
> 替换为oscap
保存扫描结果的文件名。