使用 OpenSCAP 确保系统安全
SUSE Multi-Linux Manager 使用 OpenSCAP 来审计客户端。它允许您为任何客户端安排合规性扫描并查看扫描结果。
|
An enhanced SCAP auditing experience is available as a beta feature. It provides centralized content management, reusable scan policies, recurring scans, and built-in remediation from the Web UI. To get started, see Enhanced SCAP Auditing (Beta). |
1. SCAP 简介
安全内容自动化协议 (SCAP) 是根据社区观点衍生出的一套综合性可互操作规范。它是由美国国家标准与技术研究院 (NIST) 维护的一系列规范,用于维持企业系统的系统安全性。
制定 SCAP 的目的是提供一种标准化方法来维持系统安全性,并且使用的标准会根据社区和企业的需求不断变化。新规范根据 NIST 的 SCAP 发布周期进行控制,以提供一致且可重复的修订工作流程。有关详细信息,请参见:
SUSE Multi-Linux Manager 使用 OpenSCAP 来实现 SCAP 规范。OpenSCAP 是一个利用可扩展配置清单描述格式 (XCCDF) 的审计工具。XCCDF 是表达清单内容和定义安全清单的标准方式。它还结合了其他规范,例如通用平台枚举 (CPE)、通用配置枚举 (CCE) 及开放漏洞和评估语言 (OVAL),以创建 SCAP 表达的、可由 SCAP 验证过的产品处理的清单。
OpenSCAP 使用 SUSE 安全团队生成的内容来验证补丁是否存在。OpenSCAP 使用基于标准和规范的规则来检查系统安全配置设置,并检查系统是否存在遭受入侵的迹象。有关 SUSE 安全团队的详细信息,请参见 https://www.suse.com/support/security。
2. 为 SCAP 扫描准备客户端
在开始之前,需要为客户端系统的 SCAP 扫描做好准备。
|
OpenSCAP 审计在使用 SSH 联系方法的 Salt 客户端上不可用。 |
|
扫描客户端可能会消耗被扫描客户端的大量内存和计算能力。对于 Red Hat 客户端,请确保每个要扫描的客户端上至少有 2 GB 可用 RAM。 |
在开始之前,请在客户端上安装 OpenSCAP 扫描程序和 SCAP 安全指南(内容)软件包。根据操作系统,这些软件包要么包含在基本操作系统中,要么包含在 SUSE Multi-Linux Manager 客户端工具中。
下表列出了所需的软件包:
| 操作系统 | 扫描程序 | 内容 |
|---|---|---|
SLES |
openscap-utils |
scap-security-guide |
openSUSE |
openscap-utils |
scap-security-guide |
RHEL |
openscap-utils |
scap-security-guide-redhat |
CentOS |
openscap-utils |
scap-security-guide-redhat |
Oracle Linux |
openscap-utils |
scap-security-guide-redhat |
Ubuntu |
libopenscap8 |
scap-security-guide-ubuntu |
Debian |
libopenscap8 |
scap-security-guide-debian |
RHEL 7 和兼容系统提供了一个 scap-security-guide 软件包,其中包含已过时的内容。建议您使用 SUSE Multi-Linux Manager 客户端工具中的 scap-security-guide-redhat 软件包。
|
SUSE 为不同的 openscap 配置文件提供了
对于非 SUSE 操作系统,包含的配置文件由社区提供。SUSE 不为其提供官方支持。 |
3. OpenSCAP 内容文件
OpenSCAP 使用 SCAP 内容文件来定义测试规则。这些内容文件是根据 XCCDF 或 OVAL 标准创建的。除了 SCAP 安全指南之外,您还可以下载公开的内容文件并根据要求对其进行自定义。可为默认内容文件模板安装 SCAP 安全指南软件包。或者,如果您熟悉 XCCDF 或 OVAL 的话,可以创建自己的内容文件。
|
我们建议您使用模板来创建自己的 SCAP 内容文件。如果您创建并使用自己的自定义内容文件,需要自负风险。如果您的系统因使用自定义内容文件而损坏,SUSE 可能不会为您提供支持。 |
创建内容文件后,需要将该文件传输到客户端。可以像移动任何其他文件一样,使用物理存储媒体传输该文件,或者使用 Salt(例如 salt-cp 或 Salt 文件服务器)在网络上通过 ftp 或 scp 传输该文件。
|
If you use the Enhanced SCAP Auditing (Beta) features, you do not need to manually transfer content files. The server automatically deploys the required DataStreams and tailoring files to the client at runtime. |
我们建议您创建一个软件包以将内容文件分发到使用 SUSE Multi-Linux Manager 管理的客户端。可将软件包签名并对其进行校验以确保其完整性。有关详细信息,请参见 自定义通道。
4. 查找 OpenSCAP 配置文件
不同的操作系统提供不同的 OpenSCAP 内容文件和配置文件。一个内容文件可以包含多个配置文件。
在基于 RPM 的操作系统上,可使用以下命令确定可用 SCAP 文件的位置:
rpm -ql <表中的 SCAP 安全指南软件包名称>
在基于 DEB 的操作系统上,可使用以下命令确定可用 SCAP 文件的位置:
dpkg -L <表中的 SCAP 安全指南软件包名称>
确定了一个符合您需求的 SCAP 内容文件后,列出客户端上可用的配置文件:
oscap info /usr/share/xml/scap/ssg/content/ssg-sle15-ds.xml
Document type: Source Data Stream
Imported: 2021-03-24T18:14:45
Stream: scap_org.open-scap_datastream_from_xccdf_ssg-sle15-xccdf-1.2.xml
Generated: (null)
Version: 1.2
Checklists:
Ref-Id: scap_org.open-scap_cref_ssg-sle15-xccdf-1.2.xml
Status: draft
Generated: 2021-03-24
Resolved: true
Profiles:
Title: CIS SUSE Linux Enterprise 15 Benchmark
Id: xccdf_org.ssgproject.content_profile_cis
Title: Standard System Security Profile for SUSE Linux Enterprise 15
Id: xccdf_org.ssgproject.content_profile_standard
Title: DISA STIG for SUSE Linux Enterprise 15
Id: xccdf_org.ssgproject.content_profile_stig
Referenced check files:
ssg-sle15-oval.xml
system: http://oval.mitre.org/XMLSchema/oval-definitions-5
ssg-sle15-ocil.xml
system: http://scap.nist.gov/schema/ocil/2
https://ftp.suse.com/pub/projects/security/oval/suse.linux.enterprise.15.xml
system: http://oval.mitre.org/XMLSchema/oval-definitions-5
Checks:
Ref-Id: scap_org.open-scap_cref_ssg-sle15-oval.xml
Ref-Id: scap_org.open-scap_cref_ssg-sle15-ocil.xml
Ref-Id: scap_org.open-scap_cref_ssg-sle15-cpe-oval.xml
Dictionaries:
Ref-Id: scap_org.open-scap_cref_ssg-sle15-cpe-dictionary.xml
记下用于执行扫描的文件路径和配置文件。
5. 执行审计扫描
安装或传输内容文件后,您可以执行审计扫描。可以使用 SUSE Multi-Linux Manager Web UI 触发审计扫描。还可以使用 SUSE Multi-Linux Manager API 来安排定期扫描。
在 SUSE Multi-Linux Manager Web UI 中,导航到,然后选择要扫描的客户端。
依次导航到
审计选项卡和日程安排子选项卡。在
XCCDF 文档的路径字段中,输入要在客户端上使用的 SCAP 模板和配置文件的参数。例如:
命令:/usr/bin/oscap xccdf eval
命令行参数:--profile xccdf_org.ssgproject.content_profile_stig
XCCDF 文档路径:/usr/share/xml/scap/ssg/content/ssg-sle15-ds.xml
如果使用
--fetch-remote-resources参数,将需要大量 RAM。此外,可能还需增加file_recv_max_size的值。扫描将在客户端进行下一次安排的同步时运行。
|
XCCDF 内容文件在远程系统上运行之前会经过验证。如果内容文件包含无效参数,则测试将会失败。 |
在开始之前,请确保要扫描的客户端上已安装 Python 和 XML-RPC 库。
选择现有的脚本或创建一个脚本,用于通过
system.scap.scheduleXccdfScan安排系统扫描。例如:#!/usr/bin/python3 import xmlrpc.client client = xmlrpc.client.ServerProxy('https://server.example.com/rpc/api') key = client.auth.login('username', 'password') client.system.scap.scheduleXccdfScan(key, <1000010001>, '<path_to_xccdf_file.xml>', '--profile <profile_name>') client.auth.logout(session_key)在此示例中:
<1000010001>是系统 ID (sid)。
<path_to_xccdf_file.xml>是指向客户端上的内容文件位置的路径。例如,/usr/share/xml/scap/ssg/content/ssg-sle15-ds.xml。
<profile_name>是oscap命令的附加参数。例如,使用united_states_government_configuration_baseline(USGCB)。在命令提示符下,对您要扫描的客户端运行该脚本。
6. 扫描结果
Information about the scans you have run is in the SUSE Multi-Linux Manager Web UI. Navigate to for a table of results. For more information about the data in this table, see All Scans.
为确保提供有关扫描的详细信息,需要在客户端上启用相应设置。在 SUSE Multi-Linux Manager Web UI 中,导航到并单击客户端所在的组织。导航到配置选项卡,并选中启用详细 SCAP 文件上载选项。启用后,每次扫描时都会额外生成一个包含附加信息的 HTML 文件。结果中会显示如下所示的附加行:
详细结果:xccdf-report.html xccdf-results.xml scap-yast2sec-oval.xml.result.xml
要从命令行检索扫描信息,请使用 spacewalk-report 命令:
spacewalk-report system-history-scap spacewalk-report scap-scan spacewalk-report scap-scan-results
还可以使用 SUSE Multi-Linux Manager API 通过 system.scap 处理程序来查看结果。
7. 修复
Remediation Bash scripts and Ansible playbooks are provided in the same SCAP Security Guide packages to harden the client systems.
|
If you have the beta SCAP features enabled, you can apply remediation directly from scan results in the Web UI, including custom per-rule remediation scripts. See Enhanced SCAP Auditing - Remediation. |
例如:
/usr/share/scap-security-guide/bash/sle15-script-cis.sh /usr/share/scap-security-guide/bash/sle15-script-standard.sh /usr/share/scap-security-guide/bash/sle15-script-stig.sh
/usr/share/scap-security-guide/ansible/sle15-playbook-cis.yml /usr/share/scap-security-guide/ansible/sle15-playbook-standard.yml /usr/share/scap-security-guide/ansible/sle15-playbook-stig.yml
在客户端系统中启用 Ansible 后,可以使用远程命令或 Ansible 运行这些脚本和剧本。
7.1. 使用 Bash 脚本运行修复
在所有目标系统上安装 scap-security-guide 软件包。有关详细信息,请参见 设置 Ansible 控制节点。
用于每个操作系统和发行套件的软件包、通道和脚本都不同。修复 Bash 脚本示例 一节中列出了示例。
7.1.1. 在单个系统上将 Bash 脚本作为远程命令运行
在单个系统上将 Bash 脚本作为远程命令运行。
-
在选项卡中选择您的实例。然后在中编写一个 Bash 脚本,例如:
#!/bin/bash chmod +x -R /usr/share/scap-security-guide/bash /usr/share/scap-security-guide/bash/sle15-script-stig.sh
-
单击 日程安排。
|
不同发行套件和版本中的文件夹和脚本名称有所不同。修复 Bash 脚本示例 一节列出了示例。 |
7.1.2. 在多个系统上使用系统集管理器运行 Bash 脚本
一次性在多个系统上将 Bash 脚本作为远程命令运行。
-
创建系统组后,单击
系统组并从表中选择在 SSM 中使用。 -
在
系统集管理器中的下编写一个 Bash 脚本,例如:#!/bin/bash chmod +x -R /usr/share/scap-security-guide/bash /usr/share/scap-security-guide/bash/sle15-script-stig.sh
-
单击 日程安排。
7.2. 修复 Bash 脚本示例
7.2.1. SUSE Linux Enterprise openSUSE 和变体
SUSE Linux Enterprise 和 openSUSE 脚本数据示例。
- 软件包
-
scap-security-guide
- 通道
-
-
SLE12:SLES12 更新
-
SLE15:SLES15 模块 Basesystem 更新
-
- Bash 脚本目录
-
/usr/share/scap-security-guide/bash/ - Bash 脚本
-
opensuse-script-standard.sh sle12-script-standard.sh sle12-script-stig.sh sle15-script-cis.sh sle15-script-standard.sh sle15-script-stig.sh
7.2.2. Red Hat Enterprise Linux 和 CentOS Bash 脚本数据
Red Hat Enterprise Linux 和 CentOS 脚本数据示例。
|
centos7-updates 中的 |
- 软件包
-
scap-security-guide-redhat
- 通道
-
-
SUSE Manager 工具
-
- Bash 脚本目录
-
/usr/share/scap-security-guide/bash/ - Bash 脚本
-
centos7-script-pci-dss.sh centos7-script-standard.sh centos8-script-pci-dss.sh centos8-script-standard.sh fedora-script-ospp.sh fedora-script-pci-dss.sh fedora-script-standard.sh ol7-script-anssi_nt28_enhanced.sh ol7-script-anssi_nt28_high.sh ol7-script-anssi_nt28_intermediary.sh ol7-script-anssi_nt28_minimal.sh ol7-script-cjis.sh ol7-script-cui.sh ol7-script-e8.sh ol7-script-hipaa.sh ol7-script-ospp.sh ol7-script-pci-dss.sh ol7-script-sap.sh ol7-script-standard.sh ol7-script-stig.sh ol8-script-anssi_bp28_enhanced.sh ol8-script-anssi_bp28_high.sh ol8-script-anssi_bp28_intermediary.sh ol8-script-anssi_bp28_minimal.sh ol8-script-cjis.sh ol8-script-cui.sh ol8-script-e8.sh ol8-script-hipaa.sh ol8-script-ospp.sh ol8-script-pci-dss.sh ol8-script-standard.sh rhel7-script-anssi_nt28_enhanced.sh rhel7-script-anssi_nt28_high.sh rhel7-script-anssi_nt28_intermediary.sh rhel7-script-anssi_nt28_minimal.sh rhel7-script-C2S.sh rhel7-script-cis.sh rhel7-script-cjis.sh rhel7-script-cui.sh rhel7-script-e8.sh rhel7-script-hipaa.sh rhel7-script-ncp.sh rhel7-script-ospp.sh rhel7-script-pci-dss.sh rhel7-script-rhelh-stig.sh rhel7-script-rhelh-vpp.sh rhel7-script-rht-ccp.sh rhel7-script-standard.sh rhel7-script-stig_gui.sh rhel7-script-stig.sh rhel8-script-anssi_bp28_enhanced.sh rhel8-script-anssi_bp28_high.sh rhel8-script-anssi_bp28_intermediary.sh rhel8-script-anssi_bp28_minimal.sh rhel8-script-cis.sh rhel8-script-cjis.sh rhel8-script-cui.sh rhel8-script-e8.sh rhel8-script-hipaa.sh rhel8-script-ism_o.sh rhel8-script-ospp.sh rhel8-script-pci-dss.sh rhel8-script-rhelh-stig.sh rhel8-script-rhelh-vpp.sh rhel8-script-rht-ccp.sh rhel8-script-standard.sh rhel8-script-stig_gui.sh rhel8-script-stig.sh rhel9-script-pci-dss.sh rhosp10-script-cui.sh rhosp10-script-stig.sh rhosp13-script-stig.sh rhv4-script-pci-dss.sh rhv4-script-rhvh-stig.sh rhv4-script-rhvh-vpp.sh sl7-script-pci-dss.sh sl7-script-standard.sh
7.2.3. Ubuntu Bash 脚本数据
Ubuntu 脚本数据示例。
- 软件包
-
scap-security-guide-ubuntu
- 通道
-
-
SUSE Manager 工具
-
- Bash 脚本目录
-
/usr/share/scap-security-guide/ - Bash 脚本
-
ubuntu1804-script-anssi_np_nt28_average.sh ubuntu1804-script-anssi_np_nt28_high.sh ubuntu1804-script-anssi_np_nt28_minimal.sh ubuntu1804-script-anssi_np_nt28_restrictive.sh ubuntu1804-script-cis.sh ubuntu1804-script-standard.sh ubuntu2004-script-standard.sh
7.2.4. Debian Bash 脚本数据
Debian 脚本数据示例。
- 软件包
-
scap-security-guide-debian
- 通道
-
-
SUSE Manager 工具
-
- Bash 脚本目录
-
/usr/share/scap-security-guide/bash/ - Bash 脚本
-
# Debian 12 debian12-script-anssi_np_nt28_average.sh debian12-script-anssi_np_nt28_high.sh debian12-script-anssi_np_nt28_minimal.sh debian12-script-anssi_np_nt28_restrictive.sh debian12-script-standard.sh