略過 Security Command Center 中的發現項目

本頁說明如何忽略發現項目,減少 Security Command Center 中收到的發現項目量。

將發現事項設為靜音後,系統會從Google Cloud 控制台的預設發現事項檢視畫面中隱藏該事項。您可以手動或以程式輔助方式忽略發現項目,並建立篩選器,根據您指定的條件自動忽略現有和日後的發現項目。

Security Command Center 偵測服務會對您的部署作業進行廣泛的安全評估,但您可能會發現某些發現項目不適合或與貴機構或專案無關。 Google Cloud 如果發現大量問題,安全分析師可能難以有效找出並修正最重大的風險。將發現項目設為靜音,可節省您審查或回應資安發現項目的時間,這些發現項目與隔離的資產或可接受的業務參數有關。

停用偵測器相比,將發現事項設為靜音有下列優點:

  • 您可以建立自訂篩選器,微調要靜音的發現項目。
  • 您可以暫時或無限期忽略發現項目。
  • 設為忽略的發現項目不會停止掃描基礎資產。系統仍會產生調查結果,但會隱藏這些結果,直到您決定查看為止。

權限

如要將調查結果設為靜音,您必須在機構資料夾專案層級具備下列其中一個 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 角色,請參閱存取權控管

建立及管理忽略規則

忽略規則是 Security Command Center 設定,會使用您建立的篩選條件,根據您指定的條件自動忽略日後和現有的發現項目。您可以建立篩選器,並套用靜態動態忽略規則。

靜態忽略規則會永久忽略日後的發現項目。動態忽略規則會暫時忽略未來和現有的發現項目,直到指定日期為止,或無限期忽略,直到發現項目不再符合設定為止。

忽略規則類型

Security Command Center 支援靜態和動態忽略規則設定。雖然您可以同時使用靜態和動態忽略規則,但我們不建議這麼做。如果靜態忽略規則和動態忽略規則套用至相同發現項目,系統會優先採用靜態忽略規則。因此,動態忽略規則無法正常運作,管理發現項目時可能會造成混淆。因此,建議您只使用一種靜音規則類型。

除非您已使用靜態靜音規則,否則建議只使用動態靜音規則,因為這類規則更具彈性。

下表大致比較了這兩種靜音規則類型。詳情請參閱「靜態忽略規則」和「動態忽略規則」。

靜態忽略規則 動態忽略規則
無限期根據調查結果採取行動。 可暫時根據發現結果採取行動 (設有到期時間),或無限期採取行動 (未設定到期時間)。
不會套用至現有發現項目。 適用於現有和新發現。
優先於動態忽略規則。 優先順序較低,如果發現項目同時符合這兩種規則,系統會以靜態靜音規則為準。

靜態忽略規則

  • 靜態忽略規則會無限期生效。如果發現項目符合靜態停用設定,Security Command Center 會自動將該項目的 mute 屬性設為 MUTED,直到您手動變更為止。
  • 除非使用 Google Cloud 控制台建立靜態忽略規則,否則這類規則不會影響現有發現項目。如果使用控制台建立規則,系統會追溯套用規則,忽略現有發現項目。否則,這些規則只會套用至規則定義後新建立或更新的發現項目。如要使用相同篩選器大量停用現有發現項目,請勿使用 Google Cloud 控制台,並一併停用類似的現有發現項目。
  • 靜態忽略規則的優先順序高於動態忽略規則。因此,即使新發現事項也符合定義的動態忽略規則,只要符合定義的靜態忽略規則,就會視為已忽略。

動態忽略規則

  • 動態忽略規則可暫時忽略發現項目 (設有到期時間),也可以無限期忽略 (未設定到期時間)。如果現有或新建立的發現項目符合動態靜音設定,Security Command Center 會自動將發現項目的 mute 屬性設為 MUTED,直到指定的到期日為止,或直到發現項目或設定本身發生變更為止。動態忽略規則到期後,Security Command Center 會從發現項目中移除該規則。如果發現項目不符合任何其他動態忽略規則,系統會自動將 mute 屬性重設為 UNDEFINED
  • 動態忽略規則會自動套用至符合設定的現有發現項目,以及新建立或更新的發現項目。
  • 動態忽略規則的優先順序較低,如果發現項目同時符合兩種規則,系統會以靜態忽略規則為準。

建議只使用動態靜音規則。動態忽略規則可暫時忽略發現項目,並自動取消忽略,因此比靜態忽略規則更具彈性。

如果您使用靜態忽略規則來減少手動審查的發現項目數量,並想遷移至動態忽略規則,請參閱「從靜態忽略規則遷移至動態忽略規則」。

忽略規則的範圍

建立篩選器時,請考量忽略規則的範圍。

舉例來說,如果篩選器是為了將 Project A 中的結果設為靜音而編寫,但篩選器本身是在 Project B 下建立,則篩選器可能不會比對任何結果。

同樣地,如果啟用資料落地設定,靜音規則的適用範圍會僅限於建立該規則的 Security Command Center 位置。舉例來說,如果您在「美國」(us) 位置建立忽略規則,該規則就不會忽略儲存在「歐盟」 (eu) 位置的調查結果。

如要進一步瞭解如何建立篩選器,請參閱「篩選通知」一文。

忽略規則限制

忽略規則不支援所有發現項目屬性。如需靜音規則不支援的屬性清單,請參閱「靜音規則不支援的發現項目屬性」。

您可以根據 IAM 角色的範圍,建立、查看、更新及刪除靜音規則。使用機構層級角色時,您會看到機構內所有資料夾和專案的靜音規則。如果您擁有資料夾層級的角色,就能存取及管理特定資料夾的靜音規則,以及這些資料夾中的所有子資料夾和專案。專案層級角色可讓您管理特定專案中的靜音規則。

