Security Command Center の検出結果をミュートする

このページでは、検出結果をミュートして、Security Command Center で受け取る検出結果の数を減らす方法について説明します。

概要

検出結果をミュートすると、その検出結果は Google Cloud コンソールの検出結果のデフォルト ビューに表示されなくなります。検出結果は手動またはプログラムでミュートできます。また、指定した条件に基づいて既存の検出結果と将来の検出結果を自動的にミュートするフィルタを作成できます。

Security Command Center の検出結果プロバイダは、Google Cloud のデプロイメントに関して広範なセキュリティ評価を提供しますが、組織やプロジェクトに適していない検出結果や関連性の低い検出結果が含まれている場合があります。大量の検出結果があると、セキュリティ アナリストが最も重要なリスクを迅速に特定し、修正することも難しくなります。検出結果をミュートすると、分離されているアセットや許容されるビジネス パラメータに含まれるアセットのセキュリティ検出結果を確認し、対応する時間を省くことができます。

検索結果のミュートと許可リスト

検出結果のミュートは、既存のボリューム管理ソリューションとは異なります。セキュリティ状況の分析を使用すると、専用のセキュリティ マークを使用してアセットを許可リストに追加できます。これにより、検出機能は特定のアセットに対するセキュリティの検出結果を生成しなくなります。Security Command Center では、検出機能を無効にすることもできます。

ただし、検出結果のミュートには、許可リストや検出機能の無効化と比べて次のような利点があります。

  • 基礎となるアセットが見つからなくても、検出結果をミュートできます。
  • リソースに関連付けられていない検出結果をミュートできます。
  • カスタム フィルタを作成してミュート機能を微調整できます。
  • 検出結果をミュートしても、基盤となるアセットのスキャンが停止することはありません。検出結果は引き続き生成されますが、表示の設定を行うまで非表示のままになります。

権限

検出結果をミュートするには、組織フォルダプロジェクトで次のいずれかの Identity and Access Management(IAM)ロールが必要です。

  • ミュートルールの表示:
    • セキュリティ センター管理閲覧者roles/securitycenter.adminViewer
    • セキュリティ センター設定閲覧者roles/securitycenter.settingsViewer
    • セキュリティ センターのミュート構成閲覧者roles/securitycenter.muteConfigsViewer
  • ミュートルールの表示、作成、更新、削除:
    • セキュリティ センター管理者roles/securitycenter.admin
    • セキュリティ センター管理編集者roles/securitycenter.adminEditor
    • セキュリティ センター設定編集者roles/securitycenter.settingsEditor
    • セキュリティ センターのミュート構成編集者roles/securitycenter.muteConfigsEditor
  • 検出結果の手動ミュート:
    • セキュリティ センター検出編集者roles/securitycenter.findingsEditor

次の権限の一部またはすべてを含むカスタムロールを作成して付与することもできます。

  • ミュートルールの読み取り権限
    • securitycenter.muteconfigs.get
    • securitycenter.muteconfigs.list
  • ミュートルールの書き込み権限
    • securitycenter.muteconfigs.create
    • securitycenter.muteconfigs.update
    • securitycenter.muteconfigs.delete
  • 検出結果の書き込み権限
    • securitycenter.findings.setMute
    • securitycenter.findings.bulkMuteUpdate

検出結果のミュートは、組織、フォルダ、プロジェクト レベルで付与されたロールに従います。特定のフォルダやプロジェクトの検出結果をミュートし、他のユーザーに付与する権限に基づいて検出結果のミュートを制限できます。たとえば、単一のプロジェクトにアクセスできる場合、そのプロジェクトの結果のみをミュートできます。フォルダへのアクセス権がある場合、そのフォルダ内の任意のサブフォルダまたはプロジェクトを対象とする検出結果をミュートできます。

Security Command Center のロールの詳細については、アクセス制御をご覧ください。

検出をミュートする

個々の検出結果を手動でミュートすることも、複数の検出結果をまとめてミュートすることもできます。また、定義したフィルタに基づいて将来の検出結果を自動的に抑制するミュートルールを作成することもできます。

検出結果には、MUTED または UNMUTED に設定できる mute 属性が含まれています。検出結果のミュートまたはミュート解除を行うと、属性の値が変更されます。詳しくは、検出結果のミュート プロパティをご覧ください。

検出結果のミュートは、次のような多くのユースケースに関連しています。

  • より厳しい要件が適用されない可能性のある本番環境以外のアセット。
  • 重要なデータを含まないプロジェクトで顧客管理の暗号鍵の使用が推奨される場合。
  • データストアで幅広いアクセス権を付与する場合。一般公開を意図したものとされ、情報が広く一般に配布されます。
  • 企業のポリシーから判断して組織またはプロジェクトと関係のない検出結果。

ミュートされた検出結果は引き続き監査とコンプライアンス目的でログに記録され、必要に応じて表示できます。ただし、デフォルトでは Google Cloud コンソールには表示されません。検出結果の mute 属性を使用して、Pub/Sub 通知と Security Command Center API 呼び出しからミュートされた検出結果をフィルタすることもできます。

個別の検出結果をミュートする

個別の検出結果をミュートするには、Google Cloud コンソール、gcloud CLI、または Security Command Center API を使用します。

検出結果をミュートするサンプルコードについては、検出結果のミュートをご覧ください。

個別の検出結果をミュートするには、使用する方法のタブをクリックします。

コンソール

  1. Google Cloud コンソールで、Security Command Center の [検出結果] ページに移動します。

    [検出] に移動

  2. 必要に応じて、Google Cloud プロジェクトまたは組織を選択します。プロジェクト セレクタ

  3. Security Command Center でデータ所在地が有効になっている場合は、プロジェクト セレクタのすぐ下にあるロケーション セレクタを使用して、検出結果の Security Command Center のロケーションを選択します。次に例を示します。

    ロケーション セレクタのスクリーンショット

  4. ミュートする検出結果が [検出結果のクエリ結果] パネルに表示されない場合は、[クイック フィルタ] パネルの [カテゴリ] セクションで検出結果のカテゴリを選択します。

  5. ミュートする検出結果の横にあるチェックボックスをオンにします。検出結果は 1 つ以上選択できます。

  6. [検出結果のクエリ結果] アクションバーで [ミュート オプション] をクリックし、[ミュート] を選択します。

    選択した検出結果の mute 属性は MUTED に設定され、[検出結果のクエリ結果] パネルから検出結果が削除されます。

また、詳細パネルで検出結果をミュートすることもできます。

  1. [検出結果] ページの [検出結果のクエリ結果] パネルにある [カテゴリ] 列で、個々の検出結果の名前をクリックします。検出結果の詳細パネルが開きます。
  2. [操作] をクリックします。
  3. [操作] メニューから [ミュート] を選択します。

    代わりに [これに類似する検出をミュート] を選択すると、[ミュートルールを作成する] ページが開きます。ここで、同じ種類または同じ Indicator 属性を含む検出結果のミュートルールを作成できます。

gcloud

  1. Google Cloud コンソールで、「Cloud Shell をアクティブにする」をクリックします。

    Cloud Shell をアクティブにする

    Google Cloud コンソールの下部で Cloud Shell セッションが開始し、コマンドライン プロンプトが表示されます。Cloud Shell はシェル環境です。Google Cloud CLI がすでにインストールされており、現在のプロジェクトの値もすでに設定されています。セッションが初期化されるまで数秒かかることがあります。

  2. 検出結果のミュート状態を MUTED に設定するには、gcloud CLI で set-mute コマンドを使用します。

    gcloud scc findings set-mute FINDING_ID \
     --PARENT=PARENT_ID \
     --location=LOCATION --source=SOURCE_ID \
     --mute=MUTED
    

    次のように置き換えます。

    • FINDING_ID: ミュートする検出結果の ID

      検出結果の ID を取得するには、Security Command Center API を使用して検出結果を一覧表示します。検出結果の ID は canonicalName 属性の最後の部分です(例: projects/123456789012/sources/1234567890123456789/findings/5ee30aa342e799e4e1700826de053aa9)。

    • PARENT: 親リソース(projectfolderorganization)。大文字と小文字が区別されます。

    • PARENT_ID: 親の組織、フォルダ、プロジェクトの ID

    • LOCATION: データ所在地が有効になっている場合は、検出結果が保存される Security Command Center のロケーションを指定します。

      データ所在地が有効になっていない場合、--location フラグを指定すると、Security Command Center API v2 を使用して検出結果がミュートされ、フラグの有効な値は global のみです。

    • SOURCE_ID: ソース ID

      ソース ID を取得する手順については、ソース ID の取得をご覧ください。

Go

次のサンプルでは、v1 API を使用します。v2 のサンプルを変更するには、v1v2 に置き換え、/locations/LOCATION をリソース名に追加します。

ほとんどのリソースでは、/PARENT/PARENT_ID の後に /locations/LOCATION をリソース名に追加します。ここで、PARENTorganizationsfolders、または projects です。

検出結果の場合は、/sources/SOURCE_ID の後に /locations/LOCATION をリソース名に追加します。ここで、SOURCE_ID は、検出結果を発行した Security Command Center サービスの ID です。

import (
	"context"
	"fmt"
	"io"

	securitycenter "cloud.google.com/go/securitycenter/apiv1"
	"cloud.google.com/go/securitycenter/apiv1/securitycenterpb"
)

// setMute mutes an individual finding.
// If a finding is already muted, muting it again has no effect.
// Various mute states are: MUTE_UNSPECIFIED/MUTE/UNMUTE.
func setMute(w io.Writer, findingPath string) error {
	// findingPath: The relative resource name of the finding. See:
	// https://cloud.google.com/apis/design/resource_names#relative_resource_name
	// Use any one of the following formats:
	//  - organizations/{organization_id}/sources/{source_id}/finding/{finding_id}
	//  - folders/{folder_id}/sources/{source_id}/finding/{finding_id}
	//  - projects/{project_id}/sources/{source_id}/finding/{finding_id}
	// findingPath := fmt.Sprintf("projects/%s/sources/%s/finding/%s", "your-google-cloud-project-id", "source", "finding-id")
	ctx := context.Background()
	client, err := securitycenter.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("securitycenter.NewClient: %w", err)
	}
	defer client.Close()

	req := &securitycenterpb.SetMuteRequest{
		Name: findingPath,
		Mute: securitycenterpb.Finding_MUTED}

	finding, err := client.SetMute(ctx, req)
	if err != nil {
		return fmt.Errorf("failed to set the specified mute value: %w", err)
	}
	fmt.Fprintf(w, "Mute value for the finding: %s is %s", finding.Name, finding.Mute)
	return nil
}

Java

次のサンプルでは、v1 API を使用します。v2 のサンプルを変更するには、v1v2 に置き換え、/locations/LOCATION をリソース名に追加します。

ほとんどのリソースでは、/PARENT/PARENT_ID の後に /locations/LOCATION をリソース名に追加します。ここで、PARENTorganizationsfolders、または projects です。

検出結果の場合は、/sources/SOURCE_ID の後に /locations/LOCATION をリソース名に追加します。ここで、SOURCE_ID は、検出結果を発行した Security Command Center サービスの ID です。


import com.google.cloud.securitycenter.v1.Finding;
import com.google.cloud.securitycenter.v1.Finding.Mute;
import com.google.cloud.securitycenter.v1.SecurityCenterClient;
import com.google.cloud.securitycenter.v1.SetMuteRequest;
import java.io.IOException;

public class SetMuteFinding {

  public static void main(String[] args) throws IOException {
    // TODO: Replace the variables within {}

    // findingPath: The relative resource name of the finding. See:
    // https://cloud.google.com/apis/design/resource_names#relative_resource_name
    // Use any one of the following formats:
    //  - organizations/{organization_id}/sources/{source_id}/finding/{finding_id}
    //  - folders/{folder_id}/sources/{source_id}/finding/{finding_id}
    //  - projects/{project_id}/sources/{source_id}/finding/{finding_id}
    String findingPath = "{path-to-the-finding}";
    setMute(findingPath);
  }

