《OpenShift 4.x HOL教程汇总》

文章目录

  • CIS互联网安全中心
  • SCAP安全内容自动化协议
  • SCAP Security Guide - SSG
    • 安装 SCAP Security Guide
    • 了解 SCAP Security Guide 中包含的内容
  • 用 OpenSCAP 进行 CIS 合规扫描
    • 查看 DataStream 文件包含的 Profile
    • CIS 合规扫描
      • 全面扫描
      • 局部扫描
    • 查看 CIS 合规扫描结果,了解 SSG DS 定义文件内容。
    • 定制 CIS 基线扫描指标
    • 修复不符合合规基线的项目
      • 直接修复
      • 生成修复 Ansible 剧本
    • 转换文件
      • 分解 DataStream 文件
      • 将 XCCDF 文档从适合机器处理的XML格式转为适合人工查看的HTML格式
  • 用 OpenSCAP 进行 OVAL 安全漏洞扫描
  • 参考

CIS互联网安全中心

CIS(互联网安全中心)提供各种网络安全相关服务,它制作了各种安全基准以保护系统免受不断变化的安全威胁。CIS 基准是目标系统安全配置的最佳实践。CIS 基准适用于 25 多个供应商产品系列的 100 多个 CIS 基准,是通过由全球网络安全专业人员和主题专家组成的独特的基于共识的流程开发的。CIS 基准是唯一一种基于共识的最佳实践安全配置指南,已被政府、企业、行业和学术界开发和接受。

这些基准以 PDF 的形式免费提供给 CIS 成员,PDF 中的内容是可读的但不能直接被扫描工具使用。CIS 为付费会员提供了一些 XCCDF1 格式的基准,可以被工具使用,不过这些基准不包含改变服务器状态以达到合规性所需的自动化和补救步骤。

CIS 基准包括多种 Profile 配置:

  1. 1 级 Profile 是一个基本建议,可以相当迅速地实施,其设计不会对性能产生广泛影响。1 级 Profile 基准的目的是降低企业的攻击面,同时保持机器的可用性,不妨碍业务功能。
  2. 2 级 Profile 是 "深度防御"级别建议,旨在为安全至关重要的环境服务。如果不适当地或不谨慎地实施与 2 级 Profile 相关的建议,会对你的组织产生不利影响。
  3. STIG Profile 取代了以前的 3 级。STIG Profile 提供了所有针对 STIG 的建议。其他 Profile (即1级和2级)中的建议的重叠部分,在 STIG Profile 中也有适用。

SCAP安全内容自动化协议

安全内容自动化协议 (SCAP) 由 NIST 组织制定的一套信息安全评估标准体系。SCAP安全指南实施了由权威机构 PCI DSS,STIG 和 USGCB推荐的安全指南。SCAP 安全指南将这些安全指南转换为机器可读的格式,可以使用它来审核目标系统。

SCAP 由两部分组成:Protocol(协议)与Content(内容)。Protocol 是指 SCAP 由一系列现有的公开标准构成,这些公开标准被称为 SCAP Element(SCAP元素)。Protocol 规范了这些 Element 之间如何协同工作,Content 指按照 Protocol 的约定,利用 Element 描述生成的应用于实际检查工作的数据。

SCAP标准包含以下组件:XCCDF,OVAL,DataStream,ARF,CPE,CVE,CWE。

  1. XCCDF-可扩展配置清单描述格式。该语言用于描述安全检查表,文档生成,组织和定制合规情境,自动合规性测试以及合规性评分。在评估XCCDF基准时,通常会处理 XCCDF文件,OVAL 文件和 CPE 词典。
  2. OVAL-开放漏洞和评估语言。它用来描述系统的安全漏洞或所需的配置。OVAL 定义了计算机中某些对象的安全状态,例如配置文件、文件权限、进程。OVAL定义是通过 scanner 解释器进行评估的。
  3. CPE-通用平台枚举。CPE用来描述漏洞影响了什么组件的什么版本,是信息技术系统,软件和程序包的结构化命名方案。
  4. CVE-通用漏洞和披露。它是公开披露的安全漏洞列表。
  5. CWE-通用弱点列举。它是由 MITRE 公司支持的,用来描述已知的安全弱点和缺陷。CWE 提供了关于预防、实施和缓解弱点的信息。
  6. DataStream-是一种将其他 SCAP 组件打包到一个文件中的格式。因为单个文件更易于处理,所以RedHat建议使用 DataStream。
  7. ARF-资产报告格式。它合并了多个结果文件(OVAL 结果和 XCCDF 结果),通常也称为 Result DataStream。