Security Command Center Premium 支援在機構、資料夾和專案層級授予角色。Security Command Center Standard 僅支援在機構層級授予角色。詳情請參閱存取權控管一文。

資料落地和忽略規則

如果啟用資料落地,定義靜音規則的設定 (即 muteConfig 資源) 會受到資料落地控制項的規範,並儲存在您選取的 Security Command Center 位置

如要將忽略規則套用至 Security Command Center 位置的發現項目,您必須在與發現項目相同的位置建立忽略規則。

由於忽略規則中使用的篩選器可能含有受落地控制項限制的資料,因此請務必在建立規則前指定正確的位置。Security Command Center 不會限制您建立靜音規則或串流匯出項目的位置。

忽略規則只會儲存至建立時使用的位置,無法在其他位置查看或編輯。

建立靜音規則後,就無法變更位置。 如要變更位置,請刪除靜音規則,然後在新位置重新建立。

如要瞭解啟用資料落地功能後如何使用 Security Command Center,請參閱「Security Command Center 區域端點」。

建立忽略規則

貴機構最多可以建立 1,000 條靜音規則。

建議您在忽略規則設定中只使用動態忽略規則,因為這類規則比靜態忽略規則更具彈性。如要比較忽略規則類型,請參閱「忽略規則類型」。

如要建立忽略規則,請按一下要使用程序的對應分頁:

控制台

如要使用 Google Cloud 控制台建立靜音規則,請按一下服務層級的分頁:

標準或進階

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

    前往「發現項目」

  2. 視需要選取 Google Cloud 專案或機構。

  3. 按一下「忽略選項」,然後選取「管理忽略規則」

  4. 按一下「建立忽略規則」

  5. 輸入忽略規則 ID。必須提供這個值。

  6. 輸入忽略規則說明,提供忽略結果的背景資訊。這個值為選填,但建議填寫。

  7. 檢查「父項資源」值,確認忽略規則的範圍。

  8. 如要建立靜態忽略規則,或建立沒有到期日的動態忽略規則,請繼續下一個步驟。如要建立動態靜音規則,暫時將調查結果設為靜音,請完成下列步驟:

    1. 勾選「暫時忽略相符的發現項目」核取方塊。
    2. 選取或輸入動態靜音規則的到期日。這個值表示規則忽略相符發現項目的時間長度。
  9. 在「發現項目查詢」欄位中,按一下「新增篩選器」,建立查詢陳述式。或者,您也可以手動輸入查詢陳述式。

    在「選取篩選器」對話方塊中,您可以選擇系統支援的搜尋屬性和值。

    1. 選取發現項目屬性,或在「搜尋發現項目屬性」方塊中輸入屬性名稱。畫面上會顯示可用的子屬性清單。
    2. 選取子屬性。系統會顯示選取欄位,您可以使用所選子屬性、查詢運算子,以及一或多個子屬性值,建構查詢陳述式。
    3. 從面板中選取子屬性的運算子和一或多個值。 如要進一步瞭解查詢運算子和使用的函式,請參閱「新增篩選器」選單中的「查詢運算子」。
    4. 按一下 [套用]

      對話方塊會關閉,查詢也會更新。

    5. 重複上述步驟,直到結果查詢包含所有需要的屬性為止。
  10. 按一下「預覽相符的發現項目」。 表格會顯示符合查詢條件的發現項目。

  11. 按一下 [儲存]

企業版

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

    前往「發現項目」

  2. 視需要選取 Google Cloud 專案或機構。
  3. 至少選取一項發現。
  4. 按一下「忽略選項」,然後選取「查看忽略規則」
  5. 按一下「建立忽略規則」
  6. 輸入忽略規則 ID。必須提供這個值。
  7. 輸入忽略規則說明,提供忽略結果的背景資訊。這個值為選填,但建議填寫。
  8. 檢查「父項資源」值,確認忽略規則的範圍。
  9. 如要建立靜態忽略規則,或建立沒有到期日的動態忽略規則,請繼續下一個步驟。如要建立動態靜音規則,暫時將調查結果設為靜音,請完成下列步驟:
    1. 勾選「暫時忽略相符的發現項目」核取方塊。
    2. 選取或輸入動態靜音規則的到期日。這個值表示規則忽略相符發現項目的時間長度。
  10. 在「發現項目查詢」欄位中,按一下「新增篩選器」,建立查詢陳述式。或者,您也可以手動輸入查詢陳述式。

    在「選取篩選器」對話方塊中,選擇支援的搜尋屬性和值。

    1. 選取發現項目屬性,或在「搜尋發現項目屬性」方塊中輸入屬性名稱。畫面上會顯示可用的子屬性清單。
    2. 選取子屬性。系統會顯示選取欄位,您可以使用所選子屬性、查詢運算子,以及一或多個子屬性值,建構查詢陳述式。
    3. 從面板中選取子屬性的運算子和一或多個值。 如要進一步瞭解查詢運算子和使用的函式,請參閱「新增篩選器」選單中的「查詢運算子」。
    4. 按一下 [套用]

      對話方塊會關閉,查詢也會更新。

    5. 重複上述步驟,直到結果查詢包含所有需要的屬性為止。
  11. 按一下「預覽相符的發現項目」,表格會顯示符合查詢條件的發現項目。
  12. 按一下 [儲存]

