Skip to content
Search RHEL

This page uses Chinese content. Search opens the Chinese documentation.

    Browse this documentation

    RHEL 10 OpenSCAP 基线扫描:CIS Server L1 实测

    This content is not available in your language yet.

    OpenSCAP 在 RHEL 10 上仍是“SCAP 数据流 + oscap 扫描”这套:装 scap-security-guide 拿到 RHEL 10 的规则,装 openscap-scanner 拿到 oscap。本页跑一遍 CIS Server L1,并把结果怎么读、哪里会踩坑讲清。

    在 PVE 390 rhel10-lab(RHEL 10.2 x86_64)上实际执行:

    Terminal window
    sudo dnf -y install scap-security-guide openscap-scanner
    rpm -q scap-security-guide openscap-scanner
    oscap info /usr/share/xml/scap/ssg/content/ssg-rhel10-ds.xml | grep 'Id:'
    sudo oscap xccdf eval \
    --profile xccdf_org.ssgproject.content_profile_cis_server_l1 \
    --results /tmp/oscap-cis.xml \
    --report /tmp/oscap-cis.html \
    /usr/share/xml/scap/ssg/content/ssg-rhel10-ds.xml

    E3 记录:plans/content-expansion/evidence/rhel/rhel-openscap-baseline/run.json(7 步,含扫描日志/XML/HTML 的 sha256)。

    OpenSCAP 给的是某一时刻的配置快照:

    • 扫的是本机当前状态,不覆盖网络、流程、人员;
    • 规则通过不等于审计通过,规则失败也不等于系统“不能用”;
    • 扫描本身不改系统(除非加 --remediate);
    • 结果要结合业务豁免与风险接受记录,不能只报一个分数。
    scap-security-guide-0.1.82-2.el10_2.noarch
    openscap-scanner-1.4.4-1.el10_2.x86_64
    /usr/share/xml/scap/ssg/content/ssg-rhel10-ds.xml

    数据流里有 17 个 profile,常用的包括:

    Profile用途
    cisCIS 综合
    cis_server_l1CIS Server Level 1
    cis_workstation_l1/l2CIS 工作站
    stig / stig_guiDISA STIG
    pci-dssPCI DSS
    anssi_bp28_* / bsi / e8各国/行业基线

    用 oscap info ... | grep 'Id:' 看完整列表,不要凭记忆拼 profile id。

    Terminal window
    sudo oscap xccdf eval \
    --profile xccdf_org.ssgproject.content_profile_cis_server_l1 \
    --results /tmp/oscap-cis.xml \
    --report /tmp/oscap-cis.html \
    /usr/share/xml/scap/ssg/content/ssg-rhel10-ds.xml
    echo $? # 2

    实测结果:

    结果数量
    pass170
    fail120
    notapplicable34
    error / unknown0
    score69.089 / 100

    产物:

    -rw-r--r-- 3.6M /tmp/oscap-cis.html
    -rw-r--r-- 15M /tmp/oscap-cis.xml
    退出码含义
    0所有适用规则通过
    2有规则失败(本次就是 2)
    1扫描本身出错

    自动化脚本要把“扫描失败(1)”和“规则不通过(2)”分开处理;不要把 2 当异常直接重试。--results 的 XML 适合做 diff/入库,--report 的 HTML 适合给人看;两者都应归档,并记录 profile、数据流版本、扫描时间。

    Terminal window
    # 只生成修复脚本,不执行
    oscap xccdf generate fix \
    --profile xccdf_org.ssgproject.content_profile_cis_server_l1 \
    --output /tmp/cis-fix.sh \
    /usr/share/xml/scap/ssg/content/ssg-rhel10-ds.xml

    --remediate 会直接改 sshd、audit、挂载选项等,可能中断 SSH 或业务。生产上的顺序是:快照 → 测试机 --remediate → 审 diff → 变更窗口执行 → 复扫。不要在远程生产机上一次梭哈。

    • 数据流版本与 RHEL minor 匹配(ssg-rhel10-ds.xml);
    • profile id 从 oscap info 复制,不手写;
    • 保存 XML + HTML + 日志 + 扫描时间;
    • 退出码 1/2 分开处理;
    • --remediate 前有快照/测试机/变更单;
    • 失败项有豁免/修复记录,不只看 score。
    • 未测试 --remediate 的实际改动(避免污染 390);
    • 未测试 STIG/PCI-DSS profile 的完整扫描;
    • 未测试 oscap-docker/容器镜像扫描;
    • 未测试 SCAP 工作台(scap-workbench)与远程扫描;
    • 未做合规认证结论。