SCAP Security Guide - SSG

为了实现自动化安全基线扫描,Red Hat 向用户提供“scap-security-guidelines”软件包,包含了基于SCAP的基准扫描合规性、自动化修复所需内容:

  1. openscap-scanner: 基于 SCAP 的命令扫描工具。
  2. scap-security-guide: 是 SCAP 的内容,包含定义合规 Profile 以及补救修复所需的文件,如红帽 Ansible 自动化平台 Playbook 或 Bash 脚本。
  3. scap-workbench: 基于 SCAP 的图形界面扫描工具。

其中安全合规 Profile、修复执行脚本通过 SSG 构建系统构建成“scap-security-guidelines”软件包。在 SSG 中红帽推荐使用 DataStream,它是一种 XML 文件,可将其他SCAP组件打包成一个文件。这在分发 SCAP 内容时很有用,因为单个文件更容易处理。

如果想对本地系统进行配置或漏洞扫描,那么必须具备以下条件:

  1. 一个工具(oscap 或 SCAP Workbench)
  2. SCAP 内容(可以是源数据流、XCCDF、OVAL三种格式)

安装 SCAP Security Guide

如果没有配置 RHEL 的 Yum Repo,可以参考《RHEL 8 - 配置基于安装 ISO 文件的 YUM Repo》配置 Yum。以下使用的是 RHEL 8.4 的 ISO 作为 Yum Repo。

scap-security-guide 运行所需要的包有以下三个文件:

$ ll /mnt/rhel84/AppStream/Packages/scap*
-r--r--r--. 449 root root 8093716 Feb 17  2021 /mnt/rhel84/AppStream/Packages/scap-security-guide-0.1.54-5.el8.noarch.rpm
-r--r--r--. 449 root root 6226080 Feb 17  2021 /mnt/rhel84/AppStream/Packages/scap-security-guide-doc-0.1.54-5.el8.noarch.rpm
-r--r--r--. 116 root root 1940900 Feb 12  2021 /mnt/rhel84/AppStream/Packages/scap-workbench-1.2.0-8.el8.x86_64.rpm

然后运行以下命令可在安装相关的 OpenSCAP 组件,分别是扫描工具 “openscap-scanner” 、SCAP 内容 “scap-security-guide” 和 SCAP 内容的说明文档 “scap-security-guide-doc”。

$ yum install openscap-scanner scap-security-guide scap-security-guide-doc

另外还可从 https://access.redhat.com/downloads 中查找对应 RHEL 版本的 “scap-security-guide” 相关的软件包。

我们还可以单独下载 “scap-security-guide”。由于不同版本的 RHEL 对应不同的 “scap-security-guide” ,可从 https://access.redhat.com/articles/6337261 中查找特定版本 RHEL 对应的 “scap-security-guide” 。

然后可从 https://github.com/ComplianceAsCode/content/releases 中下载对应版本的 scap-security-guide 打包文件。
注意:在 https://github.com/ComplianceAsCode/content/releases 下载的 scap-security-guide 包含更全的内容,除了包含 RHEL 外还包含其他各种常用 Linux 甚至还包含 RHCOS 的内容。

了解 SCAP Security Guide 中包含的内容

在 OpenSCAP 的 “scap-security-guide” 目录中提供了用于自动化检查和修复的脚本,其中包含 Ansible Playbook、Bash Shell 和 Anaconda Kickstart 三种类型的脚本。其中 Ansible 脚本支持 check-mode 和 run-mode 两种模式,分别用来进行检查合规和设置修复合规配置;而 Bash Shell 脚本用来设置修复合规配置(部分修复是由 Shell 脚本)。

$ ll /usr/share/scap-security-guide
total 12
drwxr-xr-x. 2 root root 4096 Feb 11 09:58 ansible
drwxr-xr-x. 2 root root 4096 Feb 11 09:58 bash
drwxr-xr-x. 2 root root 4096 Feb 11 09:58 kickstart

使用 OpenSCAP 可以对目标进行合规基线检查,其中除了 RHEL 6/7/8 外还支持对 JRE 等软件进行检查。合规检查的方法和项目在以下文件中有描述。每个文件名在 “ssg-XXXXXX” 后面是不同的合规检查描述规范。

