detectionRule を作成する

名前空間: microsoft.graph.security

重要

Microsoft Graph の /beta バージョンの API は変更される可能性があります。 実稼働アプリケーションでこれらの API を使用することは、サポートされていません。 v1.0 で API を使用できるかどうかを確認するには、Version セレクターを使用します。

新しい detectionRule オブジェクトを 作成します。

この API は、次の国内クラウド展開で使用できます。

グローバル サービス 米国政府機関 L4 米国政府機関 L5 (DOD) 21Vianet が運営する中国

アクセス許可

この API の最小特権としてマークされているアクセス許可またはアクセス許可を選択します。 アプリで必要な場合にのみ、より高い特権のアクセス許可またはアクセス許可を使用します。 委任されたアクセス許可とアプリケーションのアクセス許可の詳細については、「アクセス許可の種類」を参照してください。 これらのアクセス許可の詳細については、「アクセス許可のリファレンス」を参照してください。

アクセス許可の種類 最小特権アクセス許可 より高い特権のアクセス許可
委任 (職場または学校のアカウント) CustomDetection.ReadWrite.All 注意事項なし。
委任 (個人用 Microsoft アカウント) サポートされていません。 サポートされていません。
アプリケーション CustomDetection.ReadWrite.All 注意事項なし。

重要

職場または学校アカウントを使用した委任されたアクセスの場合、サインインしているユーザーに、この操作に必要なアクセス許可を付与するロールを割り当てる必要があります。 カスタム検出ルールでは、Microsoft Defender XDR統合ロールベースのアクセス制御 (RBAC) モデルが使用されます。 サポートされているロールは次のとおりです:

  • 検出のチューニング (管理) - カスタム検出、アラートのチューニング、侵害の脅威インジケーターなど、Microsoft Defender ポータルで検出へのアクセスを管理できるようにする、Microsoft Defender XDR統合 RBAC アクセス許可。
  • セキュリティ管理者 - Microsoft Defender ポータルとサービス間で管理アクセス許可を付与するMicrosoft Entraロール
  • Security Operator - Microsoft Entra ロール。 Microsoft Defender for Endpointでロールベースのアクセス制御がオフになっている場合にのみ、カスタム検出ルールを管理するのに十分です。 RBAC が構成されている場合は、Defender for Endpoint の [セキュリティ設定の管理] アクセス許可も必要です。

特定の Defender ワークロード (Defender for Endpoint、Defender for Office 365 など) のデータを対象とするルールを管理するには、ワークロード固有の追加のアクセス許可が必要になる場合があります。 詳細については、「 カスタム検出を管理するために必要なアクセス許可」を参照してください。

HTTP 要求

POST /security/rules/detectionRules

要求ヘッダー

名前 説明
Authorization ベアラー {token}。 必須です。 認証と認可についての詳細をご覧ください。
Content-Type application/json. 必須です。

要求本文

要求本文で、 microsoft.graph.security.detectionRule オブジェクトの JSON 表現を指定します。

detectionRule を作成するときに、次のプロパティとリレーションシップを指定できます。

プロパティ 説明
description String 検出ルールのユーザー指定の説明。 省略可能。
detectionAction microsoft.graph.security.detectionAction 作成されたアラートや自動応答アクションなど、このルールによって検出が行われたときに実行されるアクション。 省略可能。
displayName String ルールの表示名。 必須。
id 文字列 ルールのクライアント提供の一意識別子。 必須です。
isEnabled ブール値 非推奨。 代わりに 状態 を使用します。 isEnabled プロパティは、2026-10-01 にこのリソースから削除されます。 省略可能。
queryCondition microsoft.graph.security.queryCondition このルールの検出ロジックを定義する高度なハンティング クエリ。 必須です。
schedule microsoft.graph.security.ruleSchedule このルールのトリガー スケジュール。 必須です。
status microsoft.graph.security.detectionRuleStatus ルールの現在の実行状態。 使用可能な値: enableddisabledautoDisabledunknownFutureValue。 必須です。

