

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

# 使用 Amazon EventBridge 建立對 Amazon Inspector 調查結果的自訂回應 EventBridge
<a name="findings-managing-automating-responses"></a>

 Amazon Inspector 在 [Amazon EventBridge](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-what-is.html) 中為新產生的調查結果和彙總調查結果建立事件。Amazon Inspector 也會為調查結果狀態的任何變更建立事件。這表示當您採取重新啟動資源或變更與資源相關聯的標籤等動作時，Amazon Inspector 會為調查結果建立新的事件。當 Amazon Inspector 為更新的問題清單建立新事件時，問題清單會`id`保持不變。

**注意**  
 如果您的帳戶是 Amazon Inspector 委派的管理員帳戶，EventBridge 會將事件發佈到您的帳戶和產生事件的成員帳戶。

 搭配 Amazon Inspector 使用 EventBridge 事件時，您可以自動化任務，協助您回應問題清單顯示的安全性問題。若要根據 EventBridge 事件接收有關 Amazon Inspector 調查結果的通知，您必須[建立 EventBridge 規則](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-rules.html)並指定 Amazon Inspector 的目標。EventBridge 規則允許 EventBridge 傳送 Amazon Inspector 調查結果的通知，而目標指定通知的傳送位置。

 Amazon Inspector 會在您目前使用 Amazon Inspector AWS 區域 的 中，將事件發送到預設事件匯流排。這表示您必須為啟用 Amazon Inspector 的每個 AWS 區域 設定事件規則，並將 Amazon Inspector 設定為接收 EventBridge 事件。Amazon Inspector 會盡力發出事件。

 本節提供您事件結構描述的範例，並說明如何建立 EventBridge 規則。

## 事件結構描述
<a name="findings-managing-eventbridge-format"></a>

以下是 EC2 調查結果事件的 Amazon Inspector 事件格式範例。如需其他問題清單類型和事件類型的結構描述範例，請參閱 [Amazon Inspector 事件的 Amazon EventBridge 事件結構描述](eventbridge-integration.md)。

```
{
    "version": "0",
    "id": "66a7a279-5f92-971c-6d3e-c92da0950992",
    "detail-type": "Inspector2 Finding",
    "source": "aws.inspector2",
    "account": "111122223333",
    "time": "2023-01-19T22:46:15Z",
    "region": "us-east-1",
    "resources": ["i-0c2a343f1948d5205"],
    "detail": {
        "awsAccountId": "111122223333",
        "description": "\n It was discovered that the sound subsystem in the Linux kernel contained a\n race condition in some situations. A local attacker could use this to cause\n a denial of service (system crash).",
        "exploitAvailable": "YES",
        "exploitabilityDetails": {
            "lastKnownExploitAt": "Oct 24, 2022, 11:08:59 PM"
        },
        "findingArn": "arn:aws:inspector2:us-east-1:111122223333:finding/FINDING_ID",
        "firstObservedAt": "Jan 19, 2023, 10:46:15 PM",
        "fixAvailable": "YES",
        "lastObservedAt": "Jan 19, 2023, 10:46:15 PM",
        "packageVulnerabilityDetails": {
            "cvss": [{
                "baseScore": 4.7,
                "scoringVector": "CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:H",
                "source": "NVD",
                "version": "3.1"
            }],
            "referenceUrls": ["https://lore.kernel.org/all/CAFcO6XN7JDM4xSXGhtusQfS2mSBcx50VJKwQpCq=WeLt57aaZA@mail.gmail.com/", "https://ubuntu.com/security/notices/USN-5792-1", "https://ubuntu.com/security/notices/USN-5791-2", "https://ubuntu.com/security/notices/USN-5791-1", "https://ubuntu.com/security/notices/USN-5793-2", "https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8423f0b6d513b259fdab9c9bf4aaa6188d054c2d", "https://ubuntu.com/security/notices/USN-5793-1", "https://ubuntu.com/security/notices/USN-5792-2", "https://ubuntu.com/security/notices/USN-5791-3", "https://ubuntu.com/security/notices/USN-5793-4", "https://ubuntu.com/security/notices/USN-5793-3", "https://git.kernel.org/linus/8423f0b6d513b259fdab9c9bf4aaa6188d054c2d(6.0-rc5)", "https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-3303"],
            "relatedVulnerabilities": [],
            "source": "UBUNTU_CVE",
            "sourceUrl": "https://people.canonical.com/~ubuntu-security/cve/2022/CVE-2022-3303.html",
            "vendorCreatedAt": "Sep 27, 2022, 11:15:00 PM",
            "vendorSeverity": "medium",
            "vulnerabilityId": "CVE-2022-3303",
            "vulnerablePackages": [{
                "arch": "X86_64",
                "epoch": 0,
                "fixedInVersion": "0:5.15.0.1027.31~20.04.16",
                "name": "linux-image-aws",
                "packageManager": "OS",
                "remediation": "apt update && apt install --only-upgrade linux-image-aws",
                "version": "5.15.0.1026.30~20.04.16"
            }]
        },
        "remediation": {
            "recommendation": {
                "text": "None Provided"
            }
        },
        "resources": [{
            "details": {
                "awsEc2Instance": {
                    "iamInstanceProfileArn": "arn:aws:iam::111122223333:instance-profile/AmazonSSMRoleForInstancesQuickSetup",
                    "imageId": "ami-0b7ff1a8d69f1bb35",
                    "ipV4Addresses": ["172.31.85.212", "44.203.45.27"],
                    "ipV6Addresses": [],
                    "launchedAt": "Jan 19, 2023, 7:53:14 PM",
                    "platform": "UBUNTU_20_04",
                    "subnetId": "subnet-8213f2a3",
                    "type": "t2.micro",
                    "vpcId": "vpc-ab6650d1"
                }
            },
            "id": "i-0c2a343f1948d5205",
            "partition": "aws",
            "region": "us-east-1",
            "type": "AWS_EC2_INSTANCE"
        }],
        "severity": "MEDIUM",
        "status": "ACTIVE",
        "title": "CVE-2022-3303 - linux-image-aws",
        "type": "PACKAGE_VULNERABILITY",
        "updatedAt": "Jan 19, 2023, 10:46:15 PM"
    }
}
```