$ ls /usr/share/xml/scap/ssg/content
ssg-firefox-cpe-dictionary.xml  ssg-jre-cpe-dictionary.xml  ssg-rhel6-cpe-dictionary.xml  ssg-rhel7-cpe-dictionary.xml  ssg-rhel8-cpe-dictionary.xml
ssg-firefox-cpe-oval.xml        ssg-jre-cpe-oval.xml        ssg-rhel6-cpe-oval.xml        ssg-rhel7-cpe-oval.xml        ssg-rhel8-cpe-oval.xml
ssg-firefox-ds-1.2.xml          ssg-jre-ds-1.2.xml          ssg-rhel6-ds-1.2.xml          ssg-rhel7-ds-1.2.xml          ssg-rhel8-ds-1.2.xml
ssg-firefox-ds.xml              ssg-jre-ds.xml              ssg-rhel6-ds.xml              ssg-rhel7-ds.xml              ssg-rhel8-ds.xml
ssg-firefox-ocil.xml            ssg-jre-ocil.xml            ssg-rhel6-ocil.xml            ssg-rhel7-ocil.xml            ssg-rhel8-ocil.xml
ssg-firefox-oval.xml            ssg-jre-oval.xml            ssg-rhel6-oval.xml            ssg-rhel7-oval.xml            ssg-rhel8-oval.xml
ssg-firefox-xccdf.xml           ssg-jre-xccdf.xml           ssg-rhel6-xccdf.xml           ssg-rhel7-xccdf.xml           ssg-rhel8-xccdf.xml

查看说明 SCAP 内容的指导描述文档,可以看到 SSG 为每类合规检查对象提供了哪些检查 Profile。

$ ls /usr/share/doc/scap-security-guide/guides/
ssg-firefox-guide-default.html                  ssg-rhel6-guide-stig.html                           ssg-rhel7-guide-rhelh-stig.html
ssg-firefox-guide-index.html                    ssg-rhel6-guide-usgcb-rhel6-server.html             ssg-rhel7-guide-rhelh-vpp.html
ssg-firefox-guide-stig.html                     ssg-rhel6-PCIDSS-RHEL-6-guide-default.html          ssg-rhel7-guide-rht-ccp.html
ssg-jre-guide-default.html                      ssg-rhel6-PCIDSS-RHEL-6-guide-pci-dss_centric.html  ssg-rhel7-guide-standard.html
ssg-jre-guide-index.html                        ssg-rhel7-guide-anssi_nt28_enhanced.html            ssg-rhel7-guide-stig.html
ssg-jre-guide-stig.html                         ssg-rhel7-guide-anssi_nt28_high.html                ssg-rhel7-PCIDSS-RHEL-7-guide-default.html
ssg-rhel6-guide-C2S.html                        ssg-rhel7-guide-anssi_nt28_intermediary.html        ssg-rhel7-PCIDSS-RHEL-7-guide-pci-dss_centric.html
ssg-rhel6-guide-CS2.html                        ssg-rhel7-guide-anssi_nt28_minimal.html             ssg-rhel8-guide-anssi_bp28_enhanced.html
ssg-rhel6-guide-CSCF-RHEL6-MLS.html             ssg-rhel7-guide-C2S.html                            ssg-rhel8-guide-anssi_bp28_intermediary.html
ssg-rhel6-guide-default.html                    ssg-rhel7-guide-cis.html                            ssg-rhel8-guide-anssi_bp28_minimal.html
ssg-rhel6-guide-desktop.html                    ssg-rhel7-guide-cjis.html                           ssg-rhel8-guide-cis.html
ssg-rhel6-guide-fisma-medium-rhel6-server.html  ssg-rhel7-guide-cui.html                            ssg-rhel8-guide-cui.html
ssg-rhel6-guide-ftp-server.html                 ssg-rhel7-guide-default.html                        ssg-rhel8-guide-default.html
ssg-rhel6-guide-index.html                      ssg-rhel7-guide-e8.html                             ssg-rhel8-guide-e8.html
ssg-rhel6-guide-nist-CL-IL-AL.html              ssg-rhel7-guide-hipaa.html                          ssg-rhel8-guide-hipaa.html
ssg-rhel6-guide-pci-dss.html                    ssg-rhel7-guide-index.html                          ssg-rhel8-guide-index.html
ssg-rhel6-guide-rht-ccp.html                    ssg-rhel7-guide-ncp.html                            ssg-rhel8-guide-ospp.html
ssg-rhel6-guide-server.html                     ssg-rhel7-guide-ospp.html                           ssg-rhel8-guide-pci-dss.html
ssg-rhel6-guide-standard.html                   ssg-rhel7-guide-pci-dss.html                        ssg-rhel8-guide-stig.html

