{
  "name": "RedSiftPush",
  "apiVersion": "2022-09-01-preview",
  "type": "Microsoft.SecurityInsights/dataConnectorDefinitions",
  "location": "[parameters('workspace-location')]",
  "kind": "Customizable",
  "properties": {
    "connectorUiConfig": {
      "id": "RedSiftPush",
      "title": "Red Sift Events (CCP Push)",
      "publisher": "Red Sift",
      "descriptionMarkdown": "The [Red Sift](https://redsift.com/) connector provides the capability to ingest Red Sift authentication and email forensics events into Microsoft Sentinel using the CCP push model with DCE + DCR.",
      "graphQueries": [
        {
          "metricName": "Auth Events",
          "legend": "RedSiftAuth_CL",
          "baseQuery": "RedSiftAuth_CL"
        },
        {
          "metricName": "Email Forensics Events",
          "legend": "RedSiftEmailForensics_CL",
          "baseQuery": "RedSiftEmailForensics_CL"
        }
      ],
      "sampleQueries": [
        {
          "description": "Latest auth events",
          "query": "RedSiftAuth_CL\n | sort by TimeGenerated desc"
        },
        {
          "description": "Logins vs logouts",
          "query": "RedSiftAuth_CL\n | summarize count() by ActivityName"
        },
        {
          "description": "By user",
          "query": "RedSiftAuth_CL\n | summarize count() by UserUid, UserEmail"
        },
        {
          "description": "Latest email forensics events",
          "query": "RedSiftEmailForensics_CL\n | sort by TimeGenerated desc"
        },
        {
          "description": "Email forensics by DKIM/SPF result",
          "query": "RedSiftEmailForensics_CL\n | summarize count() by DkimResult, SpfResult"
        },
        {
          "description": "Email forensics by sender",
          "query": "RedSiftEmailForensics_CL\n | summarize count() by EmailFrom"
        }
      ],
      "dataTypes": [
        {
          "name": "RedSiftAuth_CL",
          "lastDataReceivedQuery": "RedSiftAuth_CL\n            | summarize Time = max(TimeGenerated)\n            | where isnotempty(Time)"
        },
        {
          "name": "RedSiftEmailForensics_CL",
          "lastDataReceivedQuery": "RedSiftEmailForensics_CL\n            | summarize Time = max(TimeGenerated)\n            | where isnotempty(Time)"
        }
      ],
      "connectivityCriteria": [
        {
          "type": "IsConnectedQuery",
          "value": [
            "RedSiftAuth_CL\n            | summarize LastLogReceived = max(TimeGenerated)\n            | project IsConnected = LastLogReceived > ago(7d)",
            "RedSiftEmailForensics_CL\n            | summarize LastLogReceived = max(TimeGenerated)\n            | project IsConnected = LastLogReceived > ago(7d)"
          ]
        }
      ],
      "availability": {
        "status": 1
      },
      "permissions": {
        "resourceProvider": [
          {
            "provider": "Microsoft.OperationalInsights/workspaces",
            "permissionsDisplayText": "read and write permissions are required.",
            "providerDisplayName": "Workspace",
            "scope": "Workspace",
            "requiredPermissions": {
              "write": true,
              "read": true,
              "delete": true
            }
          }
        ],
        "customs": [
          {
            "name": "Microsoft Entra",
            "description": "Permission to create an app registration in Microsoft Entra ID. Typically requires Entra ID Application Developer role or higher."
          },
          {
            "name": "Microsoft Azure",
            "description": "Permission to assign Monitoring Metrics Publisher role on data collection rule (DCR). Typically requires Azure RBAC Owner or User Access Administrator role."
          }
        ]
      },
      "instructionSteps": [
        {
          "title": "1. Create ARM Resources and Provide the Required Permissions",
          "description": "Deploy the DCE, DCR, custom table, and the Entra app registration used for OAuth client credentials.",
          "instructions": [
            {
              "type": "Markdown",
              "parameters": {
                "content": "#### Automated Configuration and Secure Data Ingestion with Entra Application\nClicking on \"Deploy\" will trigger the creation of Log Analytics tables and a Data Collection Rule (DCR). It will then create an Entra application, link the DCR to it, and set the entered secret in the application. This setup enables data to be sent securely to the DCR using an Entra token."
              }
            },
            {
              "parameters": {
                "label": "Deploy Red Sift connector resources",
                "applicationDisplayName": "Red Sift Connector Application"
              },
              "type": "DeployPushConnectorButton"
            }
          ]
        },
        {
          "title": "2. Configure Red Sift webhook",
          "description": "Use the following parameters to configure Red Sift to send events to Microsoft Sentinel. Use the appropriate stream name for each event type.",
          "instructions": [
            {
              "parameters": {
                "label": "Tenant ID (Directory ID)",
                "fillWith": [
                  "TenantId"
                ]
              },
              "type": "CopyableLabel"
            },
            {
              "parameters": {
                "label": "Entra App Registration Application ID",
                "fillWith": [
                  "ApplicationId"
                ],
                "placeholder": "Deploy push connector to get the App Registration Application ID"
              },
              "type": "CopyableLabel"
            },
            {
              "parameters": {
                "label": "Entra App Registration Secret",
                "fillWith": [
                  "ApplicationSecret"
                ],
                "placeholder": "Deploy push connector to get the App Registration Secret"
              },
              "type": "CopyableLabel"
            },
            {
              "parameters": {
                "label": "Data Collection Endpoint Uri",
                "fillWith": [
                  "DataCollectionEndpoint"
                ],
                "placeholder": "Deploy push connector to get the Data Collection Endpoint Uri"
              },
              "type": "CopyableLabel"
            },
            {
              "parameters": {
                "label": "Data Collection Rule Immutable ID",
                "fillWith": [
                  "DataCollectionRuleId"
                ],
                "placeholder": "Deploy push connector to get the Data Collection Rule Immutable ID"
              },
              "type": "CopyableLabel"
            },
            {
              "parameters": {
                "label": "Auth Events Stream Name",
                "value": "Custom-RedSiftAuth"
              },
              "type": "CopyableLabel"
            },
            {
              "parameters": {
                "label": "Email Forensics Events Stream Name",
                "value": "Custom-RedSiftEmailForensics"
              },
              "type": "CopyableLabel"
            }
          ]
        }
      ]
    }
  }
}