gcloud

  1. In the Google Cloud console, activate Cloud Shell.

    Activate Cloud Shell

    At the bottom of the Google Cloud console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.

  2. 如要建立忽略規則,請執行 gcloud scc muteconfigs create 指令:

    gcloud scc muteconfigs create CONFIG_ID \
      --PARENT=PARENT_ID \
      --location=LOCATION \
      --description="RULE_DESCRIPTION" \
      --filter="FILTER" \
      --type=MUTE_TYPE \
      --expiry-time=TIMESTAMP

    更改下列內容:

    • CONFIG_ID:忽略規則的名稱。ID 必須使用英數字元和連字號,且長度介於 1 至 63 個字元之間。
    • PARENT:資源階層中的範圍,靜音規則適用於 organizationfolderproject
    • PARENT_ID:父項機構、資料夾或專案的數值 ID,或是父項專案的英數 ID。
    • LOCATION: 要建立靜音規則的Security Command Center 位置;如果已啟用資料落地設定,請使用 euksaus;否則請使用值 global
    • RULE_DESCRIPTION:靜音規則的說明,最多 1,024 個字元。
    • FILTER:您定義的運算式,用於篩選調查結果。舉例來說,如要將 OPEN_FIREWALL 發現項目設為靜音,篩選器可以是 FILTER="category=\"OPEN_FIREWALL\""
    • MUTE_TYPE:要建立的忽略規則類型。有效的靜音規則類型為 DYNAMICSTATIC。預設的靜音規則類型為 STATIC。 建立靜音規則後,就無法變更規則類型。
    • TIMESTAMP:僅適用於建立動態忽略規則。指出動態靜音規則到期的日期/時間字串。值必須設為至少一天後的日期,否則系統會拒絕要求。如需時間格式的相關資訊,請參閱 gcloud topic datetimes。動態靜音規則過期後,系統會從所有相符的發現項目中移除該規則。如要讓動態忽略規則無限期忽略相符的發現項目,請省略這個欄位。

    回應會包含忽略規則 ID,您可以依據這組 ID 查看、更新及刪除忽略規則,詳情請參閱「管理忽略規則」。

Terraform

為機構建立忽略規則:

resource "google_scc_v2_organization_mute_config" "default" {
  mute_config_id    = "my-config"
  organization = "123456789"
  location     = "global"
  description  = "My custom Cloud Security Command Center Finding Organization mute Configuration"
  filter = "severity = \"HIGH\""
  type = "STATIC"
}

為資料夾建立忽略規則:

resource "google_folder" "folder" {
  parent       = "organizations/123456789"
  display_name = "folder-name"
}

resource "google_scc_v2_folder_mute_config" "default" {
  mute_config_id    = "my-config"
  folder = google_folder.folder.folder_id
  location     = "global"
  description  = "My custom Cloud Security Command Center Finding Folder mute Configuration"
  filter = "severity = \"HIGH\""
  type = "STATIC"
}

為專案建立忽略規則:

resource "google_scc_v2_project_mute_config" "default" {
  mute_config_id    = "my-config"
  project = "my-project-name"
  location     = "global"
  description  = "My custom Cloud Security Command Center Finding Project mute Configuration"
  filter = "severity = \"HIGH\""
  type = "STATIC"
}

Go


import (
	"context"
	"fmt"
	"io"

	securitycenter "cloud.google.com/go/securitycenter/apiv2"
	"cloud.google.com/go/securitycenter/apiv2/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\"",
		Type: securitycenterpb.MuteConfig_STATIC,
	}

	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


import com.google.cloud.securitycenter.v2.LocationName;
import com.google.cloud.securitycenter.v2.MuteConfig;
import com.google.cloud.securitycenter.v2.MuteConfig.MuteConfigType;
import com.google.cloud.securitycenter.v2.SecurityCenterClient;
import java.io.IOException;
import java.util.UUID;

public class CreateMuteRule {

  public static void main(String[] args) throws IOException {
    // TODO: Replace the following variables.
    // projectId: Google Cloud Project id.
    String projectId = "google-cloud-project-id";

    // Specify the location of the mute config.
    String location = "global";

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

    createMuteRule(projectId, location, muteConfigId);
  }

  // Creates a mute configuration in a project under a given location.
  public static void createMuteRule(String projectId, String location, String muteConfigId)
      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()) {

      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\"")
              .setType(MuteConfigType.STATIC)
              .build();

      // You can also create mute rules in an organization/ folder.
      // Construct the parameters according to the parent resource.
      //  * Organization -> client.createMuteConfig(OrganizationLocationName.of(...
      //  * Folder -> client.createMuteConfig(FolderLocationName.of(...
      MuteConfig response = client.createMuteConfig(
          LocationName.of(projectId, location), muteConfig, muteConfigId);
      System.out.println("Mute rule created successfully: " + response.getName());
    }
  }
}

Python

def create_mute_rule(parent_path: str, location_id: str, mute_config_id: str) -> Dict:
    """
    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}
        location_id: Gcp location id; example: 'global'
        mute_config_id: Set a unique id; max of 63 chars.
    Returns:
        Dict: returns the mute rule details
    """

    from google.cloud import securitycenter_v2

    client = securitycenter_v2.SecurityCenterClient()

    mute_config = securitycenter_v2.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"'
    )
    mute_config.type = "STATIC"

    request = securitycenter_v2.CreateMuteConfigRequest()
    request.parent = parent_path + "/locations/" + location_id
    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}")
    return mute_config

REST

在 Security Command Center API 中,使用 muteConfigs.create 方法建立靜音規則。要求主體是 MuteConfig 的例項:

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

  {
    "description": "RULE_DESCRIPTION",
    "filter": "FILTER",
    "type": "MUTE_TYPE",
    "expiryTime": "TIMESTAMP"
  }

