새 취약성이 발견될 때 Slack 알림 작성
WebSphere Automation Swagger UI, Slack Block Kit 빌더 및 Mustache 구문을 사용하여 Slack 메시지를 생성하는 웹훅에 알림을 보내는 프로세스를 작성하십시오. 알림에는 WebSphere Automation 에서 발견하는 새 취약성의 세부사항이 포함되어 있습니다.
시작하기 전에
변수나 조건부 처리를 구현할 계획이라면 Mustache 구문 을 숙지하고 있어야 합니다.
WebSphere Automation 자원 알림 검사
이 학습서의 예상 결과는 Slack이 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 포함됩니다.
프로세스 및 예상 결과 정의
결과적으로 Slack 웹훅 대상이 새 높은 심각도 CVE에 대한 정보를 수신하고 해당 정보를 새 Slack 메시지에 표시합니다.
- Slack 차단 킷 빌더에 대한 웹 브라우저를 여십시오.
https://app.slack.com/block-kit-builder/ - 블록 킷 빌더를 사용하여 원하는 형식으로 텍스트를 표시하는 메시지를 구성하십시오. 이 Slack 메시지는 다음 예제를 사용하여 구성됩니다.

{ "blocks": [ { "type": "section", "text": { "type": "mrkdwn", "text": ":alert1: WebSphere Automation detected a vulnerability for CVE <https://www.ibm.com/support/pages/node/6525706|CVE-2021-44228> (CVSS base score 10.0) on server *server1* on host *defected1.example.com*." } }, { "type": "divider" }, { "type": "section", "text": { "type": "mrkdwn", "text": "*CVE Information*\nApache Log4j could allow a remote attacker to execute arbitrary code on the system, caused by the failure to protect against attacker controlled LDAP and other JNDI related endpoints by JNDI features. By sending a specially crafted code string, an attacker could exploit this vulnerability to load arbitrary Java code on the server and take complete control of the system. Note: The vulnerability is also called Log4Shell or LogJam." } }, { "type": "divider" }, { "type": "actions", "elements": [ { "type": "button", "text": { "type": "plain_text", "text": "View Bulletin", "emoji": true }, "value": "click_me", "url": "https://www.ibm.com/support/pages/node/6525706" }, { "type": "button", "text": { "type": "plain_text", "text": "View All server1 CVEs", "emoji": true }, "value": "click_me_123", "url": "https://cpd-websphere-automation.example.com/websphereauto/websphere/1a5d141a-3294-3ff3-9182-5ae1d4f3465d/vulnerabilities/cves" } ] } ] } - Slack 메시지를 올바르게 구조화한 후에는 Mustache 구문을 사용하여 변수를 대체할 수 있습니다. WebSphere Automation 이벤트에서 전송할 매개변수에 대해 이죠가 대체되도록 하십시오.
{ "channel": "<your_Slack_channel>", "blocks": [ { "type": "header", "text": { "type": "plain_text", "text": "Vulnerability Detected" } }, { "type": "divider" }, { "type": "section", "text": { "type": "mrkdwn", "text": "{{icon}} WebSphere Automation detected a vulnerability for CVE <{{bulletinUrl}}|{{cveId}}> (CVSS base score {{cvssBaseScore}}) on {{#isJdk}}JDK *{{productName}}*{{/isJdk}}{{^isJdk}}server *{{serverName}}*{{/isJdk}} on host *{{hostName}}*." } }, { "type": "divider" }, { "type": "section", "text": { "type": "mrkdwn", "text": "*CVE Information*\n{{{@wsa_eq_cveSummary}}}" } }, { "type": "actions", "elements": [ { "type": "button", "text": { "type": "plain_text", "text": "View Bulletin" }, "value": "click_me", "url": "{{bulletinUrl}}" }{{^isJdk}}, { "type": "button", "text": { "type": "plain_text", "text": "View All CVEs for {{serverName}}" }, "value": "click_me_123", "url": "https://cpd-websphere-automation.example.com/websphereauto/websphere/{{serverId}}/vulnerabilities/cves" } {{/isJdk}} ] }, { "type": "divider" } ] }
웹훅 조치 설정
WebSphere Automation Swagger UI를 사용하여 웹훅 조치를 작성하십시오. 자세한 내용은 웹훅 액션 만들기를 참조하세요.
body 매개변수에서 Slack Block Kit 빌더에서 작성한 JSON 요소의 쉼표로 구분된 목록을 작성하십시오. 본문 매개변수 값의 따옴표는 백슬래시 문자로 이스케이프되어야 합니다. 작성한 변수 이름에 대해 Mustache 표기법 (이중 중괄호) 을 사용하십시오.
{
"id": "74313a6b-a163-4f7d-833b-31bf4f12670a",
"name": "Vulnerability Slack Notification Action",
"description": "POSTs a notification to Slack when triggered",
"type": "webhook",
"enabled": true,
"configuration": {
"targetUrl": "https://hooks.slack.com/services/12345/12345/12345",
"method": "POST",
"contentType": "application/json",
"headers": [],
"body": "{ \"channel\": \"<your_Slack_channel>\", \"blocks\": [ { \"type\": \"header\", \"text\": { \"type\": \"plain_text\", \"text\": \"Vulnerability Detected\" } }, { \"type\": \"divider\" }, { \"type\": \"section\", \"text\": { \"type\": \"mrkdwn\", \"text\": \"{{icon}} WebSphere Automation detected a vulnerability for CVE <{{bulletinUrl}}|{{cveId}}> (CVSS base score {{cvssBaseScore}}) on {{#isJdk}}JDK *{{productName}}*{{/isJdk}}{{^isJdk}}server *{{serverName}}*{{/isJdk}} on host *{{hostName}}*.\" } }, { \"type\": \"divider\" }, { \"type\": \"section\", \"text\": { \"type\": \"mrkdwn\", \"text\": \"*CVE Information*\\n{{{@wsa_eq_cveSummary}}}\" } }, { \"type\": \"actions\", \"elements\": [ { \"type\": \"button\", \"text\": { \"type\": \"plain_text\", \"text\": \"View Bulletin\" }, \"value\": \"click_me\", \"url\": \"{{bulletinUrl}}\" }{{^isJdk}}, { \"type\": \"button\", \"text\": { \"type\": \"plain_text\", \"text\": \"View All CVEs for {{serverName}}\" }, \"value\": \"click_me_123\", \"url\": \"https://cpd-websphere-automation.example.com/websphereauto/websphere/{{serverId}}/vulnerabilities/cves\" } {{/isJdk}} ] }, { \"type\": \"divider\" } ] }"
}
}
웹훅 조치 테스트
웹훅 조치를 테스트하려면 WebSphere Automation Swagger UI를 열고 PATCH /action/{actionId} 제어를 사용하여 하드 코딩된 값을 Slack에 전달하십시오. 자세한 내용은 액션 만들기를 참조하세요.
actionId 텍스트 필드에 조치 ID를 입력하십시오. Swagger UI가 조치를 작성할 때 조치를 지정한 actionId 값을 사용하십시오.
요청 본문 필드에 다음 JSON 코드를 입력하십시오.
{
"operation": "invoke-action",
"variables": {
"hostName": "example.com",
"cveSummary": "Example CVE summary",
"bulletinUrl": "https://www.ibm.com/support/pages/node/6525706",
"cveId": "CVE-2021-44228",
"icon": ":alert1:",
"serverName": "server1",
"cvssBaseScore": "10",
"isJdk": "false",
"serverId": "1a5d141a-3294-3ff3-9182-5ae1d4f3465d",
"productName": "WebSphere Application Server"
}
}
실행을 클릭하십시오.
서버 응답 코드의 값이 200인지 확인하십시오. 성공적인 응답은 다음과 같습니다."successful": true응답 본문에서.
Slack 채널을 열고 새 메시지가 작성되었는지 확인하십시오.
자원 트리거 작성
지침에 따라 리소스 트리거를 생성합니다. 다음 예제 자원 트리거를 참조하십시오.
actionId 매개변수의 값을 Swagger UI에서 조치에 지정한 조치 ID로 설정하십시오.
variableMappings 섹션에서 조치 및 인시던트 테이블에 정의된 변수와 일치하는 변수를 작성하십시오. 각 변수에 대해 부울로 평가되거나 https://try.jsonata.org/ 또는 웹훅에 전달할 값으로 평가되는 JSONata 표현식을 만듭니다.
{
"id": "46e65c6e-8c9d-4fe9-90fb-ac5ca2303fae",
"name": "Vulnerability Created Trigger",
"description": "Triggers the Slack Notification action when a vulnerability with a CVE that has a CVSS base score greater than 9 is created.",
"actionId": "<your_Slack_Notification_action_id>",
"type": "resource",
"enabled": true,
"configuration": {
"resourceType": "vulnerability",
"operation": "create"
},
"variableMappings": {
"hostName": "$asset.hostName",
"cveSummary": "($maxCvssBaseScore := $max(vulnerability.cves.cvssBaseScore); vulnerability.cves[cvssBaseScore = $maxCvssBaseScore][0].description)",
"bulletinUrl": "$bulletin.url",
"cveId": "($maxCvssBaseScore := $max(vulnerability.cves.cvssBaseScore); vulnerability.cves[cvssBaseScore = $maxCvssBaseScore][0].id)",
"icon": "($maxCvssBaseScore := $max(vulnerability.cves.cvssBaseScore); $maxCvssBaseScore > 0 and $maxCvssBaseScore <= 3.9 ? ':warning:' : ($maxCvssBaseScore >= 4 and $maxCvssBaseScore <= 6.9 ? ':standup_ibm_status_major_warning_orange:' : ($maxCvssBaseScore >= 7 and $maxCvssBaseScore <= 8.9 ? ':ibm-warning-filled:' : ':alert1:')))",
"serverName": "$asset.serverName",
"cvssBaseScore": "$number($max(vulnerability.cves.cvssBaseScore))",
"isJdk": "$asset.type = 'jdk'",
"serverId": "$asset.id",
"productName": "$asset.productName"
}
}
다양한 JSONata 표현식에 대한 설명은 다음과 같습니다.
- cveSummary: 가장 높은 CVSS 점수를 가진 자원 알림의 CVE에 대한 설명입니다.
- cveId: 가장 높은 CVSS 점수를 갖는 자원 알림에서 CVE에 대한 CVE ID입니다.
- icon: CVSS 점수가 가장 높은 CVE의 긴급성을 나타내는 아이콘입니다. 경고 기호는 CVSS 점수 3.9 이하, 4.0 - 6.9의 주요 경고 및 7.0 초과의 경보를 표시합니다.
- cvssBaseScore: 자원 알림에서 CVSS의 가장 높은 CVSS 점수입니다.
다음 변수는 컨텍스트 변수를 사용합니다. 자세한 내용은 트리거 리소스를 참조하세요.
- isJDK: CVE가 Java Developer Kit에 영향을 주는 것으로 설정된 경우
true로 평가되는 부울입니다. - productName: 취약성이 있는 제품의 이름입니다.
- servername: 취약성이 있는 서버의 이름입니다.
- hostname: 취약성이 있는 런타임의 호스트 이름입니다.
- bulletinUrl: 취약점에 대한 보안 공지 사항의 URL.
JSON 코드를 실행하기 위해 Swagger UI를 사용하여 자원 트리거를 사용으로 설정하십시오. 자세한 내용은 리소스 트리거 만들기를 참조하세요.