  // Mute an individual finding.
  // If a finding is already muted, muting it again has no effect.
  // Various mute states are: MUTE_UNSPECIFIED/MUTE/UNMUTE.
  public static Finding setMute(String findingPath) throws IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (SecurityCenterClient client = SecurityCenterClient.create()) {

      SetMuteRequest setMuteRequest =
          SetMuteRequest.newBuilder().setName(findingPath).setMute(Mute.MUTED).build();

      Finding finding = client.setMute(setMuteRequest);
      System.out.println(
          "Mute value for the finding " + finding.getName() + " is: " + finding.getMute());
      return finding;
    }
  }
}

Python

次のサンプルでは、v1 API を使用します。v2 のサンプルを変更するには、v1v2 に置き換え、/locations/LOCATION をリソース名に追加します。

ほとんどのリソースでは、/PARENT/PARENT_ID の後に /locations/LOCATION をリソース名に追加します。ここで、PARENTorganizationsfolders、または projects です。

検出結果の場合は、/sources/SOURCE_ID の後に /locations/LOCATION をリソース名に追加します。ここで、SOURCE_ID は、検出結果を発行した Security Command Center サービスの ID です。

def set_mute_finding(finding_path: str) -> None:
    """
      Mute an individual finding.
      If a finding is already muted, muting it again has no effect.
      Various mute states are: MUTE_UNSPECIFIED/MUTE/UNMUTE.
    Args:
        finding_path: The relative resource name of the finding. See:
        https://cloud.google.com/apis/design/resource_names#relative_resource_name
        Use any one of the following formats:
        - organizations/{organization_id}/sources/{source_id}/finding/{finding_id},
        - folders/{folder_id}/sources/{source_id}/finding/{finding_id},
        - projects/{project_id}/sources/{source_id}/finding/{finding_id}.
    """
    from google.cloud import securitycenter

    client = securitycenter.SecurityCenterClient()

    request = securitycenter.SetMuteRequest()
    request.name = finding_path
    request.mute = securitycenter.Finding.Mute.MUTED

    finding = client.set_mute(request)
    print(f"Mute value for the finding: {finding.mute.name}")

REST API

Security Command Center API で、setMute メソッドを使用して検出結果をミュートします。リクエストの本文は、結果のミュート状態を示す列挙型です。

データ所在地が有効になっていない限り、Security Command Center API の v1 または v2 を使用できます。API v2 は、プレビュー リリースとして利用できます。データ所在地が有効になっている場合、API v2 が唯一の利用可能な API です。

Security Command Center API v1 を使用している場合は、v1 エンドポイントを使用して setMute を呼び出します。


POST https://securitycenter.googleapis.com/v1/PARENT/PARENT_ID/sources/SOURCE_ID/findings/FINDING_ID:setMute

{
  "mute": "MUTED"
}

Security Command Center API v2 を使用している場合は、v2 エンドポイントを使用して setMute を呼び出します。

POST https://securitycenter.googleapis.com/v2/PARENT/PARENT_ID/sources/SOURCE_ID/locations/LOCATION/findings/FINDING_ID:setMute

{
  "mute": "MUTED"
}

次のように置き換えます。

  • PARENT: 親リソース(organizationsfolders、または projects
  • PARENT_ID: 親の組織、フォルダ、またはプロジェクトの ID。
  • LOCATION: v2 の場合のみ、検出結果が保存される Security Command Center のロケーションを指定します。ロケーション フィールドを省略した場合、デフォルト値は global です。
  • SOURCE_ID: ソースの数値 ID。

    ソース ID を取得する手順については、ソース ID の取得をご覧ください。

  • FINDING_ID: ミュートする検出結果の ID。

    検出結果の ID を取得するには、Security Command Center API を使用して検出結果を一覧表示します。検出結果の ID は canonicalName 属性の最後の部分です(例: projects/123456789012/sources/1234567890123456789/findings/5ee30aa342e799e4e1700826de053aa9)。

検出結果をミュートすると、mute 属性が MUTED に設定されます。

検出結果のミュートは、その有効 / 無効には影響を与えません。アクティブな検出結果がミュートされている場合、state 属性は変わらず state="ACTIVE" のまま残ります。その検出結果は非表示になりますが、根拠となる脆弱性、構成ミス、脅威が解決されるまでアクティブのまま残ります。

ミュートルールの詳細については、ミュートルールを作成するをご覧ください。

Google Cloud コンソールでミュートされた検出結果を表示する

Google Cloud コンソールでミュートされた検出結果を表示するには、検出結果クエリを編集して、プロパティ値 mute="MUTED" を含む検出結果を選択します。

たとえば、次の検出結果クエリでは、ミュートされているアクティブな検出結果のみが表示されます。

state="ACTIVE"
AND mute="MUTED"

ミュートとミュート解除の両方の結果を表示するには、クエリから mute 属性を省略します。

state="ACTIVE"

デフォルトでは、Google Cloud コンソールの検出結果クエリには、ミュートされていない検出結果のみが表示されます。

検出結果クエリの編集の詳細については、ダッシュボードで検出結果クエリを作成または編集するをご覧ください。

個別の検出結果のミュートを解除する

個々の検出結果のミュートを解除するには、Google Cloud コンソール、gcloud CLI、または Security Command Center API を使用します。

検出結果のミュートを解除するサンプルコードについては、検出結果のミュートを解除するをご覧ください。

個別の検出結果のミュートを解除するには、使用する方法のタブをクリックします。

コンソール

  1. Google Cloud Console で、Security Command Center の [検出] ページに移動します。

    [検出] に移動

  2. 必要に応じて、Google Cloud プロジェクトまたは組織を選択します。プロジェクト セレクタ

    [検出] ページが開き、[クエリのプレビュー] セクションにデフォルトのクエリが表示されます。デフォルトのクエリではミュートされた検出結果が除外されるため、そのクエリは、[検出結果のクエリ結果] パネルにミュートされた結果が表示される前に編集する必要があります。

  3. Security Command Center でデータ所在地が有効になっている場合は、プロジェクト セレクタのすぐ下にあるロケーション セレクタを使用して、検出結果の Security Command Center のロケーションを選択します。次に例を示します。

    ロケーション セレクタのスクリーンショット

  4. [クエリのプレビュー] セクションの右側にある [クエリを編集] をクリックして、[クエリエディタ] を開きます。

  5. [クエリエディタ] フィールドで、既存の mute ステートメントを次のように置き換えます。

    mute="MUTED"
  6. [適用] をクリックします。[検出結果のクエリ結果] パネルの検出結果が更新され、ミュートされた検出結果のみが含まれるようになります。

  7. 必要に応じて、ミュートされている他の検出結果を除外します。たとえば、[カテゴリ] の [クイック フィルタ] パネルで、他の検出結果のカテゴリをすべて除外するには、ミュートを解除する検出結果の名前を選択します。

  8. ミュートを解除する検索結果の横にあるチェックボックスをオンにします。検出結果は 1 つ以上選択できます。

  9. [検出結果のクエリ結果] アクションバーで [ミュート オプション] をクリックし、[ミュートを解除] を選択します。

    選択した検出結果の mute 属性は UNMUTED に設定され、[検出結果のクエリ結果] パネルから検出結果が削除されます。

また、詳細パネルで検出結果のミュートを解除することもできます。

  1. [検出結果] ページの [検出結果のクエリ結果] パネルにある [カテゴリ] 列で、個々の検出結果の名前をクリックします。検出結果の詳細パネルが開きます。
  2. [操作] をクリックします。
  3. [操作] メニューから [ミュートを解除] を選択します。

gcloud

  1. Google Cloud コンソールで、「Cloud Shell をアクティブにする」をクリックします。

    Cloud Shell をアクティブにする

    Google Cloud コンソールの下部で Cloud Shell セッションが開始し、コマンドライン プロンプトが表示されます。Cloud Shell はシェル環境です。Google Cloud CLI がすでにインストールされており、現在のプロジェクトの値もすでに設定されています。セッションが初期化されるまで数秒かかることがあります。

  2. 検出結果のミュート状態を UNMUTED に設定するには、gcloud CLI で set-mute コマンドを使用します。

    gcloud scc findings set-mute FINDING_ID \
     --PARENT=PARENT_ID \
     --location=LOCATION --source=SOURCE_ID \
     --mute=UNMUTED
    

    次のように置き換えます。

    • FINDING_ID: ミュートする検出結果の ID

      検出結果の ID を取得するには、Security Command Center API を使用して検出結果を一覧表示します。検出結果の ID は canonicalName 属性の最後の部分です(例: projects/123456789012/sources/1234567890123456789/findings/5ee30aa342e799e4e1700826de053aa9)。

    • PARENT: 親リソース(projectfolderorganization)。大文字と小文字が区別されます。

    • PARENT_ID: 親の組織、フォルダ、プロジェクトの ID

    • LOCATION: データ所在地が有効になっている場合は、検出結果が保存される Security Command Center のロケーションを指定します。

      データ所在地が有効になっていない場合、--location フラグを指定すると、Security Command Center API v2 を使用して検出結果が一覧表示されます。フラグの有効な値は global のみです。

    • SOURCE_ID: ソース ID

      ソース ID を取得する手順については、ソース ID の取得をご覧ください。

Go

次のサンプルでは、v1 API を使用します。v2 のサンプルを変更するには、v1v2 に置き換え、/locations/LOCATION をリソース名に追加します。

ほとんどのリソースでは、/PARENT/PARENT_ID の後に /locations/LOCATION をリソース名に追加します。ここで、PARENTorganizationsfolders、または projects です。

検出結果の場合は、/sources/SOURCE_ID の後に /locations/LOCATION をリソース名に追加します。ここで、SOURCE_ID は、検出結果を発行した Security Command Center サービスの ID です。


import (
	"context"
	"fmt"
	"io"

	securitycenter "cloud.google.com/go/securitycenter/apiv1"
	"cloud.google.com/go/securitycenter/apiv1/securitycenterpb"
)

// setUnmute unmutes an individual finding.
// Unmuting a finding that isn't muted has no effect.
// Various mute states are: MUTE_UNSPECIFIED/MUTE/UNMUTE.
func setUnmute(w io.Writer, findingPath string) error {
	// findingPath: The relative resource name of the finding. See:
	// https://cloud.google.com/apis/design/resource_names#relative_resource_name
	// Use any one of the following formats:
	//  - organizations/{organization_id}/sources/{source_id}/finding/{finding_id}
	//  - folders/{folder_id}/sources/{source_id}/finding/{finding_id}
	//  - projects/{project_id}/sources/{source_id}/finding/{finding_id}
	// findingPath := fmt.Sprintf("projects/%s/sources/%s/finding/%s", "your-google-cloud-project-id", "source", "finding-id")
	ctx := context.Background()
	client, err := securitycenter.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("securitycenter.NewClient: %w", err)
	}
	defer client.Close()

	req := &securitycenterpb.SetMuteRequest{
		Name: findingPath,
		Mute: securitycenterpb.Finding_UNMUTED}

	finding, err := client.SetMute(ctx, req)
	if err != nil {
		return fmt.Errorf("failed to set the specified mute value: %w", err)
	}
	fmt.Fprintf(w, "Mute value for the finding: %s is %s", finding.Name, finding.Mute)
	return nil
}

Java

次のサンプルでは、v1 API を使用します。v2 のサンプルを変更するには、v1v2 に置き換え、/locations/LOCATION をリソース名に追加します。

ほとんどのリソースでは、/PARENT/PARENT_ID の後に /locations/LOCATION をリソース名に追加します。ここで、PARENTorganizationsfolders、または projects です。

検出結果の場合は、/sources/SOURCE_ID の後に /locations/LOCATION をリソース名に追加します。ここで、SOURCE_ID は、検出結果を発行した Security Command Center サービスの ID です。


import com.google.cloud.securitycenter.v1.Finding;
import com.google.cloud.securitycenter.v1.Finding.Mute;
import com.google.cloud.securitycenter.v1.SecurityCenterClient;
import com.google.cloud.securitycenter.v1.SetMuteRequest;
import java.io.IOException;

public class SetUnmuteFinding {

  public static void main(String[] args) throws IOException {
    // TODO: Replace the variables within {}

    // findingPath: The relative resource name of the finding. See:
    // https://cloud.google.com/apis/design/resource_names#relative_resource_name
    // Use any one of the following formats:
    //  - organizations/{organization_id}/sources/{source_id}/finding/{finding_id}
    //  - folders/{folder_id}/sources/{source_id}/finding/{finding_id}
    //  - projects/{project_id}/sources/{source_id}/finding/{finding_id}
    String findingPath = "{path-to-the-finding}";
    setUnmute(findingPath);
  }

