

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 为 Security Hub CSPM 发现配置 EventBridge 规则
<a name="securityhub-cwe-all-findings"></a>

您可以在 Amazon 中创建规则 EventBridge ，定义在收到**Security Hub Findings - Imported**事件时要采取的操作。 **Security Hub Findings - Imported**事件由[https://docs.aws.amazon.com//securityhub/1.0/APIReference/API_BatchImportFindings.html](https://docs.aws.amazon.com//securityhub/1.0/APIReference/API_BatchImportFindings.html)和[https://docs.aws.amazon.com//securityhub/1.0/APIReference/API_BatchUpdateFindings.html](https://docs.aws.amazon.com//securityhub/1.0/APIReference/API_BatchUpdateFindings.html)操作的更新触发。

每条规则都包含一个事件模式，用于标识触发规则的事件。事件模式始终包含事件源（`aws.securityhub`）和事件类型（**Security Hub 调查发现 - 已导入**）。事件模式还可以指定筛选条件来识别规则适用的调查发现。

然后，该事件规则用于确定规则目标。目标是在 EventBridge 收到 Sec **urity Hub Findings-Imported 事件并且发现结果**与筛选器匹配时要采取的操作。

此处提供的说明使用 EventBridge 控制台。当您使用控制台时， EventBridge会自动创建所需的基于资源的策略， EventBridge 以允许写入 Amazon CloudWatch Logs。

您也可以使用 EventBridge API 的[https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_PutRule.html](https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_PutRule.html)操作。但是，如果您使用 EventBridge API，则必须创建基于资源的策略。有关所需策略的信息，请参阅 *Amazon EventBridge 用户指南*中的[CloudWatch 日志权限](https://docs.aws.amazon.com/eventbridge/latest/userguide/resource-based-policies-eventbridge.html#cloudwatchlogs-permissions)。

## 事件模式的格式
<a name="securityhub-cwe-all-findings-rule-format"></a>

**Security Hub 调查发现 - 已导入**事件的事件模式格式如下：

```
{
  "source": [
    "aws.securityhub"
  ],
  "detail-type": [
    "Security Hub Findings - Imported"
  ],
  "detail": {
    "findings": {
      <attribute filter values>
    }
  }
}
```
+ `source` 将 Security Hub CSPM 标识为生成事件的服务。
+ `detail-type` 标识事件的类型。
+ `detail` 是可选的，它提供了事件模式的筛选条件值。如果事件模式不包含 `detail` 字段，则所有调查发现都会触发规则。

您可以根据任何调查发现属性筛选调查发现。您可以为每个属性提供一个或多个值的逗号分隔的数组。

```
"<attribute name>": [ "<value1>", "<value2>"]
```

如果您为一个属性提供多个值，则这些值将通过 `OR` 连接在一起。如果调查发现包含任何列出的值，则该调查发现与单个属性的筛选条件相匹配。例如，如果您同时提供 `INFORMATIONAL` 和 `LOW` 作为 `Severity.Label` 的值，则如果调查发现的严重性标签为 `INFORMATIONAL` 或 `LOW`，则调查发现将匹配。

属性的连接方式为 `AND`。如果调查发现与所有提供的属性的筛选条件相匹配，则该调查发现与之匹配。

提供属性值时，它必须反映该属性在 AWS 安全调查结果格式 (ASFF) 结构中的位置。

**提示**  
筛选控件调查发现时，我们建议使用 `SecurityControlId` 或 `SecurityControlArn` [ASFF 字段](securityhub-findings-format.md)作为筛选条件，而不是 `Title` 或 `Description`。后面的字段偶尔会发生变化，而控件 ID 和 ARN 是静态标识符。

在以下示例中，事件模式为 `ProductArn` 和 `Severity.Label` 提供了筛选值，因此，如调查发现由 Amazon Inspector 生成，并且其严重性标签为 `INFORMATIONAL` 或 `LOW`，则调查发现与之匹配。

```
{
    "source": [
        "aws.securityhub"
     ],
    "detail-type": [
        "Security Hub Findings - Imported"
    ],
    "detail": {
        "findings": {
            "ProductArn": ["arn:aws:securityhub:us-east-1::product/aws/inspector"],
            "Severity": {
                "Label": ["INFORMATIONAL", "LOW"]
            }
        }
    }
}
```

## 创建事件规则
<a name="securityhub-cwe-all-findings-predefined-pattern"></a>

您可以使用预定义的事件模式或自定义的事件模式在中创建规则 EventBridge。如果您选择预定义的图案，则 EventBridge 会自动填充`source`和`detail-type`。 EventBridge 还提供了用于为以下查找结果属性指定筛选值的字段：
+ `AwsAccountId`
+ `Compliance.Status`
+ `Criticality`
+ `ProductArn`
+ `RecordState`
+ `ResourceId`
+ `ResourceType`
+ `Severity.Label`
+ `Types`
+ `Workflow.Status`

**创建 EventBridge 规则（控制台）**

1. 打开 Amazon EventBridge 控制台，网址为[https://console.aws.amazon.com/events/](https://console.aws.amazon.com/events/)。

1. 使用以下值创建监控查找事件的 EventBridge 规则：
   + 对于**规则类型**，选择**具有事件模式的规则**。
   + 选择如何构建事件模式。    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/securityhub/latest/userguide/securityhub-cwe-all-findings.html)
   + 对于**目标类型**，选择**AWS 服务**，在选择目标**中，选择目标**，例如 Amazon SNS 主题或 AWS Lambda 函数。在收到与规则中定义的事件模式匹配的事件时将触发目标。

   有关创建规则的详细信息，请参阅《[亚马逊 EventBridge 用户指南 EventBridge》中的创建对事件做出反应](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-create-rule.html)*的 Amazon* 规则。