建立及管理 Event Threat Detection 自訂模組

本頁說明如何建立及管理 Event Threat Detection 的自訂模組。

事前準備

本節說明使用 Event Threat Detection 自訂模組的相關規定。

Security Command Center Premium 和 Event Threat Detection

如要使用 Event Threat Detection 自訂模組,必須啟用 Event Threat Detection。如要啟用 Event Threat Detection,請參閱「啟用或停用內建服務」。

必要 IAM 角色和權限

IAM 角色會決定您可以使用 Event Threat Detection 自訂模組執行的動作。

下表列出必要的 Event Threat Detection 自訂模組權限,以及包含這些權限的預先定義 IAM 角色。

您可以使用 Google Cloud 控制台或 Security Command Center API,在機構、資料夾或專案層級套用這些角色。

必要權限 角色
securitycentermanagement.eventThreatDetectionCustomModules.create
securitycentermanagement.eventThreatDetectionCustomModules.update
securitycentermanagement.eventThreatDetectionCustomModules.delete
roles/securitycentermanagement.etdCustomModulesEditor
roles/securitycenter.settingsEditor
roles/securitycenter.admin
securitycentermanagement.eventThreatDetectionCustomModules.list
securitycentermanagement.eventThreatDetectionCustomModules.get
securitycentermanagement.effectiveEventThreatDetectionCustomModules.list
securitycentermanagement.effectiveEventThreatDetectionCustomModules.get
securitycentermanagement.eventThreatDetectionCustomModules.validate
roles/securitycentermanagement.etdCustomModulesViewer
roles/securitycentermanagement.etdCustomModulesEditor
roles/securitycenter.adminViewer
roles/securitycenter.admin

如果在 Security Command Center 中遇到存取錯誤,請向管理員尋求協助。視您啟用 Security Command Center 的層級而定,請參閱下列其中一個頁面:

必要記錄

請確認貴機構、資料夾和專案已啟用相關記錄。如要瞭解各個自訂模組類型需要哪些記錄,請參閱「自訂模組和範本」一文中的表格。

系統不支援 Google Cloud 以外來源的記錄。

自訂模組層級

本文使用下列術語,說明自訂模組的建立層級:

住宅模組
模組是在目前的檢視畫面或範圍中建立。舉例來說,如果您位於 Google Cloud 控制台的機構檢視畫面,住宅模組就是機構層級建立的模組。
繼承的模組
模組是在父項檢視區塊或範圍中建立。舉例來說,在機構層級建立的模組,在任何資料夾或專案層級都是沿用模組。
子系模組
模組是在孩童檢視模式或範圍建立。舉例來說,在資料夾或專案層級建立的模組,在機構層級中是子代模組。

建立自訂模組

您可以透過Google Cloud 控制台建立 Event Threat Detection 自訂模組,也可以修改 JSON 範本,然後透過 gcloud CLI 提交。如果您打算使用 gcloud CLI 建立自訂模組,才需要 JSON 範本。

如需支援的模組範本清單,請參閱「自訂模組和範本」。

範本結構

範本會定義自訂模組用來識別記錄中威脅的參數。範本是以 JSON 格式編寫,結構與 Security Command Center 產生的發現項目類似。如果您打算使用 gcloud CLI 建立自訂模組,才需要設定 JSON 範本。

每份範本都包含可自訂的欄位:

  • severity:您要指派給這類發現項目 (LOWMEDIUMHIGHCRITICAL) 的嚴重程度或風險等級。
  • description:自訂模組的說明。
  • recommendation:解決自訂模組產生結果的建議動作。
  • 偵測參數:用於評估記錄及觸發結果的變數。每個模組的偵測參數各不相同,但包含下列一或多項參數:
    • domains:要監看的網域
    • ips:要監控的 IP 位址
    • permissions:要監看的權限
    • regions:允許建立新 Compute Engine 執行個體的區域
    • roles:要監看的角色
    • accounts:要監控的帳戶
    • 定義允許的 Compute Engine 執行個體類型參數,例如 seriescpusram_mb
    • 用來檢查屬性的規則運算式,例如 caller_patternresource_pattern

下列程式碼範例是 Configurable Bad IP 的 JSON 範本。

{
  "metadata": {
    "severity": "LOW",
    "description": "Flagged by Cymbal as malicious",
    "recommendation": "Contact the owner of the relevant project."
  },
  "ips": [
    "192.0.2.1",
    "192.0.2.0/24"
  ]
}

在上述範例中,如果記錄檔指出資源已連線至 IP 位址 192.0.2.1192.0.2.0/24,自訂模組就會產生嚴重程度偏低的發現結果。

修改模組範本

如要建立模組,請選擇模組範本並加以修改。

如果您打算使用 Google Cloud CLI 建立自訂模組,就必須執行這項工作。

如果您打算使用 Google Cloud 控制台建立自訂模組,請略過這項工作。您可以使用畫面上的選項修改範本的參數。

  1. 從「自訂模組和範本」中選擇範本。
  2. 將程式碼複製到本機檔案。
  3. 更新要用來評估記錄的參數。
  4. 將檔案儲存為 JSON 檔案。
  5. 使用 JSON 檔案,透過 gcloud CLI 建立自訂模組