  // Unmute an individual finding.
  // Unmuting a finding that isn't muted has no effect.
  // Various mute states are: MUTE_UNSPECIFIED/MUTE/UNMUTE.
  public static Finding setUnmute(String findingPath) throws IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (SecurityCenterClient client = SecurityCenterClient.create()) {

      SetMuteRequest setMuteRequest =
          SetMuteRequest.newBuilder().setName(findingPath).setMute(Mute.UNMUTED).build();

      Finding finding = client.setMute(setMuteRequest);
      System.out.println(
          "Mute value for the finding " + finding.getName() + " is: " + finding.getMute());
      return finding;
    }
  }
}

Python

次のサンプルでは、v1 API を使用します。v2 のサンプルを変更するには、v1v2 に置き換え、/locations/LOCATION をリソース名に追加します。

ほとんどのリソースでは、/PARENT/PARENT_ID の後に /locations/LOCATION をリソース名に追加します。ここで、PARENTorganizationsfolders、または projects です。

検出結果の場合は、/sources/SOURCE_ID の後に /locations/LOCATION をリソース名に追加します。ここで、SOURCE_ID は、検出結果を発行した Security Command Center サービスの ID です。

def set_unmute_finding(finding_path: str) -> None:
    """
      Unmute an individual finding.
      Unmuting a finding that isn't muted has no effect.
      Various mute states are: MUTE_UNSPECIFIED/MUTE/UNMUTE.
    Args:
        finding_path: The relative resource name of the finding. See:
        https://cloud.google.com/apis/design/resource_names#relative_resource_name
        Use any one of the following formats:
        - organizations/{organization_id}/sources/{source_id}/finding/{finding_id},
        - folders/{folder_id}/sources/{source_id}/finding/{finding_id},
        - projects/{project_id}/sources/{source_id}/finding/{finding_id}.
    """
    from google.cloud import securitycenter

    client = securitycenter.SecurityCenterClient()

    request = securitycenter.SetMuteRequest()
    request.name = finding_path
    request.mute = securitycenter.Finding.Mute.UNMUTED

    finding = client.set_mute(request)
    print(f"Mute value for the finding: {finding.mute.name}")

REST API

Security Command Center API で、setMute メソッドを使用して検出結果のミュートを解除します。リクエストの本文は、結果のミュート状態を示す列挙型です。

データ所在地が有効になっていない限り、Security Command Center API の v1 または v2 を使用できます。API v2 は、プレビュー リリースとして利用できます。データ所在地が有効になっている場合、API v2 が唯一の利用可能な API です。

Security Command Center API v1 を使用している場合は、v1 エンドポイントを使用して setMute を呼び出します。

POST https://securitycenter.googleapis.com/v1/PARENT/PARENT_ID/sources/SOURCE_ID/findings/FINDING_ID:setMute

{
  "mute": "UNMUTED"
}

Security Command Center API v2 を使用している場合は、v2 エンドポイントを使用して setMute を呼び出します。

POST https://securitycenter.googleapis.com/v2/PARENT/PARENT_ID/sources/SOURCE_ID/locations/LOCATION/findings/FINDING_ID:setMute

{
  "mute": "UNMUTED"
}

次のように置き換えます。

  • PARENT: 親リソース(organizationsfolders、または projects
  • PARENT_ID: 親の組織、フォルダ、プロジェクトの ID
  • LOCATION: v2 の場合のみ、検出結果が保存される Security Command Center のロケーションを指定します。ロケーション フィールドを省略した場合、デフォルト値は global です。
  • SOURCE_ID: ソースの数値 ID

    ソース ID を取得する手順については、ソース ID の取得をご覧ください。

  • FINDING_ID: ミュートする検出結果の ID。

    検出結果の ID を取得するには、Security Command Center API を使用して検出結果を一覧表示します。検出結果の ID は canonicalName 属性の最後の部分です(例: projects/123456789012/sources/1234567890123456789/findings/5ee30aa342e799e4e1700826de053aa9)。

選択した検出結果は非表示になり、検出結果の mute 属性は UNMUTED に設定されます。

ミュートが解除された検出結果でミュートルールをオーバーライドする

ユーザーが検出結果のミュートを解除した場合、既存のミュートルールが検出結果に一致する場合でも、ミュートは解除されたままになります。ミュートの解除操作は、ユーザーがミュートルールをオーバーライドすることを意味します。

ミュートが解除された検出結果が再度ミュートされるのは、ユーザーが Google Cloud コンソールで手動でミュートするか、ミュートルールを新しく作成した場合だけです。gcloud CLI または Security Command Center API を使用して作成したミュートルールは、ユーザーがミュート解除した検出結果に影響しません。

複数の既存の検出結果をミュートする

gcloud scc findings bulk-mute gcloud CLI コマンドまたは Security Command Center API の bulkMute メソッドを使用して、複数の既存の検出結果を一括でミュートできます。同様の今後の検出結果をミュートする必要がある場合は、ミュートルールを作成します。

検出結果フィルタを定義して、ミュートする必要がある検出結果のセットを指定します。一括ミュート フィルタは、すべての検出プロパティに対応しているわけではありません。 対応していないプロパティのリストについては、ミュートルールでサポートされていない検出プロパティをご覧ください。

Security Command Center でデータ所在地が有効になっている場合、一括ミュート オペレーションのスコープは、それが実行される Security Command Center のロケーションに制限されます。

検出結果を一括でミュートするサンプルコードについては、検出結果を一括でミュートするをご覧ください。

検出結果を一括でミュートするには、使用する手順のタブをクリックします。

コンソール

Google Cloud コンソールでは、ミュートルールを作成することによってのみ、検出結果を一括でミュートできます。Google Cloud コンソールでミュートルールを作成すると、既存の検出結果と将来の検出結果がミュートされます。

gcloud

  1. Google Cloud コンソールで、「Cloud Shell をアクティブにする」をクリックします。

    Cloud Shell をアクティブにする

    Google Cloud コンソールの下部で Cloud Shell セッションが開始し、コマンドライン プロンプトが表示されます。Cloud Shell はシェル環境です。Google Cloud CLI がすでにインストールされており、現在のプロジェクトの値もすでに設定されています。セッションが初期化されるまで数秒かかることがあります。

  2. 複数の検出結果をまとめてミュートするには、gcloud scc findings bulk-mute コマンドを実行します。

    gcloud scc findings bulk-mute --PARENT=PARENT_ID \
    --location=LOCATION --filter="FILTER" \
    

    次のように置き換えます。

    • PARENT: ミュートルールが適用されるリソース階層内のスコープ(organizationfolderproject)。
    • PARENT_ID: 親組織、フォルダ、またはプロジェクトの ID。organizations/123folders/456projects/789 の形式で指定します。
    • LOCATION: データ所在地が有効になっている場合は、検出結果を一括でミュートする Security Command Center のロケーションを指定します。このロケーションの検出結果のみがミュートされます。

      データ所在地が有効になっていない場合、--location フラグを指定すると、Security Command Center API v2 を使用して検出結果がミュートされ、フラグの有効な値は global のみです。

    • FILTER: 検出結果のフィルタを定義する式

    たとえば、internal-test プロジェクトで既存の重大度が低の OPEN_FIREWALLPUBLIC_IP_ADDRESS のすべての検出結果をミュートするには、フィルタを "category=\"OPEN_FIREWALL\" OR category=\"PUBLIC_IP_ADDRESS\" AND severity=\"LOW\" AND resource.project_display_name=\"internal-test\"" にできます。

Go

次のサンプルでは、v1 API を使用します。v2 のサンプルを変更するには、v1v2 に置き換え、/locations/LOCATION をリソース名に追加します。

ほとんどのリソースでは、/PARENT/PARENT_ID の後に /locations/LOCATION をリソース名に追加します。ここで、PARENTorganizationsfolders、または projects です。

検出結果の場合は、/sources/SOURCE_ID の後に /locations/LOCATION をリソース名に追加します。ここで、SOURCE_ID は、検出結果を発行した Security Command Center サービスの ID です。


import (
	"context"
	"fmt"
	"io"

	securitycenter "cloud.google.com/go/securitycenter/apiv1"
	"cloud.google.com/go/securitycenter/apiv1/securitycenterpb"
)

// bulkMute kicks off a long-running operation (LRO) to bulk mute findings for a parent based on a filter.
// The parent can be either an organization, folder, or project. The findings
// matched by the filter will be muted after the LRO is done.
func bulkMute(w io.Writer, parent string, muteRule string) error {
	// parent: Use any one of the following options:
	//             - organizations/{organization_id}
	//             - folders/{folder_id}
	//             - projects/{project_id}
	// parent := fmt.Sprintf("projects/%s", "your-google-cloud-project-id")
	// muteRule: Expression that identifies findings that should be muted.
	// To create mute rules, see:
	// https://cloud.google.com/security-command-center/docs/how-to-mute-findings#create_mute_rules
	// muteRule := "filter-condition"
	ctx := context.Background()
	client, err := securitycenter.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("securitycenter.NewClient: %w", err)
	}
	defer client.Close()

	req := &securitycenterpb.BulkMuteFindingsRequest{
		Parent: parent,
		Filter: muteRule,
	}

	op, err := client.BulkMuteFindings(ctx, req)
	if err != nil {
		return fmt.Errorf("failed to bulk mute findings: %w", err)
	}
	response, err := op.Wait(ctx)
	if err != nil {
		return fmt.Errorf("failed to bulk mute findings: %w", err)
	}
	fmt.Fprintf(w, "Bulk mute findings completed successfully! %s", response)
	return nil
}

Java

次のサンプルでは、v1 API を使用します。v2 のサンプルを変更するには、v1v2 に置き換え、/locations/LOCATION をリソース名に追加します。

ほとんどのリソースでは、/PARENT/PARENT_ID の後に /locations/LOCATION をリソース名に追加します。ここで、PARENTorganizationsfolders、または projects です。

検出結果の場合は、/sources/SOURCE_ID の後に /locations/LOCATION をリソース名に追加します。ここで、SOURCE_ID は、検出結果を発行した Security Command Center サービスの ID です。


import com.google.cloud.securitycenter.v1.BulkMuteFindingsRequest;
import com.google.cloud.securitycenter.v1.BulkMuteFindingsResponse;
import com.google.cloud.securitycenter.v1.SecurityCenterClient;
import java.io.IOException;
import java.util.concurrent.ExecutionException;

public class BulkMuteFindings {

  public static void main(String[] args) {
    // TODO: Replace the variables within {}

    // parentPath: Use any one of the following options:
    //             - organizations/{organization_id}
    //             - folders/{folder_id}
    //             - projects/{project_id}
    String parentPath = String.format("projects/%s", "your-google-cloud-project-id");

    // muteRule: Expression that identifies findings that should be muted.
    // eg: "resource.project_display_name=\"PROJECT_ID\""
    String muteRule = "{filter-condition}";

    bulkMute(parentPath, muteRule);
  }

  // Kicks off a long-running operation (LRO) to bulk mute findings for a parent based on a filter.
  // The parent can be either an organization, folder, or project. The findings
  // matched by the filter will be muted after the LRO is done.
  public static void bulkMute(String parentPath, String muteRule) {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (SecurityCenterClient client = SecurityCenterClient.create()) {

      BulkMuteFindingsRequest bulkMuteFindingsRequest =
          BulkMuteFindingsRequest.newBuilder()
              .setParent(parentPath)
              // To create mute rules, see:
              // https://cloud.google.com/security-command-center/docs/how-to-mute-findings#create_mute_rules
              .setFilter(muteRule)
              .build();

      // ExecutionException is thrown if the below call fails.
      BulkMuteFindingsResponse response =
          client.bulkMuteFindingsAsync(bulkMuteFindingsRequest).get();
      System.out.println("Bulk mute findings completed successfully! " + response);
    } catch (IOException | InterruptedException | ExecutionException e) {
      System.out.println("Bulk mute findings failed! \n Exception: " + e);
    }
  }
}

Python

次のサンプルでは、v1 API を使用します。v2 のサンプルを変更するには、v1v2 に置き換え、/locations/LOCATION をリソース名に追加します。

