{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "workspace": {
      "type": "String"
    }
  },
  "resources": [
    {
      "apiVersion": "2024-01-01-preview",
      "id": "[concat(resourceId('Microsoft.OperationalInsights/workspaces/providers', parameters('workspace'), 'Microsoft.SecurityInsights'),'/alertRules/693c5217-e840-427f-9661-3fa0ef266040')]",
      "kind": "Scheduled",
      "name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/693c5217-e840-427f-9661-3fa0ef266040')]",
      "properties": {
        "alertRuleTemplateName": "693c5217-e840-427f-9661-3fa0ef266040",
        "customDetails": null,
        "description": "This will alert you when the user is manually invited, suspended, or deleted.\n\n!This rule should be enabled only by organizations that have User and Group Provisioning enabled.\n",
        "displayName": "Manual invitation, suspension, or deletion",
        "enabled": true,
        "entityMappings": [
          {
            "entityType": "Mailbox",
            "fieldMappings": [
              {
                "columnName": "TargetEmail",
                "identifier": "MailboxPrimaryAddress"
              }
            ]
          }
        ],
        "incidentConfiguration": {
          "createIncident": false
        },
        "OriginalUri": "https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/NordPass/Analytics%20Rules/nordpass_manual_user_manipulation.yaml",
        "query": "NordPassEventLogs_CL  \n| extend metadataParsed = parse_json(metadata)  \n| where (event_type == \"invites\" and action == \"user_invited\") or (event_type == \"access\" and action == \"user_status_updated\" and (metadataParsed.status == \"suspended\" or metadataParsed.status == \"deleted\"))  \n| extend TargetEmail = user_email\n",
        "queryFrequency": "PT1H",
        "queryPeriod": "PT1H",
        "severity": "Medium",
        "subTechniques": [],
        "suppressionDuration": "PT1H",
        "suppressionEnabled": false,
        "tactics": [
          "Persistence"
        ],
        "techniques": [
          "T1098"
        ],
        "templateVersion": "1.0.0",
        "triggerOperator": "GreaterThan",
        "triggerThreshold": 0
      },
      "type": "Microsoft.OperationalInsights/workspaces/providers/alertRules"
    }
  ]
}
