{
  "$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/7c07194a-8eda-4cb7-9bc4-cd4700eb4c4d')]",
      "kind": "Scheduled",
      "name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/7c07194a-8eda-4cb7-9bc4-cd4700eb4c4d')]",
      "properties": {
        "alertRuleTemplateName": "7c07194a-8eda-4cb7-9bc4-cd4700eb4c4d",
        "customDetails": {
          "Changes": "Changes",
          "EventNames": "EventNames",
          "Targets": "Targets"
        },
        "description": "Detects state-changing modifications (add / update / delete / enable / disable) to critical\nDelinea platform settings - authentication profiles and policies, SSO or identity-provider\n(SAML / OIDC / OAuth / federation) configuration, IP range / restriction rules and webhooks -\nthat the acting user has not performed in the prior 14 days. Configuration tampering is\nfrequently a precursor to defense evasion or persistence; routine changes an administrator\nmakes regularly are baselined out, while a first-ever change still alerts.\nMatching uses the event name only, not the free-text display message, and produces one alert\nper actor per run. Tune 'configPattern' to your tenant's event taxonomy, and use\n'excludedEventNames', 'excludedServiceTypes' and 'excludedActors' to silence known-benign\nevents, services (for example directory synchronization) and service accounts.\n",
        "displayName": "Delinea - Platform configuration change",
        "enabled": true,
        "entityMappings": [
          {
            "entityType": "Account",
            "fieldMappings": [
              {
                "columnName": "Actor",
                "identifier": "Name"
              }
            ]
          },
          {
            "entityType": "IP",
            "fieldMappings": [
              {
                "columnName": "SrcIP",
                "identifier": "Address"
              }
            ]
          }
        ],
        "eventGroupingSettings": {
          "aggregationKind": "AlertPerResult"
        },
        "incidentConfiguration": {
          "createIncident": true,
          "groupingConfiguration": {
            "enabled": true,
            "groupByEntities": [
              "Account"
            ],
            "lookbackDuration": "P1D",
            "matchingMethod": "Selected",
            "reopenClosedIncident": false
          }
        },
        "OriginalUri": "https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Delinea%20Platform/Analytic%20Rules/DelineaPlatformConfigChange.yaml",
        "query": "let detectionWindow = 1h;   // must equal queryFrequency\nlet baseline = 14d;         // must stay <= queryPeriod\n// TUNING 1 of 2: configuration objects worth alerting on, matched against the event name.\n// Generic terms such as 'setting', 'profile', 'configuration', 'connector' and 'integration'\n// are deliberately absent - they match routine directory and user-profile activity.\nlet configPattern = @\"(?i)authenticationprofile|authprofile|authentication\\.profile|polic(y|ies)|(^|[^a-z])sso|saml|oidc|oauth|federation|identityprovider|(^|[^a-z])idp|iprange|iprestriction|ipallowlist|webhook|config\";\n// Event names end in the verb (Delinea.Vault.Secret.Viewed, or PascalCase), so read-only\n// events never match this.\nlet changeVerbs = @\"(?i)(Added|Created|Updated|Modified|Changed|Set|Deleted|Removed|Enabled|Disabled|Configured|Update|Change)$\";\n// TUNING 2 of 2: tenant specific exclusions, filled in at deployment time. Exact match,\n// case insensitive. Leave empty if unused.\nlet excludedEventNames = dynamic([\"Delinea.Cloud.Core.Data.ProxyState.Changed\"]);\n//   e.g. dynamic([\"Delinea.Vault.Group.Updated\"]);\nlet excludedServiceTypes = dynamic([]);\n//   e.g. dynamic([\"Identity\"]);\nlet excludedActors = dynamic([]);\n//   e.g. dynamic([\"svc-directory-sync\"]);\nlet changes =\n    DelineaAuditEvents_CL\n    | where TimeGenerated > ago(baseline)\n    | extend IngestedAt = ingestion_time()\n    | extend d = parse_json(RawData)\n    | extend EventName = tostring(coalesce(d.eventType.name, d.eventType.internalName))\n    | where EventName matches regex configPattern and EventName matches regex changeVerbs\n    | extend Actor = tostring(coalesce(d.actor.name, d.actor.email, d.actor.displayName)),\n             ServiceType = tostring(d.service.type),\n             Target = tostring(coalesce(d.target.displayName, d.target.name)),\n             FieldChanges = tostring(d.fieldChanges),\n             RawSrcIP = tostring(d.source.host.network.ipAddress)\n    | where isnotempty(Actor)\n    | where not(EventName in~ (excludedEventNames))\n        and not(ServiceType in~ (excludedServiceTypes))\n        and not(Actor in~ (excludedActors))\n    // '0.0.0.0' is the placeholder reported for events that have no network origin.\n    | extend SrcIP = iff(RawSrcIP in (\"\", \"0.0.0.0\"), \"\", RawSrcIP);\n// Batch by ingestion time so a late arriving event is still evaluated exactly once.\nlet priorChanges = changes | where IngestedAt <= ago(detectionWindow) | distinct Actor, EventName;\nchanges\n| where IngestedAt > ago(detectionWindow)\n| join kind=leftanti priorChanges on Actor, EventName\n| summarize Changes = count(), EventNames = make_set(EventName, 20),\n            Targets = make_set_if(Target, isnotempty(Target), 20),\n            FieldChanges = make_list_if(FieldChanges, isnotempty(FieldChanges), 10),\n            SourceIPs = make_set_if(SrcIP, isnotempty(SrcIP), 20),\n            SrcIP = take_anyif(SrcIP, isnotempty(SrcIP)),\n            StartTime = min(TimeGenerated), EndTime = max(TimeGenerated) by Actor\n| project StartTime, EndTime, Actor, Changes, EventNames, Targets, FieldChanges, SourceIPs, SrcIP\n| sort by StartTime desc\n",
        "queryFrequency": "PT1H",
        "queryPeriod": "P14D",
        "severity": "Medium",
        "status": "Available",
        "subTechniques": [],
        "suppressionDuration": "PT1H",
        "suppressionEnabled": false,
        "tactics": [
          "DefenseEvasion",
          "Persistence"
        ],
        "techniques": [
          "T1098",
          "T1484",
          "T1556"
        ],
        "templateVersion": "1.2.0",
        "triggerOperator": "GreaterThan",
        "triggerThreshold": 0
      },
      "type": "Microsoft.OperationalInsights/workspaces/providers/alertRules"
    }
  ]
}
