新しい重大度の高い脆弱性が検出された場合の ServiceNow Webhook 通知の作成

WebSphere Automation Swagger UI、JSONata エクササイザー、および Mustache 構文を使用して、Web フックに通知を送信するプロセスを作成します。 この通知には、 WebSphere Automation が検出した、新しく作成された高重大度の脆弱性の詳細が含まれます。

開始前に

開発者インスタンスを提供する ServiceNow Web サイトのアカウントが必要です。 ServiceNow は、デモンストレーションの目的で Webhook ターゲットを作成するために使用できる開発者インターフェースを無料で提供します。
  1. ウェブブラウザを開いて. にアクセスしてください http://www.servicenow.com 外部リンク・アイコン
  2. 「開始」をクリックし、 「開発の開始」をクリックします。
  3. 「登録してビルドを開始」をクリックします。
  4. ServiceNow ID に登録するためのフォームに入力し、 「登録」をクリックします。

    開発者 ID が割り当てられています。 開発者インスタンスのホスト名は、以下のアドレスのようになります。

    <YOUR_SERVICENOW_DEVELOPER_ID>.service-now.com

変数や条件分岐を実装する場合は、必ずその仕組みを理解している マスタッシュ構文 外部リンク・アイコンことを確認してください。

WebSphere Automation リソース通知の調査

このチュートリアルの予期される結果は、 WebSphere Automationで新しく作成された重大度の高いリソース通知から渡された情報が ServiceNow インシデント・テーブルに表示されることです。 このチュートリアルの場合、リソース通知には、管理対象サーバーで新しい脆弱性が検出されたときの新しい脆弱性レコードの作成に関する詳細が含まれています。 以下のリソース通知の例では、 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 などが含まれます。

プロセスと予期される結果の定義

結果として、Web フック・ターゲットは新しい重大度の高い CVE に関する情報を受け取り、その情報をインシデント・テーブルの行に表示します。

  1. Web ブラウザーで ServiceNow 開発者インスタンスを開きます。
    https://<YOUR_SERVICENOW_DEVELOPER_ID>.service-now.com/now/nav/ui/classic/params/target/ui_page.do
  2. [すべて ] > [システム Web サービス] > [REST] > [REST API エクスプローラー] をクリックして、 ServiceNow REST API エクスプローラーにアクセスします。

    詳細については、を参照してください ServiceNow REST API エクスプローラー ドキュメント 外部リンク・アイコン

  3. REST API エクスプローラーで、 「API 名」TableAPI に設定し、 「レコードの作成 (POST)」をクリックします。
  4. 「表 API」 ページの 「準備要求」 セクションで、 tableName フィールドの値を Incident (incident)に設定します。
  5. 「要求本文」 セクションで、 「フィールドの追加」 をクリックし、インシデント・テーブルに以下のパラメーターと値を追加します。 静的な値を使用してテストするServiceNowPOST操作。
    フィールド
    状態 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 アカウントから値を取得します。)
  6. 「送信」をクリックします。

    「要求」 セクションの 「要求本体」 フィールドに、要求本体がコンマ区切りの 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":" ... "}

    この要求本体は、 WebSphere Automation から ServiceNowにデータを渡すために、後のステップの Webhook アクションで使用されます。

    また、 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 テキスト・フィールドにアクション ID を入力します。 作成時に 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 によってアクションに割り当てられたアクション ID に設定します。

variableMappings セクションで、アクションおよびインシデント・テーブルで定義されている変数と一致する変数を作成します。 各変数に対して、ブールhttps://try.jsonata.org/ 外部リンク・アイコン 値またはWebhookに渡す値として評価されるJSONata式を作成します。 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: 値を設定する3最も高いCVSSスコア( cvssBaseScore)は0から4.9、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 UI を使用して JSON コードを実行することにより、リソース・トリガーを有効にします。 詳細については、 「リソーストリガーの作成」 を参照してください。

次のタスク

リソース・トリガーが有効になったため、Web フック・アクションは、 WebSphere Automation が管理対象アセットで新しい重大度の高い CVE を検出した場合にのみ呼び出されます。 WebSphere Automation UI を使用してそのような CVE のフィックスを最近インストールした場合は、 WebSphere Automation を使用してそのフィックスをアンインストールし、適切な条件を作成することができます。 Webhook アクションが適切に動作していることを確認した後、フィックスを再インストールして公開を回避します。