ほとんどのリソースでは、/PARENT/PARENT_ID の後に /locations/LOCATION をリソース名に追加します。ここで、PARENTorganizationsfolders、または projects です。

検出結果の場合は、/sources/SOURCE_ID の後に /locations/LOCATION をリソース名に追加します。ここで、SOURCE_ID は、検出結果を発行した Security Command Center サービスの ID です。

def bulk_mute_findings(parent_path: str, mute_rule: str) -> None:
    """
      Kicks off a long-running operation (LRO) to bulk mute findings for a parent based on a filter.
      The parent can be either an organization, folder, or project. The findings
      matched by the filter will be muted after the LRO is done.
    Args:
        parent_path: use any one of the following options:
                     - organizations/{organization}
                     - folders/{folder}
                     - projects/{project}
        mute_rule: Expression that identifies findings that should be updated.
    """
    from google.cloud import securitycenter

    client = securitycenter.SecurityCenterClient()

    request = securitycenter.BulkMuteFindingsRequest()
    request.parent = parent_path
    # To create mute rules, see:
    # https://cloud.google.com/security-command-center/docs/how-to-mute-findings#create_mute_rules
    request.filter = mute_rule

    response = client.bulk_mute_findings(request)
    print(f"Bulk mute findings completed successfully! : {response}")

REST API

Security Command Center API で、既存の複数の検出結果をミュートするには、bulkMute メソッドを使用します。リクエストの本文には、検出結果をフィルタリングする式が含まれます。

データ所在地が有効になっていない限り、Security Command Center API の v1 または v2 を使用できます。API v2 は、プレビュー リリースとして利用できます。データ所在地が有効になっている場合、API v2 が唯一の利用可能な API です。

Security Command Center API v1 を使用している場合は、v1 エンドポイントを使用して bulkMute を呼び出します。

POST https://securitycenter.googleapis.com/v1/PARENT/PARENT_ID/findings:bulkMute -d

{
  "filter": "FILTER"
}

Security Command Center API v2 を使用している場合は、v2 エンドポイントを使用して bulkMute を呼び出します。

POST https://securitycenter.googleapis.com/v2/PARENT/PARENT_ID/locations/LOCATION/findings:bulkMute -d

{
  "filter": "FILTER"
}

次のように置き換えます。

  • PARENT: 親リソース(organizationsfolders、または projects
  • PARENT_ID: 親の組織、フォルダ、プロジェクトの ID。
  • LOCATION: v2 の場合のみ、検出結果が保存される Security Command Center のロケーションを指定します。ロケーション フィールドを省略した場合、デフォルト値は global です。
  • FILTER: 検出結果のフィルタを定義する式。

    たとえば、internal-test プロジェクトで既存の重大度が低の OPEN_FIREWALLPUBLIC_IP_ADDRESS のすべての検出結果をミュートするには、フィルタを "category=\"OPEN_FIREWALL\" OR category=\"PUBLIC_IP_ADDRESS\" AND severity=\"LOW\" AND resource.project_display_name=\"internal-test\"" にできます。

選択したリソース内にあり、フィルタと完全に一致する既存の検出結果はすべて非表示になります。検出結果の mute 属性は MUTED に設定されます。

検出結果をミュートしても状態は変わりません。アクティブな検出結果がミュートされている場合、それらは非表示になりますが、検出の原因となった脆弱性、構成ミス、または脅威が解決されるまではアクティブなままになります。

ミュートルールを作成する

ミュートルールは、指定した条件に基づいて今後の検出結果を自動的にミュートするフィルタを使用する Security Command Center の構成です。ミュート フィルタに一致する新しい検出結果は自動的にミュートされます。既存の検出結果もミュートする場合は、同じフィルタを使用して検出結果を一括でミュートします。

ミュートルールの範囲

フィルタを作成する際は、ミュートルールの範囲を考慮してください。

たとえば、Project A の検出結果をミュートするフィルタを作成しても、そのフィルタを Project B の下に作成していると、フィルタが検出結果と一致しない可能性があります。

同様に、データ所在地が有効になっている場合、ミュートルールのスコープは、ミュートルールが作成される Security Command Center のロケーションに制限されます。たとえば、次の場所にミュートルールを作成するとします。米国us)のロケーションの場合、ミュートルールは、 EUeu)または全世界global)の場所。 データ所在地とミュートルールの詳細については、ミュートルール、継続的なエクスポート、データ所在地をご覧ください。

フィルタ作成の詳細については、通知のフィルタリングをご覧ください。

ミュートルールの制限

ミュートルールは、一部の検出プロパティをサポートしていません。ミュートルールがサポートしていないプロパティのリストについては、ミュートルールでサポートされていない検出プロパティをご覧ください。

1 つの組織で作成できるミュートルールは 1,000 個までです。

データ所在地とミュートルール

データ所在地が有効になっている場合、ミュートルールを定義する構成(muteConfig リソース)はデータ所在地の制御の対象となり、Security Command Center のロケーションを選択します。

Security Command Center のロケーションの検出結果にミュートルールを適用するには、適用先の検出結果と同じロケーションにミュートルールを作成する必要があります。

ミュートルールで使用されるフィルタには、所在地管理の対象となるデータが含まれる可能性があるため、作成する前に正しいロケーションを指定していることを確認してください。Security Command Center では、ミュートルールやストリーミング エクスポートの作成場所は制限されません。

ミュートルールは作成場所にのみ保存され、他のロケーションで表示や編集はできません。

ミュートルールを作成した後に、そのロケーションを変更することはできません。場所を変更するには、ミュートルールを削除して、新しいロケーションで再作成する必要があります。

Google Cloud コンソールでミュートルールを表示するには、まず、Google Cloud コンソールのビューの作成場所を設定する必要があります。

同じルールが、ミュートルール MuteConfig の API 表現にも適用されます。

API 呼び出しを使用して MuteConfig を取得するには、MuteConfig の完全なリソース名でロケーションを指定する必要があります。次に例を示します。

GET https://securitycenter.googleapis.com/v2/{name=organizations/123/locations/eu/muteConfigs/my-mute-rule-01}

同様に、gcloud CLI を使用して muteConfig を取得するには、--locations フラグを使用してロケーションを指定します。次に例を示します。

gcloud scc muteconfigs list --organizations=123
--location=us

ミュートルールの作成

ミュートルールは、Google Cloud コンソール、gcloud CLI、または Security Command Center API を使用して作成できます。

ミュートルールを作成するサンプルコードについては、ミュートルールの作成をご覧ください。

ミュートルールを作成するには、使用する手順のタブをクリックします。

コンソール

  1. Google Cloud コンソールで、Security Command Center の [検出] ページに移動します。

    [検出結果] に移動

  2. 必要に応じて、Google Cloud プロジェクトまたは組織を選択します。

    プロジェクト セレクタ

  3. Security Command Center でデータ所在地が有効になっている場合は、プロジェクト セレクタのすぐ下にあるロケーション セレクタを使用して、ミュートルールを作成する Security Command Center のロケーションを選択します。 次に例を示します。

    ロケーション セレクタのスクリーンショット

  4. [ミュート オプション] をクリックし、[ミュートルールを作成] を選択します。

  5. ミュートルール ID を入力します。この値は必須です。

  6. 検出結果をミュートする理由を [ミュートルールの説明] に入力します。この値は省略可能ですが、指定することをおすすめします。

  7. 親リソースは、ミュートルールの作成と適用の範囲を示します。

  8. [検出クエリ] フィールドで [フィルタを追加] をクリックして、クエリ ステートメントを作成します。また、クエリ ステートメントを手動で入力することもできます。

    [フィルタを選択] ダイアログでは、サポートされている検出属性と値を選択できます。 クエリフィルタのダイアログ

    1. 検出属性を選択するか、[検出属性の検索] ボックスに名前を入力します。使用可能なサブ属性のリストが表示されます。
    2. サブ属性を選択します。評価オプションの選択フィールドは、検出結果クエリの結果パネルの検出結果にあるサブ属性値のリストの上に表示されます。
    3. 選択したサブ属性値の評価オプションを選択します。評価オプションと、それらが使用する演算子と関数の詳細については、[フィルタの追加] メニューのクエリ演算子をご覧ください。
    4. [適用] を選択します。

      ダイアログが閉じて、クエリが更新されます。

    5. 検出クエリに必要な属性がすべて表示されるまで、この操作を繰り返します。
  9. フィルタが正しいことを確認します。変更するには、必要に応じてプロパティを削除または追加し、値をフィルタします。

  10. [一致する検出をプレビュー] をクリックします。

    クエリに一致する検索結果がテーブルに表示されます。

  11. [保存] をクリックします。

gcloud

  1. Google Cloud コンソールで、「Cloud Shell をアクティブにする」をクリックします。

    Cloud Shell をアクティブにする

    Google Cloud コンソールの下部で Cloud Shell セッションが開始し、コマンドライン プロンプトが表示されます。Cloud Shell はシェル環境です。Google Cloud CLI がすでにインストールされており、現在のプロジェクトの値もすでに設定されています。セッションが初期化されるまで数秒かかることがあります。

  2. ミュートルールを作成するには、gcloud scc muteconfigs create コマンドを実行します。

    gcloud scc muteconfigs create CONFIG_ID \
    --PARENT=PARENT_ID \
    --location=LOCATION
    --description="RULE_DESCRIPTION" \
    --filter="FILTER"
    

    次のように置き換えます。

    • CONFIG_ID: ミュートルールの名前。ID には英数字とハイフンを使用し、1 ~ 63 文字にする必要があります。
    • PARENT: ミュートルールが適用されるリソース階層内のスコープ(organizationfolderproject)。
    • PARENT_ID: 親組織、フォルダ、またはプロジェクトの ID。organizations/123folders/456projects/789 の形式で指定します。
    • LOCATION: データ所在地が有効になっている場合は、ミュートルールを作成する Security Command Center のロケーションを指定します。ミュートルールの構成は保存され、このロケーションの検出結果にのみ適用されます。

      データ所在地が有効になっていない場合、--location フラグを指定すると、Security Command Center API v2 を使用して ミュートルールが作成されます。フラグの有効な値は global のみです。

    • RULE_DESCRIPTION: 1,024 文字以下のミュートルールの説明。

    • FILTER: 検出結果のフィルタを定義する式。 たとえば、OPEN_FIREWALL の検出結果をミュートするには、フィルタを FILTER="category=\"OPEN_FIREWALL\"" にします。

    レスポンスにはミュートルール ID が含まれます。この ID を使用して、ミュートルールを管理するで説明されているミュートルールを表示、更新、削除できます。

Go

次のサンプルでは、v1 API を使用します。v2 のサンプルを変更するには、v1v2 に置き換え、/locations/LOCATION をリソース名に追加します。

ほとんどのリソースでは、/PARENT/PARENT_ID の後に /locations/LOCATION をリソース名に追加します。ここで、PARENTorganizationsfolders、または projects です。

検出結果の場合は、/sources/SOURCE_ID の後に /locations/LOCATION をリソース名に追加します。ここで、SOURCE_ID は、検出結果を発行した Security Command Center サービスの ID です。


import (
	"context"
	"fmt"
	"io"

	securitycenter "cloud.google.com/go/securitycenter/apiv1"
	"cloud.google.com/go/securitycenter/apiv1/securitycenterpb"
)

// createMuteRule: Creates a mute configuration under a given scope that will mute
// all new findings that match a given filter.
// Existing findings will not be muted.
func createMuteRule(w io.Writer, parent string, muteConfigId string) error {
	// parent: Use any one of the following options:
	//             - organizations/{organization_id}
	//             - folders/{folder_id}
	//             - projects/{project_id}
	// parent := fmt.Sprintf("projects/%s", "your-google-cloud-project-id")
	// muteConfigId: Set a random id; max of 63 chars.
	// muteConfigId := "random-mute-id-" + uuid.New().String()
	ctx := context.Background()
	client, err := securitycenter.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("securitycenter.NewClient: %w", err)
	}
	defer client.Close()

	muteConfig := &securitycenterpb.MuteConfig{
		Description: "Mute low-medium IAM grants excluding 'compute' ",
		// Set mute rule(s).
		// To construct mute rules and for supported properties, see:
		// https://cloud.google.com/security-command-center/docs/how-to-mute-findings#create_mute_rules
		Filter: "severity=\"LOW\" OR severity=\"MEDIUM\" AND " +
			"category=\"Persistence: IAM Anomalous Grant\" AND " +
			"-resource.type:\"compute\"",
	}

	req := &securitycenterpb.CreateMuteConfigRequest{
		Parent:       parent,
		MuteConfigId: muteConfigId,
		MuteConfig:   muteConfig,
	}

	response, err := client.CreateMuteConfig(ctx, req)
	if err != nil {
		return fmt.Errorf("failed to create mute rule: %w", err)
	}
	fmt.Fprintf(w, "Mute rule created successfully: %s", response.Name)
	return nil
}

