5.4. Compliance Operator 概念
5.4.1. 了解 Compliance Operator
通过 Compliance Operator,OpenShift Container Platform 管理员可以描述集群所需的合规状态,并概述缺陷及修复方法。Compliance Operator 评估 OpenShift Container Platform 的 Kubernetes API 资源以及运行集群的节点的合规性。Compliance Operator 使用 NIST 认证工具 OpenSCAP 扫描并执行内容所提供的安全性策略。
Compliance Operator 仅适用于 Red Hat Enterprise Linux CoreOS(RHCOS)部署。
5.4.1.1. Compliance Operator 配置集
有多个配置集可用于安装 Compliance Operator。您可以使用 oc get
命令来查看可用的配置集、配置集详情和特定规则。
查看可用的配置集:
$ oc get profile.compliance -n openshift-compliance
输出示例
NAME AGE VERSION ocp4-cis 3h49m 1.5.0 ocp4-cis-1-4 3h49m 1.4.0 ocp4-cis-1-5 3h49m 1.5.0 ocp4-cis-node 3h49m 1.5.0 ocp4-cis-node-1-4 3h49m 1.4.0 ocp4-cis-node-1-5 3h49m 1.5.0 ocp4-e8 3h49m ocp4-high 3h49m Revision 4 ocp4-high-node 3h49m Revision 4 ocp4-high-node-rev-4 3h49m Revision 4 ocp4-high-rev-4 3h49m Revision 4 ocp4-moderate 3h49m Revision 4 ocp4-moderate-node 3h49m Revision 4 ocp4-moderate-node-rev-4 3h49m Revision 4 ocp4-moderate-rev-4 3h49m Revision 4 ocp4-nerc-cip 3h49m ocp4-nerc-cip-node 3h49m ocp4-pci-dss 3h49m 3.2.1 ocp4-pci-dss-3-2 3h49m 3.2.1 ocp4-pci-dss-4-0 3h49m 4.0.0 ocp4-pci-dss-node 3h49m 3.2.1 ocp4-pci-dss-node-3-2 3h49m 3.2.1 ocp4-pci-dss-node-4-0 3h49m 4.0.0 ocp4-stig 3h49m V2R1 ocp4-stig-node 3h49m V2R1 ocp4-stig-node-v1r1 3h49m V1R1 ocp4-stig-node-v2r1 3h49m V2R1 ocp4-stig-v1r1 3h49m V1R1 ocp4-stig-v2r1 3h49m V2R1 rhcos4-e8 3h49m rhcos4-high 3h49m Revision 4 rhcos4-high-rev-4 3h49m Revision 4 rhcos4-moderate 3h49m Revision 4 rhcos4-moderate-rev-4 3h49m Revision 4 rhcos4-nerc-cip 3h49m rhcos4-stig 3h49m V2R1 rhcos4-stig-v1r1 3h49m V1R1 rhcos4-stig-v2r1 3h49m V2R1
这些配置集代表不同的合规性基准。每个配置集将其应用到的产品名称添加为配置集名称的前缀。
ocp4-e8
将 Essential 8 基准应用到 OpenShift Container Platform 产品,而rhcos4-e8
将 Essential 8 基准应用到 Red Hat Enterprise Linux CoreOS (RHCOS) 产品。运行以下命令,以查看
rhcos4-e8
配置集的详情:$ oc get -n openshift-compliance -oyaml profiles.compliance rhcos4-e8
例 5.1. 输出示例
apiVersion: compliance.openshift.io/v1alpha1 description: 'This profile contains configuration checks for Red Hat Enterprise Linux CoreOS that align to the Australian Cyber Security Centre (ACSC) Essential Eight. A copy of the Essential Eight in Linux Environments guide can be found at the ACSC website: https://www.cyber.gov.au/acsc/view-all-content/publications/hardening-linux-workstations-and-servers' id: xccdf_org.ssgproject.content_profile_e8 kind: Profile metadata: annotations: compliance.openshift.io/image-digest: pb-rhcos4hrdkm compliance.openshift.io/product: redhat_enterprise_linux_coreos_4 compliance.openshift.io/product-type: Node creationTimestamp: "2022-10-19T12:06:49Z" generation: 1 labels: compliance.openshift.io/profile-bundle: rhcos4 name: rhcos4-e8 namespace: openshift-compliance ownerReferences: - apiVersion: compliance.openshift.io/v1alpha1 blockOwnerDeletion: true controller: true kind: ProfileBundle name: rhcos4 uid: 22350850-af4a-4f5c-9a42-5e7b68b82d7d resourceVersion: "43699" uid: 86353f70-28f7-40b4-bf0e-6289ec33675b rules: - rhcos4-accounts-no-uid-except-zero - rhcos4-audit-rules-dac-modification-chmod - rhcos4-audit-rules-dac-modification-chown - rhcos4-audit-rules-execution-chcon - rhcos4-audit-rules-execution-restorecon - rhcos4-audit-rules-execution-semanage - rhcos4-audit-rules-execution-setfiles - rhcos4-audit-rules-execution-setsebool - rhcos4-audit-rules-execution-seunshare - rhcos4-audit-rules-kernel-module-loading-delete - rhcos4-audit-rules-kernel-module-loading-finit - rhcos4-audit-rules-kernel-module-loading-init - rhcos4-audit-rules-login-events - rhcos4-audit-rules-login-events-faillock - rhcos4-audit-rules-login-events-lastlog - rhcos4-audit-rules-login-events-tallylog - rhcos4-audit-rules-networkconfig-modification - rhcos4-audit-rules-sysadmin-actions - rhcos4-audit-rules-time-adjtimex - rhcos4-audit-rules-time-clock-settime - rhcos4-audit-rules-time-settimeofday - rhcos4-audit-rules-time-stime - rhcos4-audit-rules-time-watch-localtime - rhcos4-audit-rules-usergroup-modification - rhcos4-auditd-data-retention-flush - rhcos4-auditd-freq - rhcos4-auditd-local-events - rhcos4-auditd-log-format - rhcos4-auditd-name-format - rhcos4-auditd-write-logs - rhcos4-configure-crypto-policy - rhcos4-configure-ssh-crypto-policy - rhcos4-no-empty-passwords - rhcos4-selinux-policytype - rhcos4-selinux-state - rhcos4-service-auditd-enabled - rhcos4-sshd-disable-empty-passwords - rhcos4-sshd-disable-gssapi-auth - rhcos4-sshd-disable-rhosts - rhcos4-sshd-disable-root-login - rhcos4-sshd-disable-user-known-hosts - rhcos4-sshd-do-not-permit-user-env - rhcos4-sshd-enable-strictmodes - rhcos4-sshd-print-last-log - rhcos4-sshd-set-loglevel-info - rhcos4-sysctl-kernel-dmesg-restrict - rhcos4-sysctl-kernel-kptr-restrict - rhcos4-sysctl-kernel-randomize-va-space - rhcos4-sysctl-kernel-unprivileged-bpf-disabled - rhcos4-sysctl-kernel-yama-ptrace-scope - rhcos4-sysctl-net-core-bpf-jit-harden title: Australian Cyber Security Centre (ACSC) Essential Eight
运行以下命令,以查看
rhcos4-audit-rules-login-events
规则的详情:$ oc get -n openshift-compliance -oyaml rules rhcos4-audit-rules-login-events
例 5.2. 输出示例
apiVersion: compliance.openshift.io/v1alpha1 checkType: Node description: |- The audit system already collects login information for all users and root. If the auditd daemon is configured to use the augenrules program to read audit rules during daemon startup (the default), add the following lines to a file with suffix.rules in the directory /etc/audit/rules.d in order to watch for attempted manual edits of files involved in storing logon events: -w /var/log/tallylog -p wa -k logins -w /var/run/faillock -p wa -k logins -w /var/log/lastlog -p wa -k logins If the auditd daemon is configured to use the auditctl utility to read audit rules during daemon startup, add the following lines to /etc/audit/audit.rules file in order to watch for unattempted manual edits of files involved in storing logon events: -w /var/log/tallylog -p wa -k logins -w /var/run/faillock -p wa -k logins -w /var/log/lastlog -p wa -k logins id: xccdf_org.ssgproject.content_rule_audit_rules_login_events kind: Rule metadata: annotations: compliance.openshift.io/image-digest: pb-rhcos4hrdkm compliance.openshift.io/rule: audit-rules-login-events control.compliance.openshift.io/NIST-800-53: AU-2(d);AU-12(c);AC-6(9);CM-6(a) control.compliance.openshift.io/PCI-DSS: Req-10.2.3 policies.open-cluster-management.io/controls: AU-2(d),AU-12(c),AC-6(9),CM-6(a),Req-10.2.3 policies.open-cluster-management.io/standards: NIST-800-53,PCI-DSS creationTimestamp: "2022-10-19T12:07:08Z" generation: 1 labels: compliance.openshift.io/profile-bundle: rhcos4 name: rhcos4-audit-rules-login-events namespace: openshift-compliance ownerReferences: - apiVersion: compliance.openshift.io/v1alpha1 blockOwnerDeletion: true controller: true kind: ProfileBundle name: rhcos4 uid: 22350850-af4a-4f5c-9a42-5e7b68b82d7d resourceVersion: "44819" uid: 75872f1f-3c93-40ca-a69d-44e5438824a4 rationale: Manual editing of these files may indicate nefarious activity, such as an attacker attempting to remove evidence of an intrusion. severity: medium title: Record Attempts to Alter Logon and Logout Events warning: Manual editing of these files may indicate nefarious activity, such as an attacker attempting to remove evidence of an intrusion.
5.4.1.1.1. Compliance Operator 配置集类型
可用的合规性配置集有两种:Platform(平台)和 Node(节点)。
- 平台
- 平台扫描目标 OpenShift Container Platform 集群。
- 节点
- 节点扫描集群节点目标。
对于具有 Node 和 Platform 应用程序的合规性配置集,如 pci-dss
合规性配置集,您必须在 OpenShift Container Platform 环境中运行。
5.4.1.2. 其他资源
5.4.2. 了解自定义资源定义
OpenShift Container Platform 中的 Compliance Operator 为您提供了几个自定义资源定义(CRD)来完成合规性扫描。要运行合规性扫描,它会利用预定义的安全策略,该策略从 ComplianceAsCode 社区项目衍生而来。Compliance Operator 把这些安全策略转换为 CRD,您可以使用它来运行合规性扫描,并为发现的问题获取补救。
5.4.2.1. CRD 工作流
CRD 为您提供了以下工作流来完成合规性扫描:
- 定义合规性扫描要求
- 配置合规性扫描设置
- 使用合规性扫描设置处理合规性要求
- 监控合规性扫描
- 检查合规性扫描结果
5.4.2.2. 定义合规性扫描要求
默认情况下,Compliance Operator CRD 包含 ProfileBundle
和 Profile
对象,您可以在其中定义和设置合规性扫描要求的规则。您还可以使用 TailoredProfile
对象自定义默认配置集。
5.4.2.2.1. ProfileBundle 对象
安装 Compliance Operator 时,它包含 ready-to-run ProfileBundle
对象。Compliance Operator 解析 ProfileBundle
对象,并为捆绑包中的每个配置集创建一个 Profile
对象。它还会解析 Rule
和 Variable
对象,这些对象会被 Profile
对象使用。
ProfileBundle
对象示例
apiVersion: compliance.openshift.io/v1alpha1
kind: ProfileBundle
name: <profile bundle name>
namespace: openshift-compliance
status:
dataStreamStatus: VALID 1
- 1
- 指明 Compliance Operator 是否能够解析内容文件。
当 contentFile
失败时,会出现一个 errorMessage
属性,它提供所发生错误的详细信息。
故障排除
当您从无效的镜像回滚到已知内容镜像时,ProfileBundle
对象停止响应并显示 PENDING
状态。作为临时解决方案,您可以移到与上一个镜像不同的镜像。另外,您可以删除并重新创建 ProfileBundle
对象以返回到工作状态。
5.4.2.2.2. 配置集对象
Profile
对象定义可以为某个合规性标准评估的规则和变量。它包含 OpenSCAP 配置集的解析详情,如其 XCCDF 标识符和配置集会检查 Node
或 Platform
类型。您可以直接使用 Profile
对象,也可以使用 TailorProfile
对象进一步自定义它。
您无法手动创建或修改 Profile
对象,因为它是从单个 ProfileBundle
对象衍生而来。通常,单个 ProfileBundle
对象可以包含多个 Profile
对象。
Profile
对象示例
apiVersion: compliance.openshift.io/v1alpha1 description: <description of the profile> id: xccdf_org.ssgproject.content_profile_moderate 1 kind: Profile metadata: annotations: compliance.openshift.io/product: <product name> compliance.openshift.io/product-type: Node 2 creationTimestamp: "YYYY-MM-DDTMM:HH:SSZ" generation: 1 labels: compliance.openshift.io/profile-bundle: <profile bundle name> name: rhcos4-moderate namespace: openshift-compliance ownerReferences: - apiVersion: compliance.openshift.io/v1alpha1 blockOwnerDeletion: true controller: true kind: ProfileBundle name: <profile bundle name> uid: <uid string> resourceVersion: "<version number>" selfLink: /apis/compliance.openshift.io/v1alpha1/namespaces/openshift-compliance/profiles/rhcos4-moderate uid: <uid string> rules: 3 - rhcos4-account-disable-post-pw-expiration - rhcos4-accounts-no-uid-except-zero - rhcos4-audit-rules-dac-modification-chmod - rhcos4-audit-rules-dac-modification-chown title: <title of the profile>
5.4.2.2.3. 规则对象
Rule
对象形成了配置文件,也会作为对象公开。使用 Rule
对象定义合规检查要求,并指定它是如何修复的。
Rule
对象示例
apiVersion: compliance.openshift.io/v1alpha1 checkType: Platform 1 description: <description of the rule> id: xccdf_org.ssgproject.content_rule_configure_network_policies_namespaces 2 instructions: <manual instructions for the scan> kind: Rule metadata: annotations: compliance.openshift.io/rule: configure-network-policies-namespaces control.compliance.openshift.io/CIS-OCP: 5.3.2 control.compliance.openshift.io/NERC-CIP: CIP-003-3 R4;CIP-003-3 R4.2;CIP-003-3 R5;CIP-003-3 R6;CIP-004-3 R2.2.4;CIP-004-3 R3;CIP-007-3 R2;CIP-007-3 R2.1;CIP-007-3 R2.2;CIP-007-3 R2.3;CIP-007-3 R5.1;CIP-007-3 R6.1 control.compliance.openshift.io/NIST-800-53: AC-4;AC-4(21);CA-3(5);CM-6;CM-6(1);CM-7;CM-7(1);SC-7;SC-7(3);SC-7(5);SC-7(8);SC-7(12);SC-7(13);SC-7(18) labels: compliance.openshift.io/profile-bundle: ocp4 name: ocp4-configure-network-policies-namespaces namespace: openshift-compliance rationale: <description of why this rule is checked> severity: high 3 title: <summary of the rule>
Rule
对象获取适当的标签,以便轻松识别关联的 ProfileBundle
对象。ProfileBundle
也在此对象的 OwnerReferences
中指定。
5.4.2.2.4. TailoredProfile 对象
使用 TailoredProfile
对象根据您的机构要求修改默认的 Profile
对象。您可以启用或禁用规则,设置变量值,并为自定义提供合理化。验证后,TailoredProfile
对象会创建一个 ConfigMap
,它可以被 ComplianceScan
对象引用。
您可以通过在 ScanSettingBinding
对象中引用 TailoredProfile
对象来使用 TailoredProfile 对象。有关 ScanSettingBinding
的更多信息,请参阅 ScanSettingBinding 对象。
TailoredProfile
对象示例
apiVersion: compliance.openshift.io/v1alpha1 kind: TailoredProfile metadata: name: rhcos4-with-usb spec: extends: rhcos4-moderate 1 title: <title of the tailored profile> disableRules: - name: <name of a rule object to be disabled> rationale: <description of why this rule is checked> status: id: xccdf_compliance.openshift.io_profile_rhcos4-with-usb 2 outputRef: name: rhcos4-with-usb-tp 3 namespace: openshift-compliance state: READY 4
使用 TailoredProfile
对象时,可以使用 TailoredProfile
构造来创建新的 Profile
对象。要创建新 配置集
,请设置以下配置参数:
- 合适的标题
-
extends
值必须为空 TailoredProfile
对象上的扫描类型注解:compliance.openshift.io/product-type: Platform/Node
注意如果您没有设置
product-type
注解,Compliance Operator 会默认使用Platform
扫描类型。在TailoredProfile
对象的名称中添加-node
后缀会导致node
扫描类型。
5.4.2.3. 配置合规性扫描设置
在定义了合规性扫描的要求后,您可以通过指定扫描类型、扫描和扫描位置来配置它。要做到这一点,Compliance Operator 为您提供了 ScanSetting
对象。
5.4.2.3.1. ScanSetting 对象
使用 ScanSetting
对象定义并重用操作策略来运行扫描。默认情况下,Compliance Operator 会创建以下 ScanSetting
对象:
- default - 它在 master 和 worker 节点(使用 1Gi PV)上每天的 1 AM 运行一次扫描,并保留最后三条结果。补救都不会自动更新。
-
default-auto-apply - 它在 control plane 和 worker 节点(使用 1Gi PV)上每天 1AM 运行一次扫描,并保留最后三个结果。
autoApplyRemediations
和autoUpdateRemediations
设置为 true。
ScanSetting
对象示例
apiVersion: compliance.openshift.io/v1alpha1 autoApplyRemediations: true 1 autoUpdateRemediations: true 2 kind: ScanSetting maxRetryOnTimeout: 3 metadata: creationTimestamp: "2022-10-18T20:21:00Z" generation: 1 name: default-auto-apply namespace: openshift-compliance resourceVersion: "38840" uid: 8cb0967d-05e0-4d7a-ac1c-08a7f7e89e84 rawResultStorage: nodeSelector: node-role.kubernetes.io/master: "" pvAccessModes: - ReadWriteOnce rotation: 3 3 size: 1Gi 4 tolerations: - effect: NoSchedule key: node-role.kubernetes.io/master operator: Exists - effect: NoExecute key: node.kubernetes.io/not-ready operator: Exists tolerationSeconds: 300 - effect: NoExecute key: node.kubernetes.io/unreachable operator: Exists tolerationSeconds: 300 - effect: NoSchedule key: node.kubernetes.io/memory-pressure operator: Exists roles: 5 - master - worker scanTolerations: - operator: Exists schedule: 0 1 * * * 6 showNotApplicable: false strictNodeScan: true timeout: 30m
5.4.2.4. 使用合规性扫描设置处理合规性扫描要求
当您定义了合规性扫描要求并将设置配置为运行扫描时,Compliance Operator 会使用 ScanSettingBinding
对象处理它。
5.4.2.4.1. ScanSettingBinding 对象
使用 ScanSettingBinding
对象指定您的合规要求,并引用 Profile
或 TailoredProfile
对象。然后,它会链接到一个 ScanSetting
对象,它为扫描提供操作限制。然后,Compliance Operator 根据 ScanSetting
和 ScanSettingBinding
对象生成 ComplianceSuite
对象。
ScanSettingBinding
对象示例
apiVersion: compliance.openshift.io/v1alpha1 kind: ScanSettingBinding metadata: name: <name of the scan> profiles: 1 # Node checks - name: rhcos4-with-usb kind: TailoredProfile apiGroup: compliance.openshift.io/v1alpha1 # Cluster checks - name: ocp4-moderate kind: Profile apiGroup: compliance.openshift.io/v1alpha1 settingsRef: 2 name: my-companys-constraints kind: ScanSetting apiGroup: compliance.openshift.io/v1alpha1
创建 ScanSetting
和 ScanSettingBinding
对象会导致合规性套件。要获取合规套件列表,请运行以下命令:
$ oc get compliancesuites
如果删除了 ScanSettingBinding
,则也会删除合规性套件。
5.4.2.5. 跟踪合规性扫描
创建合规套件后,您可以使用 ComplianceSuite
对象监控部署的扫描的状态。
5.4.2.5.1. ComplianceSuite 对象
ComplianceSuite
对象可帮助您跟踪扫描的状态。它包含创建扫描的原始设置以及总体结果。
对于 Node
类型扫描,您应该将扫描映射到 MachineConfigPool
,因为它包含任何问题的补救。如果指定了标签,请确保它直接应用到池。
ComplianceSuite
对象示例
apiVersion: compliance.openshift.io/v1alpha1 kind: ComplianceSuite metadata: name: <name of the scan> spec: autoApplyRemediations: false 1 schedule: "0 1 * * *" 2 scans: 3 - name: workers-scan scanType: Node profile: xccdf_org.ssgproject.content_profile_moderate content: ssg-rhcos4-ds.xml contentImage: registry.redhat.io/compliance/openshift-compliance-content-rhel8@sha256:45dc... rule: "xccdf_org.ssgproject.content_rule_no_netrc_files" nodeSelector: node-role.kubernetes.io/worker: "" status: Phase: DONE 4 Result: NON-COMPLIANT 5 scanStatuses: - name: workers-scan phase: DONE result: NON-COMPLIANT
后台中的套件会根据 scan
参数创建 ComplianceScan
对象。您可以以编程方式获取 ComplianceSuites
事件。要获取套件的事件,请运行以下命令:
$ oc get events --field-selector involvedObject.kind=ComplianceSuite,involvedObject.name=<name of the suite>
在手动定义 ComplianceSuite
时可能会创建错误,因为它包含 XCCDF 属性。
5.4.2.5.2. 高级 ComplianceScan 对象
Compliance Operator 包括用于调试或与现有工具集成的高级用户的选项。虽然建议您不要直接创建一个 ComplianceScan
对象,但您可以使用 ComplianceSuite
对象来管理它。
高级 ComplianceScan
对象示例
apiVersion: compliance.openshift.io/v1alpha1 kind: ComplianceScan metadata: name: <name of the scan> spec: scanType: Node 1 profile: xccdf_org.ssgproject.content_profile_moderate 2 content: ssg-ocp4-ds.xml contentImage: registry.redhat.io/compliance/openshift-compliance-content-rhel8@sha256:45dc... 3 rule: "xccdf_org.ssgproject.content_rule_no_netrc_files" 4 nodeSelector: 5 node-role.kubernetes.io/worker: "" status: phase: DONE 6 result: NON-COMPLIANT 7
- 1
- 指定
Node
或Platform
。节点配置集扫描集群节点和平台配置集扫描 Kubernetes 平台。 - 2
- 指定您要运行的配置集的 XCCDF 标识符。
- 3
- 指定封装配置集文件的容器镜像。
- 4
- 它是可选的。指定要运行单个规则的扫描。该规则必须使用 XCCDF ID 标识,并且必须属于指定的配置集。注意
如果您跳过
rule
参数,则针对指定配置集的所有可用规则运行扫描。 - 5
- 如果您在 OpenShift Container Platform 上,并希望生成补救,则 nodeSelector 标签必须与
MachineConfigPool
标签匹配。注意如果没有指定
nodeSelector
参数或与MachineConfig
标签匹配,则扫描仍将运行,但不会创建补救。 - 6
- 指示扫描的当前阶段。
- 7
- 表示扫描的结果。
如果您删除了 ComplianceSuite
对象,则所有关联的扫描都会被删除。
扫描完成后,它将生成结果作为 ComplianceCheckResult
对象的自定义资源。但是,原始结果以 ARF 格式提供。这些结果存储在持久性卷(PV)中,它具有与扫描名称关联的持久性卷声明(PVC)。您可以以编程方式获取 ComplianceScans
事件。要为套件生成事件,请运行以下命令:
oc get events --field-selector involvedObject.kind=ComplianceScan,involvedObject.name=<name of the suite>
5.4.2.6. 查看合规性结果
当合规性套件达到 DONE
阶段时,您可以查看扫描结果和可能的补救方法。
5.4.2.6.1. ComplianceCheckResult 对象
当使用特定配置集运行扫描时,会验证配置集中的多个规则。对于每个规则,都会创建一个 ComplianceCheckResult
对象,它为特定规则提供集群状态。
ComplianceCheckResult
对象示例
apiVersion: compliance.openshift.io/v1alpha1 kind: ComplianceCheckResult metadata: labels: compliance.openshift.io/check-severity: medium compliance.openshift.io/check-status: FAIL compliance.openshift.io/suite: example-compliancesuite compliance.openshift.io/scan-name: workers-scan name: workers-scan-no-direct-root-logins namespace: openshift-compliance ownerReferences: - apiVersion: compliance.openshift.io/v1alpha1 blockOwnerDeletion: true controller: true kind: ComplianceScan name: workers-scan description: <description of scan check> instructions: <manual instructions for the scan> id: xccdf_org.ssgproject.content_rule_no_direct_root_logins severity: medium 1 status: FAIL 2
要获得套件中的所有检查结果,请运行以下命令:
oc get compliancecheckresults \ -l compliance.openshift.io/suite=workers-compliancesuite
5.4.2.6.2. ComplianceRemediation 对象
对于特定的检查,您可以有一个 datastream 指定的修复。但是,如果 Kubernetes 修复可用,则 Compliance Operator 会创建一个 ComplianceRemediation
对象。
ComplianceRemediation
对象示例
apiVersion: compliance.openshift.io/v1alpha1 kind: ComplianceRemediation metadata: labels: compliance.openshift.io/suite: example-compliancesuite compliance.openshift.io/scan-name: workers-scan machineconfiguration.openshift.io/role: worker name: workers-scan-disable-users-coredumps namespace: openshift-compliance ownerReferences: - apiVersion: compliance.openshift.io/v1alpha1 blockOwnerDeletion: true controller: true kind: ComplianceCheckResult name: workers-scan-disable-users-coredumps uid: <UID> spec: apply: false 1 object: current: 2 apiVersion: machineconfiguration.openshift.io/v1 kind: MachineConfig spec: config: ignition: version: 2.2.0 storage: files: - contents: source: data:,%2A%20%20%20%20%20hard%20%20%20core%20%20%20%200 filesystem: root mode: 420 path: /etc/security/limits.d/75-disable_users_coredumps.conf outdated: {} 3
要从套件中获得所有补救,请运行以下命令:
oc get complianceremediations \ -l compliance.openshift.io/suite=workers-compliancesuite
要列出可自动修复的所有失败检查,请运行以下命令:
oc get compliancecheckresults \ -l 'compliance.openshift.io/check-status in (FAIL),compliance.openshift.io/automated-remediation'
要列出可手动修复的所有失败检查,请运行以下命令:
oc get compliancecheckresults \ -l 'compliance.openshift.io/check-status in (FAIL),!compliance.openshift.io/automated-remediation'