偵測到新的高嚴重性漏洞時建立 ServiceNow Webhook 通知
使用 WebSphere Automation Swagger 使用者介面、JSONata Exerciser 及 Mustache 語法,建立將通知傳送至 Webhook 的處理程序。 通知包含 WebSphere Automation 偵測到的任何新建立的高嚴重性漏洞的詳細資料。
開始之前
- 開啟 Web 瀏覽器,並移至 https://www.servicenow.com。
- 按一下 開始使用,然後按一下 開始開發。
- 按一下 註冊並開始建置。
- 完成表單以註冊 ServiceNow ID ,然後按一下 註冊。
您已獲指派開發人員 ID。 您的開發人員實例主機名稱類似於下列位址:
<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 瀏覽器」中,將 API 名稱 設為
TableAPI,然後按一下 建立記錄 (POST)。 - 在「 表格 API 」頁面的 準備要求 區段中,將 tableName 欄位的值設為
Incident (incident)。 - 在 要求內文 區段中,按一下 新增欄位 ,並將下列參數及值新增至突發事件表格。 連接至 Webhook 動作的變數以 Mustache 表示法 (雙大括弧,即
{{ }}) 定義。 如果您想要測試 ServiceNow POST 作業,一開始可以使用靜態值。欄位 值 狀態 1影響 {{impact}}緊急性 {{urgency}}簡要說明 WebSphere Automation detected a vulnerability for {{cveID}} with a CVSS base score of {{cvssBaseScore}} on {{#isJDK}}JDK {{productName}}{{/isJDK}}{{^isJDK}}server {{serverName}}{{/isJDK}} on host {{hostName}}說明 {{description}}工作附註 Security Bulletin: {{bulletinUrl}}種類 Software指派群組 (此英數是 ServiceNow 構件; 從 ServiceNow 帳戶取得值。) - 按一下傳送。
在 要求 區段中, 要求內文 欄位以逗點區隔 JSON 表示法顯示要求內文。
{"state":"1","impact":"{{impact}}","urgency":"{{urgency}}","short_description":"WebSphere Automation detected a vulnerability for {{cveID}} with a CVSS base score of {{cvssBaseScore}} on {{#isJDK}}JDK {{productName}}{{/isJDK}}{{^isJDK}}server {{serverName}}{{/isJDK}} on host {{hostName}}","description":"{{description}}","work_notes": "Security Bulletin: {{bulletinUrl}}","category":"Software","assignment_group":" ... "}在後續步驟中的 Webhook 動作中使用此要求內文,以將資料從 WebSphere Automation 傳遞至 ServiceNow。
此外,請記下 HTTP 方法 /URI 參數的值。 URI 是 WebSphere Automation Webhook 動作所需的目標 URL。
https://<YOUR_SERVICENOW_DEVELOPER_ID>.service-now.com/api/now/table/incident
設定 Webhook 動作
使用 WebSphere Automation Swagger 使用者介面來建立 Webhook 動作。 如需相關資訊,請參閱 建立 Webhook 動作。
將 body 參數的值設為您為突發事件表格建立的鍵值組清單 (以逗點區隔)。 body 參數值中的引號必須以反斜線字元跳出。 對您建立的變數名稱使用 Mustache 表示法 (雙大括弧)。
{
"name": "ServiceNow Incident Action",
"description": "Creates incidents in ServiceNow when triggered",
"type": "webhook",
"enabled": true,
"configuration": {
"targetUrl": "https://<YOUR_SERVICENOW_DEVELOPER_ID>.servicenow.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\": \"{{impact}}\", \"urgency\": \"{{urgency}}\", \"short_description\":\"WebSphere Automation detected a vulnerability for {{cveId}} (CVSS base score {{cvssBaseScore}}) on {{#isJdk}}JDK {{productName}}{{/isJdk}}{{^isJdk}}server {{serverName}}{{/isJdk}} on host {{hostName}}\", \"description\":\"{{description}}\", \"work_notes\": \"Security Bulletin: {{bulletinUrl}}\", \"category\":\"Software\", \"assignment_group\":\"8a4dde73c6112278017a6a4baf547aa7\" }"
}
}
測試 Webhook 動作
若要測試 Webhook 動作,請開啟 WebSphere Automation Swagger 使用者介面,並使用 PATCH /action/{actionId} 控制項,將寫在程式中的值傳遞至 ServiceNow 開發人員實例。 如需相關資訊,請參閱 建立動作。
在 actionId 文字欄位中輸入動作 ID。 使用您建立 Webhook 時 ServiceNow 所指派的 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 使用者介面指派給動作的動作 ID。
在 variableMappings 區段中,建立與動作及突發事件表格中定義的變數相符的變數。 針對每一個變數,建立 JSONata 表示式,以評估為布林https://try.jsonata.org/ 或您要傳遞至 Webhook 的值。 condition 參數也可以設為布林 JSONata 表示式。 使用位於的 JSONata Exerciser 來根據資源通知的 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 評分 (cvssBase評分) 介於 0 與 4.9之間,則設為
3值,2表示介於 5 與 7.4之間,否則為1。 - urgency: 與 impact的值相同。
- cveId:CVSS 評分最高之資源通知中的 CVE CVE ID。
- cvssBaseScore: 資源通知中 CVE 的最高 CVSS 評分。
- description:CVSS 評分最高之資源通知中的 CVE 說明。
下列變數使用環境定義變數。 如需相關資訊,請參閱 觸發程式資源。
- isJDK:布林值,如果 CVE 設定為影響 Java Developer Kit ,則會評估為
true。 - productName: 具有漏洞的產品名稱。
- servername: 具有漏洞的伺服器名稱。
- hostname: 具有漏洞之執行時期的主機名稱。
- bulletinUrl: 漏洞安全公告的 URL。
使用 Swagger 使用者介面來啟用資源觸發程式,以執行其 JSON 程式碼。 如需相關資訊,請參閱 建立資源觸發程式。