Java

次のサンプルでは、v1 API を使用します。v2 のサンプルを変更するには、v1v2 に置き換え、/locations/LOCATION をリソース名に追加します。

ほとんどのリソースでは、/PARENT/PARENT_ID の後に /locations/LOCATION をリソース名に追加します。ここで、PARENTorganizationsfolders、または projects です。

検出結果の場合は、/sources/SOURCE_ID の後に /locations/LOCATION をリソース名に追加します。ここで、SOURCE_ID は、検出結果を発行した Security Command Center サービスの ID です。


import com.google.cloud.securitycenter.v1.CreateMuteConfigRequest;
import com.google.cloud.securitycenter.v1.MuteConfig;
import com.google.cloud.securitycenter.v1.SecurityCenterClient;
import java.io.IOException;
import java.util.UUID;

public class CreateMuteRule {

  public static void main(String[] args) {
    // TODO: Replace the variables within {}

    // parentPath: Use any one of the following options:
    //             - organizations/{organization_id}
    //             - folders/{folder_id}
    //             - projects/{project_id}
    String parentPath = String.format("projects/%s", "your-google-cloud-project-id");

    // muteConfigId: Set a random id; max of 63 chars.
    String muteConfigId = "random-mute-id-" + UUID.randomUUID();
    createMuteRule(parentPath, muteConfigId);
  }

  // Creates a mute configuration under a given scope that will mute
  // all new findings that match a given filter.
  // Existing findings will not be muted.
  public static void createMuteRule(String parentPath, String muteConfigId) {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (SecurityCenterClient client = SecurityCenterClient.create()) {

      MuteConfig muteConfig =
          MuteConfig.newBuilder()
              .setDescription("Mute low-medium IAM grants excluding 'compute' ")
              // Set mute rule(s).
              // To construct mute rules and for supported properties, see:
              // https://cloud.google.com/security-command-center/docs/how-to-mute-findings#create_mute_rules
              .setFilter(
                  "severity=\"LOW\" OR severity=\"MEDIUM\" AND "
                      + "category=\"Persistence: IAM Anomalous Grant\" AND "
                      + "-resource.type:\"compute\"")
              .build();

      CreateMuteConfigRequest request =
          CreateMuteConfigRequest.newBuilder()
              .setParent(parentPath)
              .setMuteConfigId(muteConfigId)
              .setMuteConfig(muteConfig)
              .build();

      // ExecutionException is thrown if the below call fails.
      MuteConfig response = client.createMuteConfig(request);
      System.out.println("Mute rule created successfully: " + response.getName());
    } catch (IOException e) {
      System.out.println("Mute rule creation failed! \n Exception: " + e);
    }
  }
}

Python

次のサンプルでは、v1 API を使用します。v2 のサンプルを変更するには、v1v2 に置き換え、/locations/LOCATION をリソース名に追加します。

ほとんどのリソースでは、/PARENT/PARENT_ID の後に /locations/LOCATION をリソース名に追加します。ここで、PARENTorganizationsfolders、または projects です。

検出結果の場合は、/sources/SOURCE_ID の後に /locations/LOCATION をリソース名に追加します。ここで、SOURCE_ID は、検出結果を発行した Security Command Center サービスの ID です。



def create_mute_rule(parent_path: str, mute_config_id: str) -> None:
    """
    Creates a mute configuration under a given scope that will mute
    all new findings that match a given filter.
    Existing findings will NOT BE muted.
    Args:
        parent_path: use any one of the following options:
                     - organizations/{organization_id}
                     - folders/{folder_id}
                     - projects/{project_id}
        mute_config_id: Set a unique id; max of 63 chars.
    """

    from google.cloud import securitycenter

    client = securitycenter.SecurityCenterClient()

    mute_config = securitycenter.MuteConfig()
    mute_config.description = "Mute low-medium IAM grants excluding 'compute' "
    # Set mute rule(s).
    # To construct mute rules and for supported properties, see:
    # https://cloud.google.com/security-command-center/docs/how-to-mute-findings#create_mute_rules
    mute_config.filter = (
        'severity="LOW" OR severity="MEDIUM" AND '
        'category="Persistence: IAM Anomalous Grant" AND '
        '-resource.type:"compute"'
    )

    request = securitycenter.CreateMuteConfigRequest()
    request.parent = parent_path
    request.mute_config_id = mute_config_id
    request.mute_config = mute_config

    mute_config = client.create_mute_config(request=request)
    print(f"Mute rule created successfully: {mute_config.name}")

REST API

Security Command Center API で、muteConfigs create メソッドを使用してミュートルールを作成します。リクエストの本文は MuteConfig のインスタンスです。

データ所在地が有効になっていない限り、Security Command Center API の v1 または v2 を使用できます。API v2 は、プレビュー リリースとして利用できます。データ所在地が有効になっている場合、API v2 が唯一の利用可能な API です。

Security Command Center API v1 を使用している場合は、バージョン 1 エンドポイントを使用して muteConfigs create を呼び出します。リクエストの本文で、バージョン 1 の MuteConfig の定義を使用します。

POST https://securitycenter.googleapis.com/v1/PARENT/PARENT_ID/muteConfigs?muteConfigId=MUTE_CONFIG_ID -d

  {
    "description": "RULE_DESCRIPTION",
    "filter": FILTER
  }

Security Command Center API v2 を使用している場合は、バージョン 2 エンドポイントを使用して muteConfigs create を呼び出します。リクエストの本文で、バージョン 2 の MuteConfig 定義を使用します。

POST https://securitycenter.googleapis.com/v2/PARENT/PARENT_ID/locations/LOCATION/muteConfigs?muteConfigId=MUTE_CONFIG_ID -d

  {
    "description": "RULE_DESCRIPTION",
    "filter": FILTER
    "type": "STATIC"
  }

次のように置き換えます。

  • PARENT: ミュートルールの親リソース(organizationsfolders、または projects
  • PARENT_ID: 親の組織、フォルダ、プロジェクトの ID
  • LOCATION: v2 の場合のみ、ミュートルールが適用される Security Command Center のロケーションを指定します。ロケーション フィールドを省略した場合、デフォルト値は global です。
  • MUTE_CONFIG_ID: ミュートルールの名前(1~63 文字)
  • RULE_DESCRIPTION: ミュートルールの説明(最大: 1,024 文字)
  • FILTER: 検出結果のフィルタを定義する式

    たとえば、OPEN_FIREWALL の検出結果をミュートするには、フィルタを "category=\"OPEN_FIREWALL\"" にします。

レスポンスにはミュート構成 ID が含まれます。この ID を使用して、ミュートルールを管理するで説明されているミュートルールを表示、更新、削除できます。

フィルタと完全に一致する新しい検出結果は非表示になり、検出結果の mute 属性は MUTED に設定されます。

ミュートルールでサポートされていない検出プロパティ

ミュートルールは、フィルタ内の検出プロパティをすべてサポートしているわけではありません。ミュートルールのフィルタでは、次のプロパティがサポートされていません。

  • createTime
  • eventTime
  • mute
  • mute_initiator
  • mute_update_time
  • name
  • parent
  • security_marks
  • source_properties
  • state

検出結果のミュート プロパティ

このセクションでは、検出結果のミュート プロパティを示し、それらがミュート操作によってどのような影響を受けるか説明します。

  • mute: 検出結果が作成されると UNDEFINED にセットされます。次のシナリオで変更されます。
    • MUTED: 検出結果が手動またはミュートルールでミュートされる。
    • UNMUTED: ユーザーが検出結果のミュートを解除する。
  • mute_update_time: 検出結果がミュート、またはミュートが解除された時間。
  • mute_initiator: 検出結果をミュートしたプリンシパル、またはミュートルールの ID。

ミュートされた検出結果の通知を停止する

検出通知を有効にすると、通知フィルタに一致してミュートされた検出結果により Pub/Sub の通知がトリガーされます。

ミュートされた検出結果の通知を停止するには、mute 属性を使用して、NotificationConfig フィルタでミュートされた検出結果を除外します。たとえば、次のフィルタは、ミュートされていないか、ミュート属性が設定されていないアクティブな検出結果に対してのみ通知を送信します。

FILTER="state=\"ACTIVE\" AND -mute=\"MUTED\""

ミュートルールを管理する

ミュートルールは、IAM ロールの範囲に基づいて表示、更新、削除できます。組織レベルのロールでは、組織内のすべてのフォルダとプロジェクトのミュートルールが表示されます。フォルダレベルのロールがある場合は、特定のフォルダと、そのフォルダ内のすべてのサブフォルダとプロジェクトのミュートルールにアクセスして管理できます。プロジェクト レベルのロールの場合は、特定のプロジェクトのミュートルールを管理できます。

Security Command Center Premium では、組織レベル、フォルダレベル、プロジェクト レベルでロールを付与できます。Security Command Center Standard では、組織レベルでのロールの付与のみサポートされています。詳細については、アクセス制御をご覧ください。

ミュートルールを一覧表示する

組織、フォルダ、プロジェクトのミュートルールを一覧表示するには、Google Cloud Console、gcloud CLI、または Security Command Center API を使用します。

特定のスコープのミュートルールを一覧表示する権限は、IAM ロールに付与された権限によって異なります。

Security Command Center でデータ所在地が有効になっている場合、list コマンドのスコープも、選択した Security Command Center のロケーションに制限されます。

ミュートルールを一覧表示するサンプルコードについては、ミュートルールを一覧表示するをご覧ください。

組織、フォルダ、プロジェクトのミュートルールを一覧表示するには、使用する手順のタブをクリックします。

コンソール

  1. Google Cloud コンソールで、Security Command Center の [設定] ページの [ミュートルール] タブに移動します。

    [ミュートルール] に移動

  2. 必要に応じて、Google Cloud プロジェクトまたは組織を選択します。

    プロジェクト セレクタ

  3. Security Command Center でデータ所在地が有効になっている場合は、プロジェクト セレクタのすぐ下にあるロケーション セレクタを使用して、ミュートルールが保存されている Security Command Center のロケーションを選択します。次に例を示します。

    ロケーション セレクタのスクリーンショット

  4. [ミュートルール] セクションに、次のようなアクティブなミュートルールの詳細が表示されます。

    • 名前: ミュートルール ID
    • 親リソース: ミュートルールが存在するリソース
    • 説明: ミュートルールの説明(説明がある場合)
    • 最終更新者: ルールを最後に更新したプリンシパル
    • 最終更新: ルールが最後に更新された日時

gcloud

  1. Google Cloud コンソールで、「Cloud Shell をアクティブにする」をクリックします。

    Cloud Shell をアクティブにする

    Google Cloud コンソールの下部で Cloud Shell セッションが開始し、コマンドライン プロンプトが表示されます。Cloud Shell はシェル環境です。Google Cloud CLI がすでにインストールされており、現在のプロジェクトの値もすでに設定されています。セッションが初期化されるまで数秒かかることがあります。

  2. ミュートルールを一覧表示するには、gcloud scc muteconfigs list コマンドを実行します。

    gcloud scc muteconfigs list --PARENT=PARENT_ID --location=LOCATION
    

    次のように置き換えます。

    • PARENT: ミュートルールを一覧表示する親 organizationfolderproject
    • PARENT_ID: 親の組織、フォルダ、プロジェクトの ID
    • LOCATION: データ所在地が有効になっている場合は、ミュートルールを一覧表示する Security Command Center のロケーションを指定します。

      データ所在地が有効になっていない場合、--location フラグを指定すると、Security Command Center API v2 を使用してミュートルールが一覧表示されます。このフラグの有効な値は global のみです。

Go

次のサンプルでは、v1 API を使用します。v2 のサンプルを変更するには、v1v2 に置き換え、/locations/LOCATION をリソース名に追加します。

ほとんどのリソースでは、/PARENT/PARENT_ID の後に /locations/LOCATION をリソース名に追加します。ここで、PARENTorganizationsfolders、または projects です。

検出結果の場合は、/sources/SOURCE_ID の後に /locations/LOCATION をリソース名に追加します。ここで、SOURCE_ID は、検出結果を発行した Security Command Center サービスの ID です。

import (
	"context"
	"fmt"
	"io"

	securitycenter "cloud.google.com/go/securitycenter/apiv1"
	"cloud.google.com/go/securitycenter/apiv1/securitycenterpb"
	"google.golang.org/api/iterator"
)

// listMuteRules lists mute configs at the organization level will return all the configs
// at the org, folder, and project levels.
// Similarly, listing configs at folder level will list all the configs
// at the folder and project levels.
func listMuteRules(w io.Writer, parent string) error {
	// Use any one of the following resource paths to list mute configurations:
	//         - organizations/{organization_id}
	//         - folders/{folder_id}
	//         - projects/{project_id}
	// parent := fmt.Sprintf("projects/%s", "your-google-cloud-project-id")
	ctx := context.Background()
	client, err := securitycenter.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("securitycenter.NewClient: %w", err)
	}
	defer client.Close()

	req := &securitycenterpb.ListMuteConfigsRequest{Parent: parent}

	// List all mute configs present in the resource.
	it := client.ListMuteConfigs(ctx, req)
	for {
		muteconfig, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			return fmt.Errorf("it.Next: %w", err)
		}
		fmt.Fprintf(w, "Muteconfig Name: %s, ", muteconfig.Name)
	}
	return nil
}