建立自訂模組

本節說明如何透過Google Cloud 控制台、gcloud CLI、REST API 和 Terraform 建立自訂模組。每個 Event Threat Detection 自訂模組的大小上限為 6 MB。

如要建立自訂模組,請按照下列步驟操作:

控制台

  1. 查看模組 Event Threat Detection 服務。預先定義和自訂的模組會顯示在清單中。
  2. 按一下「建立模組」
  3. 按一下要使用的模組範本。
  4. 按一下「選取」
  5. 在「Module name」(模組名稱) 部分,輸入新範本的顯示名稱。名稱長度不得超過 128 個半形字元,且只能包含英數字元和底線,例如 example_custom_module
  6. 選取或新增要求的參數值。每個模組的參數都不相同。舉例來說,如果您選取 Configurable allowed Compute Engine region 模組範本,請選取一或多個區域。 或者,以 JSON 格式提供清單。
  7. 點選「下一步」
  8. 在「嚴重程度」部分,輸入要指派給新自訂模組所產生結果的嚴重程度等級。
  9. 在「說明」中,輸入新自訂模組的說明。
  10. 在「後續步驟」中,以純文字格式輸入建議採取的行動。 系統會忽略您新增的任何段落分隔符。
  11. 點選「建立」

gcloud

gcloud scc manage custom-modules etd create 指令會為機構、資料夾或專案建立 Event Threat Detection 自訂模組。

使用下列任何指令資料之前,請先替換以下項目:

  • RESOURCE_TYPE:自訂模組所屬的資源類型 (organizationfolderproject)
  • RESOURCE_ID:自訂模組的機構、資料夾或專案的數字 ID。如果是專案,您也可以使用英數專案 ID。
  • MODULE_CONFIG:自訂模組的設定。使用自訂模組範本做為起點。
  • MODULE_TYPE:自訂模組的類型。如需支援的類型清單,請參閱「自訂模組和範本」。
  • MODULE_DISPLAY_NAME:自訂模組的顯示名稱,可包含英文字母、數字和底線 (_),最多 128 個字元。

將下列內容儲存到名為 request.json 的檔案:

{
  MODULE_CONFIG
}

執行 gcloud scc manage custom-modules etd create 指令:

Linux、macOS 或 Cloud Shell

gcloud scc manage custom-modules etd create \
    --RESOURCE_TYPE=RESOURCE_ID \
    --custom-config-file=request.json \
    --display-name=MODULE_DISPLAY_NAME \
    --module-type=MODULE_TYPE \
    --enablement-state=ENABLED

Windows (PowerShell)

