为 Security and Compliance Center 启用事件通知
自 2025 年 7 月 17 日起,您不能在本产品的此版本中创建新实例。 Security and Compliance Center Workload Protection 的更新体验中提供了所有功能。 更多信息,请参阅 过渡文档。
作为 IBM Cloud® Security and Compliance Center的管理员,您可能希望使用电子邮件,SMS 或其他受支持的传递通道将 Security and Compliance Center 中的事件通知发送给其他用户或人员目标。 此外,您可能希望将事件的这些通知发送到其他应用程序,以通过使用事件驱动的编程 (例如,使用 Webhook) 来构建逻辑。 此操作通过 Security and Compliance Center 与 IBM Cloud® Event Notifications之间的集成实现。
Security and Compliance Center 的事件
查看以下部分以了解特定 Security and Compliance Center 组件生成的事件。
事件类型 | 子类型 | 描述 |
---|---|---|
com.ibm.cloud.compliance.test |
当您测试 Security and Compliance Center 与已连接的 Event Notifications 服务实例之间的连接时,将发送事件。 | |
com.ibm.cloud.compliance.posture |
posture-scan-completed |
扫描完成时将发送事件。 |
com.ibm.cloud.compliance.posture |
posture-scan-failure-threshold-limit-exceeds |
当满足指定的失败控制阈值时,将发送事件。 |
com.ibm.cloud.compliance.posture |
posture-scan-new-resource-in-inventory |
在库存中找到新资源时,将发送事件。 |
启用通知
可以将 Security and Compliance Center 生成的事件转发到同一帐户中可用的 Event Notifications 服务实例。 要开始,请确保您具有:
- Security and Compliance Center的 管理员 平台访问。
- Event Notifications 服务的 Manager 服务访问权。 要查看帐户中的现有 Event Notifications 服务实例,您还需要 查看者 平台访问权或更高版本。
在控制台中连接到 Event Notifications
在可以对 Security and Compliance Center启用通知之前,请确保您具有同一帐户中的 Event Notifications 服务实例。 然后,可以使用 Security and Compliance Center UI 中的 设置> Event Notifications 部分来连接服务。
-
在 IBM Cloud 控制台中,转到 Resource list 页面并选择 Security and Compliance Center 实例。
-
在 Security and Compliance Center 实例中,转到 Settings 页面。
-
在 Event Notifications 部分中,单击 连接。
-
在侧面板中,查看连接的源详细信息。 (可选)提供描述。
-
选择要连接的资源组和 Event Notifications 服务实例。
如果帐户中不存在 Security and Compliance Center 与 Event Notifications 之间的 IAM 授权,那么将显示一个对话框。 遵循提示以授予服务之间的访问权。
- 要授予 Security and Compliance Center 与 Event Notifications之间的访问权,请单击 授权。
- 在侧面板中,选择 Event Notifications 作为目标服务。
- 从实例列表中,选择要授权的 Event Notifications 服务实例。
- 选择 事件源管理器 角色。
- 点击回顾。
- 单击分配。
-
要确认连接,请单击 连接。
将显示一条成功消息,指示 Security and Compliance Center 现在已连接到 Event Notifications。 如果您需要稍后与 Event Notifications 断开连接,那么可以使用选项菜单
> 断开连接 来除去 Security and Compliance Center 作为 Event Notifications 实例中的源服务。
如果选择断开 Event Notifications的连接,请勿删除 Security and Compliance Center 与 Event Notifications之间的 IAM 授权。 Security and Compliance Center 使用现有授权从 Event Notifications注销。 如果删除 Event Notifications 实例,那么 IAM 也会删除服务与 Security and Compliance Center 之间存在的任何授权。
使用 API 连接到 Event Notifications
在可以对 Security and Compliance Center启用通知之前,请确保您具有同一帐户中的 Event Notifications 服务实例。 然后,可以通过调用 Security and Compliance Center API 以编程方式连接到 Event Notifications。
以下示例显示可用于向 Event Notifications注册 Security and Compliance Center 源详细信息的查询。
通过转至 资源列表 并单击 Event Notifications 实例行,可以在控制台中找到 event_notifications_instance_crn
值。
curl -X PATCH
--location --header "Authorization: Bearer {IAM_token}"
--header "Accept: application/json"
--header "Content-Type: application/json-patch+json"
--data '{
"event_notifications": {
"instance_crn": "crn:v1:staging:public:event-notifications:us-south:a/130003ea8bfa43c5aacea07a86da3000:1c858449-3537-45b8-9d39-2707115b4cc7::"
},
"object_storage": {
"instance_crn": "crn:v1:staging:public:cloud-object-storage:global:a/130003ea8bfa43c5aacea07a86da3000:1c858449-3537-45b8-9d39-2707115b4cc7::",
"bucket": "scc-bucket"
}
}' "
https://us-south.compliance.cloud.ibm.com/instances/{instance_id}/v3/settings"
eventNotificationsModel := &securityandcompliancecenterapiv3.EventNotifications{
InstanceCrn: &eventNotificationsCrnForUpdateSettingsLink,
SourceDescription: core.StringPtr("This source is used for integration with IBM Cloud Security and Compliance Center."),
SourceName: core.StringPtr("compliance"),
}
objectStorageModel := &securityandcompliancecenterapiv3.ObjectStorage{
InstanceCrn: &objectStorageCrnForUpdateSettingsLink,
Bucket: &objectStorageBucketForUpdateSettingsLink,
BucketLocation: &objectStorageLocationForUpdateSettingsLink,
}
updateSettingsOptions := securityAndComplianceCenterApiService.NewUpdateSettingsOptions()
updateSettingsOptions.SetEventNotifications(eventNotificationsModel)
updateSettingsOptions.SetObjectStorage(objectStorageModel)
updateSettingsOptions.SetXCorrelationID("1a2b3c4d-5e6f-4a7b-8c9d-e0f1a2b3c4d5")
settings, response, err := securityAndComplianceCenterApiService.UpdateSettings(updateSettingsOptions)
if err != nil {
panic(err)
}
b, _ := json.MarshalIndent(settings, "", " ")
fmt.Println(string(b))
EventNotifications eventNotificationsModel = new EventNotifications.Builder()
.instanceCrn(eventNotificationsCrnForUpdateSettingsLink)
.sourceDescription("This source is used for integration with IBM Cloud Security and Compliance Center.")
.sourceName("compliance")
.build();
ObjectStorage objectStorageModel = new ObjectStorage.Builder()
.instanceCrn(objectStorageCrnForUpdateSettingsLink)
.bucket(objectStorageBucketForUpdateSettingsLink)
.bucketLocation(objectStorageLocationForUpdateSettingsLink)
.build();
UpdateSettingsOptions updateSettingsOptions = new UpdateSettingsOptions.Builder()
.eventNotifications(eventNotificationsModel)
.objectStorage(objectStorageModel)
.xCorrelationId(xCorrelationIdLink)
.build();
Response<Settings> response = securityAndComplianceCenterApiService.updateSettings(updateSettingsOptions).execute();
Settings settings = response.getResult();
System.out.println(settings);
// Request models needed by this operation.
// EventNotifications
const eventNotificationsModel = {
instance_crn: eventNotificationsCrnForUpdateSettingsLink,
source_description: 'This source is used for integration with IBM Cloud Security and Compliance Center.',
source_name: 'compliance',
};
// ObjectStorage
const objectStorageModel = {
instance_crn: objectStorageCrnForUpdateSettingsLink,
bucket: objectStorageBucketForUpdateSettingsLink,
bucket_location: objectStorageLocationForUpdateSettingsLink,
};
const params = {
eventNotifications: eventNotificationsModel,
objectStorage: objectStorageModel,
xCorrelationId: xCorrelationIdLink,
};
let res;
try {
res = await securityAndComplianceCenterApiService.updateSettings(params);
console.log(JSON.stringify(res.result, null, 2));
} catch (err) {
console.warn(err);
}
event_notifications_model = {
'instance_crn': event_notifications_crn_for_update_settings_link,
'source_description': 'This source is used for integration with IBM Cloud Security and Compliance Center.',
'source_name': 'compliance',
}
object_storage_model = {
'instance_crn': object_storage_crn_for_update_settings_link,
'bucket': object_storage_bucket_for_update_settings_link,
'bucket_location': object_storage_location_for_update_settings_link,
}
response = security_and_compliance_center_api_service.update_settings(
event_notifications=event_notifications_model,
object_storage=object_storage_model,
x_correlation_id=x_correlation_id_link,
)
settings = response.get_result()
print(json.dumps(settings, indent=2))
成功响应将返回已连接的 Event Notifications 和 Cloud Object Storage 服务实例的 CRN 值。 有关必需和可选请求参数的更多信息,请参阅 API 文档。
使用 CLI 连接到 Event Notifications
在可以对 Security and Compliance Center启用通知之前,请确保您具有同一帐户中的 Event Notifications 服务实例。 然后,可以使用 Security and Compliance Center CLI 以编程方式连接到 Event Notifications。
以下示例显示可用于向 Event Notifications注册 Security and Compliance Center 源详细信息的命令。 使用 CLI 时,请将标识变量和 IAM 令牌替换为特定于您帐户的值。 有关更多信息,请参阅 CLI 参考。
ibmcloud security-compliance settings update
--event-notifications='{
"instance_crn": "crn:v1:staging:public:event-notifications:us-south:a/ff88f007f9ff4622aac4fbc0eda36255:7199ae60-a214-4dd8-9bf7-ce571de49d01::",
"updated_on": "2019-01-01T12:00:00.000Z",
"source_id": "crn:v1:staging:public:event-notifications:us-south:a/ff88f007f9ff4622aac4fbc0eda36255:b8b07245-0bbe-4478-b11c-0dce523105fd::",
"source_description": "This source is used for integration with IBM Cloud Security and Compliance Center.",
"source_name": "compliance"
}'
--object-storage='{
"instance_crn": "crn:v1:staging:public:cloud-object-storage:global:a/ff88f007f9ff4622aac4fbc0eda36255:7199ae60-a214-4dd8-9bf7-ce571de49d01::",
"bucket": "px-scan-results",
"bucket_location": "us-south",
"bucket_endpoint": "exampleString",
"updated_on": "2019-01-01T12:00:00.000Z"
}'
--x-correlation-id=1a2b3c4d-5e6f-4a7b-8c9d-e0f1a2b3c4d5
--x-request-id=exampleString
通过转至 资源列表 并单击 Event Notifications 实例行,可以在控制台中找到 event_notifications_instance_crn
值。
从 UI 将测试事件发送到 Event Notifications
为 Security and Compliance Center启用通知后,请测试连接以确保将 Security and Compliance Center 生成的事件转发到 Event Notifications。
必须先在 Event Notifications 实例中创建 主题,目标和预订,然后才能发送测试 Security and Compliance Center 事件。 确保将 测试配置 事件类型 (com.ibm.cloud.compliance.test
)
作为条件包含在 Event Notifications 主题中。
-
在 Security and Compliance Center UI 中,单击 设置。
-
在 " Event Notifications " 部分中,单击 发送测试事件。
将显示一条成功消息,指示测试事件已成功转发到 Event Notifications。
使用 API 将测试事件发送到 Event Notifications
为 Security and Compliance Center启用通知后,请测试连接以确保将 Security and Compliance Center 生成的事件转发到 Event Notifications。
必须先在 Event Notifications 实例中创建 主题,目标和预订,然后才能发送测试 Security and Compliance Center 事件。 确保将 测试配置 事件类型 (com.ibm.cloud.compliance.test
)
作为条件包含在 Event Notifications 主题中。
以下示例显示可用于将测试事件从 Security and Compliance Center 发送到 Event Notifications的查询。
curl -X POST
--location --header "Authorization: Bearer {iam_token}"
--header "Accept: application/json"
"https://us-south.compliance.cloud.ibm.com/instances/{instance_id}/v3/test_event"
(securityAndComplianceCenterApi *SecurityAndComplianceCenterApiV3) PostTestEvent(postTestEventOptions *PostTestEventOptions) (result *TestEvent, response *core.DetailedResponse, err error)
PostTestEventOptions postTestEventOptions = new PostTestEventOptions.Builder()
.xCorrelationId(xCorrelationIdLink)
.build();
Response<TestEvent> response = securityAndComplianceCenterApiService.postTestEvent(postTestEventOptions).execute();
TestEvent testEvent = response.getResult();
System.out.println(testEvent);
const params = {
xCorrelationId: xCorrelationIdLink,
};
let res;
try {
res = await securityAndComplianceCenterApiService.postTestEvent(params);
console.log(JSON.stringify(res.result, null, 2));
} catch (err) {
console.warn(err);
}
response = security_and_compliance_center_api_service.post_test_event(
x_correlation_id=x_correlation_id_link,
)
test_event = response.get_result()
print(json.dumps(test_event, indent=2))
成功响应将返回 {"success": true}
以指示已成功将测试事件转发到已连接的 Event Notifications 服务实例。 有关更多信息,请参阅 API 文档。
使用 CLI 将测试事件发送到 Event Notifications
为 Security and Compliance Center启用通知后,请测试连接以确保将 Security and Compliance Center 生成的事件转发到 Event Notifications。
必须先在 Event Notifications 实例中创建 主题,目标和预订,然后才能发送测试 Security and Compliance Center 事件。 确保将 测试配置 事件类型 (com.ibm.cloud.compliance.test
)
作为条件包含在 Event Notifications 主题中。
以下示例显示可用于将测试事件从 Security and Compliance Center 发送到 Event Notifications的查询。 有关更多信息,请查看 CLI 参考。
ibmcloud security-compliance settings post-test-event
--x-correlation-id=1a2b3c4d-5e6f-4a7b-8c9d-e0f1a2b3c4d5
--x-request-id=exampleString
将通知交付到所选目标
为 Security and Compliance Center启用通知后,请在 Event Notifications 中创建主题和预订,以便可以将警报转发并传递到所选目标。
有关受支持目标的完整列表,请参阅 Event Notifications 文档。
电子邮件通知
您可以使用 IBM Cloud 电子邮件服务 作为 Security and Compliance Center 事件通知的传递通道。 在现有主题与 IBM Cloud 电子邮件服务之间创建 Event Notifications 预订,以通过电子邮件将警报转发给各个收件人。
来自 IBM Cloud 的电子邮件,其中包含有关 Security and Compliance Center 事件的信息,类似于以下示例:
Subject: Validation completed: my-test-validation-scan
Body: The following validation scan was successfully completed in the Security and Compliance Center: my-test-validation-scan. You can view the scan results from the Security and Compliance Center in the console. For more information, check out the docs.
要在电子邮件中接收有关事件通知的详细信息,请在创建 Event Notifications 预订时选择 添加通知有效内容 选项。 您的电子邮件将显示与事件关联的 通知有效内容详细信息。
Webhook
您可以配置 Webhook 目标,以便应用程序或服务可以通过编程方式使用入局通知的属性。 有关更多信息,请查看 Event Notifications 文档。
通知有效内容详细信息
Security and Compliance Center 组件生成的成功事件包含各种字段,可帮助您识别事件的源和详细信息。
来自 Security and Compliance Center 的事件通知仅包含元数据属性,例如资源的名称或标识。 生成的事件中不包含敏感数据,例如 API 密钥或密码。
发送到 Event Notifications 的元数据属性因事件类型和子类型而异。 例如,如果发生 com.ibm.cloud.compliance.posture:posture-scan-completed
事件,那么 Security and Compliance Center 将通知有效内容发送到类似于以下示例的 Event Notifications。
{
"action": "Validation completed",
"summary": "my-test-scan",
"scope": "my-test-scope",
"profile": "CIS IBM Foundations Benchmark 1.0.0",
"start_time": "2021-11-24 13:46:21.672",
"end_time": "2021-11-24 13:46:21.672"
}
请查看下表以获取有关事件通知属性的更多信息。
属性 | 描述 |
---|---|
action |
触发通知的 事件类型。 |
summary |
验证扫描的名称。 |
scope |
与扫描相关联的作用域名称。 |
profile |
与扫描相关联的配置文件的名称。 |
start_time |
扫描开始的日期和时间。 |
end_time |
扫描完成的日期和时间。 |