忽略個別發現項目

本文說明如何在 Security Command Center 中,靜態略過個別發現項目、取消略過,或大量略過發現項目。

必要的角色

如要取得將調查結果設為靜音或取消靜音所需的權限,請要求管理員在組織、資料夾或專案中,授予您下列 IAM 角色:

如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和組織的存取權」。

您或許也能透過自訂角色或其他預先定義的角色,取得必要權限。

忽略個別發現項目

如要靜態將個別發現項目設為靜音,可以使用Google Cloud 控制台、gcloud CLI 或 Security Command Center API。

靜態忽略發現項目不會影響其有效狀態。如果忽略有效發現項目,state 屬性會維持不變:state="ACTIVE"。發現項目會隱藏,但仍處於有效狀態,直到解決潛在的安全漏洞、錯誤配置或威脅為止。此外,靜態忽略發現項目會覆寫套用至該項目的任何動態忽略規則。

將有害組合發現項目設為靜音後,系統會關閉對應的有害組合案件。

如要忽略所有符合指定條件的未來發現項目,請參閱「管理忽略規則」。

如需將發現項目設為靜音的程式碼範例,請參閱「將發現項目設為靜音」。

如要靜態隱藏個別發現項目,請按一下要使用的程序分頁:

控制台

  1. 前往 Google Cloud 控制台的 Security Command Center「發現項目」頁面。

    前往「發現項目」

  2. 視需要選取 Google Cloud 專案或機構。
  3. 如果「發現項目查詢結果」面板未顯示要忽略的發現項目,請在「快速篩選器」面板的「類別」部分選取該發現項目的類別。
  4. 選取要忽略的發現項目。您可以選取一或多項發現。
  5. 在「發現項目查詢結果」動作列中,按一下「忽略選項」,然後選取「套用忽略覆寫」

    所選發現項目的 mute 屬性會設為 MUTED,且該發現項目會從「發現項目查詢結果」面板中移除。或者,您也可以透過詳細資料面板將發現項目設為忽略:

  6. 在「發現項目」頁面的「發現項目查詢結果」面板中,點選「類別」欄中的個別發現項目名稱。發現項目的詳細資料面板隨即開啟。

  7. 按一下「採取行動」

  8. 在「採取行動」選單中,選取「套用靜音覆寫」

    如果改為選取「忽略類似的發現項目」,系統會開啟「建立忽略規則」頁面,您可以在這裡為相同類型的發現項目建立忽略規則,或是為包含相同 Indicator 屬性的發現項目建立忽略規則。

gcloud

  1. 在 Google Cloud 控制台中啟用 Cloud Shell。

    啟用 Cloud Shell

    控制台底部會開啟 Cloud Shell 工作階段,並顯示指令列提示。 Google Cloud 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 位置;如果已啟用資料落地功能,請使用 eusaus;否則請使用值 global

    • SOURCE_ID:來源 ID

      如需擷取來源 ID 的操作說明,請參閱「取得來源 ID」。

Go