gcloud scc manage custom-modules etd create `
    --RESOURCE_TYPE=RESOURCE_ID `
    --custom-config-file=request.json `
    --display-name=MODULE_DISPLAY_NAME `
    --module-type=MODULE_TYPE `
    --enablement-state=ENABLED

Windows (cmd.exe)

gcloud scc manage custom-modules etd create ^
    --RESOURCE_TYPE=RESOURCE_ID ^
    --custom-config-file=request.json ^
    --display-name=MODULE_DISPLAY_NAME ^
    --module-type=MODULE_TYPE ^
    --enablement-state=ENABLED

REST

Security Command Center Management API 的 RESOURCE_TYPE.locations.eventThreatDetectionCustomModules.create 方法會為機構、資料夾或專案建立 Event Threat Detection 自訂模組。

使用任何要求資料之前,請先修改下列項目的值:

  • RESOURCE_TYPE:自訂模組所屬的資源類型 (organizationsfoldersprojects)。
  • QUOTA_PROJECT:用於帳單和配額追蹤的專案 ID。
  • RESOURCE_ID:自訂模組的機構、資料夾或專案的數字 ID。如果是專案,您也可以使用英數專案 ID。
  • MODULE_CONFIG:自訂模組的設定。使用自訂模組範本做為起點。
  • MODULE_TYPE:自訂模組的類型。如需支援的類型清單,請參閱「自訂模組和範本」。
  • MODULE_DISPLAY_NAME:自訂模組的顯示名稱,可包含英文字母、數字和底線 (_),最多 128 個字元。

HTTP 方法和網址:

POST https://securitycentermanagement.googleapis.com/v1/RESOURCE_TYPE/RESOURCE_ID/locations/global/eventThreatDetectionCustomModules

JSON 要求主體:

{
  "config": MODULE_CONFIG,
  "enablementState": "ENABLED",
  "type": "MODULE_TYPE",
  "displayName": "MODULE_DISPLAY_NAME"
}

請展開以下其中一個選項,以傳送要求:

您應該會收到如下的 JSON 回覆:

{
  "name": "projects/1234567890123/locations/global/eventThreatDetectionCustomModules/98765432109876543210",
  "config": {
    "metadata": {
      "severity": "MEDIUM",
      "description": "An IAM custom role contains permissions that aren't allowed.",
      "recommendation": "Remove the permissions from the custom role."
    },
    "permissions": [
      "accessapproval.requests.get",
      "accessapproval.requests.invalidate",
      "accessapproval.requests.list",
      "accessapproval.settings.delete"
    ]
  },
  "enablementState": "ENABLED",
  "type": "CONFIGURABLE_CUSTOM_ROLE_WITH_PROHIBITED_PERMISSION",
  "displayName": "iam_custom_role_prohibited_permissions",
  "updateTime": "2026-03-16T19:44:58.588134Z"
}

Terraform

如要瞭解如何套用或移除 Terraform 設定,請參閱「基本 Terraform 指令」。詳情請參閱 Terraform 供應商參考文件

resource "google_scc_management_organization_event_threat_detection_custom_module" "example" {
  organization = "123456789"
  location = "global"
  display_name = "basic_custom_module"
  enablement_state = "ENABLED"
  type = "CONFIGURABLE_BAD_IP"
  description = "My Event Threat Detection Custom Module"
  config = jsonencode({
    "metadata": {
      "severity": "LOW",
      "description": "Flagged by Forcepoint as malicious",
      "recommendation": "Contact the owner of the relevant project."
    },
    "ips": [
      "192.0.2.1",
      "192.0.2.0/24"
    ]
  })
}

系統會建立自訂模組並開始掃描。如要刪除模組,請參閱「刪除自訂模組」。

自訂模組的類別名稱包含模組類型的發現項目類別,以及您設定的模組顯示名稱。舉例來說,自訂模組的類別名稱可以是 Unexpected Compute Engine Region: example_custom_module。在 Google Cloud 控制台中,底線會顯示為空格。不過,您必須在查詢中加入底線。

配額 會控管您使用 Event Threat Detection 自訂模組的情況。

偵測延遲

如要瞭解 Event Threat Detection 和所有其他內建 Security Command Center 服務的偵測延遲時間,請參閱「掃描延遲時間」。

查看結果

您可以在 Google Cloud 控制台查看自訂模組產生的調查結果,也可以使用 gcloud CLI 或 REST API 查看。

控制台

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

    前往「發現項目」

  2. 選取 Google Cloud 專案或機構。
  3. 在「快速篩選器」部分的「來源顯示名稱」子部分,選取「Event Threat Detection Custom Modules」。發現項目查詢結果會更新,只顯示來自這個來源的發現項目。
  4. 如要查看特定發現項目的詳細資料,請按一下「類別」欄中的發現項目名稱。 系統會開啟發現項目的詳細資料面板,並顯示「摘要」分頁。
  5. 在「摘要」分頁中,查看發現項目的詳細資料,包括偵測到的內容、受影響的資源,以及 (如適用) 可採取哪些步驟修正發現項目。
  6. 選用:如要查看發現項目的完整 JSON 定義,請按一下「JSON」分頁。

gcloud

找出來源 ID

gcloud scc sources describe 指令會顯示 Security Command Center 發現項目來源的相關資訊。

使用下列任何指令資料之前,請先替換以下項目:

  • RESOURCE_TYPE:來源所屬的資源類型 (organizationsfoldersprojects)。
  • RESOURCE_ID:機構、資料夾或專案的數字 ID。如果是專案,您也可以使用英數專案 ID。

執行 gcloud scc sources describe 指令:

Linux、macOS 或 Cloud Shell

gcloud scc sources describe RESOURCE_TYPE/RESOURCE_ID \
    --source-display-name="Event Threat Detection Custom Modules"

Windows (PowerShell)

gcloud scc sources describe RESOURCE_TYPE/RESOURCE_ID `
    --source-display-name="Event Threat Detection Custom Modules"

Windows (cmd.exe)

gcloud scc sources describe RESOURCE_TYPE/RESOURCE_ID ^
    --source-display-name="Event Threat Detection Custom Modules"

您應該會收到類似以下的回應:

canonicalName: organizations/123456789012/sources/98765432109876543210
description: Provider used by Event Threat Detection Custom Modules
displayName: Event Threat Detection Custom Modules
name: organizations/123456789012/sources/98765432109876543210

來源 ID 是 canonicalNamename 欄位結尾的數值,例如 98765432109876543210

列出 Event Threat Detection 自訂模組的所有發現項目

gcloud scc findings list 指令會列出特定位置中來源的發現項目。

使用下列任何指令資料之前,請先替換以下項目:

  • RESOURCE_TYPE:要取得的資源類型 (organizationsfoldersprojects)。
  • RESOURCE_ID:要取得的機構、資料夾或專案的數字 ID。如果是專案,您也可以使用英數專案 ID。
  • LOCATION:要使用的Security Command Center 位置,例如 eu。如果未啟用資料落地設定,請使用 global
  • SOURCE_ID:發現項目來源的數值 ID。

執行下列指令:

Linux、macOS 或 Cloud Shell

gcloud scc findings list RESOURCE_TYPE/RESOURCE_ID \
    --source=SOURCE_ID \
    --location=LOCATION

Windows (PowerShell)

gcloud scc findings list RESOURCE_TYPE/RESOURCE_ID `
    --source=SOURCE_ID `
    --location=LOCATION

Windows (cmd.exe)

gcloud scc findings list RESOURCE_TYPE/RESOURCE_ID ^
    --source=SOURCE_ID ^
    --location=LOCATION

回覆會包含調查結果清單。

列出特定自訂模組的發現項目

gcloud scc findings list 指令會列出特定位置中來源的發現項目。