更改下列內容:

  • PARENT:靜音規則的父項資源 (organizationsfoldersprojects)
  • PARENT_ID:上層機構、資料夾或專案的 ID
  • LOCATION: 要建立靜音規則的Security Command Center 位置;如果已啟用資料落地功能,請使用 euksaus;否則請使用值 global
  • MUTE_CONFIG_ID:忽略規則的名稱 (長度介於 1 到 63 個字元之間)
  • RULE_DESCRIPTION:靜音規則的說明 (最多 1,024 個半形字元)
  • FILTER:您定義的運算式,用於篩選調查結果

    舉例來說,如要將 OPEN_FIREWALL 發現項目設為靜音,篩選器可以是 "category=\"OPEN_FIREWALL\""

  • MUTE_TYPE:要建立的忽略規則類型。有效的靜音規則類型為 DYNAMICSTATIC。建立靜音規則後,就無法變更規則類型。

  • TIMESTAMP:僅適用於建立動態忽略規則。指出動態靜音規則到期的日期/時間字串。值必須設為至少一天後的日期,否則系統會拒絕要求。如需時間格式的相關資訊,請參閱 gcloud topic datetimes。動態靜音規則過期後,系統會從所有相符的發現項目中移除該規則。如要讓動態忽略規則無限期忽略相符的發現項目,請省略這個欄位。

回應會包含靜音設定 ID,可用於查看、更新及刪除靜音規則,詳情請參閱「管理靜音規則」。

系統會隱藏與篩選條件完全相符的新發現項目,並將發現項目的 mute 屬性設為 MUTED

忽略規則不支援的發現項目屬性

忽略規則不支援篩選器中的所有發現項目屬性。展開下列章節,即可查看靜音規則篩選器不支援的屬性清單。

不支援的發現項目屬性

  • caiResource
  • canonicalName
  • createTime
  • description
  • eventTime
  • externalUri
  • gcpMetadata.folders1
  • libraryPaths
  • mute
  • muteAnnotation
  • muteInfo
  • muteInitiator
  • muteUpdateTime
  • name
  • nextSteps
  • originalProviderId
  • parent
  • processes.binaryPath
  • processes.libraryPaths
  • propertyDataTypes
  • resourceName
  • securityMarks
  • sourceProperties
  • state
  • workflowState
  • 1 gcpMetadata.folders 屬性包含靜音篩選器支援的子欄位。

列出忽略規則

如要列出機構、資料夾或專案中的靜音規則,請使用 Google Cloud 控制台、gcloud CLI 或 Security Command Center API。

您能否列出特定範圍的靜音規則,取決於 IAM 角色獲得的權限。

如果已為 Security Command Center 啟用資料落地設定,清單指令的範圍也會限制在所選的 Security Command Center 位置

如需列出忽略規則的程式碼範例,請參閱「列出忽略規則」。

如要列出機構、資料夾或專案的靜音規則,請按一下要使用程序的對應分頁:

控制台

  1. 在 Google Cloud 控制台中,前往 Security Command Center「Settings」(設定) 頁面的「Mute rules」(靜音規則) 分頁標籤。

    前往忽略規則

  2. 視需要選取 Google Cloud 專案或機構。

  3. 「忽略規則」部分會顯示有效忽略規則的詳細資料,包括:

    • 名稱:忽略規則 ID
    • 父項資源:忽略規則所在的資源
    • 說明:忽略規則說明 (如有)
    • 上次更新者:上次更新規則的主體
    • 上次更新時間:上次更新規則的日期和時間

gcloud

  1. In the Google Cloud console, activate Cloud Shell.

    Activate Cloud Shell

    At the bottom of the Google Cloud console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.

  2. 如要列出靜音規則,請執行 gcloud scc muteconfigs list 指令:

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

    更改下列內容:

    • PARENT:要列出忽略規則的父項 organizationfolderproject
    • PARENT_ID:上層機構、資料夾或專案的 ID
    • LOCATION:要列出靜音規則的Security Command Center 位置。如果已啟用資料落地設定,請使用 euksaus;否則請使用值 global

Go

import (
	"context"
	"fmt"
	"io"

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


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

public class ListMuteRules {

  public static void main(String[] args) throws IOException {
    // TODO: Replace variables enclosed within {}
    // projectId: Google Cloud Project id.
    String projectId = "google-cloud-project-id";

    // Specify the location to list mute configs.
    String location = "global";

    listMuteRules(projectId, location);
  }

  // Lists all mute rules present under the resource type in the given location.
  public static void listMuteRules(String projectId, String location) 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()) {

      // Parent can also be one of:
      //  * "organizations/{org_id}/locations/{location}"
      //  * "folders/{folder_id}/locations/{location}"
      ListMuteConfigsRequest listMuteConfigsRequest = ListMuteConfigsRequest.newBuilder()
          .setParent(String.format("projects/%s/locations/%s", projectId, location))
          .build();

      // List all mute configs present in the resource.
      for (MuteConfig muteConfig : client.listMuteConfigs(listMuteConfigsRequest).iterateAll()) {
        System.out.println(muteConfig.getName());
      }
    }
  }
}

Python

def list_mute_rules(parent: str, location_id: str) -> Dict:
    """
    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}
        location_id: Gcp location id; example: 'global'
    Returns:
         Dict: returns the mute rule details
    """
    from google.cloud import securitycenter_v2

    client = securitycenter_v2.SecurityCenterClient()

    request = securitycenter_v2.ListMuteConfigsRequest()
    request.parent = parent + "/locations/" + location_id
    response = client.list_mute_configs(request)
    # List all Mute Configs present in the resource.
    for mute_config in response:
        print(mute_config.name)
    return response

REST

在 Security Command Center API 中,使用 muteConfigs.list 方法列出靜音規則:

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