Java

次のサンプルでは、v1 API を使用します。v2 のサンプルを変更するには、v1v2 に置き換え、/locations/LOCATION をリソース名に追加します。

ほとんどのリソースでは、/PARENT/PARENT_ID の後に /locations/LOCATION をリソース名に追加します。ここで、PARENTorganizationsfolders、または projects です。

検出結果の場合は、/sources/SOURCE_ID の後に /locations/LOCATION をリソース名に追加します。ここで、SOURCE_ID は、検出結果を発行した Security Command Center サービスの ID です。


import com.google.cloud.securitycenter.v1.ListMuteConfigsRequest;
import com.google.cloud.securitycenter.v1.MuteConfig;
import com.google.cloud.securitycenter.v1.SecurityCenterClient;
import java.io.IOException;

public class ListMuteRules {

  public static void main(String[] args) {
    // TODO: Replace variables enclosed within {}

    // parent: Use any one of the following resource paths to list mute configurations:
    //         - organizations/{organization_id}
    //         - folders/{folder_id}
    //         - projects/{project_id}
    String parentPath = String.format("projects/%s", "your-google-cloud-project-id");
    listMuteRules(parentPath);
  }

  // Listing mute configs at the organization level will return all the configs
  // at the org, folder, and project levels.
  // Similarly, listing configs at folder level will list all the configs
  // at the folder and project levels.
  public static void listMuteRules(String parent) {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (SecurityCenterClient client = SecurityCenterClient.create()) {

      ListMuteConfigsRequest listMuteConfigsRequest =
          ListMuteConfigsRequest.newBuilder().setParent(parent).build();

      // List all mute configs present in the resource.
      for (MuteConfig muteConfig : client.listMuteConfigs(listMuteConfigsRequest).iterateAll()) {
        System.out.println(muteConfig.getName());
      }
    } catch (IOException e) {
      System.out.println("Listing Mute rule failed! \n Exception: " + e);
    }
  }
}

Python

次のサンプルでは、v1 API を使用します。v2 のサンプルを変更するには、v1v2 に置き換え、/locations/LOCATION をリソース名に追加します。

ほとんどのリソースでは、/PARENT/PARENT_ID の後に /locations/LOCATION をリソース名に追加します。ここで、PARENTorganizationsfolders、または projects です。

検出結果の場合は、/sources/SOURCE_ID の後に /locations/LOCATION をリソース名に追加します。ここで、SOURCE_ID は、検出結果を発行した Security Command Center サービスの ID です。

def list_mute_rules(parent: str) -> None:
    """
    Listing mute configs at organization level will return all the configs
    at the org, folder and project levels.
    Similarly, listing configs at folder level will list all the configs
    at the folder and project levels.
    Args:
        parent: Use any one of the following resource paths to list mute configurations:
                - organizations/{organization_id}
                - folders/{folder_id}
                - projects/{project_id}
    """
    from google.cloud import securitycenter

    client = securitycenter.SecurityCenterClient()

    request = securitycenter.ListMuteConfigsRequest()
    request.parent = parent

    # List all Mute Configs present in the resource.
    for mute_config in client.list_mute_configs(request):
        print(mute_config.name)

REST API

Security Command Center API で、muteConfigs list メソッドを使用してミュートルールを一覧表示します。リクエストの本文は空です。

データ所在地が有効になっていない限り、Security Command Center API の v1 または v2 を使用できます。API v2 は、プレビュー リリースとして利用できます。データ所在地が有効になっている場合、API v2 が唯一の利用可能な API です。

Security Command Center API v1 を使用している場合は、v1 エンドポイントを使用して muteConfigs list を呼び出します。

GET https://securitycenter.googleapis.com/v1/PARENT/PARENT_ID/muteConfigs

Security Command Center API v2 を使用している場合は、v2 エンドポイントを使用して muteConfigs list を呼び出します。

GET https://securitycenter.googleapis.com/v2/PARENT/PARENT_ID/locations/LOCATION/muteConfigs

