{
  "$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/a7c3f9e2-4d18-4b6a-9f0c-2e5d8b1a6c43')]",
      "kind": "Scheduled",
      "name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/a7c3f9e2-4d18-4b6a-9f0c-2e5d8b1a6c43')]",
      "properties": {
        "alertRuleTemplateName": "a7c3f9e2-4d18-4b6a-9f0c-2e5d8b1a6c43",
        "customDetails": {
          "Attribution": "Attribution",
          "Labels": "Labels",
          "RiskScore": "RiskScore"
        },
        "description": "'Matches network events in CommonSecurityLog against high-risk Speculus IP indicators (risk score >= 75)\nreceived in the last 14 days. These IPs are associated with malicious activity such as command and control,\nbotnets, ransomware infrastructure, or brute-force campaigns.'\n",
        "displayName": "Speculus - Network traffic to or from high-risk IP indicator",
        "enabled": true,
        "entityMappings": [
          {
            "entityType": "IP",
            "fieldMappings": [
              {
                "columnName": "MatchIP",
                "identifier": "Address"
              }
            ]
          }
        ],
        "eventGroupingSettings": {
          "aggregationKind": "AlertPerResult"
        },
        "incidentConfiguration": {
          "createIncident": true,
          "groupingConfiguration": {
            "enabled": true,
            "groupByEntities": [
              "IP"
            ],
            "lookbackDuration": "P1D",
            "matchingMethod": "Selected",
            "reopenClosedIncident": false
          }
        },
        "OriginalUri": "https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Speculus%20Threat%20Intelligence/Analytic%20Rules/Speculus%20-%20IP%20Indicator%20Match%20CommonSecurityLog.yaml",
        "query": "let indicators = Speculus_Indicators_CL\n    | where TimeGenerated > ago(14d)\n    | where isnotempty(IndicatorValue)\n    | where RiskScore >= 75\n    | summarize arg_max(Modified, *) by IndicatorValue\n    | project\n        IndicatorValue,\n        RiskScore,\n        SpeculusActivity = Activity,\n        Attribution,\n        Labels,\n        IndicatorDescription = Description;\nCommonSecurityLog\n| where TimeGenerated > ago(1h)\n| where isnotempty(SourceIP) or isnotempty(DestinationIP)\n| extend MatchIP = iff(isnotempty(DestinationIP), DestinationIP, SourceIP)\n| join kind=inner indicators on $left.MatchIP == $right.IndicatorValue\n| project\n    TimeGenerated,\n    MatchIP,\n    SourceIP,\n    DestinationIP,\n    DeviceVendor,\n    DeviceProduct,\n    RiskScore,\n    SpeculusActivity,\n    Attribution,\n    Labels,\n    IndicatorDescription\n",
        "queryFrequency": "PT1H",
        "queryPeriod": "P14D",
        "severity": "High",
        "status": "Available",
        "subTechniques": [],
        "suppressionDuration": "PT1H",
        "suppressionEnabled": false,
        "tactics": [
          "CommandAndControl",
          "InitialAccess"
        ],
        "techniques": [
          "T1071",
          "T1090"
        ],
        "templateVersion": "1.0.0",
        "triggerOperator": "GreaterThan",
        "triggerThreshold": 0
      },
      "type": "Microsoft.OperationalInsights/workspaces/providers/alertRules"
    }
  ]
}
