{
  "id": "GitHubWebhook",
  "title": "GitHub (using Webhooks)",
  "publisher": "Microsoft",
  "descriptionMarkdown": "The [GitHub](https://www.github.com) webhook data connector provides the capability to ingest GitHub subscribed events into Microsoft Sentinel using [GitHub webhook events](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads). The connector provides ability to get events into Microsoft Sentinel which helps to examine potential security risks, analyze your team's use of collaboration, diagnose configuration problems and more. \n\n **Note:** If you are intended to ingest Github Audit logs, Please refer to GitHub Enterprise Audit Log Connector from \"**Data Connectors**\" gallery.",
  "graphQueries": [
    {
      "metricName": "Total data received",
      "legend": "githubscanaudit_CL",
      "baseQuery": "githubscanaudit_CL"
    }
  ],
  "sampleQueries": [
    {
      "description": "GitHub Events - All Activities.",
      "query": "githubscanaudit_CL\n | sort by TimeGenerated desc"
    }
  ],
  "dataTypes": [
    {
      "name": "githubscanaudit_CL",
      "lastDataReceivedQuery": "githubscanaudit_CL\n            | summarize Time = max(TimeGenerated)\n            | where isnotempty(Time)"
    }
  ],
  "connectivityCriterias": [
    {
      "type": "IsConnectedQuery",
      "value": [
        "githubscanaudit_CL\n            | summarize LastLogReceived = max(TimeGenerated)\n            | project IsConnected = LastLogReceived > ago(3d)"
      ]
    }
  ],
  "availability": {
    "status": 1,
    "isPreview": false
  },
  "permissions": {
    "resourceProvider": [
      {
        "provider": "Microsoft.OperationalInsights/workspaces",
        "permissionsDisplayText": "read and write permissions on the workspace are required.",
        "providerDisplayName": "Workspace",
        "scope": "Workspace",
        "requiredPermissions": {
          "write": true,
          "read": true,
          "delete": true
        }
      },
      {
        "provider": "Microsoft.OperationalInsights/workspaces/sharedKeys",
        "permissionsDisplayText": "read permissions to shared keys for the workspace are required. [See the documentation to learn more about workspace keys](https://docs.microsoft.com/azure/azure-monitor/platform/agent-windows#obtain-workspace-id-and-key).",
        "providerDisplayName": "Keys",
        "scope": "Workspace",
        "requiredPermissions": {
          "action": true
        }
      }
    ],
    "customs": [
      {
        "name": "Microsoft.Web/sites permissions",
        "description": "Read and write permissions to Azure Functions to create a Function App is required. [See the documentation to learn more about Azure Functions](https://docs.microsoft.com/azure/azure-functions/)."
      }
    ]
  },
  "instructionSteps": [
    {
      "title": "",
      "description": ">**NOTE:** This connector has been built on http trigger based Azure Function. And it provides an endpoint to which github will be connected through it's webhook capability and posts the subscribed events into Microsoft Sentinel. This might result in additional data ingestion costs. Check the [Azure Functions pricing page](https://azure.microsoft.com/pricing/details/functions/) for details."
    },
    {
      "title": "",
      "description": ">**(Optional Step)** Securely store workspace and API authorization key(s) or token(s) in Azure Key Vault. Azure Key Vault provides a secure mechanism to store and retrieve key values. [Follow these instructions](https://docs.microsoft.com/azure/app-service/app-service-key-vault-references) to use Azure Key Vault with an Azure Function App."
    },
    {
      "title": "",
      "description": "**Choose ONE from the following two deployment options to deploy the connector and the associated Azure Function**\n\n>**IMPORTANT:** Before deploying the Github Webhook connector, have the Workspace ID  and Workspace Primary Key (can be copied from the following).",
      "instructions": [
        {
          "parameters": {
            "fillWith": [
              "WorkspaceId"
            ],
            "label": "Workspace ID"
          },
          "type": "CopyableLabel"
        },
        {
          "parameters": {
            "fillWith": [
              "PrimaryKey"
            ],
            "label": "Primary Key"
          },
          "type": "CopyableLabel"
        }
      ]
    },
    {
      "instructions": [
        {
          "parameters": {
            "instructionSteps": [
              {
                "title": "Option 1 - Azure Resource Manager (ARM) Template",
                "description": "Use this method for automated deployment of the GitHub data connector using an ARM Tempate.\n\n1. Click the **Deploy to Azure** button below. \n\n\t[![Deploy To Azure](https://aka.ms/deploytoazurebutton)](https://aka.ms/sentinel-GitHubwebhookAPI-azuredeploy)\n2. Select the preferred **Subscription**, **Resource Group** and **Location**. \n> **NOTE:** Within the same resource group, you can't mix Windows and Linux apps in the same region and deploy. \n3. Mark the checkbox labeled **I agree to the terms and conditions stated above**. \n5. Click **Purchase** to deploy."
              },
              {
                "title": "Option 2 - Manual Deployment of Azure Functions",
                "description": "Use the following step-by-step instructions to deploy the GitHub webhook data connector manually with Azure Functions (Deployment via Visual Studio Code).",
                "instructions": [
                  {
                    "parameters": {
                      "instructionSteps": [
                        {
                          "title": "Step 1 - Deploy a Function App",
                          "description": "1. Download the [Azure Function App](https://aka.ms/sentinel-GitHubWebhookAPI-functionapp) file. Extract archive to your local development computer.\n2. Follow the [function app manual deployment instructions](https://github.com/Azure/Azure-Sentinel/blob/master/DataConnectors/AzureFunctionsManualDeployment.md#function-app-manual-deployment-instructions) to deploy the Azure Functions app using VSCode.\n3. After successful deployment of the function app, follow next steps for configuring it."
                        },
                        {
                          "title": "Step 2 - Configure the Function App",
                          "description": "1. Go to Azure Portal for the Function App configuration. \n2. In the Function App, select the Function App Name and select **Configuration**.\n3. In the **Application settings** tab, select ** New application setting**.\n4. Add each of the following application settings individually, with their respective string values (case-sensitive): \n\t\tWorkspaceID\n\t\tWorkspaceKey\n\t\tlogAnalyticsUri (optional) - Use logAnalyticsUri to override the log analytics API endpoint for dedicated cloud. For example, for public cloud, leave the value empty; for Azure GovUS cloud environment, specify the value in the following format: `https://<CustomerId>.ods.opinsights.azure.us`.\n4. Once all application settings have been entered, click **Save**."
                        }
                      ]
                    },
                    "type": "InstructionStepsGroup"
                  }
                ]
              }
            ]
          },
          "type": "InstructionStepsGroup"
        }
      ]
    },
    {
      "title": "",
      "description": "**Post Deployment steps**\n\n"
    },
    {
      "instructions": [
        {
          "parameters": {
            "instructionSteps": [
              {
                "title": "STEP 1 - To get the Azure Function url",
                "description": " 1. Go to Azure function Overview page and Click on \"Functions\" in the left blade.\n 2. Click on the function called \"GithubwebhookConnector\".\n 3. Go to \"GetFunctionurl\" and copy the function url."
              },
              {
                "title": "STEP 2 - Configure Webhook to Github Organization",
                "description": "1. Go to [GitHub](https://www.github.com) and open your account and click on \"Your Organizations.\"\n 2. Click on Settings.\n 3. Click on \"Webhooks\" and enter the function app url which was copied from above STEP 1 under payload URL textbox. \n 4. Choose content type as \"application/json\". \n 5. Subscribe for events and Click on \"Add Webhook\""
              }
            ]
          },
          "type": "InstructionStepsGroup"
        }
      ]
    },
    {
      "title": "",
      "description": "*Now we are done with the github Webhook configuration. Once the github events triggered and after the delay of 20 to 30 mins (As there will be a dealy for LogAnalytics to spin up the resources for the first time), you should be able to see all the transactional events from the Github into LogAnalytics workspace table called \"githubscanaudit_CL\".*\n\n For more details, Click [here](https://aka.ms/sentinel-gitHubwebhooksteps)"
    }
  ],
  "metadata": {
    "id": "40c0d851-9873-4db5-92a1-078b3e82b1b7",
    "version": "1.0.1",
    "kind": "dataConnector",
    "source": {
      "kind": "community"
    },
    "author": {
      "name": "Microsoft"
    },
    "support": {
      "tier": "community",
      "name": "Microsoft",
      "link": "https://github.com/Azure/Azure-Sentinel/issues"
    }
  }
}