使用 CASB webhook 将态势发现实例从 Cloudflare One 发送到外部系统,例如聊天平台、工单系统、SIEM、SOAR 工具和自定义自动化服务。
配置 webhook 目标后,您可以从 Webhooks 页面测试投递,并直接从发现详情工作流发送态势发现实例。
- 您可以访问 Cloudflare One。
- 您拥有一个可接收
POST请求的公开 HTTPS 端点。 - 您拥有目标所需的任何身份验证值,例如 bearer 令牌、Basic Auth 凭据、静态标头或 HMAC 签名密钥。
- 在 Cloudflare One ↗ 中,前往 Integrations(集成) > Webhooks。
- 选择 Create webhook(创建 webhook)。
- 为 webhook 输入一个 Name(名称)。
- 输入将接收 webhook 请求的系统的 Destination URL(目标 URL)。
- 选择 Authentication method(身份验证方式)。
- 输入所需的凭据、标头或签名密钥。
- (可选)选择 Test delivery(测试投递),在保存前验证目标。
- 选择 Save(保存)。
向创建 webhook 端点发送 POST 请求:
Required API token permissions
At least one of the following token permissions is required:Zero Trust Write
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/data-security/posture/webhooks" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"label": "Send to SIEM",
"destination_url": "https://example.com/webhook",
"authentication_type": "Bearer Auth",
"headers": [
{
"key": "Authorization",
"value": "Bearer <TOKEN>"
}
]
}'-
为
cloudflare_api_token↗ 添加以下权限:Zero Trust Write
-
使用
cloudflare_zero_trust_casb_webhook↗ 资源创建 webhook:variable "siem_token" { type = string sensitive = true } resource "cloudflare_zero_trust_casb_webhook" "siem" { account_id = var.cloudflare_account_id label = "Send to SIEM" destination_url = "https://example.com/webhook" authentication_type = "Bearer Auth" headers = [{ key = "Authorization" value = "Bearer ${var.siem_token}" }] }如需使用 HMAC 签名,请将
authentication_type = "HMAC-Signing",并提供signing_secret而不是headers。
Cloudflare 仅接受使用 https:// 且可公开访问的目标 URL。解析到本地主机、回环地址、私有地址或其他保留地址的 URL 将被拒绝。
CASB webhook 支持以下身份验证方式:
- None(无):如果您的目标不需要身份验证,请使用此选项。
- Basic Auth:目标端需要 HTTP Basic 身份验证时使用。需要一个以
Basic开头的Authorization标头。 - Bearer Auth:目标端需要 bearer token 时使用。需要一个以
Bearer开头的Authorization标头。 - Static Headers:目标端需要一个或多个固定的自定义标头时使用。至少需要一个标头,且标头名称必须唯一。
- HMAC-Signing:目标端需要验证签名请求时使用。需要提供
signing_secret。
使用 Test delivery(测试投递) 在保存新 webhook 或更新现有 webhook 后,向已配置的目标发送测试请求。
测试成功表示 Cloudflare 已到达目标 URL,且目标已返回响应。
测试投递不会从您的环境发送实时发现实例。
更新现有 webhook 的步骤:
- 在 Cloudflare One ↗ 中,前往 Integrations(集成) > Webhooks。
- 选择您要更新的 webhook。
- 修改 webhook 配置。
- 选择 Save(保存)。
要关闭或开启 webhook,请使用 Webhooks 页面上的状态切换开关。
要删除 webhook,请打开 webhook 菜单并选择 Delete(删除)。
要更新 webhook,请向更新 webhook 端点发送包含 label、destination_url、authentication_type 和 status 的 PUT 请求。该请求会替换现有配置,因此要包含所有需要保留的标头。如需保留已存储的标头值,请仅发送其 key,不要发送 value。
例如,以下请求通过将 status 设为 disabled 来关闭 webhook:
Required API token permissions
At least one of the following token permissions is required:Zero Trust Write
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/data-security/posture/webhooks/$WEBHOOK_ID" \
--request PUT \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"label": "Send to SIEM",
"destination_url": "https://example.com/webhook",
"authentication_type": "Bearer Auth",
"headers": [
{
"key": "Authorization"
}
],
"status": "disabled"
}'要删除 webhook,请向删除 webhook 端点发送 DELETE 请求:
Required API token permissions
At least one of the following token permissions is required:Zero Trust Write
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/data-security/posture/webhooks/$WEBHOOK_ID" \
--request DELETE \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"要更新 webhook,请更改其属性并运行 terraform apply。要关闭 webhook,请设置 status = "disabled"。
要删除 webhook,请从配置中移除该资源并运行 terraform apply,或单独指定该资源进行销毁:
terraform destroy -target=cloudflare_zero_trust_casb_webhook.siem编辑现有 webhook 时,Cloudflare 不会显示已保存的标头值或签名密钥。如需替换已存储的值,请输入新值并再次保存 webhook。
要让 Terraform 管理通过仪表板或 API 创建的 webhook,请使用账户 ID 和 webhook ID 导入:
terraform import cloudflare_zero_trust_casb_webhook.siem '<ACCOUNT_ID>/<WEBHOOK_ID>'Cloudflare 不会返回标头值或签名密钥。导入 webhook 后,请在配置中设置这些值,以便 Terraform 管理。
使用 cloudflare_zero_trust_casb_webhook ↗ 数据源读取单个 webhook,或使用 cloudflare_zero_trust_casb_webhooks ↗ 列出账户中的所有 webhook:
data "cloudflare_zero_trust_casb_webhook" "siem" {
account_id = var.cloudflare_account_id
webhook_id = "<WEBHOOK_ID>"
}
data "cloudflare_zero_trust_casb_webhooks" "all" {
account_id = var.cloudflare_account_id
}配置一个或多个 webhook 目标后,您可以直接从发现工作流发送态势发现实例。
- 在 Cloudflare One ↗ 中,前往 Cloud & SaaS findings(云和 SaaS 发现) > Posture Findings(安全状况发现)。
- 选择 SaaS 或 Cloud(云)。
- 选择您要查看的发现,然后选择 Manage(管理)。
- 选择一个实例。
- 在实例详情面板中,选择 Send webhook(发送 webhook)。
- 选择您要使用的 webhook 目标(一个或多个)。
- 选择 Send webhooks(发送 webhooks)。
Cloudflare 会在后台将 webhook 发送排队。成功消息表示 Cloudflare 已接受该投递请求。
有关发现工作流的更多信息,请参阅管理发现结果。
如需针对匹配的发现自动发送 webhook,而无需逐条手动发送,请参阅修复策略。
CASB 发送描述态势发现实例的 JSON 负载。
Webhook 负载包括事件元数据、发现详情、资产详情以及与发现实例相关的任何附加元数据。确切内容因集成和发现类型而异。
Webhook 负载包含顶层 id、type、metadata 和 data 对象。
根据发现类型,metadata 对象可包含事件详情,例如操作者、目标、发送时间和负载版本。
data 对象可包含发现详情、资产详情以及与发现实例相关的附加元数据。
如果您的下游系统需要自定义架构,请将 webhook 发送到中间服务或工作流引擎,由其在转发到最终目标之前对负载进行转换。
- CASB webhook 仅支持态势发现实例。
- CASB webhook 不发送内容发现结果。
- 测试投递发送测试请求,但不发送实时发现实例。
如果 webhook 测试或投递失败:
- 验证目标 URL 是否使用
https://。 - 验证目标是否可公开访问。
- 确认您的身份验证值、标头和签名密钥是否正确。
- 如果仪表板报告成功但目标未立即处理事件,请记住发现实例的发送会在后台排队。
更多信息请参阅 CASB 故障排除。