更改下列內容:

  • PARENT:靜音規則的父項資源 (organizationsfoldersprojects)
  • PARENT_ID:上層機構、資料夾或專案的 ID
  • LOCATION:要列出靜音規則的Security Command Center 位置。如果已啟用資料落地設定,請使用 euksaus;否則請使用值 global

回應會包含忽略規則的名稱、說明和忽略設定 ID。

查看忽略規則設定

您可以使用 Google Cloud 控制台、gcloud CLI 或 Security Command Center API,查看靜音規則設定。

如需擷取忽略規則設定的範例程式碼,請參閱「查看忽略規則」。

如要查看忽略規則設定,請按一下要使用的程序分頁標籤:

控制台

  1. 在 Google Cloud 控制台中,前往 Security Command Center「Settings」(設定) 頁面的「Mute rules」(靜音規則) 分頁標籤。

    前往忽略規則

  2. 視需要選取 Google Cloud 專案或機構。

  3. 「忽略規則」部分會顯示忽略規則清單。

  4. 按一下要查看的規則名稱。

    系統會開啟頁面,顯示靜音規則的設定。

gcloud

  1. In the Google Cloud console, activate Cloud Shell.

    Activate Cloud Shell

    At the bottom of the Google Cloud console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.

  2. 如要查看靜音規則的設定,請執行 gcloud scc muteconfigs get 指令:

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

    更改下列內容:

    • MUTE_CONFIG_ID:忽略規則的 ID
    • PARENT:靜音規則的父項資源 (organizationfolderproject)
    • PARENT_ID:機構、資料夾或專案的 ID
    • LOCATION: 查看忽略規則設定的Security Command Center 位置;如果已啟用資料落地功能,請使用 euksaus;否則請使用值 global

Go

import (
	"context"
	"fmt"
	"io"

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


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

public class GetMuteRule {

  public static void main(String[] args) throws IOException {
    // TODO(Developer): Replace the following variables
    // projectId: Google Cloud Project id.
    String projectId = "google-cloud-project-id";

    // Specify the location of the mute config. If the mute config was
    // created with v1 API, it can be accessed with "global".
    String location = "global";

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

    getMuteRule(projectId, location, muteConfigId);
  }

  // Retrieves a mute configuration given its resource name.
  public static MuteConfig getMuteRule(String projectId, String location, String muteConfigId)
      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()) {
      // Use appropriate `MuteConfigName` methods depending on the parent type.
      //  * organization -> MuteConfigName.ofOrganizationLocationMuteConfigName()
      //  * folder -> MuteConfigName.ofFolderLocationMuteConfigName()

      MuteConfigName muteConfigName = MuteConfigName.ofProjectLocationMuteConfigName(projectId,
          location, muteConfigId);
      return client.getMuteConfig(muteConfigName);
    }
  }
}

Python

def get_mute_rule(parent_path: str, location_id: str, mute_config_id: str) -> Dict:
    """
    Retrieves a mute configuration given its resource name.
    Args:
        parent_path: use any one of the following options:
                     - organizations/{organization_id}
                     - folders/{folder_id}
                     - projects/{project_id}
        location_id: Gcp location id; example: 'global'
        mute_config_id: Set a unique id; max of 63 chars.
    Returns:
         Dict: returns the mute rule details
    """
    from google.cloud import securitycenter_v2

    client = securitycenter_v2.SecurityCenterClient()

    request = securitycenter_v2.GetMuteConfigRequest()
    request.name = (
        parent_path + "/locations/" + location_id + "/muteConfigs/" + mute_config_id
    )

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

REST

在 Security Command Center API 中,使用 muteConfigs.get 方法傳回靜音規則的設定:

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

更改下列內容:

  • PARENT:靜音規則的父項資源 (organizationsfoldersprojects)
  • PARENT_ID:機構、資料夾或專案的 ID
  • LOCATION: 查看忽略規則設定的Security Command Center 位置;如果已啟用資料落地功能,請使用 euksaus;否則請使用值 global
  • CONFIG_ID:忽略規則的數值 ID

更新忽略規則

如要更新靜音規則的說明或發現項目篩選器,可以使用 Google Cloud 主控台、gcloud CLI 或 Security Command Center API。

您無法變更靜音規則的 ID、上層機構、資料夾或專案,也無法變更靜音規則的位置。如要變更這些值,請建立新的靜音規則。

如果先前取消忽略發現項目,但這些項目符合在 Google Cloud 管理控制台中更新的忽略規則,系統會再次忽略這些項目。詳情請參閱「取消個別發現項目的靜音」。

如需更新忽略規則的程式碼範例,請參閱「更新忽略規則」。

如要更新靜音規則,請按一下要使用的程序分頁:

控制台

  1. 在 Google Cloud 控制台中,前往 Security Command Center「Settings」(設定) 頁面的「Mute rules」(靜音規則) 分頁標籤。

    前往忽略規則

  2. 選取要修改靜音規則的父項資源 Google Cloud 專案或機構。

  3. 按一下要修改的靜音規則名稱。

    如果未選取適當的專案或機構,系統可能會顯示附註,告知您沒有權限修改靜音規則。

  4. 輸入新的說明,然後按一下「儲存」

  5. 如果是動態靜音規則,請更新或變更規則的到期時間。

  6. 更新或變更篩選器。

    如需操作說明,請參閱「建立忽略規則」。

  7. 如要查看符合更新後篩選條件的發現項目,請按一下「預覽相符的發現項目」

    系統會載入與新查詢相符的發現項目。

  8. 按一下 [儲存]

