检测到新的高严重性漏洞时创建 ServiceNow Webhook 通知
通过使用 WebSphere Automation Swagger UI , JSONata 试验程序和 Mustache 语法,创建用于向 Webhook 发送通知的进程。 通知包含 WebSphere Automation 检测到的任何新创建的高严重性漏洞的详细信息。
准备工作
- 打开网页浏览器访问 http://www.servicenow.com
。
- 单击 入门,然后单击 开始开发。
- 单击 注册并开始构建。
- 填写表单以注册 ServiceNow 标识,然后单击 注册。
将为您分配开发者标识。 开发者实例主机名类似于以下地址:
<YOUR_SERVICENOW_DEVELOPER_ID>.service-now.com
若计划实现变量或条件处理,请确保您熟悉 Mustache 语法 。
检查 WebSphere Automation 资源通知
本教程的预期结果是 ServiceNow 事件表显示从 WebSphere Automation中新创建的高严重性资源通知传递的信息。 对于本教程,资源通知包含在受管服务器中检测到新漏洞时创建新漏洞记录的详细信息。 在以下示例资源通知中, type 参数的值为 create; 创建的对象为 vulnerability。
{
"type": "CREATE",
"vulnerability": {
"id": "70357d34-411d-3321-a60f-ede653897a55",
"name": "6557248 : server1@defected1.example.com",
"description": "Multiple vulnerabilities exist in the Apache Log4j (CVE-2022-23302, CVE-2022-23305, CVE-2022-23307) library used by IBM WebSphere Application Server in the Admin Console and UDDI Registry application. The same Apache library is also used by the IBM WebSphere Application Server Liberty for z/OS in features zosConnect-1.0 and zosConnect-1.2. All vulnerabilities have been addressed previously by removing all existing Apache Log4j versions.",
"assetId": "1a5d141a-3294-3ff3-9182-5ae1d4f3465d",
"securityBulletinId": "23c15e59-1ef9-3eb5-a175-0845597cdbc1",
"resolved": false,
"cves": [
{
"id": "CVE-2022-23302",
"description": "Apache Log4j could allow a remote authenticated attacker to execute arbitrary code on the system, caused by an unsafe deserialization in JMSSink. By sending specially-crafted JNDI requests using TopicConnectionFactoryBindingName configuration, an attacker could exploit this vulnerability to execute arbitrary code on the system.",
"cvssBaseScore": 8.8
},
{
"id": "CVE-2022-23305",
"description": "Apache Log4j is vulnerable to SQL injection. A remote attacker could send specially-crafted SQL statements to the JDBCAppender, which could allow the attacker to view, add, modify or delete information in the back-end database.",
"cvssBaseScore": 6.5
},
{
"id": "CVE-2022-23307",
"description": "Apache Log4j could allow a remote attacker to execute arbitrary code on the system, caused by an unsafe deserialization in the in Apache Chainsaw component. By sending specially-crafted input, an attacker could exploit this vulnerability to execute arbitrary code on the system.",
"cvssBaseScore": 9.8
}
],
"remediations": [
{
"startVersion": "9.0.0.0",
"endVersion": "9.0.5.10",
"operator": "OR",
"iFixes": [
"PH42762"
],
"fixPack": "9.0.5.11",
"additionalInstallationInstructions": "https://www.ibm.com/support/pages/node/6557248"
}
],
"links": {
"self": {
"rel": "self",
"href": "https://cpd-websphere-automation.apps.wsa-412.example.com/vulnerabilities/70357d34-411d-3321-a60f-ede653897a55",
"type": "application/json",
"title": "self"
},
"asset": {
"rel": "related",
"href": "https://cpd-websphere-automation.apps.wsa-412.example.com/assets/1a5d141a-3294-3ff3-9182-5ae1d4f3465d",
"type": "application/json",
"title": "asset"
},
"securityBulletin": {
"rel": "related",
"href": "https://cpd-websphere-automation.apps.wsa-412.example.com/bulletins/23c15e59-1ef9-3eb5-a175-0845597cdbc1",
"type": "application/json",
"title": "securityBulletin"
}
},
"created": "2023-05-17T10:10:29Z",
"createdBy": "vulnerability-manager",
"updated": "2023-05-17T10:10:29Z",
"updatedBy": "vulnerability-manager",
"secondsExposed": 1379
}
}
感兴趣的信息包括CVE ID、CVSS评分、受影响的服务器、漏洞描述和安全公告URL。
定义过程和预期结果
结果是使 Webhook 目标接收有关新的高严重性 CVE 的信息,并在突发事件表的一行中显示该信息。
- 打开 Web 浏览器以访问 ServiceNow 开发者实例。
https://<YOUR_SERVICENOW_DEVELOPER_ID>.service-now.com/now/nav/ui/classic/params/target/ui_page.do - 通过点击 ”,访问 ServiceNow REST API 资源管理器。
有关更多信息,请参阅 ServiceNow REST API Explorer 文档
。
- 在 REST API Explorer 中,将 API 名称 设置为
TableAPI,然后单击 创建记录 (POST)。 - 在 " 表 API " 页面的 准备请求 部分中,将 tableName 字段的值设置为
Incident (incident)。 - 在 请求主体 部分中,单击 添加字段 并将以下参数和值添加到突发事件表。 使用静态值测试 ServiceNow POST 操作。
字段 值 状态 1影响 test_impact_value紧急程度 test_urgency_value简短描述 WebSphere Automation detected a vulnerability for test_cveId_value with a CVSS base score of test_cvssBaseScore on test_server on test_hostname描述 test_description工作说明 Security Bulletin: test_bulletinUrl类别 Software分配组 (此字母数字是 ServiceNow 工件; 从 ServiceNow 帐户获取值。) - 单击发送。
在 请求 部分中, 请求主体 字段以逗号分隔的 JSON 表示法显示请求主体。
{"state":"1","impact":"test_impact_value","urgency":"test_urgency_value","short_description":"WebSphere Automation detected a vulnerability for test_cveId_value with a CVSS base score of test_cvssBaseScore on test_server on test_hostname","description":"test_description","work_notes": "Security Bulletin: test_bulletinUrl","category":"Software","assignment_group":" ... "}此请求主体在后续步骤中的 Webhook 操作中用于将数据从 WebSphere Automation 传递到 ServiceNow。
此外,请注意 HTTP /URI参数的值。 URI是 WebSphere Automation 网络挂钩操作所需URL。
https://<YOUR_SERVICENOW_DEVELOPER_ID>.service-now.com/api/now/table/incident
设置 Webhook 操作
使用 WebSphere Automation Swagger UI 来创建 Webhook 操作。 有关更多信息,请参阅创建 webhook 操作。
将 body 参数的值设置为您为突发事件表创建的键/值对的逗号分隔列表。 主体参数值中的引号必须使用反斜杠字符进行转义。 将 Mustache 表示法 (双花括号) 用于您创建的变量名称。
{
"name": "ServiceNow Incident Action",
"description": "Creates incidents in ServiceNow when triggered",
"type": "webhook",
"enabled": true,
"configuration": {
"targetUrl": "https://<YOUR_SERVICENOW_DEVELOPER_ID>.service-now.com/api/now/table/incident",
"method": "POST",
"contentType": "application/json",
"user": "<YOUR_SERVICENOW_DEVELOPER_INSTANCE_USER_ID>",
"password": "<YOUR_SERVICENOW_DEVELOPER_INSTANCE_PASSWORD>",
"headers": [
{
"name": "Accept",
"value": "application/json"
}
],
"body": "{ \"state\": \"1\", \"impact\": \"test_impact_value\", \"urgency\": \"test_urgency_value\", \"short_description\":\"WebSphere Automation detected a vulnerability for test_cveId_value with a CVSS base score of test_cvssBaseScore on test_server on test_hostname\", \"description\":\"test_description\", \"work_notes\": \"Security Bulletin: test_bulletinUrl\", \"category\":\"Software\", \"assignment_group\":\"8a4dde73c6112278017a6a4baf547aa7\" }"
}
}
测试 Webhook 操作
要测试 Webhook 操作,请打开 WebSphere Automation Swagger UI 并使用 PATCH /action/{actionId} 控件将硬编码值传递到 ServiceNow 开发者实例。 有关更多信息,请参阅创建操作。
在 actionId 文本字段中输入操作标识。 使用 ServiceNow 在创建 Webhook 时为其分配的 actionId 值。
在 请求主体 字段中输入以下 JSON 代码:
{
"operation": "invoke-action",
"variables": {
"impact": "1",
"urgency": "1",
"cveId": "CVE-2021-44228",
"cvssBaseScore": "10",
"isJdk": false,
"serverName": "server1",
"hostName": "defected1.example.com ",
"description": "My hardcoded test description",
"bulletinUrl": "https://www.ibm.com/support/pages/node/6525706"
}
}
单击 执行。
确保服务器响应代码的值为 200。 成功的响应还具有"successful": true在响应主体中。
在 ServiceNow 上的开发者实例中打开突发事件表,并确认已创建新条目。
创建资源触发器
按照说明创建资源触发器。 请参阅以下示例资源触发器。
将 actionId 参数的值设置为 Swagger UI 分配给操作的操作标识。
在 variableMappings 部分中,创建与操作和事件表中定义的变量匹配的变量。 对于每个变量,创建JSONata表达式,该表达式评估结果为布尔值 https://try.jsonata.org/ ,或评估结果为要传递给webhook的值。 condition参数也可以设置为布尔 JSONata 表达式。 使用 JSONata 试验程序来根据资源通知的 JSON 定义来检查表达式。
{
"name": "Vulnerability Created Trigger",
"description": "Triggers the action when a vulnerability with a CVE that has a CVSS base score greater than 9 is created.",
"actionId": "<YOUR_ACTION_ID>",
"type": "resource",
"enabled": true,
"configuration": {
"resourceType": "vulnerability",
"operation": "create"
},
"condition": "$count(vulnerability.cves[cvssBaseScore > 9 ]) > 0",
"variableMappings": {
"impact": "($maxCvssBaseScore := $max(vulnerability.cves.cvssBaseScore); $maxCvssBaseScore > 0 and $maxCvssBaseScore <= 4.9 ? '3' : ($maxCvssBaseScore >= 5 and $maxCvssBaseScore <= 7.4 ? '2' : '1'))",
"urgency": "($maxCvssBaseScore := $max(vulnerability.cves.cvssBaseScore); $maxCvssBaseScore > 0 and $maxCvssBaseScore <= 4.9 ? '3' : ($maxCvssBaseScore >= 5 and $maxCvssBaseScore <= 7.4 ? '2' : '1'))",
"cveId": "($maxCvssBaseScore := $max(vulnerability.cves.cvssBaseScore); vulnerability.cves[cvssBaseScore = $maxCvssBaseScore][0].id)",
"cvssBaseScore": "$number($max(vulnerability.cves.cvssBaseScore))",
"isJdk": "$asset.type = 'jdk'",
"productName": "$asset.productName",
"serverName": "$asset.serverName",
"hostName": "$asset.hostName",
"description": "($maxCvssBaseScore := $max(vulnerability.cves.cvssBaseScore); vulnerability.cves[cvssBaseScore = $maxCvssBaseScore][0].description)",
"bulletinUrl": "$bulletin.url"
}
}
各种 JSONata 表达式的描述如下所示。
- impact:如果资源通知中的最高 CVSS 得分(cvssBaseScore)介于 0 和 4.9 之间,则设置为
3值;如果介于 5 和 7.4 之间,则设置为2值;否则设置为1值。 - urgency: 与 impact的值相同。
- cveId: 具有最高 CVSS 分数的资源通知中 CVE 的 CVE 标识。
- cvssBaseScore: 资源通知中 CVE 的最高 CVSS 分数。
- description: 具有最高 CVSS 分数的资源通知中 CVE 的描述。
以下变量使用上下文变量。 有关更多信息,请参阅 Trigger 资源。
- isJdk: 如果将 CVE 设置为影响 Java Developer Kit ,那么求值为
true的布尔值。 - productName: 具有漏洞的产品的名称。
- servername: 具有漏洞的服务器的名称。
- hostname: 具有漏洞的运行时的主机名。
- bulletinUrl:漏洞安全公告URL。
通过使用 Swagger UI 运行其 JSON 代码来启用资源触发器。 有关详细信息,请参阅创建资源触发器。