次のように置き換えます。

  • PARENT: ミュートルールの親リソース(organizationsfolders、または projects
  • PARENT_ID: 親の組織、フォルダ、プロジェクトの ID
  • LOCATION: v2 の場合のみ、ミュートルールを一覧表示する Security Command Center のロケーションを指定します。ロケーション フィールドを省略した場合、デフォルト値は global です。

レスポンスには、ミュートルールの名前、説明、ミュートの構成 ID が含まれます。

ミュートルールの構成の表示

ミュートルールの構成は、Google Cloud コンソール、gcloud CLI、または Security Command Center API を使用して表示できます。

ミュートルールの構成を取得するサンプルコードについては、ミュートルールの表示をご覧ください。

ミュートルールの構成を表示するには、使用する手順のタブをクリックします。

コンソール

  1. Google Cloud コンソールで、Security Command Center の [設定] ページの [ミュートルール] タブに移動します。

    [ミュートルール] に移動

  2. 必要に応じて、Google Cloud プロジェクトまたは組織を選択します。

    プロジェクト セレクタ

  3. Security Command Center でデータ所在地が有効になっている場合は、プロジェクト セレクタのすぐ下にあるロケーション セレクタを使用して、ミュートルールの Security Command Center のロケーションを選択します。次に例を示します。

    ロケーション セレクタのスクリーンショット

  4. [ミュートルール] セクションにミュートルールの一覧が表示されます。

  5. 表示するルールの名前をクリックします。

    ミュートルールの構成を示すページが表示されます。

gcloud

  1. Google Cloud コンソールで、「Cloud Shell をアクティブにする」をクリックします。

    Cloud Shell をアクティブにする

    Google Cloud コンソールの下部で Cloud Shell セッションが開始し、コマンドライン プロンプトが表示されます。Cloud Shell はシェル環境です。Google Cloud CLI がすでにインストールされており、現在のプロジェクトの値もすでに設定されています。セッションが初期化されるまで数秒かかることがあります。

  2. ミュートルールの構成を表示するには、gcloud scc muteconfigs get コマンドを実行します。

    gcloud scc muteconfigs get MUTE_CONFIG_ID \
     --PARENT=PARENT_ID --location=LOCATION
    

    次のように置き換えます。

    • MUTE_CONFIG_ID: ミュートルールの ID
    • PARENT: ミュートルールの親リソース(organizationfolder、または project
    • PARENT_ID: 組織、フォルダ、またはプロジェクトの ID
    • LOCATION: データ所在地が有効になっている場合は、ミュートルールが保存される Security Command Center のロケーションを指定します。デフォルト値は global です。

      データ所在地が有効になっていない場合、--location フラグを指定すると、Security Command Center API v2 を使用してミュートルールが取得され、フラグの有効な値は global のみです。

Go

次のサンプルでは、v1 API を使用します。v2 のサンプルを変更するには、v1v2 に置き換え、/locations/LOCATION をリソース名に追加します。

ほとんどのリソースでは、/PARENT/PARENT_ID の後に /locations/LOCATION をリソース名に追加します。ここで、PARENTorganizationsfolders、または projects です。

検出結果の場合は、/sources/SOURCE_ID の後に /locations/LOCATION をリソース名に追加します。ここで、SOURCE_ID は、検出結果を発行した Security Command Center サービスの ID です。

import (
	"context"
	"fmt"
	"io"

	securitycenter "cloud.google.com/go/securitycenter/apiv1"
	"cloud.google.com/go/securitycenter/apiv1/securitycenterpb"
)

// getMuteRule retrieves a mute configuration given its resource name.
func getMuteRule(w io.Writer, parent string, muteConfigId string) error {
	// Use any one of the following resource paths to get mute configuration:
	//         - organizations/{organization_id}
	//         - folders/{folder_id}
	//         - projects/{project_id}
	// parent := fmt.Sprintf("projects/%s", "your-google-cloud-project-id")
	//
	// Name of the mute config to retrieve.
	// muteConfigId := "mute-config-id"
	ctx := context.Background()
	client, err := securitycenter.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("securitycenter.NewClient: %w", err)
	}
	defer client.Close()

	req := &securitycenterpb.GetMuteConfigRequest{
		Name: fmt.Sprintf("%s/muteConfigs/%s", parent, muteConfigId),
	}

	muteconfig, err := client.GetMuteConfig(ctx, req)
	if err != nil {
		return fmt.Errorf("Failed to retrieve Muteconfig: %w", err)
	}
	fmt.Fprintf(w, "Muteconfig Name: %s ", muteconfig.Name)
	return nil
}

Java

次のサンプルでは、v1 API を使用します。v2 のサンプルを変更するには、v1v2 に置き換え、/locations/LOCATION をリソース名に追加します。

ほとんどのリソースでは、/PARENT/PARENT_ID の後に /locations/LOCATION をリソース名に追加します。ここで、PARENTorganizationsfolders、または projects です。

検出結果の場合は、/sources/SOURCE_ID の後に /locations/LOCATION をリソース名に追加します。ここで、SOURCE_ID は、検出結果を発行した Security Command Center サービスの ID です。


import com.google.cloud.securitycenter.v1.MuteConfig;
import com.google.cloud.securitycenter.v1.MuteConfigName;
import com.google.cloud.securitycenter.v1.SecurityCenterClient;
import java.io.IOException;

public class GetMuteRule {

  public static void main(String[] args) {
    // TODO(Developer): Replace the following variables

    // parentPath: Use any one of the following options:
    //             - organizations/{organization_id}
    //             - folders/{folder_id}
    //             - projects/{project_id}
    String parentPath = String.format("projects/%s", "your-google-cloud-project-id");

    // muteConfigId: Name of the mute config to retrieve.
    String muteConfigId = "mute-config-id";

    getMuteRule(parentPath, muteConfigId);
  }

  // Retrieves a mute configuration given its resource name.
  public static void getMuteRule(String projectId, String muteConfigId) {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (SecurityCenterClient client = SecurityCenterClient.create()) {
      // Use appropriate MuteConfigName methods depending on the type of parent.
      // (org -> MuteConfigName.ofOrganizationMuteConfigName()
      // folder -> MuteConfigName.ofFolderMuteConfigName()
      // project -> MuteConfigName.ofProjectMuteConfigName)
      MuteConfig muteConfig =
          client.getMuteConfig(MuteConfigName.ofProjectMuteConfigName(projectId, muteConfigId));

      System.out.println("Retrieved the mute config: " + muteConfig);
    } catch (IOException e) {
      System.out.println("Mute rule retrieval failed! \n Exception: " + e);
    }
  }
}

Python

次のサンプルでは、v1 API を使用します。v2 のサンプルを変更するには、v1v2 に置き換え、/locations/LOCATION をリソース名に追加します。

ほとんどのリソースでは、/PARENT/PARENT_ID の後に /locations/LOCATION をリソース名に追加します。ここで、PARENTorganizationsfolders、または projects です。

検出結果の場合は、/sources/SOURCE_ID の後に /locations/LOCATION をリソース名に追加します。ここで、SOURCE_ID は、検出結果を発行した Security Command Center サービスの ID です。

def get_mute_rule(mute_config_name: str) -> None:
    """
    Retrieves a mute configuration given its resource name.
    Args:
        mute_config_name: Name of the mute config to retrieve.
                          Use any one of the following formats:
                          - organizations/{organization}/muteConfigs/{config_id}
                          - folders/{folder}/muteConfigs/{config_id}
                          - projects/{project}/muteConfigs/{config_id}
    """
    from google.cloud import securitycenter

    client = securitycenter.SecurityCenterClient()

    request = securitycenter.GetMuteConfigRequest()
    request.name = mute_config_name

    mute_config = client.get_mute_config(request)
    print(f"Retrieved the mute rule: {mute_config.name}")

REST API

Security Command Center API で muteConfigs get メソッドを使用して、ミュートルールの構成を返します。リクエストの本文は空です。

ミュートルールの CONFIG_ID を取得するには、まずミュートルールを一覧表示するための API 呼び出しを実行します。レスポンスでミュートルールの構成 ID が返されます。

データ所在地が有効になっていない限り、Security Command Center API の v1 または v2 を使用できます。API v2 は、プレビュー リリースとして利用できます。データ所在地が有効になっている場合、API v2 が唯一の利用可能な API です。

Security Command Center API v1 を使用している場合は、v1 エンドポイントを使用して muteConfigs get を呼び出します。

GET https://securitycenter.googleapis.com/v1/PARENT/PARENT_ID/muteConfigs/CONFIG_ID

Security Command Center API v2 を使用している場合は、v2 エンドポイントを使用して muteConfigs get を呼び出します。

GET https://securitycenter.googleapis.com/v2/PARENT/PARENT_ID/locations/LOCATION/muteConfigs/CONFIG_ID

次のように置き換えます。

  • PARENT: ミュートルールの親リソース(organizationsfolders、または projects
  • PARENT_ID: 組織、フォルダ、またはプロジェクトの ID
  • LOCATION: v2 の場合のみ、ミュートルールが保存される Security Command Center のロケーションを指定します。ロケーション フィールドを省略した場合、デフォルト値は global です。
  • CONFIG_ID: ミュートルールの数値 ID

ミュートルールを更新する

ミュートルールの説明または検出フィルタは、Google Cloud コンソール、gcloud CLI、または Security Command Center API を使用して更新できます。

ID、親組織、フォルダ、プロジェクト、ミュートルールのロケーションは変更できません。これらの値を変更するには、新しいミュートルールを作成する必要があります。

以前に検出結果のミュートを解除しても、その検出結果が Google Cloud コンソールで更新されたミュートルールと一致すると、再びミュートされます。詳しくは、ミュートが解除された検出結果がミュートルールをオーバーライドするをご覧ください。

ミュートルールを更新するサンプルコードについては、ミュートルールの更新をご覧ください。

ミュートルールを更新するには、使用する手順のタブをクリックします。

コンソール

  1. Google Cloud コンソールで、Security Command Center の [設定] ページの [ミュートルール] タブに移動します。

    [ミュートルール] に移動

  2. 変更するミュートルールの親リソースである Google Cloud プロジェクトまたは組織を選択します。プロジェクト セレクタ

  3. 条件データ所在地Security Command Center が有効になっている場合は、プロジェクト セレクタのすぐ下にあるロケーション セレクタを使用して、ミュートルールの Security Command Center のロケーションを選択します。次に例を示します。

    ロケーション セレクタのスクリーンショット

  4. 変更するミュートルールの名前をクリックします。

    適切なプロジェクトまたは組織を選択していない場合は、ミュートルールを変更する権限がないことを示す注が表示されることがあります。

  5. 新しい説明を入力して、[保存] をクリックします。

  6. フィルタを更新または変更します。

    手順については、ミュートルールの作成をご覧ください。

  7. 更新されたフィルタと一致する検出結果を表示するには、[一致する検出をプレビュー] をクリックします。

    新しいクエリに一致する検出結果がテーブルに読み込まれます。

  8. [保存] をクリックします。

gcloud

  1. Google Cloud コンソールで、「Cloud Shell をアクティブにする」をクリックします。

    Cloud Shell をアクティブにする

    Google Cloud コンソールの下部で Cloud Shell セッションが開始し、コマンドライン プロンプトが表示されます。Cloud Shell はシェル環境です。Google Cloud CLI がすでにインストールされており、現在のプロジェクトの値もすでに設定されています。セッションが初期化されるまで数秒かかることがあります。

  2. ミュートルールを更新するには、gcloud scc muteconfigs update コマンドを実行します。

      gcloud scc muteconfigs update MUTE_CONFIG_ID \
        --PARENT=PARENT_ID \
        --location=LOCATION
        --description=RULE_DESCRIPTION \
        --filter=FILTER
    

    次のように置き換えます。

    • MUTE_CONFIG_ID: ミュートルールの ID。
    • PARENT: ミュートルールの親リソース(organizationfolder、または project
    • PARENT_ID: 組織、フォルダ、プロジェクトの ID。
    • LOCATION: データ所在地が有効になっている場合は、ミュートルールが保存される Security Command Center のロケーションを指定します。デフォルト値は global です。

      データ所在地が有効になっていない場合、--location フラグを指定すると、Security Command Center API v2 を使用してミュートルールの構成が更新されます。このフラグの有効な値は global のみです。

    • RULE_DESCRIPTION: ミュートルールの説明(最大: 1,024 文字)

    • FILTER: 検出結果のフィルタを定義する式。

      たとえば、OPEN_FIREWALL の検出結果をミュートするには、フィルタを FILTER="category=\"OPEN_FIREWALL\"" にします。

Go

次のサンプルでは、v1 API を使用します。v2 のサンプルを変更するには、v1v2 に置き換え、/locations/LOCATION をリソース名に追加します。

ほとんどのリソースでは、/PARENT/PARENT_ID の後に /locations/LOCATION をリソース名に追加します。ここで、PARENTorganizationsfolders、または projects です。

検出結果の場合は、/sources/SOURCE_ID の後に /locations/LOCATION をリソース名に追加します。ここで、SOURCE_ID は、検出結果を発行した Security Command Center サービスの ID です。


import (
	"context"
	"fmt"
	"io"

	securitycenter "cloud.google.com/go/securitycenter/apiv1"
	"cloud.google.com/go/securitycenter/apiv1/securitycenterpb"
	"google.golang.org/protobuf/types/known/fieldmaskpb"
)

// updateMuteRule Updates an existing mute configuration.
// The following can be updated in a mute config: description and filter.
func updateMuteRule(w io.Writer, muteConfigName string) error {
	// Specify the name of the mute config to delete.
	// muteConfigName: Use any one of the following formats:
	//                 - organizations/{organization}/muteConfigs/{config_id}
	//                 - folders/{folder}/muteConfigs/{config_id}
	//                 - projects/{project}/muteConfigs/{config_id}
	// muteConfigName := fmt.Sprintf("projects/%s/muteConfigs/%s", "project-id", "mute-config")
	ctx := context.Background()
	client, err := securitycenter.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("securitycenter.NewClient: %w", err)
	}
	defer client.Close()

	updateMuteConfig := &securitycenterpb.MuteConfig{
		Name:        muteConfigName,
		Description: "Updated mute config description",
	}

	req := &securitycenterpb.UpdateMuteConfigRequest{
		MuteConfig: updateMuteConfig,
		// Set the update mask to specify which properties of the mute config should be
		// updated.
		// If empty, all mutable fields will be updated.
		// Make sure that the mask fields match the properties changed in 'updateMuteConfig'.
		// For more info on constructing update mask path, see the proto or:
		// https://cloud.google.com/security-command-center/docs/reference/rest/v1/folders.muteConfigs/patch?hl=en#query-parameters
		UpdateMask: &fieldmaskpb.FieldMask{
			Paths: []string{
				"description",
			},
		},
	}

	response, err := client.UpdateMuteConfig(ctx, req)
	if err != nil {
		return fmt.Errorf("mute rule update failed! %v", err)
	}
	fmt.Fprintf(w, "Mute rule updated %s", response.Name)
	return nil
}

Java

次のサンプルでは、v1 API を使用します。v2 のサンプルを変更するには、v1v2 に置き換え、/locations/LOCATION をリソース名に追加します。

ほとんどのリソースでは、/PARENT/PARENT_ID の後に /locations/LOCATION をリソース名に追加します。ここで、PARENTorganizationsfolders、または projects です。

検出結果の場合は、/sources/SOURCE_ID の後に /locations/LOCATION をリソース名に追加します。ここで、SOURCE_ID は、検出結果を発行した Security Command Center サービスの ID です。


import com.google.cloud.securitycenter.v1.MuteConfig;
import com.google.cloud.securitycenter.v1.SecurityCenterClient;
import com.google.cloud.securitycenter.v1.UpdateMuteConfigRequest;
import com.google.protobuf.FieldMask;
import java.io.IOException;

public class UpdateMuteRule {

  public static void main(String[] args) {
    // TODO: Replace the variables within {}

    // Specify the name of the mute config to delete.
    // muteConfigName: Use any one of the following formats:
    //                 - organizations/{organization}/muteConfigs/{config_id}
    //                 - folders/{folder}/muteConfigs/{config_id}
    //                 - projects/{project}/muteConfigs/{config_id}
    String muteConfigName = "{any-one-of-the-above-formats}";
    updateMuteRule(muteConfigName);
  }

  // Updates an existing mute configuration.
  // The following can be updated in a mute config: description and filter.
  public static void updateMuteRule(String muteConfigName) {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) {

      MuteConfig updateMuteConfig =
          MuteConfig.newBuilder()
              .setName(muteConfigName)
              .setDescription("Updated mute config description")
              .build();

      UpdateMuteConfigRequest updateMuteConfigRequest =
          UpdateMuteConfigRequest.newBuilder()
              .setMuteConfig(updateMuteConfig)
              // Set the update mask to specify which properties of the mute config should be
              // updated.
              // If empty, all mutable fields will be updated.
              // Make sure that the mask fields match the properties changed in 'updateMuteConfig'.
              // For more info on constructing update mask path, see the proto or:
              // https://cloud.google.com/security-command-center/docs/reference/rest/v1/folders.muteConfigs/patch?hl=en#query-parameters
              .setUpdateMask(FieldMask.newBuilder().addPaths("description").build())
              .build();

      MuteConfig response = securityCenterClient.updateMuteConfig(updateMuteConfigRequest);
      System.out.println(response);
    } catch (IOException e) {
      System.out.println("Mute rule update failed! \n Exception: " + e);
    }
  }
}

Python

次のサンプルでは、v1 API を使用します。v2 のサンプルを変更するには、v1v2 に置き換え、/locations/LOCATION をリソース名に追加します。

ほとんどのリソースでは、/PARENT/PARENT_ID の後に /locations/LOCATION をリソース名に追加します。ここで、PARENTorganizationsfolders、または projects です。

検出結果の場合は、/sources/SOURCE_ID の後に /locations/LOCATION をリソース名に追加します。ここで、SOURCE_ID は、検出結果を発行した Security Command Center サービスの ID です。

def update_mute_rule(mute_config_name: str) -> None:
    """
    Updates an existing mute configuration.
    The following can be updated in a mute config: description, and filter/ mute rule.
    Args:
        mute_config_name: Specify the name of the mute config to delete.
                          Use any one of the following formats:
                          - organizations/{organization}/muteConfigs/{config_id}
                          - folders/{folder}/muteConfigs/{config_id}
                          - projects/{project}/muteConfigs/{config_id}
    """
    from google.cloud import securitycenter
    from google.protobuf import field_mask_pb2

    client = securitycenter.SecurityCenterClient()

    update_mute_config = securitycenter.MuteConfig()
    update_mute_config.name = mute_config_name
    update_mute_config.description = "Updated mute config description"

    field_mask = field_mask_pb2.FieldMask(paths=["description"])

    request = securitycenter.UpdateMuteConfigRequest()
    request.mute_config = update_mute_config
    # Set the update mask to specify which properties of the Mute Config should be updated.
    # If empty, all mutable fields will be updated.
    # Make sure that the mask fields match the properties changed in 'update_mute_config'.
    # For more info on constructing update mask path, see the proto or:
    # https://cloud.google.com/security-command-center/docs/reference/rest/v1/folders.muteConfigs/patch?hl=en#query-parameters
    request.update_mask = field_mask

    mute_config = client.update_mute_config(request)
    print(f"Updated mute rule : {mute_config}")

REST API

Security Command Center API で、muteConfigs patch メソッドを使用してミュートルールを更新します。リクエストの本文は MuteConfig のインスタンスです。

ミュートルールの CONFIG_ID を取得するには、API 呼び出しを実行してミュートルールを一覧表示します。レスポンスでミュートルールの構成 ID が返されます。

データ所在地が有効になっていない限り、Security Command Center API の v1 または v2 を使用できます。API v2 は、プレビュー リリースとして利用できます。データ所在地が有効になっている場合、API v2 が唯一の利用可能な API です。

Security Command Center API v1 を使用している場合は、v1 エンドポイントを使用して muteConfigs patch を呼び出します。

PATCH https://securitycenter.googleapis.com/v1/PARENT/PARENT_ID/muteConfigs/CONFIG_ID

  {
    "description": "RULE_DESCRIPTION",
    "filter": "FILTER",
    "type": "STATIC"
  }

Security Command Center API v2 を使用している場合は、v2 エンドポイントを使用して muteConfigs patch を呼び出します。

PATCH https://securitycenter.googleapis.com/v2/PARENT/PARENT_ID/locations/LOCATION/muteConfigs/CONFIG_ID

  {
    "description": "RULE_DESCRIPTION",
    "filter": "FILTER",
  }

次のように置き換えます。

  • PARENT: ミュートルールの親リソース(organizationsfolders、または projects
  • PARENT_ID: 組織、フォルダ、またはプロジェクトの ID
  • LOCATION: v2 の場合のみ、ミュートルールが保存される Security Command Center のロケーションを指定します。ロケーション フィールドを省略した場合、デフォルト値は global です。
  • CONFIG_ID: ミュートルールの数値 ID
  • RULE_DESCRIPTION: ミュートルールの説明(最大: 1,024 文字)
  • FILTER: 検出結果のフィルタを定義する式

    たとえば、OPEN_FIREWALL の検出結果をミュートするには、フィルタを "category=\"OPEN_FIREWALL\"" にします。

フィルタと完全に一致する新しい検出結果は非表示になり、検出結果の mute 属性は MUTED に設定されます。

ミュートルールを更新しても、前のルールでミュートされた検出結果のミュートが自動的に解除されることはありません。手動で検出結果をミュートする必要があります。

ミュートルールを削除する

ミュートルールは、Google Cloud コンソール、gcloud CLI、または Security Command Center API を使用して削除できます。

ミュートルールを削除する前に、次の点にご注意ください。

  • 削除したミュートルールは復元できません。
  • ミュートルールを削除しても、ミュートされている検出結果のミュートが自動的に解除されることはありません。手動またはプログラムで検出結果のミュートを解除する必要があります。
  • 削除されたミュートルールのフィルタと一致する将来の検出結果はミュートの対象となりません。

ミュートルールを削除するサンプルコードについては、ミュートルールを削除するをご覧ください。

ミュートルールを削除するには、使用する手順のタブをクリックします。

コンソール

  1. Google Cloud コンソールで、Security Command Center の [設定] ページの [ミュートルール] タブに移動します。

    [ミュートルール] に移動

  2. 必要に応じて、Google Cloud プロジェクトまたは組織を選択します。

    プロジェクト セレクタ

  3. Security Command Center でデータ所在地が有効になっている場合は、プロジェクト セレクタのすぐ下にあるロケーション セレクタを使用して、ミュートルールが保存されている Security Command Center のロケーションを選択します。次に例を示します。

    ロケーション セレクタのスクリーンショット

  4. 削除するミュートルールの名前をクリックします。

  5. [削除] をクリックします。

  6. ダイアログを読み、問題がなければ [削除] をクリックします。

gcloud

  1. Google Cloud コンソールで、「Cloud Shell をアクティブにする」をクリックします。

    Cloud Shell をアクティブにする

    Google Cloud コンソールの下部で Cloud Shell セッションが開始し、コマンドライン プロンプトが表示されます。Cloud Shell はシェル環境です。Google Cloud CLI がすでにインストールされており、現在のプロジェクトの値もすでに設定されています。セッションが初期化されるまで数秒かかることがあります。

  2. ミュートルールを削除するには、gcloud scc muteconfigs delete コマンドを実行します。

    gcloud scc muteconfigs delete MUTE_CONFIG_ID \
     --PARENT=PARENT_ID --location=LOCATION
    

    次のように置き換えます。

    • MUTE_CONFIG_ID: ミュート構成の ID
    • PARENT: ミュートルールの親リソース(organizationfolder、または project
    • PARENT_ID: 組織、フォルダ、またはプロジェクトの ID
    • LOCATION: データ所在地が有効になっている場合は、ミュートルールの構成を保存する Security Command Center のロケーションを指定します。デフォルト値は global です。

      データ所在地が有効でない場合、--location フラグを指定すると、Security Command Center API v2 を使用してミュートルールが削除されます。このフラグの有効な値は global のみです。

  3. ミュートルールを削除するリクエストを確定します。

Go

次のサンプルでは、v1 API を使用します。v2 のサンプルを変更するには、v1v2 に置き換え、/locations/LOCATION をリソース名に追加します。

ほとんどのリソースでは、/PARENT/PARENT_ID の後に /locations/LOCATION をリソース名に追加します。ここで、PARENTorganizationsfolders、または projects です。

検出結果の場合は、/sources/SOURCE_ID の後に /locations/LOCATION をリソース名に追加します。ここで、SOURCE_ID は、検出結果を発行した Security Command Center サービスの ID です。


import (
	"context"
	"fmt"
	"io"

	securitycenter "cloud.google.com/go/securitycenter/apiv1"
	"cloud.google.com/go/securitycenter/apiv1/securitycenterpb"
)

// deleteMuteRule deletes a mute configuration given its resource name.
// Note: Previously muted findings are not affected when a mute config is deleted.
func deleteMuteRule(w io.Writer, parent string, muteConfigId string) error {
	// parent: Use any one of the following options:
	//             - organizations/{organization_id}
	//             - folders/{folder_id}
	//             - projects/{project_id}
	// parent := fmt.Sprintf("projects/%s", "your-google-cloud-project-id")
	//
	// muteConfigId: Specify the name of the mute config to delete.
	// muteConfigId := "mute-config-id"
	ctx := context.Background()
	client, err := securitycenter.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("securitycenter.NewClient: %w", err)
	}
	defer client.Close()

	req := &securitycenterpb.DeleteMuteConfigRequest{
		Name: fmt.Sprintf("%s/muteConfigs/%s", parent, muteConfigId),
	}

	if err := client.DeleteMuteConfig(ctx, req); err != nil {
		return fmt.Errorf("failed to delete Muteconfig: %w", err)
	}
	fmt.Fprintf(w, "Mute rule deleted successfully: %s", muteConfigId)
	return nil
}

Java

次のサンプルでは、v1 API を使用します。v2 のサンプルを変更するには、v1v2 に置き換え、/locations/LOCATION をリソース名に追加します。

ほとんどのリソースでは、/PARENT/PARENT_ID の後に /locations/LOCATION をリソース名に追加します。ここで、PARENTorganizationsfolders、または projects です。

検出結果の場合は、/sources/SOURCE_ID の後に /locations/LOCATION をリソース名に追加します。ここで、SOURCE_ID は、検出結果を発行した Security Command Center サービスの ID です。


import com.google.cloud.securitycenter.v1.MuteConfigName;
import com.google.cloud.securitycenter.v1.SecurityCenterClient;
import java.io.IOException;

public class DeleteMuteRule {

  public static void main(String[] args) {
    // TODO(Developer): Replace the following variables
    // parentPath: Use any one of the following options:
    //             - organizations/{organization_id}
    //             - folders/{folder_id}
    //             - projects/{project_id}
    String parentPath = String.format("projects/%s", "your-google-cloud-project-id");

    // muteConfigId: Specify the name of the mute config to delete.
    String muteConfigId = "mute-config-id";

    deleteMuteRule(parentPath, muteConfigId);
  }

  // Deletes a mute configuration given its resource name.
  // Note: Previously muted findings are not affected when a mute config is deleted.
  public static void deleteMuteRule(String projectId, String muteConfigId) {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (SecurityCenterClient client = SecurityCenterClient.create()) {
      // Use appropriate MuteConfigName methods depending on the type of parent.
      // org -> MuteConfigName.ofOrganizationMuteConfigName()
      // folder -> MuteConfigName.ofFolderMuteConfigName()
      // project -> MuteConfigName.ofProjectMuteConfigName)
      client.deleteMuteConfig(MuteConfigName.ofProjectMuteConfigName(projectId, muteConfigId));

      System.out.println("Mute rule deleted successfully: " + muteConfigId);
    } catch (IOException e) {
      System.out.println("Mute rule deletion failed! \n Exception: " + e);
    }
  }
}

Python

次のサンプルでは、v1 API を使用します。v2 のサンプルを変更するには、v1v2 に置き換え、/locations/LOCATION をリソース名に追加します。

ほとんどのリソースでは、/PARENT/PARENT_ID の後に /locations/LOCATION をリソース名に追加します。ここで、PARENTorganizationsfolders、または projects です。

検出結果の場合は、/sources/SOURCE_ID の後に /locations/LOCATION をリソース名に追加します。ここで、SOURCE_ID は、検出結果を発行した Security Command Center サービスの ID です。

def delete_mute_rule(mute_config_name: str) -> None:
    """
    Deletes a mute configuration given its resource name.
    Note: Previously muted findings are not affected when a mute config is deleted.
    Args:
        mute_config_name: Specify the name of the mute config to delete.
                          Use any one of the following formats:
                          - organizations/{organization}/muteConfigs/{config_id}
                          - folders/{folder}/muteConfigs/{config_id} or
                          - projects/{project}/muteConfigs/{config_id}
    """
    from google.cloud import securitycenter

    client = securitycenter.SecurityCenterClient()

    request = securitycenter.DeleteMuteConfigRequest()
    request.name = mute_config_name

    client.delete_mute_config(request)
    print(f"Mute rule deleted successfully: {mute_config_name}")

REST API

Security Command Center API で、muteConfigs delete メソッドを使用してミュートルールを削除します。リクエストの本文は空です。

ミュートルールの CONFIG_ID を取得するには、ミュートルールを一覧表示するための API 呼び出しを実行します。レスポンスでミュートルールの構成 ID が返されます。

データ所在地が有効になっていない限り、Security Command Center API の v1 または v2 を使用できます。API v2 は、プレビュー リリースとして利用できます。データ所在地が有効になっている場合、API v2 が唯一の利用可能な API です。

Security Command Center API v1 を使用している場合は、v1 エンドポイントを使用して muteConfigs delete を呼び出します。

DELETE https://securitycenter.googleapis.com/v1/PARENT/PARENT_ID/muteConfigs/CONFIG_ID

Security Command Center API v2 を使用している場合は、v2 エンドポイントを使用して muteConfigs delete を呼び出します。

DELETE https://securitycenter.googleapis.com/v2/PARENT/PARENT_ID/locations/LOCATION/muteConfigs/CONFIG_ID

次のように置き換えます。

  • PARENT: ミュートルールの親リソース(organizationsfolders、または projects
  • PARENT_ID: 組織、フォルダ、またはプロジェクトの ID
  • LOCATION: v2 の場合のみ、ミュートルールが保存される Security Command Center のロケーションを指定します。ロケーション フィールドを省略した場合、デフォルト値は global です。
  • CONFIG_ID: ミュートルールの数値 ID

次のステップ

検出通知のフィルタリングの詳細を確認する。

使用できるフィルタの例を確認する。