在浏览器中打开 “ssg-rhel8-guide-cis.html” 文件,可以在下图的描述中查看该文档对应的是哪种 Profile。

在 Profile 的说明中检查项目和规则被分为若干大类,见下图。注意:下图中 SSG 对 CIS 的项目分类和 CIS 官方分类有区别,在本文后面介绍如何对合规结果按照 CIS 的分类重新排序项目指标。

为了了解 “ssg-rhel8-guide-cis.html” 文档的内容,可以在文档中找到名为 “Set Lockouts for Failed Password Attempts” 的 Group,如下图的组包含3个规则(截图有限,只显示了 1 个规则)。

在上图下方的 References 区域是使用该规则所有的合规项目,其中 “5.4.3” 会链接到 CIS。我们可以在 CIS 网站获得《CIS RHEL 8 Benchmark》文档,并确认编号 “5.4.3” 的内容也是限制用户密码重用的规则。

注意:在上面 SSG 的 ssg-rhel8-guide-cis.html 文件中使用的引用的 CIS 编号是和 SSG 的版本以及 CIS 的版本相关。两者的版本如果不兼容,则无法对应上。

注意:无论在 ssg-rhel8-guide-cis.html 文件中还是在《CIS RHEL 8 Benchmark》文档中都提供了项目的修复代码,但两者的代码有一定差异。

还可在 ssg-rhel8-guide-cis.html 中查找 Rule ID 为 “xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_deny” 的规则,它对应的是上图中 CIS 为 “5.4.2” 的条目。

用 OpenSCAP 进行 CIS 合规扫描

查看 DataStream 文件包含的 Profile

执行命令查看 ssg-rhel8-ds.xml 中支持包含的 Profile,其中有一个的 Title 为 “CIS Red Hat Enterprise Linux 8 Benchmark”。另外从 Id 名称可以知道,该 Data Stream 中所有 Profile 使用的是 XCCDF 格式定义的。

$ oscap info /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml
Document type: Source Data Stream
Imported: 2021-02-17T10:44:54Stream: scap_org.open-scap_datastream_from_xccdf_ssg-rhel8-xccdf-1.2.xml
Generated: (null)
Version: 1.3
Checklists:Ref-Id: scap_org.open-scap_cref_ssg-rhel8-xccdf-1.2.xml
WARNING: Datastream component 'scap_org.open-scap_cref_security-data-oval-com.redhat.rhsa-RHEL8.xml' points out to the remote 'https://www.redhat.com/security/data/oval/com.redhat.rhsa-RHEL8.xml'. Use '--fetch-remote-resources' option to download it.
WARNING: Skipping 'https://www.redhat.com/security/data/oval/com.redhat.rhsa-RHEL8.xml' file which is referenced from datastreamStatus: draftGenerated: 2021-02-17Resolved: trueProfiles:Title: ANSSI-BP-028 (enhanced)Id: xccdf_org.ssgproject.content_profile_anssi_bp28_enhancedTitle: ANSSI-BP-028 (intermediary)Id: xccdf_org.ssgproject.content_profile_anssi_bp28_intermediaryTitle: ANSSI-BP-028 (minimal)Id: xccdf_org.ssgproject.content_profile_anssi_bp28_minimalTitle: CIS Red Hat Enterprise Linux 8 BenchmarkId: xccdf_org.ssgproject.content_profile_cisTitle: Unclassified Information in Non-federal Information Systems and Organizations (NIST 800-171)Id: xccdf_org.ssgproject.content_profile_cuiTitle: Australian Cyber Security Centre (ACSC) Essential EightId: xccdf_org.ssgproject.content_profile_e8Title: Health Insurance Portability and Accountability Act (HIPAA)Id: xccdf_org.ssgproject.content_profile_hipaaTitle: Protection Profile for General Purpose Operating SystemsId: xccdf_org.ssgproject.content_profile_osppTitle: PCI-DSS v3.2.1 Control Baseline for Red Hat Enterprise Linux 8Id: xccdf_org.ssgproject.content_profile_pci-dssTitle: DISA STIG for Red Hat Enterprise Linux 8Id: xccdf_org.ssgproject.content_profile_stigReferenced check files:ssg-rhel8-oval.xmlsystem: http://oval.mitre.org/XMLSchema/oval-definitions-5ssg-rhel8-ocil.xmlsystem: http://scap.nist.gov/schema/ocil/2security-data-oval-com.redhat.rhsa-RHEL8.xmlsystem: http://oval.mitre.org/XMLSchema/oval-definitions-5
Checks:Ref-Id: scap_org.open-scap_cref_ssg-rhel8-oval.xmlRef-Id: scap_org.open-scap_cref_ssg-rhel8-ocil.xmlRef-Id: scap_org.open-scap_cref_ssg-rhel8-cpe-oval.xmlRef-Id: scap_org.open-scap_cref_security-data-oval-com.redhat.rhsa-RHEL8.xml
Dictionaries:Ref-Id: scap_org.open-scap_cref_ssg-rhel8-cpe-dictionary.xml

