5.8. コンプライアンス Operator の調整

コンプライアンス Operator には、追加の設定なしで使用できるプロファイルが同梱されますが、それらは組織のニーズおよび要件を満たすために変更される必要があります。プロファイルを変更するプロセスは、テーラリング と呼ばれます。

コンプライアンス Operator は、TailoredProfile オブジェクトを提供し、プロファイルを調整します。

5.8.1. 調整されたプロファイルの新規作成

TailoredProfile オブジェクトを使用して、調整されたプロファイルをゼロから作成できます。適切な タイトル説明 を設定し、extends フィールドを空のままにします。このカスタムプロファイルが生成するスキャンのタイプをコンプライアンス Operator に指定します。

  • ノードのスキャン: オペレーティングシステムをスキャンします。
  • プラットフォームスキャン: OpenShift 設定をスキャンします。

手順

TailoredProfile オブジェクトに以下のアノテーションを設定します。

+ .例 new-profile.yaml

apiVersion: compliance.openshift.io/v1alpha1
kind: TailoredProfile
metadata:
  name: new-profile
  annotations:
    compliance.openshift.io/product-type: Node 1
spec:
  extends:
  description: My custom profile 2
  title: Custom profile 3
1
それに応じて Node または Platform を設定します。
2
description フィールドを使用して、新しい TailoredProfile オブジェクトの機能を記述します。
3
title フィールドで、TailoredProfile オブジェクトにタイトルを付けます。
注記

TailoredProfile オブジェクトの 名前 フィールドに -node 接尾辞を追加することは、Node 製品タイプのアノテーションを追加することと同様であり、オペレーティングシステムスキャンを生成します。

5.8.2. 調整されたプロファイルを使用した既存の ProfileBundles の拡張

TailoredProfile CR は最も一般的なテーラリング操作を有効にする一方で、XCCDF 標準は OpenSCAP プロファイルの調整におけるより多くの柔軟性を提供します。さらに、組織が以前に OpenScap を使用していた場合、既存の XCCDF テーラリングファイルが存在し、これを再利用できる可能性があります。

ComplianceSuite オブジェクトには、カスタムのテーラリングファイルにポイントできるオプションの TailoringConfigMap 属性が含まれます。TailoringConfigMap 属性の値は設定マップの名前です。これには、tailoring.xml というキーが含まれる必要があり、このキーの値はテーラリングのコンテンツです。

手順

  1. Red Hat Enterprise Linux CoreOS (RHCOS) ProfileBundle の利用可能なルールを参照します。

    $ oc get rules.compliance -n openshift-compliance -l compliance.openshift.io/profile-bundle=rhcos4
  2. 同じ ProfileBundle で利用可能な変数を参照します。

    $ oc get variables.compliance -n openshift-compliance -l compliance.openshift.io/profile-bundle=rhcos4
  3. nist-moderate-modified という名前の調整されたプロファイルを作成します。

    1. 調整されたプロファイル nist-moderate-modified に追加するルールを選択します。この例では、2 つのルールを無効にし、1 つの値を変更することにより、rhcos4-moderate プロファイルを拡張します。rationale 値を使用して、これらの変更が加えられた理由を記述します。

      new-profile-node.yaml の例

      apiVersion: compliance.openshift.io/v1alpha1
      kind: TailoredProfile
      metadata:
        name: nist-moderate-modified
      spec:
        extends: rhcos4-moderate
        description: NIST moderate profile
        title: My modified NIST moderate profile
        disableRules:
        - name: rhcos4-file-permissions-var-log-messages
          rationale: The file contains logs of error messages in the system
        - name: rhcos4-account-disable-post-pw-expiration
          rationale: No need to check this as it comes from the IdP
        setValues:
        - name: rhcos4-var-selinux-state
          rationale: Organizational requirements
          value: permissive

      表5.2 スペック変数の属性

      属性説明

      extends

      この TailoredProfile がビルドされる Profile オブジェクトの名前。

      title

      人間が判読できる TailoredProfile のタイトル。

      disableRules

      名前および理論的根拠のペアの一覧。名前ごとに、無効にするルールオブジェクトの名前を参照します。理論的根拠の値は、人間が判読できるテキストで、ルールが無効になっている理由を記述します。

      manualRules

      名前および理論的根拠のペアの一覧。手動ルールを追加すると、チェック結果のステータスは常に manual になり、修復は生成されません。この属性は自動であり、手動ルールとして設定されている場合、デフォルトでは値がありません。

      enableRules

      名前および理論的根拠のペアの一覧。名前ごとに、有効にするルールオブジェクトの名前を参照します。理論的根拠の値は、人間が判読できるテキストで、ルールが有効になっている理由を記述します。

      description

      TailoredProfile を記述する人間が判読できるテキスト。

      setValues

      名前、理論的根拠、および値のグループ化の一覧。各名前は値セットの名前を参照します。この理論的根拠は、値セットを記述する、人間が判読できるテキストです。この値は実際の設定です。

    2. tailoredProfile.spec.manualRules 属性を追加します。

      tailoredProfile.spec.manualRules.yaml

      apiVersion: compliance.openshift.io/v1alpha1
      kind: TailoredProfile
      metadata:
        name: ocp4-manual-scc-check
      spec:
        extends: ocp4-cis
        description: This profile extends ocp4-cis by forcing the SCC check to always return MANUAL
        title: OCP4 CIS profile with manual SCC check
        manualRules:
          - name: ocp4-scc-limit-container-allowed-capabilities
            rationale: We use third party software that installs its own SCC with extra privileges

    3. TailoredProfile オブジェクトを作成します。

      $ oc create -n openshift-compliance -f new-profile-node.yaml 1
      1
      TailoredProfile オブジェクトは、デフォルトの openshift-compliance namespace で作成されます。

      出力例

      tailoredprofile.compliance.openshift.io/nist-moderate-modified created

  4. ScanSettingBinding オブジェクトを定義して、新しい調整されたプロファイル nist-moderate-modified をデフォルトの ScanSetting オブジェクトにバインドします。

    new-scansettingbinding.yaml の例

    apiVersion: compliance.openshift.io/v1alpha1
    kind: ScanSettingBinding
    metadata:
      name: nist-moderate-modified
    profiles:
      - apiGroup: compliance.openshift.io/v1alpha1
        kind: Profile
        name: ocp4-moderate
      - apiGroup: compliance.openshift.io/v1alpha1
        kind: TailoredProfile
        name: nist-moderate-modified
    settingsRef:
      apiGroup: compliance.openshift.io/v1alpha1
      kind: ScanSetting
      name: default

  5. ScanSettingBinding オブジェクトを作成します。

    $ oc create -n openshift-compliance -f new-scansettingbinding.yaml

    出力例

    scansettingbinding.compliance.openshift.io/nist-moderate-modified created