使用下列任何指令資料之前,請先替換以下項目:

  • RESOURCE_TYPE:要取得的資源類型 (organizationsfoldersprojects)。
  • RESOURCE_ID:要取得的機構、資料夾或專案的數字 ID。如果是專案,您也可以使用英數專案 ID。
  • LOCATION:要使用的Security Command Center 位置,例如 eu。如果未啟用資料落地設定,請使用 global
  • SOURCE_ID:發現項目來源的數值 ID。
  • CUSTOM_MODULE_CATEGORY_NAME:自訂模組的類別名稱,由模組的發現項目類別 (如「自訂模組和範本」中所列)、半形冒號、半形空格,以及模組顯示名稱 (空格會替換為底線) 組成。例如:Unexpected Compute Engine region: example_custom_module

執行下列指令:

Linux、macOS 或 Cloud Shell

gcloud scc findings list RESOURCE_TYPE/RESOURCE_ID \
    --source=SOURCE_ID \
    --location=LOCATION \
    --filter="category=\"CUSTOM_MODULE_CATEGORY_NAME\""

Windows (PowerShell)

gcloud scc findings list RESOURCE_TYPE/RESOURCE_ID `
    --source=SOURCE_ID `
    --location=LOCATION `
    --filter="category=\"CUSTOM_MODULE_CATEGORY_NAME\""

Windows (cmd.exe)

gcloud scc findings list RESOURCE_TYPE/RESOURCE_ID ^
    --source=SOURCE_ID ^
    --location=LOCATION ^
    --filter="category=\"CUSTOM_MODULE_CATEGORY_NAME\""

回覆會包含調查結果清單。

REST

找出來源 ID

Security Command Center API 的 RESOURCE_TYPE.sources.list 方法會列出 Security Command Center 發現項目來源的相關資訊。

使用任何要求資料之前,請先修改下列項目的值:

  • RESOURCE_TYPE:父項資源的類型 (organizationsfoldersprojects)。
  • QUOTA_PROJECT:用於帳單和配額追蹤的專案 ID。
  • RESOURCE_ID:機構、資料夾或專案的數字 ID。如果是專案,您也可以使用英數專案 ID。

HTTP 方法和網址:

GET https://securitycenter.googleapis.com/v2/RESOURCE_TYPE/RESOURCE_ID/sources

請展開以下其中一個選項,以傳送要求:

回覆會包含調查結果清單。

{
  "sources": [
    {
      "name": "organizations/123456789012/sources/9876543210987654321",
      "displayName": "Security Command Center",
      "description": "Detector for misconfigurations within the Security Command Center platform.",
      "canonicalName": "organizations/123456789012/sources/9876543210987654321"
    },
    {
      "name": "organizations/123456789012/sources/8765432109876543210",
      "displayName": "Application Design Center",
      "description": "Provides vulnerabilities on ADC resources.",
      "canonicalName": "organizations/123456789012/sources/8765432109876543210"
    },
    {
      "name": "organizations/123456789012/sources/7654321098765432109",
      "displayName": "Cloud Anomaly Detection",
      "description": "Provider used by Cloud Anomaly Detection",
      "canonicalName": "organizations/123456789012/sources/7654321098765432109"
    },
    {
      "name": "organizations/123456789012/sources/6543210987654321098",
      "displayName": "Vulnerability Assessment",
      "description": "Provider for Vulnerability Assessment.",
      "canonicalName": "organizations/123456789012/sources/6543210987654321098"
    },
    {
      "name": "organizations/123456789012/sources/5432109876543210987",
      "displayName": "Data Security Posture Management",
      "description": "Service to detect drift and post findings",
      "canonicalName": "organizations/123456789012/sources/5432109876543210987"
    },
    {
      "name": "organizations/123456789012/sources/4321098765432109876",
      "displayName": "Notebook Security Scanner",
      "description": "Provider for the Notebook Security Scanner",
      "canonicalName": "organizations/123456789012/sources/4321098765432109876"
    },
    {
      "name": "organizations/123456789012/sources/3210987654321098765",
      "displayName": "GKE Security Posture",
      "description": "Provides actionable security issues on GKE.",
      "canonicalName": "organizations/123456789012/sources/3210987654321098765"
    },
    {
      "name": "organizations/123456789012/sources/2109876543210987654",
      "displayName": "Integrated Vulnerability Scanner",
      "description": "Provider for Integrated Vulnerability Scanner.",
      "canonicalName": "organizations/123456789012/sources/2109876543210987654"
    },
    {
      "name": "organizations/123456789012/sources/1098765432109876543",
      "displayName": "Event Threat Detection Custom Modules",
      "description": "Provider used by Event Threat Detection Custom Modules",
      "canonicalName": "organizations/123456789012/sources/1098765432109876543"
    },
    {
      "name": "organizations/123456789012/sources/9876543210987654321",
      "displayName": "Serverless Vulnerability Detection",
      "description": "Provides vulnerability detection for serverless assets.",
      "canonicalName": "organizations/123456789012/sources/9876543210987654321"
    }
  ]
}

來源 ID 是 canonicalNamename 欄位結尾的數值。

列出 Event Threat Detection 自訂模組的發現項目

Security Command Center API 的 RESOURCE_TYPE.sources.locations.findings.list 方法會列出特定位置中來源的發現項目。

使用任何要求資料之前,請先修改下列項目的值:

  • QUOTA_PROJECT:用於帳單和配額追蹤的專案 ID。
  • RESOURCE_TYPE:要取得的資源類型 (organizationsfoldersprojects)。
  • RESOURCE_ID:要取得的機構、資料夾或專案的數字 ID。如果是專案,您也可以使用英數專案 ID。
  • LOCATION:要使用的Security Command Center 位置,例如 eu。如果未啟用資料落地設定,請使用 global
  • SOURCE_ID:發現項目來源的數值 ID。

HTTP 方法和網址:

GET https://securitycenter.googleapis.com/v2/RESOURCE_TYPE/RESOURCE_ID/sources/SOURCE_ID/locations/LOCATION/findings

請展開以下其中一個選項,以傳送要求:

回覆會包含調查結果清單。

如要進一步瞭解如何篩選調查結果,請參閱「列出安全性調查結果」。

自訂模組產生的發現項目,可像 Security Command Center 中的所有發現項目一樣管理。如要瞭解詳情,請參考下列資源:

管理 Event Threat Detection 自訂模組

本節說明如何查看、列出、更新及刪除 Event Threat Detection 自訂模組。

查看或列出自訂模組

根據預設,列出 Event Threat Detection 的自訂模組時,您會看到下列所有項目:

  • 屬於機構、資料夾或專案的所有 Event Threat Detection 自訂模組。
  • 所有沿用的 Event Threat Detection 自訂模組。舉例來說,如果您正在查看專案,結果會包含在該專案的父項機構和資料夾中建立的自訂模組。
  • 在子項資源中建立的所有 Event Threat Detection 自訂模組。舉例來說,如果您處於機構檢視畫面,結果就會包含機構資料夾和專案中的自訂模組。

控制台

  1. 查看 Event Threat Detection 服務的模組預先定義和自訂的模組會顯示在清單中。
  2. 選用步驟:如要只查看自訂模組,請在「篩選器」方塊中輸入 Type:Custom

gcloud

gcloud scc manage custom-modules etd list 指令會列出機構、資料夾或專案的所有 Event Threat Detection 自訂模組。

使用下列任何指令資料之前,請先替換以下項目:

  • RESOURCE_TYPE:自訂模組所屬的資源類型 (organizationfolderproject)。
  • RESOURCE_ID:要取得的機構、資料夾或專案的數字 ID。如果是專案,您也可以使用英數專案 ID。

執行 gcloud scc manage custom-modules etd list 指令:

Linux、macOS 或 Cloud Shell

gcloud scc manage custom-modules etd list \
    --RESOURCE_TYPE=RESOURCE_ID

Windows (PowerShell)

gcloud scc manage custom-modules etd list `
    --RESOURCE_TYPE=RESOURCE_ID