応答

成功した場合、このメソッドは応答本文に 201 Created 応答コードと microsoft.graph.security.detectionRule オブジェクトを返します。

要求

次の例は要求を示しています。

POST https://graph.microsoft.com/beta/security/rules/detectionRules
Content-Type: application/json

{
  "@odata.type": "#microsoft.graph.security.detectionRule",
  "id": "office-encoded-powershell",
  "displayName": "Suspicious encoded PowerShell from Office",
  "description": "Detects encoded PowerShell processes launched by Office applications, a common phishing payload pattern.",
  "status": "enabled",
  "queryCondition": {
    "queryText": "DeviceProcessEvents | where InitiatingProcessFileName in~ ('winword.exe','excel.exe','outlook.exe') | where FileName == 'powershell.exe' | where ProcessCommandLine has '-enc'"
  },
  "schedule": {
    "frequency": "PT1H"
  },
  "detectionAction": {
    "alertTemplate": {
      "title": "Suspicious encoded PowerShell from Office",
      "description": "An Office app launched an encoded PowerShell command, which may indicate phishing-driven code execution.",
      "severity": "high",
      "recommendedActions": "Investigate the parent Office document, isolate the device, and review the user's recent email activity.",
      "entityMappings": {
        "accounts": [
          {
            "nameColumn": "AccountName",
            "ntDomainColumn": "AccountDomain",
            "sidColumn": "AccountSid"
          }
        ],
        "hosts": [
          {
            "deviceIdColumn": "DeviceId",
            "nameColumn": "DeviceName"
          }
        ],
        "files": [
          {
            "nameColumn": "FileName",
            "sha1Column": "SHA1",
            "sha256Column": "SHA256"
          }
        ]
      },
      "tactics": [
        {
          "tactic": "Execution",
          "techniques": [
            {
              "technique": "T1059.001"
            }
          ]
        }
      ]
    }
  }
}

応答

次の例は応答を示しています。

注: ここに示す応答オブジェクトは、読みやすさのために短縮されている場合があります。

HTTP/1.1 201 Created
Content-Type: application/json
Location: https://graph.microsoft.com/beta/security/rules/detectionRules/office-encoded-powershell

{
  "@odata.type": "#microsoft.graph.security.detectionRule",
  "id": "office-encoded-powershell",
  "displayName": "Suspicious encoded PowerShell from Office",
  "description": "Detects encoded PowerShell processes launched by Office applications, a common phishing payload pattern.",
  "status": "enabled",
  "createdBy": "alice@contoso.com",
  "createdDateTime": "2026-05-25T10:15:00Z",
  "lastModifiedBy": "alice@contoso.com",
  "lastModifiedDateTime": "2026-05-25T10:15:00Z",
  "queryCondition": {
    "queryText": "DeviceProcessEvents | where InitiatingProcessFileName in~ ('winword.exe','excel.exe','outlook.exe') | where FileName == 'powershell.exe' | where ProcessCommandLine has '-enc'"
  },
  "schedule": {
    "frequency": "PT1H"
  },
  "detectionAction": {
    "alertTemplate": {
      "title": "Suspicious encoded PowerShell from Office",
      "description": "An Office app launched an encoded PowerShell command, which may indicate phishing-driven code execution.",
      "severity": "high",
      "recommendedActions": "Investigate the parent Office document, isolate the device, and review the user's recent email activity.",
      "entityMappings": {
        "accounts": [
          {
            "nameColumn": "AccountName",
            "sidColumn": "AccountSid"
          }
        ]
      },
      "tactics": [
        {
          "tactic": "Execution",
          "techniques": [
            {
              "technique": "T1059.001"
            }
          ]
        }
      ]
    },
    "automatedActions": {
      "isolateDevices": [
        {
          "deviceIdColumn": "DeviceId",
          "isolationType": "full"
        }
      ],
      "initiateInvestigations": [
        {
          "deviceIdColumn": "DeviceId"
        }
      ]
    }
  }
}