gcloud

  1. In the Google Cloud console, activate Cloud Shell.

    Activate Cloud Shell

    At the bottom of the Google Cloud console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.

  2. 如要更新靜音規則,請執行 gcloud scc muteconfigs update 指令:

    gcloud scc muteconfigs update MUTE_CONFIG_ID \
        --PARENT=PARENT_ID \
        --location=LOCATION \
        --description=RULE_DESCRIPTION \
        --filter=FILTER \
        --type=MUTE_TYPE \
        --expiry-time=TIMESTAMP
    

    更改下列內容:

    • MUTE_CONFIG_ID:忽略規則的 ID。
    • PARENT:靜音規則的父項資源 (organizationfolderproject)。
    • PARENT_ID:機構、資料夾或專案的 ID。
    • LOCATION:要更新靜音規則的Security Command Center 位置;如果已啟用資料落地功能,請使用 euksaus;否則請使用值 global
    • RULE_DESCRIPTION:靜音規則的說明 (最多 1,024 個字元)。
    • FILTER:您定義的運算式,用於篩選調查結果。

      舉例來說,如要將 OPEN_FIREWALL 發現項目設為靜音,篩選條件可以是 FILTER="category=\"OPEN_FIREWALL\""

    • MUTE_TYPE:要更新的忽略規則類型。有效的靜音規則類型為 DYNAMICSTATIC。忽略規則建立後即無法變更類型。

    • TIMESTAMP:僅適用於更新動態忽略規則。指出動態靜音規則到期的日期/時間字串。值必須設為至少一天後的日期,否則系統會拒絕要求。如要瞭解時間格式,請參閱 gcloud topic datetimes。動態靜音規則過期後,系統會從所有相符的發現項目中移除該規則。如要讓動態忽略規則無限期忽略相符的發現項目,請省略這個欄位。

Go


import (
	"context"
	"fmt"
	"io"

	securitycenter "cloud.google.com/go/securitycenter/apiv2"
	"cloud.google.com/go/securitycenter/apiv2/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! %w", err)
	}
	fmt.Fprintf(w, "Mute rule updated %s", response.Name)
	return nil
}

Java


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

public class UpdateMuteRule {

  public static void main(String[] args) throws IOException {
    // TODO: Replace the variables within {}
    // projectId: Google Cloud Project id.
    String projectId = "google-cloud-project-id";

    // Specify the location of the mute config to update. If the mute config was
    // created with v1 API, it can be accessed with "global".
    String location = "global";

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

    updateMuteRule(projectId, location, muteConfigId);
  }

  // Updates an existing mute configuration.
  // The following can be updated in a mute config: description and filter.
  public static void updateMuteRule(String projectId, String location, String muteConfigId)
      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 securityCenterClient = SecurityCenterClient.create()) {

      MuteConfig updateMuteConfig =
          MuteConfig.newBuilder()
              // Construct the name according to the parent type of the mute rule.
              // Parent can also be one of:
              //  * "organizations/{org_id}/locations/{location}/muteConfigs/{muteConfig_id}"
              //  * "folders/{folder_id}/locations/{location}/muteConfigs/{muteConfig_id}"
              .setName(String.format("projects/%s/locations/%s/muteConfigs/%s", projectId, location,
                  muteConfigId))
              .setDescription("Updated mute config description")
              .build();

      UpdateMuteConfigRequest updateMuteConfigRequest =
          UpdateMuteConfigRequest.newBuilder()
              .setMuteConfig(updateMuteConfig)
              // Make sure that the mask fields match the properties changed in
              // 'updateMuteConfig' object.
              // For more info on constructing update mask path, see the proto or:
              // https://cloud.google.com/security-command-center/docs/reference/rest/v2/folders.muteConfigs/patch?hl=en#query-parameters
              .setUpdateMask(FieldMask.newBuilder().addPaths("description").build())
              .build();

      MuteConfig response = securityCenterClient.updateMuteConfig(updateMuteConfigRequest);
      System.out.println(response);
    }
  }
}

Python

def update_mute_rule(parent_path: str, location_id: str, mute_config_id: str) -> Dict:
    """
    Updates an existing mute configuration.
    The following can be updated in a mute config: description, and filter/ mute rule.
    Args:
        parent: Use any one of the following resource paths to list mute configurations:
                - organizations/{organization_id}
                - folders/{folder_id}
                - projects/{project_id}
        location_id: Gcp location id; example: 'global'
        mute_config_id: Set a unique id; max of 63 chars.
    Returns:
         Dict: returns the mute rule details
    """
    from google.cloud import securitycenter_v2
    from google.protobuf import field_mask_pb2

    client = securitycenter_v2.SecurityCenterClient()

    update_mute_config = securitycenter_v2.MuteConfig()
    update_mute_config.name = (
        parent_path + "/locations/" + location_id + "/muteConfigs/" + mute_config_id
    )
    update_mute_config.description = "Updated mute config description"

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

    request = securitycenter_v2.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}")
    return mute_config

REST

在 Security Command Center API 中,使用 muteConfigs.patch 方法更新靜音規則。要求主體是 MuteConfig 的例項:

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

  {
    "description": "RULE_DESCRIPTION",
    "filter": "FILTER",
    "type": "MUTE_TYPE",
    "expiryTime": "TIMESTAMP"
  }