Windows (cmd.exe)

gcloud scc manage custom-modules etd list ^
    --RESOURCE_TYPE=RESOURCE_ID

您應該會收到類似以下的回應:

- config:
    metadata:
      description: There is a Compute Engine instance in a region that's not allowed.
      recommendation: Delete the instance. If necessary, create a new instance in
        an allowed region.
      severity: MEDIUM
    regions:
    - region: northamerica-northeast1
  displayName: compute_instance_prohibited_region
  enablementState: ENABLED
  name: organizations/123456789012/locations/global/eventThreatDetectionCustomModules/9876543210987654321
  type: CONFIGURABLE_ALLOWED_COMPUTE_ENGINE_REGION
  updateTime: '2026-02-19T01:23:10.237946Z'
- config:
    metadata:
      description: An IAM custom role contains permissions that aren't allowed.
      recommendation: Remove the permissions from the custom role.
      severity: MEDIUM
    permissions:
    - accessapproval.requests.get
    - accessapproval.requests.invalidate
    - accessapproval.requests.list
    - accessapproval.settings.delete
  displayName: iam_custom_role_prohibited_permissions
  enablementState: ENABLED
  name: organizations/123456789012/locations/global/eventThreatDetectionCustomModules/8765432109876543210
  type: CONFIGURABLE_CUSTOM_ROLE_WITH_PROHIBITED_PERMISSION
  updateTime: '2025-12-23T06:54:15.618430Z'

REST

Security Command Center Management API 的 RESOURCE_TYPE.locations.eventThreatDetectionCustomModules.list 方法會列出機構、資料夾或專案的所有 Event Threat Detection 自訂模組。

使用任何要求資料之前,請先修改下列項目的值:

  • RESOURCE_TYPE:自訂模組所屬的資源類型 (organizationsfoldersprojects)。
  • QUOTA_PROJECT:用於帳單和配額追蹤的專案 ID。
  • RESOURCE_ID:要取得的機構、資料夾或專案的數字 ID。如果是專案,您也可以使用英數專案 ID。

HTTP 方法和網址:

GET https://securitycentermanagement.googleapis.com/v1/RESOURCE_TYPE/RESOURCE_ID/locations/global/eventThreatDetectionCustomModules

請展開以下其中一個選項,以傳送要求:

您應該會收到如下的 JSON 回覆:

[
  {
    "config": {
      "metadata": {
        "description": "There is a Compute Engine instance in a region that's not allowed.",
        "recommendation": "Delete the instance. If necessary, create a new instance in an allowed region.",
        "severity": "MEDIUM"
      },
      "regions": [
        {
          "region": "northamerica-northeast1"
        }
      ]
    },
    "displayName": "compute_instance_prohibited_region",
    "enablementState": "ENABLED",
    "name": "organizations/123456789012/locations/global/eventThreatDetectionCustomModules/9876543210987654321",
    "type": "CONFIGURABLE_ALLOWED_COMPUTE_ENGINE_REGION",
    "updateTime": "2026-02-19T01:23:10.237946Z"
  },
  {
    "config": {
      "metadata": {
        "description": "An IAM custom role contains permissions that aren't allowed.",
        "recommendation": "Remove the permissions from the custom role.",
        "severity": "MEDIUM"
      },
      "permissions": [
        "accessapproval.requests.get",
        "accessapproval.requests.invalidate",
        "accessapproval.requests.list",
        "accessapproval.settings.delete"
      ]
    },
    "displayName": "iam_custom_role_prohibited_permissions",
    "enablementState": "ENABLED",
    "name": "organizations/123456789012/locations/global/eventThreatDetectionCustomModules/8765432109876543210",
    "type": "CONFIGURABLE_CUSTOM_ROLE_WITH_PROHIBITED_PERMISSION",
    "updateTime": "2025-12-23T06:54:15.618430Z"
  }
]

啟用或停用自訂模組

啟用或停用自訂模組時,這項變更會套用至自訂模組所屬的機構、資料夾或專案。這個資源是自訂模組的父項

自訂模組上層的任何資料夾或專案,也可能會沿用這項變更。舉例來說,如果您在資料夾中建立自訂模組,該資料夾中的專案就能繼承自訂模組的狀態。

如果自訂模組的父項是資料夾或專案,您必須在資源階層的相同或較低層級啟用或停用自訂模組。舉例來說,如果自訂模組的上層是專案,您就無法為機構或資料夾啟用或停用自訂模組,因為這些資源類型一律是專案的祖先。

控制台

請參閱「查看及編輯服務的模組」。

gcloud

gcloud scc manage custom-modules etd update 指令會更新 Event Threat Detection 自訂模組的狀態。

使用下列任何指令資料之前,請先替換以下項目:

  • RESOURCE_TYPE:要更新的資源類型 (organizationfolderproject)。
  • RESOURCE_ID:自訂模組的機構、資料夾或專案的數字 ID。如果是專案,您也可以使用英數專案 ID。
  • MODULE_ID:模組的數值 ID
  • NEW_STATEENABLED 啟用模組;DISABLED 停用模組;或 INHERITED 沿用父項資源的啟用狀態 (僅適用於專案和資料夾)。

執行 gcloud scc manage custom-modules etd update 指令:

Linux、macOS 或 Cloud Shell

gcloud scc manage custom-modules etd update event-threat-detection MODULE_ID \
    --RESOURCE_TYPE=RESOURCE_ID \
    --enablement-state="NEW_STATE"

Windows (PowerShell)

gcloud scc manage custom-modules etd update event-threat-detection MODULE_ID `
    --RESOURCE_TYPE=RESOURCE_ID `
    --enablement-state="NEW_STATE"

Windows (cmd.exe)

gcloud scc manage custom-modules etd update event-threat-detection MODULE_ID ^
    --RESOURCE_TYPE=RESOURCE_ID ^
    --enablement-state="NEW_STATE"

您應該會收到類似以下的回應:

config:
  metadata:
    description: An IAM custom role contains permissions that aren't allowed.
    recommendation: Remove the permissions from the custom role.
    severity: MEDIUM
  permissions:
  - accessapproval.requests.get
  - accessapproval.requests.invalidate
  - accessapproval.requests.list
  - accessapproval.settings.delete
displayName: iam_custom_role_prohibited_permissions
enablementState: DISABLED
name: projects/1234567890123/locations/global/eventThreatDetectionCustomModules/98765432109876543210
type: CONFIGURABLE_CUSTOM_ROLE_WITH_PROHIBITED_PERMISSION
updateTime: '2026-03-20T16:52:27.046766Z'

REST

Security Command Center Management API 的 RESOURCE_TYPE.locations.eventThreatDetectionCustomModules.patch 方法會更新 Event Threat Detection 自訂模組的狀態。

使用任何要求資料之前,請先修改下列項目的值:

  • RESOURCE_TYPE:要更新的資源類型 (organizationsfoldersprojects)。
  • QUOTA_PROJECT:用於帳單和配額追蹤的專案 ID。
  • RESOURCE_ID:自訂模組的機構、資料夾或專案的數字 ID。如果是專案,您也可以使用英數專案 ID。
  • MODULE_ID:模組的數值 ID
  • NEW_STATEENABLED 啟用模組;DISABLED 停用模組;或 INHERITED 沿用父項資源的啟用狀態 (僅適用於專案和資料夾)。
  • FIELDS_TO_UPDATE:選用。以逗號分隔的欄位清單,列出要更新的欄位。如省略,系統會更新所有欄位。