可以注意到上面有 “WARNING” 提示,这是因为 ssg-rhel8-ds.xml 文件引用了在线的 com.redhat.rhsa-RHEL8.xml 文件。可以根据提示在以上命令中通过增加 ‘–fetch-remote-resources’ 参数,还可以根据提示下载 https://www.redhat.com/security/data/oval/com.redhat.rhsa-RHEL8.xml 文件到 /usr/share/xml/scap/ssg/content 目录中,然后再修改 ssg-rhel8-ds.xml 文件以下部分的 2 处远程引用,即可修复告警。

执行命令,查看名为 xccdf_org.ssgproject.content_profile_cis 的 Profile 信息。注意:可以根据 Description 了解当前 CIS Profile 的版本为 “v1.0.0”。

$ oscap info --fetch-remote-resources --profile xccdf_org.ssgproject.content_profile_cis /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml
Document type: Source Data Stream
Imported: 2021-02-17T10:44:54Stream: scap_org.open-scap_datastream_from_xccdf_ssg-rhel8-xccdf-1.2.xml
Generated: (null)
Version: 1.3
Downloading: https://www.redhat.com/security/data/oval/com.redhat.rhsa-RHEL8.xml ... ok
ProfileTitle: CIS Red Hat Enterprise Linux 8 BenchmarkId: xccdf_org.ssgproject.content_profile_cisDescription: This profile defines a baseline that aligns to the Center for Internet Security® Red Hat Enterprise Linux 8 Benchmark™, v1.0.0, released 09-30-2019.  This profile includes Center for Internet Security® Red Hat Enterprise Linux 8 CIS Benchmarks™ content.

CIS 合规扫描

全面扫描

执行以下命令,使用 ssg-rhel8-ds.xml 中名为 “CIS Red Hat Enterprise Linux 8 Benchmark” 对应的 Profile Id 进行合规扫描。将扫描结果保存在 cis-result.xml 文件中,该文件可用于 OpenSCAP 工具后续处理,不适合人直接查阅;而供人查看的扫描报告是 cis-report.html。

$ oscap xccdf eval --profile xccdf_org.ssgproject.content_profile_cis --results-arf cis-results.xml --report cis-report.html --fetch-remote-resources /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml

局部扫描

执行以下命令,只使用 CIS Profile(这里使用了 CIS 的简称)中的 “content_rule_accounts_passwords_pam_faillock_deny” 规则进行扫描。

$ oscap xccdf eval --profile cis --rule xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_deny --report cis-rule-report.html --fetch-remote-resources /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml
Downloading: https://www.redhat.com/security/data/oval/com.redhat.rhsa-RHEL8.xml ... ok
Title   Set Deny For Failed Password Attempts
Rule    xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_deny
Ident   CCE-80667-9
Result  fail

查看 CIS 合规扫描结果,了解 SSG DS 定义文件内容。

可以查看扫描结果文件 cis-results.xml,从 “Group rules by” 下拉框中选择下图的 CIS 地址,此时下方的扫描结果就会按照 CIS 分类和编号进行重新排序。

在扫描结果文件中可以根据 Rule ID 查找 “xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_deny”,可以看到该规则的检查结果。