更改下列內容:

  • PARENT:靜音規則的父項資源 (organizationsfoldersprojects)
  • PARENT_ID:機構、資料夾或專案的 ID
  • LOCATION:要更新靜音規則的 Security Command Center 位置;如果已啟用資料落地功能,請使用 euksaus;否則請使用值 global
  • CONFIG_ID:忽略規則的數值 ID
  • RULE_DESCRIPTION:忽略規則的說明 (最多 1,024 個半形字元)
  • FILTER:您定義的運算式,用於篩選結果

    舉例來說,如要將 OPEN_FIREWALL 發現項目設為靜音,篩選器可以是 "category=\"OPEN_FIREWALL\""

  • MUTE_TYPE:要更新的忽略規則類型。有效的靜音規則類型為 DYNAMICSTATIC。忽略規則建立後即無法變更類型。

  • TIMESTAMP:僅適用於更新動態忽略規則。指出動態靜音規則到期的日期/時間字串。這個值必須設為至少一天後的日期,否則系統會拒絕要求。如要瞭解時間格式,請參閱 gcloud topic datetimes。動態忽略規則過期後,系統會從所有相符的發現項目中移除該規則。如要讓動態忽略規則無限期忽略相符的發現項目,請省略這個欄位。

系統會隱藏與篩選條件完全相符的新發現項目,並將發現項目的 mute 屬性設為 MUTED

刪除忽略規則

您可以使用 Google Cloud 主控台、gcloud CLI 或 Security Command Center API 刪除靜音規則。

刪除靜音規則前,請先瞭解下列事項:

  • 刪除的忽略規則無法復原。
  • 刪除靜態忽略規則後,系統不會自動取消忽略任何已忽略的發現項目。您必須手動或以程式輔助方式取消將調查結果設為靜音
  • 刪除動態忽略規則後,系統會自動從所有先前相符的發現項目中移除該規則,並取消忽略這些項目 (如果這些項目不符合任何其他規則)。
  • 系統不會忽略日後符合已刪除忽略規則中篩選條件的發現項目。

如需刪除忽略規則的程式碼範例,請參閱「刪除忽略規則」。

如要刪除靜音規則,請按一下要使用程序的標籤:

控制台

  1. 在 Google Cloud 控制台中,前往 Security Command Center「Settings」(設定) 頁面的「Mute rules」(靜音規則) 分頁標籤。

    前往忽略規則

  2. 視需要選取 Google Cloud 專案或機構。

  3. 按一下要刪除的靜音規則名稱。

  4. 按一下「刪除」圖示

  5. 閱讀對話方塊,如果同意,請按一下「刪除」

gcloud

  1. In the Google Cloud console, activate Cloud Shell.

    Activate Cloud Shell

    At the bottom of the Google Cloud console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.

  2. 如要刪除靜音規則,請執行 gcloud scc muteconfigs delete 指令:

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

    更改下列內容:

    • MUTE_CONFIG_ID:靜音設定的 ID
    • PARENT:靜音規則的父項資源 (organizationfolderproject)
    • PARENT_ID:機構、資料夾或專案的 ID
    • LOCATION: 要刪除靜音規則的Security Command Center 位置;如果已啟用資料落地設定,請使用 euksaus;否則請使用值 global
  3. 確認要刪除靜音規則。

Go


import (
	"context"
	"fmt"
	"io"

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


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

public class DeleteMuteRule {

  public static void main(String[] args) throws IOException {
    // TODO(Developer): Replace the following variables
    // projectId: Google Cloud Project id.
    String projectId = "google-cloud-project-id";

    // Specify the location of the mute config. If the mute config was
    // created with v1 API, it can be accessed with "global".
    String location = "global";

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

    deleteMuteRule(projectId, location, 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 location, String muteConfigId)
      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()) {
      // Use appropriate `MuteConfigName` methods depending on the parent type.
      // folder -> MuteConfigName.ofFolderLocationMuteConfigName()
      // organization -> MuteConfigName.ofOrganizationLocationMuteConfigName()
      client.deleteMuteConfig(
          MuteConfigName.ofProjectLocationMuteConfigName(projectId, location, muteConfigId));

      System.out.println("Mute rule deleted successfully: " + muteConfigId);
    }
  }
}

Python

def delete_mute_rule(parent_path: str, location_id: str, mute_config_id: str) -> None:
    """
    Deletes a mute configuration given its resource name.
    Note: Previously muted findings are not affected when a mute config is deleted.
    Args:
         parent_path: use any one of the following options:
                     - organizations/{organization_id}
                     - folders/{folder_id}
                     - projects/{project_id}
        location_id: Gcp location id; example: 'global'
        mute_config_id: Set a unique id; max of 63 chars.
    Returns:
         None: returns none mute rule is deleted
    """
    from google.cloud import securitycenter_v2

    client = securitycenter_v2.SecurityCenterClient()

    request = securitycenter_v2.DeleteMuteConfigRequest()
    request.name = (
        parent_path + "/locations/" + location_id + "/muteConfigs/" + mute_config_id
    )

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

REST

在 Security Command Center API 中,使用 muteConfigs.delete 方法刪除靜音規則:

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

更改下列內容:

  • PARENT:靜音規則的父項資源 (organizationsfoldersprojects)
  • PARENT_ID:機構、資料夾或專案的 ID
  • LOCATION: 要刪除靜音規則的Security Command Center 位置;如果已啟用資料落地設定,請使用 euksaus;否則請使用值 global
  • CONFIG_ID:忽略規則的數值 ID

忽略個別發現項目

如要靜態將個別發現項目設為靜音,可以使用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,且該發現項目會從「發現項目查詢結果」面板中移除。

或者,您也可以透過詳細資料面板將發現項目設為忽略:

  1. 在「發現項目」頁面的「發現項目查詢結果」面板中,按一下「類別」欄中的個別發現項目名稱。系統會開啟該發現項目的詳細資料面板。
  2. 按一下「採取行動」
  3. 在「採取行動」選單中,選取「套用靜音覆寫」

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