import (
	"context"
	"fmt"
	"io"

	securitycenter "cloud.google.com/go/securitycenter/apiv2"
	"cloud.google.com/go/securitycenter/apiv2/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


import com.google.cloud.securitycenter.v2.Finding;
import com.google.cloud.securitycenter.v2.Finding.Mute;
import com.google.cloud.securitycenter.v2.SecurityCenterClient;
import com.google.cloud.securitycenter.v2.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/{org_id}/sources/{source_id}/locations/{location}/finding/{finding_id}
    //  - folders/{folder_id}/sources/{source_id}/locations/{location}/finding/{finding_id}
    //  - projects/{project_id}/sources/{source_id}/locations/{location}/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.
    try (SecurityCenterClient client = SecurityCenterClient.create()) {

      SetMuteRequest setMuteRequest =
          SetMuteRequest.newBuilder()
              // Relative path for the finding.
              .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

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_v2

    client = securitycenter_v2.SecurityCenterClient()

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

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

REST

在 Security Command Center API 中,使用 findings.setMute 方法將發現項目設為靜音。要求主體是列舉,表示產生的靜音狀態:

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

{
  "mute": "MUTED"
}

更改下列內容:

  • PARENT:父項資源 (organizationsfoldersprojects)。
  • PARENT_ID:父項機構、資料夾或專案的 ID。
  • LOCATION: 要將調查結果設為靜音或取消靜音的Security Command Center 位置;如果已啟用資料落地功能,請使用 eusaus;否則請使用值 global
  • SOURCE_ID:來源的數值 ID。

    如需擷取來源 ID 的操作說明,請參閱「取得來源 ID」。

  • FINDING_ID:要忽略的發現項目 ID。

    如要擷取發現項目 ID,請使用 Security Command Center API 列出發現項目。發現項目 ID 是 canonicalName 屬性的最後一部分,例如 projects/123456789012/sources/1234567890123456789/findings/5ee30aa342e799e4e1700826de053aa9

將發現項目設為靜音後,系統會將其 mute 屬性設為 MUTED

取消忽略個別發現項目

您可以使用 Google Cloud 控制台、gcloud CLI 或 Security Command Center API,靜態取消個別發現項目的靜音。

如果忽略規則過於寬鬆,或規則太過複雜而無法修改,導致您認為重要的發現項目遭到隱藏,這時取消忽略發現項目就很有用。

只有在手動忽略發現項目時,系統才會再次忽略取消忽略的發現項目。 使用 gcloud CLI 或 Security Command Center API 建立的忽略規則,不會影響使用者取消忽略的發現項目。

如需取消將發現項目設為靜音的程式碼範例,請參閱「取消將發現項目設為靜音」。

控制台

如要使用 Google Cloud 控制台取消個別發現項目的靜音,請按一下服務層級的分頁:

  1. 前往 Google Cloud 控制台的 Security Command Center「發現項目」頁面。

    前往「發現項目」

  2. 視需要選取 Google Cloud 專案或機構。 「發現項目」頁面隨即會開啟,且「查詢預覽」部分會顯示預設查詢。預設查詢會濾除已忽略的發現項目,因此您必須先編輯查詢,已忽略的發現項目才會顯示在「發現項目查詢結果」面板中。
  3. 在「查詢預覽」部分右側,按一下「編輯查詢」,開啟「查詢編輯器」
  4. 在「查詢編輯器」欄位中,將現有的靜音陳述式替換為下列內容:
    mute="MUTED"
  5. 按一下 [套用]。「發現項目查詢結果」面板中的發現項目會更新,只顯示已靜音的發現項目。
  6. 如有需要,請篩除其他已靜音的發現項目。舉例來說,在「快速篩選器」面板的「類別」下方,選取要取消靜音的發現項目名稱,即可篩除所有其他類別的發現項目。
  7. 選取要取消靜音的發現項目。您可以選取一或多項發現。
  8. 在「發現項目查詢結果」動作列中,按一下「忽略選項」,然後選取「套用取消忽略覆寫」。所選發現項目的 mute 屬性會設為 UNMUTED,且該發現項目會從「發現項目查詢結果」面板中移除。或者,您也可以透過詳細資料面板取消忽略發現項目:
  9. 在「發現項目」頁面的「發現項目查詢結果」面板中,點選「類別」欄中的個別發現項目名稱。發現項目的詳細資料面板隨即開啟。
  10. 按一下「採取行動」
  11. 在「採取行動」選單中,選取「套用取消靜音覆寫」

gcloud

  1. 在 Google Cloud 控制台中啟用 Cloud Shell。

    啟用 Cloud Shell

    控制台底部會開啟 Cloud Shell 工作階段,並顯示指令列提示。 Google Cloud 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 位置;如果已啟用資料落地功能,請使用 eusaus;否則請使用值 global

    • SOURCE_ID:來源 ID

      如需擷取來源 ID 的操作說明,請參閱「取得來源 ID」。

Go


import (
	"context"
	"fmt"
	"io"

	securitycenter "cloud.google.com/go/securitycenter/apiv2"
	"cloud.google.com/go/securitycenter/apiv2/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


import com.google.cloud.securitycenter.v2.Finding;
import com.google.cloud.securitycenter.v2.Finding.Mute;
import com.google.cloud.securitycenter.v2.SecurityCenterClient;
import com.google.cloud.securitycenter.v2.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/{org_id}/sources/{source_id}/locations/{location}/finding/{finding_id}
    //  - folders/{folder_id}/sources/{source_id}/locations/{location}/finding/{finding_id}
    //  - projects/{project_id}/sources/{source_id}/locations/{location}/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.
    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

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_v2

    client = securitycenter_v2.SecurityCenterClient()

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

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

REST

在 Security Command Center API 中,使用 findings.setMute 方法取消將發現項目設為靜音。要求主體是列舉,表示產生的靜音狀態:

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

{
  "mute": "UNMUTED"
}

更改下列內容:

  • PARENT:上層資源 (organizationsfoldersprojects)
  • PARENT_ID:父項機構、資料夾或專案的 ID
  • LOCATION: 要將調查結果設為靜音或取消靜音的Security Command Center 位置;如果已啟用資料落地功能,請使用 eusaus;否則請使用值 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。

從發現項目中移除靜音狀態覆寫前,請先瞭解下列事項:

  • 如果發現項目已靜態忽略或取消忽略,就會覆寫忽略狀態。您可以手動或使用靜態忽略規則,對任何發現項目套用忽略狀態覆寫。
  • 忽略狀態覆寫會無限期套用至發現項目,且優先順序高於任何相符的忽略規則。
  • 從發現項目中移除忽略狀態覆寫後,系統會重設發現項目的忽略狀態,以便靜態或動態忽略規則處理。
  • 從發現項目移除忽略狀態覆寫,與取消忽略發現項目不同。取消忽略發現項目 (套用取消忽略覆寫) 後,您必須手動移除忽略狀態覆寫,忽略規則才能忽略該發現項目。

如要從個別發現項目移除靜音覆寫,請按照下列步驟操作:

控制台

  1. 前往 Google Cloud 控制台的 Security Command Center「發現項目」頁面。

    前往「發現項目」

  2. 選取 Google Cloud 專案或機構。
  3. 在「查詢預覽」部分右側,按一下「編輯查詢」,開啟「查詢編輯器」
  4. 在「查詢編輯器」欄位中,將現有的靜音陳述式替換為下列內容:
    mute="MUTED" OR mute="UNMUTED"
  5. 按一下 [套用]。「發現項目查詢結果」面板中的發現項目會更新,納入靜態忽略和取消忽略的發現項目。
  6. 如有需要,請篩除其他發現。舉例來說,在「快速篩選器」面板的「類別」下方,選取要重設的發現項目名稱,篩除所有其他類別的發現項目。
  7. 選取要重設的發現項目。您可以選取一或多項發現。
  8. 在「發現項目查詢結果」動作列中,按一下「忽略選項」,然後選取「移除忽略覆寫」。 所選發現項目的 mute 屬性會設為 UNDEFINED,且該發現項目會從「發現項目查詢結果」面板中移除。或者,您也可以透過詳細資料面板取消忽略發現項目:
  9. 在「發現項目」頁面的「發現項目查詢結果」面板中,點選「類別」欄中的個別發現項目名稱。發現項目的詳細資料面板隨即開啟。
  10. 按一下「採取行動」
  11. 在「採取行動」選單中,選取「移除靜音覆寫值」

gcloud

  1. 在 Google Cloud 控制台中啟用 Cloud Shell。

    啟用 Cloud Shell

    控制台底部會開啟 Cloud Shell 工作階段,並顯示指令列提示。 Google Cloud Cloud Shell 是已安裝 Google Cloud CLI 的殼層環境,並已針對您目前的專案設定好相關值。工作階段可能要幾秒鐘的時間才能初始化。

  2. 如要將發現項目的靜音狀態設為 UNDEFINED,請在 gcloud CLI 中使用 set-mute 指令:

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

    更改下列內容:

    • 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 位置;如果已啟用資料落地功能,請使用 eusaus;否則請使用值 global

    • SOURCE_ID:來源 ID

      如需擷取來源 ID 的操作說明,請參閱「取得來源 ID」。

REST

在 Security Command Center API 中,使用 findings.setMute 方法重設發現項目的靜音狀態。要求主體是列舉,表示產生的靜音狀態:

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

{
  "mute": "UNDEFINED"
}

更改下列內容:

  • PARENT:上層資源 (organizationsfoldersprojects)
  • PARENT_ID:父項機構、資料夾或專案的 ID
  • LOCATION: 要將調查結果設為靜音或取消靜音的Security Command Center 位置;如果已啟用資料落地功能,請使用 eusaus;否則請使用值 global
  • SOURCE_ID:來源的數值 ID

Java


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

public class SetMuteUndefinedFinding {

  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}";
    setMuteUndefined(findingPath);
  }

  // Reset mute state of an individual finding.
  // If a finding is already reset, resetting it again has no effect.
  // Various mute states are: MUTE_UNSPECIFIED/MUTE/UNMUTE/UNDEFINED.
  public static Finding setMuteUndefined(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.
    try (SecurityCenterClient client = SecurityCenterClient.create()) {

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

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

忽略或重設多項現有發現項目

如要對多個現有發現項目執行大量靜音作業,可以使用 gcloud scc findings bulk-mute gcloud CLI 指令,或 Security Command Center API 的 bulkMute 方法:

  • 忽略多個現有發現項目。大量忽略現有發現項目時,系統會靜態忽略這些項目,並覆寫適用於該發現項目的任何動態忽略規則。如要忽略日後類似的發現項目,請建立忽略規則

  • 移除多個現有發現項目的忽略狀態覆寫。移除發現項目的忽略狀態覆寫後,忽略狀態會從 MUTED (靜態忽略) 或 UNMUTED (靜態取消忽略) 重設為 UNDEFINED。 如果您從靜態忽略規則遷移至動態忽略規則,這項功能就非常實用。

定義發現項目篩選器,指定要忽略的發現項目。大量靜音篩選器不支援所有發現項目屬性。 如需不支援的屬性清單,請參閱「靜音規則不支援的發現項目屬性」。

如果已為 Security Command Center 啟用資料落地設定,大量靜音作業的範圍會限制在執行作業的 Security Command Center 位置。

如需一次將大量發現項目設為忽略的程式碼範例,請參閱「一次將大量發現項目設為忽略」。

如要大量靜音或重設發現項目,請按一下要使用的程序分頁:

控制台

在 Google Cloud 控制台中,您只能建立忽略規則,大量忽略調查結果。在Google Cloud 控制台中建立忽略規則,即可忽略現有和日後的發現項目。

gcloud

  1. 在 Google Cloud 控制台中啟用 Cloud Shell。

    啟用 Cloud Shell

    控制台底部會開啟 Cloud Shell 工作階段,並顯示指令列提示。 Google Cloud Cloud Shell 是已安裝 Google Cloud CLI 的殼層環境,並已針對您目前的專案設定好相關值。工作階段可能要幾秒鐘的時間才能初始化。

  2. 如要大量忽略或重設多個發現項目,請執行 gcloud scc findings bulk-mute 指令:

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

    更改下列內容:

    • PARENT:資源階層結構中的範圍,忽略規則適用於 organizationfolderproject
    • PARENT_ID:父項機構、資料夾或專案的數值 ID,或是父項專案的英數字元 ID。
    • LOCATION:要將調查結果設為靜音或取消靜音的Security Command Center 位置;如果已啟用資料落地功能,請使用 eusaus;否則請使用值 global
    • FILTER:您定義的運算式,用於篩選結果。

      舉例來說,如要忽略 internal-test 專案中所有現有的低嚴重程度 OPEN_FIREWALLPUBLIC_IP_ADDRESS 發現項目,篩選器可以是 "category=\"OPEN_FIREWALL\" OR category=\"PUBLIC_IP_ADDRESS\" AND severity=\"LOW\" AND resource.projectDisplayName=\"internal-test\""

    • MUTE_STATE:表示發現項目是否靜態忽略的值。有效值為 MUTEDUNDEFINED。預設值為 MUTED。只有在重設多個現有發現項目的靜音狀態時,才將這個值設為 UNDEFINED

REST

在 Security Command Center API 中,使用 findings.bulkMute 方法,即可忽略或重設多個現有發現項目的忽略狀態。要求主體包含用於篩選結果的運算式:

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

{
  "filter": "FILTER",
  "muteState": "MUTE_STATE"
}

更改下列內容:

  • PARENT:父項資源 (organizationsfoldersprojects)。
  • PARENT_ID:父項機構、資料夾或專案的 ID。
  • LOCATION:要將調查結果設為靜音或取消靜音的Security Command Center 位置;如果已啟用資料落地功能,請使用 eusaus;否則請使用值 global
  • FILTER:您定義的運算式,用於篩選結果。

    舉例來說,如要忽略 internal-test 專案中所有現有的低嚴重程度 OPEN_FIREWALLPUBLIC_IP_ADDRESS 發現項目,篩選器可以是 "category=\"OPEN_FIREWALL\" OR category=\"PUBLIC_IP_ADDRESS\" AND severity=\"LOW\" AND resource.projectDisplayName=\"internal-test\""

  • MUTE_STATE:表示發現項目是否已忽略的值。有效值為 MUTEDUNDEFINED。預設值為 MUTED。只有在重設多個現有發現項目的忽略狀態時,才將這個值設為 UNDEFINED

系統會隱藏所選資源中與篩選條件完全相符的所有現有發現項目。發現結果的 mute 屬性設為 MUTED

忽略發現項目不會變更其狀態。如果將有效發現項目設為忽略,系統會隱藏這些項目,但仍會保持有效,直到解決潛在的安全漏洞、錯誤配置或威脅為止。

在 Google Cloud 控制台中查看已忽略的發現項目

如要查看已靜音的發現項目,請在 Google Cloud 控制台中編輯發現項目查詢,選取包含屬性值 mute="MUTED" 的發現項目。

舉例來說,下列發現項目查詢只會顯示已設為忽略的尚未解決發現項目:

state="ACTIVE"
AND mute="MUTED"

如要顯示所有尚未解決的發現項目 (包括已設為忽略和未設為忽略的項目),請完全省略查詢中的 mute 屬性:

state="ACTIVE"

根據預設, Google Cloud 控制台中的發現項目查詢只會顯示未設為忽略的發現項目。

查看依忽略規則類型忽略的發現項目

以下各節說明如何依忽略規則類型查詢有效發現項目。

如要進一步瞭解如何列出特定調查結果,請參閱「篩選調查結果」。

查詢結果中的發現項目已由靜態忽略規則忽略

如要顯示在特定時間後,遭靜態忽略規則忽略的未解決問題,請使用下列查詢並檢查 muteInitiator 屬性,判斷問題是否遭靜態忽略規則忽略。

state="ACTIVE" AND
muteInfo.staticMute.applyTime>=TIMESTAMP AND
muteInfo.staticMute.state="MUTED"

TIMESTAMP 替換為日期和時間字串,指出要查詢時間範圍的開頭。如要瞭解時間格式,請參閱 gcloud topic datetimes

查詢動態忽略規則忽略的發現項目

如要顯示在指定時間後,遭動態忽略規則忽略的有效發現項目,請使用下列查詢:

state="ACTIVE" AND
muteUpdateTime>=TIMESTAMP AND
contains(muteInfo.dynamicMuteRecords, muteConfig="PARENT_ID/muteConfigs/CONFIG_ID")

更改下列內容:

  • TIMESTAMP:日期和時間字串,指出要查詢的時間範圍開頭。如要瞭解時間格式,請參閱 gcloud topic datetimes
  • PARENT_ID:父項機構、資料夾或專案的 ID,格式為 organizations/123folders/456projects/789
  • CONFIG_ID:忽略規則的名稱。ID 必須使用英數字元和連字號,且長度介於 1 至 63 個字元之間。

如要進一步瞭解如何編輯發現項目查詢,請參閱「在資訊主頁中建立或編輯發現項目查詢」。

停止通知和匯出已忽略的發現項目

如果您啟用發現項目通知,系統仍會將符合通知篩選條件的新發現項目或已更新的已靜音發現項目匯出至 Pub/Sub。

如要停止匯出及接收已靜音的發現項目通知,請使用 mute 屬性,在 NotificationConfig 篩選器中排除已靜音的發現項目。舉例來說,下列篩選器只會針對未設為忽略的有效發現項目,或未設定忽略屬性的發現項目傳送通知:

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