查看上图的 “Set Deny For Failed Password Attempts” 链接,可以得到下图详细的扫描结果。从中可以看出名为 “xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_deny” 的 Rule ID 对应的是内容为 “oval:ssg-accounts_passwords_pam_faillock_deny:def:1” 的 “OVAL Definition ID”。

在 “ssg-rhel8-ds.xml” 文件中可以找到 “oval:ssg-accounts_passwords_pam_faillock_deny:def:1” 的 OVAL Definition ID,它定义了规则是如何实现的。其下有 8 个 “oval-def:criterion”,每个都包含了一个 “test_ref” ,例如 “oval:ssg-test_accounts_passwords_pam_faillock_preauth_silent_system-auth:tst:1”。这 8 个 “test_ref” 对应上图下方显示的OVAL test results 的 8 个项目。

下面结合上面一个 test-ref 的内容进行进一步分析。查找上图第一个 “oval-def:criterion” 对应的 test-ref:“oval:ssg-test_accounts_passwords_pam_faillock_preauth_silent_system-auth:tst:1”,可以获得下图的内容,其中包含了 OVAL 需要检查的对象和状态。

然后在 “ssg-rhel8-ds.xml” 文件中查找上图中 “oval:ssg-object_accounts_passwords_pam_faillock_when_lines_skipped_system-auth:obj:1” 可以得到下图的内容。

根据上图的 var_ref 在文件中查找 “oval:ssg-object_accounts_passwords_pam_faillock_when_lines_skipped_system-auth:obj:1”,可以看到下图对象。

根据上图的 object_ref 在文件中查找 “oval:ssg-object_accounts_passwords_pam_faillock_lines_value_system-auth:obj:1”,可以看到下图内容,它定义了实现规则的操作。

在 “ssg-rhel8-ds.xml” 文件中查找 “oval:ssg-state_var_accounts_passwords_pam_faillock_deny_value_upper_bound:ste:1” 和 “oval:ssg-state_var_accounts_passwords_pam_faillock_deny_value_lower_bound:ste:1”(它们是向上数第 4 个图中绿框中的内容),可以看到下图 2 个对象,分别定义了表达式。

根据上图的 var_ref 在文件中查找 “oval:ssg-var_accounts_passwords_pam_faillock_deny:var:1”,可以看到下图的内容。

此时一个用 XCCDF 定义的规则就分析完了。

定制 CIS 基线扫描指标

修改 “ssg-rhel8-ds.xml” 文件,在下图的 CIS Profile 区域将 “xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_deny” 后的 selected 设置为 “false”。

执行命令再次扫描,然后查看扫描结果。

$ oscap xccdf eval --profile xccdf_org.ssgproject.content_profile_cis --results-arf customize-cis-results.xml --report customize-cis-report.html --fetch-remote-resources /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml

确认已经找不到 “content_rule_accounts_passwords_pam_faillock_deny”了,而且 failed 状态的数量也少了 1 个。

修复不符合合规基线的项目

直接修复

可以使用 “–remediate” 参数在扫描的同时直接修复发现问题项目。

$ oscap xccdf eval --profile cis --rule xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_deny --results one-cis-results.xml --remediate --fetch-remote-resources /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml
Downloading: https://www.redhat.com/security/data/oval/com.redhat.rhsa-RHEL8.xml ... ok
Title   Set Deny For Failed Password Attempts
Rule    xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_deny
Ident   CCE-80667-9
Result  fail--- Starting Remediation ---
Title   Set Deny For Failed Password Attempts
Rule    xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_deny
Ident   CCE-80667-9
Result  fixed

生成修复 Ansible 剧本

先运行命令根据扫描结果文件生成基于 Ansible 的修复文件。

$ oscap xccdf generate fix --fix-type ansible --output PlaybookToRemediate.yml --fetch-remote-resources --result-id "" cis-result.xml

然后运行以下命令,针对当前主机执行Ansible脚本。

$ ansible-playbook -i "localhost," -c local PlaybookToRemediate.yml

最后可再次进行扫描,确认已经有大部分项目通过扫描,少量还不能通过基线的项目需要手动修复。

$ oscap xccdf eval --profile xccdf_org.ssgproject.content_profile_cis --fetch-remote-resources --report customize-cis-report.html /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml

转换文件