gcloud

  1. In the Google Cloud console, activate Cloud Shell.

    Activate Cloud Shell

    At the bottom of the Google Cloud console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.

  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 位置;如果已啟用資料落地功能,請使用 euksaus;否則請使用值 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 位置;如果已啟用資料落地功能,請使用 euksaus;否則請使用值 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 建立的忽略規則,不會影響使用者取消忽略的發現項目。

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

控制台

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

    前往「發現項目」

  2. 視需要選取 Google Cloud 專案或機構。

    「發現項目」頁面隨即開啟,預設查詢會顯示在「查詢預覽」部分。預設查詢會濾除已靜音的發現項目,因此您必須先編輯查詢,已靜音的發現項目才會顯示在「發現項目查詢結果」面板中。

  3. 在「查詢預覽」部分右側,按一下「編輯查詢」,開啟「查詢編輯器」

  4. 在「Query editor」(查詢編輯器) 欄位中,將現有的靜音陳述式替換為下列內容:

    mute="MUTED"
  5. 按一下 [套用]。「發現項目查詢結果」面板中的發現項目會更新,只顯示已忽略的發現項目。

  6. 如有需要,請篩除其他已靜音的發現項目。舉例來說,在「類別」下方的「快速篩選器」面板中,選取要取消靜音的發現項目名稱,即可篩除所有其他類別的發現項目。

  7. 找出要取消靜音的發現項目,然後勾選旁邊的核取方塊。您可以選取一或多項發現。

  8. 在「發現項目查詢結果」動作列中,按一下「忽略選項」,然後選取「套用取消忽略覆寫」

    所選發現項目的 mute 屬性會設為 UNMUTED,且該發現項目會從「發現項目查詢結果」面板中移除。

或者,您也可以透過詳細資料面板取消忽略發現項目:

  1. 在「發現項目」頁面的「發現項目查詢結果」面板中,按一下「類別」欄中的個別發現項目名稱。系統會開啟該發現項目的詳細資料面板。
  2. 按一下「採取行動」
  3. 在「採取行動」選單中,選取「套用取消靜音覆寫」

gcloud

  1. In the Google Cloud console, activate Cloud Shell.

    Activate Cloud Shell

    At the bottom of the Google Cloud console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.

  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 位置;如果已啟用資料落地功能,請使用 euksaus;否則請使用值 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 位置;如果已啟用資料落地功能,請使用 euksaus;否則請使用 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. 在「Query editor」(查詢編輯器) 欄位中,將現有的靜音陳述式替換為下列內容:

    mute="MUTED" OR mute="UNMUTED"
  5. 按一下 [套用]。「發現項目查詢結果」面板中的發現項目會更新,納入靜態忽略和取消忽略的發現項目。

  6. 如有需要,請篩除其他發現。舉例來說,在「類別」下方的「快速篩選器」面板中,選取需要重設的發現項目名稱,即可篩除所有其他類別的發現項目。

  7. 找出要重設的發現項目,然後勾選旁邊的核取方塊。您可以選取一或多項發現。

  8. 在「發現項目查詢結果」動作列中,按一下「忽略選項」,然後選取「移除忽略覆寫」

    所選發現項目的 mute 屬性會設為 UNDEFINED,且該發現項目會從「發現項目查詢結果」面板中移除。

或者,您也可以透過詳細資料面板取消忽略發現項目:

  1. 在「發現項目」頁面的「發現項目查詢結果」面板中,按一下「類別」欄中的個別發現項目名稱。系統會開啟該發現項目的詳細資料面板。
  2. 按一下「採取行動」
  3. 在「採取行動」選單中,選取「移除靜音覆寫值」

gcloud

  1. In the Google Cloud console, activate Cloud Shell.

    Activate Cloud Shell

    At the bottom of the Google Cloud console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.

  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 位置;如果已啟用資料落地設定,請使用 euksaus;否則請使用值 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 位置;如果已啟用資料落地設定,請使用 euksaus;否則請使用值 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. In the Google Cloud console, activate Cloud Shell.

    Activate Cloud Shell

    At the bottom of the Google Cloud console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.

  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 位置;如果已啟用資料落地設定,請使用 euksaus;否則請使用值 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 位置;如果已啟用資料落地設定,請使用 euksaus;否則請使用值 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 控制台中查看已忽略的發現項目

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

舉例來說,下列發現項目查詢只會顯示已靜音的有效發現項目:

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 個字元之間。

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

尋找與靜音相關的屬性

本節列出與發現項目靜音狀態相關的發現項目屬性,並說明這些屬性如何受到靜音作業影響:

  • mute:在建立調查結果時設為 UNDEFINED,並在下列情況發生變化時變更:
    • MUTED:發現項目是手動或透過忽略規則遭到忽略。
    • UNMUTED:使用者取消將發現事項設為靜音。
  • muteUpdateTime:發現事項遭到靜音或取消靜音的時間。
  • muteInitiator:主體或忽略規則的 ID,這些主體或規則會忽略發現項目。
  • muteInfo:發現項目的忽略資訊,例如忽略規則類型 (靜態或動態),以及發現項目符合的忽略規則。
  • muteInfo.staticMute:靜態忽略狀態會覆寫套用至這項發現項目的任何動態忽略規則。
    • state:靜態忽略狀態,可透過直接忽略發現項目或靜態忽略規則設定。
    • applyTime:對結果套用靜態靜音狀態的時間。
  • muteInfo.dynamicMuteRecords:與發現項目相符的動態忽略規則記錄。
    • muteConfig::靜音規則的相對資源名稱,由建立記錄的靜音設定代表。例如:organizations/123/muteConfigs/examplemuteconfig
    • matchTime:動態忽略規則與發現項目相符的時間。

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

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

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

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

後續步驟

進一步瞭解如何篩選搜尋結果通知

查看更多可用的篩選器範例