

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 為 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 收到 **Security Hub 調查結果 - 匯入**的事件，且調查結果符合篩選條件時，目標為要採取的動作。

此處提供的指示使用 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 Logs 許可](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. 前往 [https://console.aws.amazon.com/events/](https://console.aws.amazon.com/events/) 開啟 Amazon EventBridge 主控台。

1. 使用下列值，建立 EventBridge 規則來監控調查結果事件：
   + 針對**規則類型**，選擇**具有事件模式的規則**。
   + 選擇如何建置事件模式。    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/securityhub/latest/userguide/securityhub-cwe-all-findings.html)
   + 對於**目標類型**，請選擇**AWS 服務**，對於**選取目標**，選擇目標，例如 Amazon SNS 主題或 AWS Lambda 函數。當接收到符合規則中定義之事件模式的事件時，就會觸發目標。

   如需建立規則的詳細資訊，請參閱《[Amazon EventBridge 使用者指南》中的建立對事件做出反應的](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-create-rule.html) *Amazon EventBridge *規則。