352 строки
20 KiB
JSON
352 строки
20 KiB
JSON
{
|
|
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
|
"contentVersion": "1.0.0.0",
|
|
"metadata":{
|
|
"comments": "This playbook works on ASC incident creation rule, uses Sentienl Watchlists to find the subowner email in order to inform them by Email and Teams about the alert.",
|
|
"author": "Lior Tamir"
|
|
},
|
|
"parameters": {
|
|
"PlaybookName": {
|
|
"defaultValue": "InformSubowner-Watchlists-IncidentTrigger",
|
|
"type": "string"
|
|
},
|
|
"UserName": {
|
|
"defaultValue": "<username>@<domain>",
|
|
"type": "string"
|
|
}
|
|
},
|
|
"variables": {
|
|
"AzureSentinelConnectionName": "[concat('azuresentinel-', parameters('PlaybookName'))]",
|
|
"Office365ConnectionName": "[concat('office365', parameters('PlaybookName'))]",
|
|
"MicrosoftTeamsConnectionName": "[concat('teams', parameters('PlaybookName'))]",
|
|
"AzureMonitorLogsConnectionName": "[concat('azuremonitorlogs-', parameters('PlaybookName'))]"
|
|
},
|
|
"resources": [
|
|
{
|
|
"type": "Microsoft.Web/connections",
|
|
"apiVersion": "2016-06-01",
|
|
"name": "[variables('AzureSentinelConnectionName')]",
|
|
"location": "[resourceGroup().location]",
|
|
"properties": {
|
|
"displayName": "[parameters('UserName')]",
|
|
"customParameterValues": {
|
|
},
|
|
"api": {
|
|
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/azuresentinel')]"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"type": "Microsoft.Web/connections",
|
|
"apiVersion": "2016-06-01",
|
|
"name": "[variables('Office365ConnectionName')]",
|
|
"location": "[resourceGroup().location]",
|
|
"properties": {
|
|
"displayName": "[parameters('UserName')]",
|
|
"customParameterValues": {
|
|
},
|
|
"api": {
|
|
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/office365')]"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"type": "Microsoft.Web/connections",
|
|
"apiVersion": "2016-06-01",
|
|
"name": "[variables('AzureMonitorLogsConnectionName')]",
|
|
"location": "[resourceGroup().location]",
|
|
"properties": {
|
|
"displayName": "[parameters('UserName')]",
|
|
"customParameterValues": {},
|
|
"api": {
|
|
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/azuremonitorlogs')]"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"type": "Microsoft.Web/connections",
|
|
"apiVersion": "2016-06-01",
|
|
"name": "[variables('MicrosoftTeamsConnectionName')]",
|
|
"location": "[resourceGroup().location]",
|
|
"properties": {
|
|
"displayName": "[parameters('UserName')]",
|
|
"customParameterValues": {
|
|
},
|
|
"api": {
|
|
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/teams')]"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"type": "Microsoft.Logic/workflows",
|
|
"apiVersion": "2017-07-01",
|
|
"name": "[parameters('PlaybookName')]",
|
|
"location": "[resourceGroup().location]",
|
|
"dependsOn": [
|
|
"[resourceId('Microsoft.Web/connections', variables('AzureSentinelConnectionName'))]",
|
|
"[resourceId('Microsoft.Web/connections', variables('Office365ConnectionName'))]",
|
|
"[resourceId('Microsoft.Web/connections', variables('AzureMonitorLogsConnectionName'))]",
|
|
"[resourceId('Microsoft.Web/connections', variables('MicrosoftTeamsConnectionName'))]"
|
|
],
|
|
"properties": {
|
|
"state": "Enabled",
|
|
"definition": {
|
|
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
|
|
"contentVersion": "1.0.0.0",
|
|
"parameters": {
|
|
"$connections": {
|
|
"defaultValue": {},
|
|
"type": "Object"
|
|
}
|
|
},
|
|
"triggers": {
|
|
"When_Azure_Sentinel_incident_creation_rule_was_triggered": {
|
|
"inputs": {
|
|
"body": {
|
|
"callback_url": "@{listCallbackUrl()}"
|
|
},
|
|
"host": {
|
|
"connection": {
|
|
"name": "@parameters('$connections')['azuresentinel']['connectionId']"
|
|
}
|
|
},
|
|
"path": "/incident-creation"
|
|
},
|
|
"type": "ApiConnectionWebhook"
|
|
}
|
|
},
|
|
"actions": {
|
|
"For_each_Alert": {
|
|
"actions": {
|
|
"Condition": {
|
|
"actions": {
|
|
"Post_a_message_as_the_Flow_bot_to_a_user": {
|
|
"inputs": {
|
|
"body": {
|
|
"messageBody": " Hi @{body('Run_query_and_list_results_-_Get_Watchlist')?['value'][0]['OwnerName']}\n\nA new alert was triggered on your subscription: @{body('Run_query_and_list_results_-_Get_Watchlist')?['value'][0]['SubscriptionName']} by Azure Security Center.\n\nAn incident was created in Azure Sentinel.\n\nAlert title: @{items('For_each_Alert')?['properties']?['alertDisplayName']}\n\nDescription: @{items('For_each_Alert')?['properties']?['description']}\n\nThe Azure resource that triggered the alert:\n@{first(body('Filter_array_to_get_AzureResource_identifier'))['resourceId']}\n\nLink to the ASC alert: @{items('For_each_Alert')?['properties']?['alertLink']}\n\nLink to the Azure Sentinel incident: @{triggerBody()?['object']?['properties']?['incidentUrl']}",
|
|
"messageTitle": "New alert from Azure Sentinel in your subscription",
|
|
"recipient": {
|
|
"isAlert": true,
|
|
"summary": "New Alert from Azure Sentinel in subscription @{body('Parse_JSON_to_get_subscriptionId')?['properties']?['effectiveSubscriptionId']}",
|
|
"to": "@{body('Run_query_and_list_results_-_Get_Watchlist')?['value'][0]['OwnerEmail']}"
|
|
}
|
|
},
|
|
"host": {
|
|
"connection": {
|
|
"name": "@parameters('$connections')['teams']['connectionId']"
|
|
}
|
|
},
|
|
"method": "post",
|
|
"path": "/flowbot/actions/notification/recipienttypes/user"
|
|
},
|
|
"runAfter": {},
|
|
"type": "ApiConnection"
|
|
},
|
|
"Send_an_email_(V2)": {
|
|
"inputs": {
|
|
"body": {
|
|
"Body": "<p><strong> Hi </strong><strong>@{body('Run_query_and_list_results_-_Get_Watchlist')?['value'][0]['OwnerName']}</strong><strong><br>\n<br>\nA new alert was triggered on your subscription: </strong><strong>@{body('Run_query_and_list_results_-_Get_Watchlist')?['value'][0]['SubscriptionName']}</strong><strong> by Azure Security Center.<br>\n<br>\nAn incident was created in Azure Sentinel.<br>\n<br>\n</strong>Alert title: <strong></strong><strong>@{items('For_each_Alert')?['properties']?['alertDisplayName']}</strong><strong><br>\n<br>\n</strong>Description:<strong> </strong><strong>@{items('For_each_Alert')?['properties']?['description']}</strong><strong><br>\n<br>\n</strong>The <strong>Azure resource</strong> that triggered the alert:<strong><br>\n</strong><strong>@{first(body('Filter_array_to_get_AzureResource_identifier'))['resourceId']}</strong><strong><br>\n<br>\n</strong>Link to the<strong> ASC alert: </strong><strong>@{items('For_each_Alert')?['properties']?['alertLink']}</strong><strong><br>\n<br>\n</strong>Link to the <strong>Azure Sentinel incident: </strong><strong>@{triggerBody()?['object']?['properties']?['incidentUrl']}</strong><strong></strong></p>",
|
|
"Subject": "New Alert from Azure Sentinel in subscription @{body('Parse_JSON_to_get_subscriptionId')?['properties']?['effectiveSubscriptionId']}",
|
|
"To": "@{body('Run_query_and_list_results_-_Get_Watchlist')?['value'][0]['OwnerEmail']}"
|
|
},
|
|
"host": {
|
|
"connection": {
|
|
"name": "@parameters('$connections')['office365']['connectionId']"
|
|
}
|
|
},
|
|
"method": "post",
|
|
"path": "/v2/Mail"
|
|
},
|
|
"runAfter": {
|
|
"Post_a_message_as_the_Flow_bot_to_a_user": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"type": "ApiConnection"
|
|
}
|
|
},
|
|
"expression": {
|
|
"and": [
|
|
{
|
|
"greater": [
|
|
"@length(body('Run_query_and_list_results_-_Get_Watchlist')?['value'])",
|
|
0
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"runAfter": {
|
|
"Run_query_and_list_results_-_Get_Watchlist": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"type": "If"
|
|
},
|
|
"Filter_array_to_get_AzureResource_identifier": {
|
|
"inputs": {
|
|
"from": "@items('For_each_Alert')?['properties']?['resourceIdentifiers']",
|
|
"where": "@equals(item()['type'], 'AzureResource')"
|
|
},
|
|
"runAfter": {},
|
|
"type": "Query"
|
|
},
|
|
"Parse_JSON_to_get_subscriptionId": {
|
|
"description": "This action parses the additional data of the ASC alert, to get the subscription id field",
|
|
"inputs": {
|
|
"content": "@items('For_each_Alert')?['properties']?['additionalData']",
|
|
"schema": {
|
|
"properties": {
|
|
"ActionTaken": {
|
|
"type": "string"
|
|
},
|
|
"Entities": {
|
|
"items": {
|
|
"properties": {
|
|
"id": {
|
|
"type": "string"
|
|
},
|
|
"kind": {
|
|
"type": "string"
|
|
},
|
|
"name": {
|
|
"type": "string"
|
|
},
|
|
"properties": {
|
|
"properties": {
|
|
"address": {
|
|
"type": "string"
|
|
},
|
|
"friendlyName": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"type": "object"
|
|
},
|
|
"type": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": [
|
|
"id",
|
|
"name",
|
|
"type",
|
|
"kind",
|
|
"properties"
|
|
],
|
|
"type": "object"
|
|
},
|
|
"type": "array"
|
|
},
|
|
"Hit Count": {
|
|
"type": "string"
|
|
},
|
|
"Management URL": {
|
|
"type": "string"
|
|
},
|
|
"ProcessingData": {
|
|
"type": "string"
|
|
},
|
|
"Source IPs": {
|
|
"type": "string"
|
|
},
|
|
"StoreAlertPublisher": {
|
|
"type": "string"
|
|
},
|
|
"effectiveSubscriptionId": {
|
|
"type": "string"
|
|
},
|
|
"resourceType": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"type": "object"
|
|
}
|
|
},
|
|
"runAfter": {
|
|
"Filter_array_to_get_AzureResource_identifier": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"type": "ParseJson"
|
|
},
|
|
"Run_query_and_list_results_-_Get_Watchlist": {
|
|
"inputs": {
|
|
"body": "_GetWatchlist('SubOwners')\n| project SubscriptionId, OwnerName, SubscriptionName, OwnerEmail\n| where SubscriptionId == \"@{body('Parse_JSON_to_get_subscriptionId')?['effectiveSubscriptionId']}\"",
|
|
"host": {
|
|
"connection": {
|
|
"name": "@parameters('$connections')['azuremonitorlogs']['connectionId']"
|
|
}
|
|
},
|
|
"method": "post",
|
|
"path": "/queryData",
|
|
"queries": {
|
|
"resourcegroups": "@triggerBody()?['workspaceInfo']?['ResourceGroupName']",
|
|
"resourcename": "@triggerBody()?['workspaceInfo']?['WorkspaceName']",
|
|
"resourcetype": "Log Analytics Workspace",
|
|
"subscriptions": "@variables('SubscriptionID')",
|
|
"timerange": "Last 24 hours"
|
|
}
|
|
},
|
|
"runAfter": {
|
|
"Parse_JSON_to_get_subscriptionId": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"type": "ApiConnection"
|
|
}
|
|
},
|
|
"foreach": "@triggerBody()?['object']?['properties']?['Alerts']",
|
|
"runAfter": {
|
|
"Initialize_variable_-_subscriptionId": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"type": "Foreach"
|
|
},
|
|
"Initialize_variable_-_subscriptionId": {
|
|
"description": "The subscription where watchlist is under. Will be used to query watchlist in Azure Monitor Logs",
|
|
"inputs": {
|
|
"variables": [
|
|
{
|
|
"name": "SubscriptionID",
|
|
"type": "string",
|
|
"value": "[subscription().subscriptionId]"
|
|
}
|
|
]
|
|
},
|
|
"runAfter": {},
|
|
"type": "InitializeVariable"
|
|
}
|
|
},
|
|
"outputs": {}
|
|
},
|
|
"parameters": {
|
|
"$connections": {
|
|
"value": {
|
|
"azuresentinel": {
|
|
"connectionId": "[resourceId('Microsoft.Web/connections', variables('AzureSentinelConnectionName'))]",
|
|
"connectionName": "[variables('AzureSentinelConnectionName')]",
|
|
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/azuresentinel')]"
|
|
},
|
|
"office365": {
|
|
"connectionId": "[resourceId('Microsoft.Web/connections', variables('Office365ConnectionName'))]",
|
|
"connectionName": "[variables('Office365ConnectionName')]",
|
|
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/office365')]"
|
|
},
|
|
"teams": {
|
|
"connectionId": "[resourceId('Microsoft.Web/connections', variables('MicrosoftTeamsConnectionName'))]",
|
|
"connectionName": "[variables('MicrosoftTeamsConnectionName')]",
|
|
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/teams')]"
|
|
},
|
|
"azuremonitorlogs": {
|
|
"connectionId": "[resourceId('Microsoft.Web/connections', variables('AzureMonitorLogsConnectionName'))]",
|
|
"connectionName": "[variables('AzureMonitorLogsConnectionName')]",
|
|
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/azuremonitorlogs')]"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
} |