HTTP 方法和網址:

PATCH https://securitycentermanagement.googleapis.com/v1/RESOURCE_TYPE/RESOURCE_ID/locations/global/eventThreatDetectionCustomModules/MODULE_ID?updateMask=enablementState

JSON 要求主體:

{
  "enablementState": "NEW_STATE"
}

請展開以下其中一個選項,以傳送要求:

您應該會收到如下的 JSON 回覆:

{
  "name": "projects/1234567890123/locations/global/eventThreatDetectionCustomModules/98765432109876543210",
  "config": {
    "metadata": {
      "severity": "MEDIUM",
      "description": "An IAM custom role contains permissions that aren't allowed.",
      "recommendation": "Remove the permissions from the custom role."
    },
    "permissions": [
      "accessapproval.requests.get",
      "accessapproval.requests.invalidate",
      "accessapproval.requests.list",
      "accessapproval.settings.delete"
    ]
  },
  "enablementState": "DISABLED",
  "type": "CONFIGURABLE_CUSTOM_ROLE_WITH_PROHIBITED_PERMISSION",
  "displayName": "iam_custom_role_prohibited_permissions",
  "updateTime": "2026-03-20T16:52:27.046766Z"
}

更新自訂模組的定義

本節說明如何透過Google Cloud console 和 gcloud CLI 更新自訂模組。每個 Event Threat Detection 自訂模組的大小上限為 6 MB。

自訂模組的模組類型無法更新。

如要更新自訂模組,請按照下列步驟操作:

控制台

你只能編輯住宅自訂模組。舉例來說,如果您在機構檢視畫面中,就只能編輯在機構層級建立的自訂模組。

  1. 查看 Event Threat Detection 服務的模組。預先定義和自訂的模組會顯示在清單中。
  2. 找出要編輯的自訂模組。
  3. 針對該自訂模組,依序按一下「 Actions」(動作) >「Edit」(編輯)
  4. 視需要編輯自訂模組。
  5. 按一下 [儲存]

gcloud

如要更新模組,請執行下列指令,並加入更新後的模組範本 JSON:

 gcloud alpha scc custom-modules etd update CUSTOM_MODULE_ID \
     --RESOURCE_FLAG=RESOURCE_ID \
     --enablement-state="ENABLED" \
     --custom-config-from-file=PATH_TO_JSON_FILE

更改下列內容:

  • CUSTOM_MODULE_ID:Event Threat Detection 自訂模組的數字 ID,例如 1234567890查看自訂模組清單時,您可以從相關自訂模組的 name 欄位取得數字 ID。
  • RESOURCE_FLAG:自訂模組所在的父項資源範圍,即 organizationfolderproject
  • RESOURCE_ID:父項資源的 ID,也就是機構 ID、資料夾 ID 或專案 ID。
  • PATH_TO_JSON_FILE:包含自訂模組 JSON 定義的 JSON 檔案。

查看單一自訂模組的狀態

控制台

  1. 查看模組 Event Threat Detection 服務。預先定義和自訂的模組會顯示在清單中。
  2. 在清單中找出自訂模組。

    自訂模組的狀態會顯示在「狀態」欄中。

gcloud

gcloud scc manage custom-modules etd describe 指令會取得機構、資料夾或專案的 Event Threat Detection 自訂模組。

使用下列任何指令資料之前,請先替換以下項目:

  • RESOURCE_TYPE:自訂模組所屬的資源類型 (organizationfolderproject)。
  • RESOURCE_ID:要取得的機構、資料夾或專案的數字 ID。如果是專案,您也可以使用英數專案 ID。
  • MODULE_ID:自訂模組的數值 ID。

執行 gcloud scc manage custom-modules etd describe 指令:

Linux、macOS 或 Cloud Shell

gcloud scc manage custom-modules etd describe MODULE_ID \
    --RESOURCE_TYPE=RESOURCE_ID

Windows (PowerShell)

