在 Security Command Center 中忽略发现结果

本页面介绍了如何通过忽略发现结果来减少您在 Security Command Center 中收到的发现结果数量。

忽略发现结果会将其从Google Cloud 控制台中的发现结果的默认视图中隐藏。您可以手动或以编程方式忽略发现结果,并创建过滤条件以根据您指定的条件自动忽略现有和未来的发现结果。

Security Command Center 检测服务会对您的 Google Cloud 部署进行广泛的安全评估,但您可能会发现某些发现结果不适合或与您的组织或项目不相关。大量的发现结果还可能导致安全分析师难以有效识别和消除最关键的风险。您在审核或响应隔离资产或处于可接受业务参数范围内的资产的安全发现结果时,忽略发现结果可以帮助您节省时间。

停用检测器相比,忽略发现结果具有多项优势:

  • 您可以创建自定义过滤条件来微调忽略的发现结果。
  • 您可以使用忽略规则暂时或无限期地忽略发现结果。
  • 忽略发现结果不会停止扫描底层资源。发现结果仍会生成,但在您决定查看它们之前会保持隐藏状态。

权限

如需忽略发现结果,您需要组织文件夹项目级别的以下某个 Identity and Access Management (IAM) 角色:

  • 查看忽略规则:
    • Security Center Admin Viewer (roles/securitycenter.adminViewer)
    • Security Center Settings Viewer (roles/securitycenter.settingsViewer)
    • Security Center Mute Configurations Viewer (roles/securitycenter.muteConfigsViewer)
  • 查看、创建、更新和删除忽略规则:
    • Security Center Admin (roles/securitycenter.admin)
    • Security Center Admin Editor (roles/securitycenter.adminEditor)
    • Security Center Settings Editor (roles/securitycenter.settingsEditor)
    • Security Center Mute Configurations Editor (roles/securitycenter.muteConfigsEditor)
  • 手动忽略发现结果:
    • Security Center Findings Editor (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 条忽略规则。

我们建议您仅在忽略规则配置中使用动态忽略规则,因为它们比静态忽略规则更灵活。如需比较忽略规则类型,请参阅忽略规则的类型

如需创建忽略规则,请点击要使用的过程对应的标签页:

控制台

  1. 在 Google Cloud 控制台中,前往 Security Command Center 发现结果页面。

    转至“发现结果”

  2. 如有必要,选择您的 Google Cloud 项目或组织。

  3. 点击忽略选项,然后选择管理忽略规则

  4. 点击创建忽略规则,然后选择动态忽略规则静态忽略规则。如需详细了解忽略规则类型,请参阅忽略规则的类型

  5. 输入忽略规则 ID。必须提供此值。

  6. 输入忽略规则说明,其提供为何忽略发现结果的上下文。该值是可选的,但我们建议您使用。

    父级资源表示将创建和应用忽略规则的范围。

  7. 如果您要创建静态忽略规则或无失效时间的动态忽略规则,请继续执行下一步。如果您要创建动态忽略规则以暂时忽略发现结果,请完成以下步骤:

    1. 选中暂时忽略匹配的发现结果复选框。
    2. 选择或输入动态忽略规则的失效日期。此值表示规则将忽略匹配的发现结果的时长。
  8. 发现结果查询字段中,通过点击添加过滤条件来构建查询语句。或者,您也可以手动输入查询语句。

    选择过滤条件对话框允许您选择支持的发现结果属性和值。

    1. 选择发现结果特性或在搜索发现结果特性框中输入其名称。系统会显示可用子特性的列表。
    2. 选择子特性。系统会显示一个选择字段,您可以在其中使用所选子属性、查询运算符以及子属性的一个或多个值来构建查询语句。
    3. 从面板中为子属性选择运算符和一个或多个值。 如需详细了解查询运算符及其使用的函数,请参阅“添加过滤条件”菜单中的查询运算符
    4. 点击应用

      对话框将会关闭,并且您的查询即会更新。

    5. 重复这些步骤,直到发现结果查询包含所需的所有特性。
  9. 查看过滤条件,以确保准确性。如需进行更改,请根据需要删除或添加属性和过滤条件值。

  10. 点击预览匹配的发现结果

    表会显示与您的查询匹配的发现结果。

  11. 点击保存

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:忽略规则的说明,不超过 1024 个字符。
    • 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:忽略规则的说明(最多 1024 个字符)
  • FILTER:您定义来过滤发现结果的表达式

    例如,如需忽略 OPEN_FIREWALL 发现结果,您的过滤条件可以是 "category=\"OPEN_FIREWALL\""

  • MUTE_TYPE:您要创建的忽略规则的类型。有效的忽略规则类型为 DYNAMICSTATIC。您无法在创建后更改忽略规则的类型。

  • TIMESTAMP:仅在您创建动态忽略规则时适用。表示动态忽略规则何时到期的日期/时间字符串。该值必须设置为至少未来一天,否则请求将被拒绝。如需了解时间格式,请参阅 gcloud topic datetimes。动态忽略规则到期后,系统会将其从所有匹配的结果中移除。如果您希望动态忽略规则对匹配的发现结果无限期地起作用,请省略此字段。

响应包括忽略配置 ID,您可以使用该 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 设置页面中的忽略规则标签页。

    转到“忽略规则”

  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 设置页面中的忽略规则标签页。

    转到“忽略规则”

  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 设置页面中的忽略规则标签页。

    转到“忽略规则”

  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 设置页面中的忽略规则标签页。

    转到“忽略规则”

  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. 查询编辑器字段中,将现有忽略语句替换为以下内容:

    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. 查询编辑器字段中,将现有忽略语句替换为以下内容:

    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 控制台中查看已忽略的发现结果

您可以在 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 个字符之间。

如需详细了解如何修改发现结果查询,请参阅在信息中心内创建或修改发现结果查询

与忽略相关的发现结果属性

本部分列出了与发现结果的忽略状态相关的发现结果属性,并介绍了忽略操作对它们的影响:

  • mute:在创建发现结果时设置为 UNDEFINED 并在以下情况下进行更改:
    • MUTED:发现结果被手动忽略或通过忽略规则忽略。
    • UNMUTED:用户取消忽略发现结果。
  • muteUpdateTime:发现结果被忽略或取消忽略的时间
  • muteInitiator:忽略发现结果的主账号或忽略规则的标识符。
  • muteInfo:有关发现结果的忽略信息,例如忽略规则类型(静态或动态)以及发现结果匹配的忽略规则。
  • muteInfo.staticMute:静态忽略状态会替换适用于此发现结果的任何动态忽略规则。
    • state:静态忽略状态,可以通过直接忽略发现结果或静态忽略规则来设置。
    • applyTime:对发现结果应用静态忽略状态的时间。
  • muteInfo.dynamicMuteRecords:与发现结果匹配的动态忽略规则的记录。
    • muteConfig: 忽略规则的相对资源名称,由创建该记录的忽略配置表示。例如 organizations/123/muteConfigs/examplemuteconfig
    • matchTime:动态忽略规则与发现结果匹配的时间。

停止已忽略的发现结果的通知和导出

如果您启用发现结果通知,则与通知过滤条件匹配的新的或更新的已忽略发现结果仍会导出到 Pub/Sub。

如需停止已忽略的发现结果的导出和通知,请在 NotificationConfig 过滤条件中使用 mute 属性来排除已忽略的发现结果。 例如,以下过滤条件仅发送有关未忽略或未设置忽略特性的有效发现结果的通知:

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

后续步骤

详细了解如何过滤发现结果通知

浏览您可以使用的更多过滤条件示例