## 建立 EventBridge 規則以通知您 Amazon Inspector 問題清單
<a name="findings-managing-eventbridge-tutorial"></a>

若要提高 Amazon Inspector 問題清單的可見性，您可以使用 EventBridge 設定傳送至訊息中樞的自動問題清單提醒。本主題說明如何將 `CRITICAL`和`HIGH`嚴重性問題清單的提醒傳送至電子郵件、Slack 或 Amazon Chime。您將了解如何設定 Amazon Simple Notification Service 主題，然後將該主題連線至 EventBridge 事件規則。

### 步驟 1. 設定 Amazon SNS 主題和端點
<a name="findings-managing-eventbridge-tutorial-SNS"></a>

若要設定自動提醒，您必須先在 Amazon Simple Notification Service 中設定主題，並新增端點。如需詳細資訊，請參閱 [SNS 指南](https://docs.aws.amazon.com//sns/latest/dg/sns-getting-started.html)。

此程序會建立您要傳送 Amazon Inspector 調查結果資料的位置。SNS 主題可以在建立事件規則期間或之後新增至 EventBridge 事件規則。

------
#### [ Email setup ]

**建立 SNS 主題**

1. 登入 Amazon SNS 主控台，網址為 [https://console.aws.amazon.com/sns/v3/home](https://console.aws.amazon.com/sns/v3/home)。

1. 從導覽窗格中，選取**主題**，然後選取**建立主題**。

1. 在**建立主題**區段中，選取**標準**。接著，輸入主題名稱，例如 **Inspector\_to\_Email**。其他詳細資料是選擇性的。

1. 選擇**建立主題**。這會開啟包含新主題詳細資訊的新面板。

1. 在**訂閱**區段中，選取**建立訂閱**。

1. 

   1. 從**通訊協定**功能表中，選取**電子郵件**。

   1. 在**端點**欄位中，輸入您要接收通知的電子郵件地址。
**注意**  
建立訂閱後，您需要透過電子郵件用戶端確認您的訂閱。

   1. 選擇**建立訂閱**。

1. 在收件匣中尋找訂閱訊息，然後選擇**確認訂閱**。

------
#### [ Slack setup ]

**建立 SNS 主題**

1. 登入 Amazon SNS 主控台，網址為 [https://console.aws.amazon.com/sns/v3/home](https://console.aws.amazon.com/sns/v3/home)。

1. 從導覽窗格中，選取**主題**，然後選取**建立主題**。

1. 在**建立主題**區段中，選取**標準**。接著，輸入主題名稱，例如 **Inspector\_to\_Slack**。其他詳細資料是選擇性的。選擇**建立主題**以完成端點建立。

**在聊天應用程式用戶端中設定 Amazon Q Developer**

1. 在 的聊天應用程式主控台中導覽至 Amazon Q Developer[https://console.aws.amazon.com/chatbot/](https://console.aws.amazon.com/chatbot/)。

1. 從**已設定的用戶端**窗格中，選取**設定新的用戶端**。

1. 選擇 **Slack**，然後選擇**設定**以確認。
**注意**  
選擇 Slack 時，您必須選取**允許**，確認聊天應用程式中 Amazon Q Developer 存取頻道的許可。

1. 選取**設定新頻道**以開啟組態詳細資訊窗格。

   1. 輸入頻道的名稱。

   1. 針對 **Slack 頻道**，選擇您要使用的頻道。

   1. 在 Slack 中，在頻道名稱上按一下滑鼠右鍵，然後選取複製**連結**，以複製私有頻道的頻道 ID。

   1. 在聊天應用程式視窗中 AWS 管理主控台的 Amazon Q Developer 中，將您從 Slack 複製的頻道 ID 貼到**私有頻道 ID **欄位。

   1. 在**許可**中，如果您還沒有角色，請選擇使用範本建立 IAM 角色。

   1. 針對**政策**範本，選擇**通知許可**。這是聊天應用程式中 Amazon Q Developer 的 IAM 政策範本。此政策為 CloudWatch 警示、事件和日誌以及 Amazon SNS 主題提供必要的讀取和清單許可。

   1. 針對**頻道護欄政策**，選擇 **AmazonInspector2ReadOnlyAccess**。

   1. 選擇您先前建立 SNS 主題的區域，然後選取您建立的 Amazon SNS 主題，將通知傳送至 Slack 頻道。

1. 選取**設定**。

------
#### [ Amazon Chime setup ]

**建立 SNS 主題**

1. 登入 Amazon SNS 主控台，網址為 [https://console.aws.amazon.com/sns/v3/home](https://console.aws.amazon.com/sns/v3/home)。

1. 從導覽窗格中選取**主題**，然後選取**建立主題**。

1. 在**建立主題**區段中，選取**標準**。接著，輸入主題名稱，例如 **Inspector\_to\_Chime**。其他詳細資料是選擇性的。選擇**建立主題**以完成。

**在聊天應用程式用戶端中設定 Amazon Q Developer**

1. 在 的聊天應用程式主控台中導覽至 Amazon Q Developer[https://console.aws.amazon.com/chatbot/](https://console.aws.amazon.com/chatbot/)。

1. 從**設定的用戶端**面板中，選取**設定新用戶端**。

1. 選擇 **Chime**，然後選擇**設定**以確認。

1. 在**組態詳細資訊**窗格中，輸入頻道的名稱。

1. 在 Amazon Chime 中，開啟所需的聊天室。

   1. 選擇右上角的齒輪圖示，然後選擇**管理 Webhook 和機器人**。

   1. 選取**複製 URL**，將 Webhook URL 複製到剪貼簿。

1. 在聊天應用程式視窗中 AWS 管理主控台的 Amazon Q Developer 中，將您複製的 URL 貼到 **Webhook URL** 欄位中。

1. 在**許可**中，如果您還沒有角色，請選擇使用範本建立 IAM 角色。

1. 針對**政策**範本，選擇**通知許可**。這是聊天應用程式中 Amazon Q Developer 的 IAM 政策範本。它為 CloudWatch 警示、事件和日誌以及 Amazon SNS 主題提供必要的讀取和清單許可。

1. 選擇您先前建立 SNS 主題的區域，然後選取您建立的 Amazon SNS 主題，將通知傳送至 Amazon Chime 會議室。

1. 選取**設定**。

------

### 步驟 2. 為 Amazon Inspector 調查結果建立 EventBridge 規則
<a name="findings-managing-eventbridge-tutorial-event-setup"></a>

1.  使用您的 登入資料登入。

1. 前往 [https://console.aws.amazon.com/events/](https://console.aws.amazon.com/events/) 開啟 Amazon EventBridge 主控台。

1. 從導覽窗格中選取**規則**，然後選取**建立規則**。

1. 輸入規則的名稱和選用描述。

1. 選取**具有事件模式的規則**，然後選取**下一步**。

1. 在**事件模式**窗格中，選擇**自訂模式 (JSON 編輯器）**。

1. 將以下 JSON 貼至編輯器中。

   ```
   {
     "source": ["aws.inspector2"],
     "detail-type": ["Inspector2 Finding"],
     "detail": {
       "severity": ["HIGH", "CRITICAL"],
       "status": ["ACTIVE"]
     }
   }
   ```
**注意**  
此模式會針對 Amazon Inspector 偵測到的任何作用中`CRITICAL`或`HIGH`嚴重性調查結果傳送通知。

   當您完成進入事件模式時，請選取**下一步**。

1. 在**選取目標**頁面上，選擇 **AWS 服務**。然後，針對**選取目標類型**，選擇 **SNS 主題**。

1. 針對**主題**，選取您在步驟 1 中建立的 SNS 主題名稱。然後選擇**下一步**。

1. 視需要新增選用標籤，然後選擇**下一步**。

1. 檢閱您的規則，然後選擇**建立規則**。

## 適用於 Amazon Inspector 多帳戶環境的 EventBridge
<a name="findings-managing-eventbridge-multiaccount"></a>

如果您是 Amazon Inspector 委派管理員，根據成員帳戶的適用調查結果，EventBridge 規則會顯示在您的帳戶上。如果您在管理員帳戶中透過 EventBridge 設定問題清單通知，如上節所述，您將會收到多個帳戶的通知。換句話說，除了您自有帳戶產生的問題清單和事件之外，您還會收到成員帳戶產生的問題清單和事件通知。

您可以使用調查結果的 JSON 詳細資訊`accountId`中的 來識別產生 Amazon Inspector 調查結果的成員帳戶。