gcloud scc manage custom-modules etd describe MODULE_ID `
    --RESOURCE_TYPE=RESOURCE_ID

Windows (cmd.exe)

gcloud scc manage custom-modules etd describe MODULE_ID ^
    --RESOURCE_TYPE=RESOURCE_ID

您應該會收到類似以下的回應:

config:
  metadata:
    description: An IAM custom role contains permissions that aren't allowed.
    recommendation: Remove the permissions from the custom role.
    severity: MEDIUM
  permissions:
  - accessapproval.requests.get
  - accessapproval.requests.invalidate
  - accessapproval.requests.list
  - accessapproval.settings.delete
displayName: iam_custom_role_prohibited_permissions
enablementState: ENABLED
name: organizations/123456789012/locations/global/eventThreatDetectionCustomModules/8765432109876543210
type: CONFIGURABLE_CUSTOM_ROLE_WITH_PROHIBITED_PERMISSION
updateTime: '2025-12-23T06:54:15.618430Z'

REST

Security Command Center Management API 的 RESOURCE_TYPE.locations.eventThreatDetectionCustomModules.get 方法會取得機構、資料夾或專案的 Event Threat Detection 自訂模組。

使用任何要求資料之前,請先修改下列項目的值:

  • RESOURCE_TYPE:自訂模組所屬的資源類型 (organizationsfoldersprojects)。
  • QUOTA_PROJECT:用於帳單和配額追蹤的專案 ID。
  • RESOURCE_ID:要取得的機構、資料夾或專案的數字 ID。如果是專案,您也可以使用英數專案 ID。
  • MODULE_ID:自訂模組的數值 ID。

HTTP 方法和網址:

GET https://securitycentermanagement.googleapis.com/v1/RESOURCE_TYPE/RESOURCE_ID/locations/global/eventThreatDetectionCustomModules/MODULE_ID

請展開以下其中一個選項,以傳送要求:

您應該會收到如下的 JSON 回覆:

{
  "config": {
    "metadata": {
      "description": "An IAM custom role contains permissions that aren't allowed.",
      "recommendation": "Remove the permissions from the custom role.",
      "severity": "MEDIUM"
    },
    "permissions": [
      "accessapproval.requests.get",
      "accessapproval.requests.invalidate",
      "accessapproval.requests.list",
      "accessapproval.settings.delete"
    ]
  },
  "displayName": "iam_custom_role_prohibited_permissions",
  "enablementState": "ENABLED",
  "name": "organizations/123456789012/locations/global/eventThreatDetectionCustomModules/8765432109876543210",
  "type": "CONFIGURABLE_CUSTOM_ROLE_WITH_PROHIBITED_PERMISSION",
  "updateTime": "2025-12-23T06:54:15.618430Z"
}

刪除自訂模組

刪除 Event Threat Detection 自訂模組後,系統不會修改該模組產生的發現項目,這些項目仍會顯示在 Security Command Center 中。相較之下,刪除安全狀態分析自訂模組時,系統會將產生的發現項目標示為無效。

已刪除的自訂模組無法復原。

控制台

您無法刪除繼承的自訂模組。舉例來說,如果您位於專案檢視畫面,就無法刪除在資料夾或機構層級建立的自訂模組。

如要透過 Google Cloud 控制台刪除自訂模組,請按照下列步驟操作:

  1. 查看模組 Event Threat Detection 服務。預先定義和自訂的模組會顯示在清單中。
  2. 找出要刪除的自訂模組。
  3. 找出要刪除的自訂模組,然後依序點選「動作」圖示 >「刪除」。系統會顯示訊息,提示您確認刪除動作。
  4. 點選「刪除」。

gcloud

gcloud scc manage custom-modules etd delete 指令會為機構、資料夾或專案建立 Event Threat Detection 自訂模組。

使用下列任何指令資料之前,請先替換以下項目:

  • RESOURCE_TYPE:自訂模組所屬的資源類型 (organizationfolderproject)。
  • RESOURCE_ID:自訂模組的機構、資料夾或專案的數字 ID。如果是專案,您也可以使用英數專案 ID。
  • MODULE_ID:自訂模組的數值 ID。

執行 gcloud scc manage custom-modules etd delete 指令:

Linux、macOS 或 Cloud Shell

gcloud scc manage custom-modules etd delete MODULE_ID \
    --RESOURCE_TYPE=RESOURCE_ID

Windows (PowerShell)

gcloud scc manage custom-modules etd delete MODULE_ID `
    --RESOURCE_TYPE=RESOURCE_ID

Windows (cmd.exe)

gcloud scc manage custom-modules etd delete MODULE_ID ^
    --RESOURCE_TYPE=RESOURCE_ID

您應該會收到類似以下的回應:

Deleted [projects/1234567890123/locations/global/eventThreatDetectionCustomModules/98765432109876543210].

REST

Security Command Center Management API 的 RESOURCE_TYPE.locations.eventThreatDetectionCustomModules.delete 方法會為機構、資料夾或專案建立 Event Threat Detection 自訂模組。

使用任何要求資料之前,請先修改下列項目的值:

  • RESOURCE_TYPE:自訂模組所屬的資源類型 (organizationsfoldersprojects)
  • QUOTA_PROJECT:用於帳單和配額追蹤的專案 ID。
  • RESOURCE_ID:自訂模組的機構、資料夾或專案的數字 ID。如果是專案,您也可以使用英數專案 ID。
  • MODULE_ID:自訂模組的數值 ID。

HTTP 方法和網址:

DELETE https://securitycentermanagement.googleapis.com/v1/RESOURCE_TYPE/RESOURCE_ID/locations/global/eventThreatDetectionCustomModules/MODULE_ID

請展開以下其中一個選項,以傳送要求:

您應該會收到如下的 JSON 回覆:

{}

複製自訂模組

複製自訂模組時,系統會將產生的自訂模組建立為您正在查看的資源常駐項目。舉例來說,如果您複製專案從機構繼承的自訂模組,則新的自訂模組會是專案中的住宅模組。

您無法複製後代自訂模組。

如要透過 Google Cloud 控制台複製自訂模組,請執行下列步驟:

  1. 查看模組 Event Threat Detection 服務。預先定義和自訂的模組會顯示在清單中。
  2. 找出要複製的自訂模組。
  3. 在該自訂模組中,依序按一下「 Actions」(動作) >「Clone」(複製)
  4. 視需要編輯自訂模組。
  5. 點選「建立」

後續步驟