{
  "$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/6711b747-16d7-4df4-9f61-8633617f45d7')]",
      "kind": "Scheduled",
      "name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/6711b747-16d7-4df4-9f61-8633617f45d7')]",
      "properties": {
        "alertRuleTemplateName": "6711b747-16d7-4df4-9f61-8633617f45d7",
        "customDetails": null,
        "description": "This will alert when a secret extraction has occurred after an administrator has changed their own vault access permissions within that same vault.\nRef: https://1password.com/\nRef: https://github.com/securehats/",
        "displayName": "1Password - Secret extraction post vault access change by administrator",
        "enabled": true,
        "entityMappings": [
          {
            "entityType": "Account",
            "fieldMappings": [
              {
                "columnName": "TargetUsername",
                "identifier": "FullName"
              }
            ]
          },
          {
            "entityType": "IP",
            "fieldMappings": [
              {
                "columnName": "SrcIpAddr",
                "identifier": "Address"
              }
            ]
          }
        ],
        "eventGroupingSettings": {
          "aggregationKind": "SingleAlert"
        },
        "incidentConfiguration": {
          "createIncident": true,
          "groupingConfiguration": {
            "enabled": true,
            "lookbackDuration": "PT1H",
            "matchingMethod": "AllEntities",
            "reopenClosedIncident": false
          }
        },
        "OriginalUri": "https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/1Password/Analytics%20Rules/1Password%20-%20Secret%20Extraction%20Post%20Vault%20Access%20Change%20By%20Administrator.yaml",
        "query": "let lookback = 1h;\nlet secretExtractionActivity =\n    OnePasswordEventLogs_CL\n    | where TimeGenerated between (ago(lookback) .. now())\n    | where log_source == \"itemusages\"\n    | where action has_any(\"server-fetch\", \"reveal\", \"secure-copy\")\n;\nOnePasswordEventLogs_CL\n| where log_source == \"auditevents\"\n| where (action == \"grant\" and object_type  == \"uva\") or (action == \"update\" and object_type  == \"uva\")\n| where tostring(actor_details.uuid) == tostring(aux_details.uuid)\n| extend\n    userUuid = tostring(actor_details.uuid)\n    , vaultUuid = tostring(object_uuid)\n| join (\n    secretExtractionActivity\n    | extend\n        userUuid = tostring(user.uuid)\n        , vaultUuid = tostring(vault_uuid)\n    )\n    on $left.userUuid == $right.userUuid and $left.vaultUuid == $right.vaultUuid\n| extend\n    auditevents = bag_pack(\"action\", action, \"object_type\", object_type)\n    , itemusages = bag_pack(\"action\", action1, \"object_type\", object_type1)\n    , vault_details = bag_pack(\"vault_uuid\", vault_uuid1, \"item_uuid\", item_uuid1)\n| project\n    TimeGenerated\n    , actor_details\n    , target_details = aux_details\n    , location_details = location\n    , client_details = client1\n    , auditevents\n    , itemusages\n    , vault_details\n    , TargetUsername = tostring(user1.email)\n    , SrcIpAddr = tostring(client1.ip_address)",
        "queryFrequency": "PT5M",
        "queryPeriod": "PT1H",
        "severity": "High",
        "subTechniques": [],
        "suppressionDuration": "PT1H",
        "suppressionEnabled": false,
        "tactics": [
          "CredentialAccess"
        ],
        "techniques": [
          "T1555"
        ],
        "templateVersion": "1.0.0",
        "triggerOperator": "GreaterThan",
        "triggerThreshold": 0
      },
      "type": "Microsoft.OperationalInsights/workspaces/providers/alertRules"
    }
  ]
}