所有 SCAP 包含的对象都是用 XML 来进行描述,因此可以对基于 XML 规范的 SCAP 内容文档进行格式转换、内容拆分组合。

分解 DataStream 文件

执行命令,可以将在 ssg-rhel8-ds.xml 文件中包含的内容分解出来。

$ oscap ds sds-split --fetch-remote-resources /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml ssg-rhel8-ds-extracted/
$ ls -1 ssg-rhel8-ds-extracted/
scap_org.open-scap_cref_ssg-rhel8-cpe-dictionary.xml
scap_org.open-scap_cref_ssg-rhel8-xccdf-1.2.xml
security-data-oval-com.redhat.rhsa-RHEL8.xml
ssg-rhel8-cpe-oval.xml
ssg-rhel8-ocil.xml
ssg-rhel8-oval.xml

将 XCCDF 文档从适合机器处理的XML格式转为适合人工查看的HTML格式

以下将根据 ssg-rhel8-xccdf.xml 中的 CIS Profile 生成 HTML 格式的 Guide 文件。

$ oscap xccdf generate guide --profile cis /usr/share/xml/scap/ssg/content/ssg-rhel8-xccdf.xml > rhel8-cis-guide.html

以下将根据适合机器处理的 cis-results.xml 扫描结果文件生成 HTML 格式的 Report 文件,以方便人工阅读。

$ oscap xccdf generate report cis-results.xml > cis-report.html

用 OpenSCAP 进行 OVAL 安全漏洞扫描

红帽安全队为 RHEL 的漏洞提供了基于 OVAL 的扫描定义,用户能够执行漏洞扫描以诊断系统是否受到 CVE 漏洞攻击。使用 OpenSCAP 不但可以直接根据 OVAL 进行漏洞扫描,还可以根据 OVAL + XCCDF 或 Source DataStream 文件进行漏洞扫描(后面两种的扫描结果格式更友好)。

执行以下命令,前面是根据 Source DataStream 进行 CVE 漏洞扫描,后面是根据 OVAL + XCCDF 进行 CVE 漏洞扫描。

$ wget https://www.redhat.com/security/data/metrics/ds/com.redhat.rhsa-all.ds.xml
$ oscap xccdf eval --results cve-results.xml --report cve-report.html com.redhat.rhsa-all.ds.xml$ wget https://www.redhat.com/security/data/metrics/com.redhat.rhsa-all.xccdf.xml
$ wget https://www.redhat.com/security/data/oval/com.redhat.rhsa-all.xml
$ oscap xccdf eval --results cve-results.xml --report cve-report.html com.redhat.rhsa-all.xccdf.xml

参考

https://access.redhat.com/articles/6337261
https://access.redhat.com/sites/default/files/attachments/scap-security-guide-0.1.50-scap-1.3-rhel8.zip
https://github.com/ComplianceAsCode/content/releases
http://www.open-scap.org/security-policies/choosing-policy/
https://www.redhat.com/en/blog/center-internet-security-cis-compliance-red-hat-enterprise-linux-using-openscap
https://ncp.nist.gov/repository
https://static.open-scap.org/openscap-1.3/oscap_user_manual.html
https://www.redhat.com/en/blog/center-internet-security-cis-compliance-red-hat-enterprise-linux-using-openscap
http://static.open-scap.org/openscap-1.3/oscap_user_manual.html

RHEL 8 - CIS安全合规基线、SCAP、SSG和合规扫描、漏洞扫描相关推荐

  1. 基于等级保护梳理服务器安全合规基线

    背景 作为运维,当对新上架的服务器装完操作系统后,第一步就是对操作系统进行初始化配置来保证配置合规,此时你可能就会有疑问:我们应该初始化哪些参数,有没有相关标准参考呢? 要想真正了解进行初始化配置的目 ...

  2. K8s:开源安全平台 kubescape 实现 Pod 的安全合规检查/镜像漏洞扫描

    写在前面 生产环境中的 k8s 集群安全不可忽略,即使是内网环境 容器化的应用部署虽然本质上没有变化,始终是机器上的一个进程 但是提高了安全问题的处理的复杂性 分享一个开源的 k8s 集群安全合规检查 ...

  3. 安全评估之漏洞扫描、基线检查、渗透测试

    为保证业务系统运营的安全稳定,在业务系统上线前需要开展三同步检查,针对新业务系统上线.新版本上线.项目验收前开展安全评估.可以帮助其在技术层面了解系统存在的安全漏洞.今天就来了解一下安全评估之漏洞扫描 ...

  4. 车规级芯片,工规级芯片和消费级芯片差异简述

    近花了一些时间研究了一下关于工规,车规和消费级芯片在设计要求上的一些差异. 有一个概念需要了解,车载芯片未必是车规. 汽车电子分前装,后装之分.前装主要是主机厂为整车厂做配套的.作为整车的一部分提供给 ...

  5. 安规测试简介--认识安规基本测试项目(一)

    安规就是安全规范,指产品在设计中必须保持和遵守的规范.也就是目前各种产品使用的安全标准,这些标准根据产品的不同特点和需要,以及产品的安全要求制定出来的,由于对于安全要求和认识不断变化,因此标准也是不停 ...

  6. 第4章 法律、法规和合规

    4.1 法律的分类 法律分三大类 4.1.1刑法(Criminal law) 保护社会免受违反我们所信仰的基本原则的行为的侵害. 许多刑法通过打击计算机犯罪来保护社会安全.违反刑法的行为将由美国联邦和 ...

  7. 电器产品为什么要过安规认证?这些安规知识你了解吗

    电器产品为什么要过安规认证?安规测试是为了保证人在使用电器产品时不受任何危害而制定的,安规测试标准是电器产品在设计.制造时必须遵照执行的标准文件.所以我们在设计产品时需要遵循安规的各项规定,这样设计出 ...

  8. 国产替代STM32芯片MCU降本保供,数算我知道的国产车规级单片机AEC-Q100车规级汽车级认证芯片

    前言: 随着汽车行业进入智能化和新能源时代,过去由瑞萨.英飞凌.恩智浦.ST等芯片巨头所垄断的汽车级芯片市场竞争格局被打破,国产MCU中科芯.先楫.中微爱芯,GD.复旦微电子.航顺.中微.芯海科技等相 ...

  9. CSS大会 | 打破常“规”:挖掘语法解析器规则漏洞

    2019年7月30-31日,第五届互联网安全领袖峰会(CSS 2019)在北京开幕.作为前沿技术安全研究团队代表,Tencent Blade Team两位高级安全研究员受邀登台,探讨如何挖掘语法解析器 ...

最新文章

  1. linux个性化定制登录信息
  2. python的zip函数
  3. vue 内打开一个新窗口,带传参!
  4. zookeeper+kafka集群部署+storm集群
  5. jquery返回顶部
  6. Python中比元组更好用的namedtuple
  7. web安全-XSS攻击(一)
  8. assign与weak区别(面试)
  9. 小demo, java swing窗口编程(JDK 1.6)
  10. 程序员如何跟领导提离职_如何优雅地跟老板提加薪?按照这3个步骤来,也不是什么难事...
  11. java默认代码地址_Java 8默认方法可能会破坏您的(用户)代码
  12. Java 四种线程池的用法分析
  13. 接口implements(Java)
  14. java正则卡号4位一空格_银行卡号每隔4位插入空格
  15. 规格模式(Specification)
  16. 数学中的哈斯图如何构造?附实例
  17. 在Excel中将人民币金额小写转成大写(转)
  18. Nginx的http_access_module模块
  19. 【流浪地球——休眠仓】题解
  20. 成功解决:计算交叉熵lossFunction报错“1D target tensor expected, multi-target not supported”的解决办法

热门文章

  1. 三星app图标不见了怎么恢复_电脑任务栏显示桌面图标不见了怎么办
  2. 只用一个marker 替换 高德_Android基于高德地图完全自定义Marker的实现方法
  3. 中心对称数 java_【LeetCode(Java) - 246】中心对称数
  4. 苹果hdmi没有声音怎么办_HDMI线连接到电视后没有信号怎么办?给你7个方法,常见但很实用...
  5. 怎么禁用域控下的计算机配置,怎样从Windows域环境下禁用USB口设备
  6. 惊喜!想要高清背景壁纸图片素材,看这里
  7. LOGO设计没有灵感?5种方法来寻找标志设计的灵感和想法
  8. 早秋精品电商男装页面\海报设计PSD模板
  9. UI线框图模板素材实际应用好帮手
  10. c++绘制函数图像_简洁优雅的Matplotlib可视化 | 绘制论文曲线图