feat: add Playbooks/Enrich-AzureResourceGraph-Incident
This commit is contained in:
Родитель
edbf3602fe
Коммит
d2d3514427
|
@ -0,0 +1,432 @@
|
|||
{
|
||||
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"resourceTags": {
|
||||
"type": "object",
|
||||
"defaultValue": {
|
||||
"LogicAppsCategory": "security"
|
||||
},
|
||||
"metadata": {
|
||||
"description": "The Azure tags to set on the resource."
|
||||
}
|
||||
},
|
||||
"PlaybookName": {
|
||||
"defaultValue": "Enrich-AzureResourceGraph-Incident",
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "The Playbook aka LogicApp name."
|
||||
}
|
||||
},
|
||||
"workflows_Enrich_AzureResourceGraph_name": {
|
||||
"defaultValue": "Enrich-AzureResourceGraph",
|
||||
"type": "String",
|
||||
"metadata": {
|
||||
"description": "The Playbook aka LogicApp to query Azure Resource Graph."
|
||||
}
|
||||
},
|
||||
"location": {
|
||||
"type": "string",
|
||||
"defaultValue": "[resourceGroup().location]",
|
||||
"metadata": {
|
||||
"description": "Location for all resources."
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
"AzureSentinelConnectionName": "[concat('azuresentinel-', parameters('PlaybookName'))]"
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"type": "Microsoft.Web/connections",
|
||||
"apiVersion": "2016-06-01",
|
||||
"name": "[variables('AzureSentinelConnectionName')]",
|
||||
"location": "[parameters('location')]",
|
||||
"tags": "[parameters('resourceTags')]",
|
||||
"properties": {
|
||||
"customParameterValues": {},
|
||||
"parameterValueType": "Alternative",
|
||||
"api": {
|
||||
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', parameters('location'), '/managedApis/azuresentinel')]"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Logic/workflows",
|
||||
"apiVersion": "2019-05-01",
|
||||
"name": "[parameters('PlaybookName')]",
|
||||
"location": "[parameters('location')]",
|
||||
"tags": "[parameters('resourceTags')]",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.Web/connections', variables('AzureSentinelConnectionName'))]"
|
||||
],
|
||||
"identity": {
|
||||
"type": "SystemAssigned"
|
||||
},
|
||||
"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": {
|
||||
"type": "ApiConnectionWebhook",
|
||||
"inputs": {
|
||||
"body": {
|
||||
"callback_url": "@{listCallbackUrl()}"
|
||||
},
|
||||
"host": {
|
||||
"connection": {
|
||||
"name": "@parameters('$connections')['azuresentinel']['connectionId']"
|
||||
}
|
||||
},
|
||||
"path": "/incident-creation"
|
||||
}
|
||||
}
|
||||
},
|
||||
"actions": {
|
||||
"Condition_-_No_entities": {
|
||||
"actions": {
|
||||
"Terminate": {
|
||||
"runAfter": {},
|
||||
"type": "Terminate",
|
||||
"inputs": {
|
||||
"runStatus": "Cancelled"
|
||||
}
|
||||
}
|
||||
},
|
||||
"runAfter": {
|
||||
"Entities_-_Get_Hosts": [
|
||||
"Succeeded"
|
||||
]
|
||||
},
|
||||
"expression": {
|
||||
"and": [
|
||||
{
|
||||
"equals": [
|
||||
"@length(body('Entities_-_Get_Hosts')?['Hosts'])",
|
||||
0
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"type": "If"
|
||||
},
|
||||
"Condition_comment_string_is_not_empty": {
|
||||
"actions": {
|
||||
"Add_comment_to_incident_(V3)": {
|
||||
"runAfter": {},
|
||||
"type": "ApiConnection",
|
||||
"inputs": {
|
||||
"body": {
|
||||
"incidentArmId": "@triggerBody()?['object']?['id']",
|
||||
"message": "[concat('<p><span style=\"font-size: 14px\"><strong>', parameters('PlaybookName'), ' playbook:</strong></span><br>\n@{variables(''comment'')}</p>')]"
|
||||
},
|
||||
"host": {
|
||||
"connection": {
|
||||
"name": "@parameters('$connections')['azuresentinel']['connectionId']"
|
||||
}
|
||||
},
|
||||
"method": "post",
|
||||
"path": "/Incidents/Comment"
|
||||
}
|
||||
},
|
||||
"Update_incident_-_tag_found": {
|
||||
"runAfter": {
|
||||
"Add_comment_to_incident_(V3)": [
|
||||
"Succeeded"
|
||||
]
|
||||
},
|
||||
"type": "ApiConnection",
|
||||
"inputs": {
|
||||
"body": {
|
||||
"incidentArmId": "@triggerBody()?['object']?['id']",
|
||||
"tagsToAdd": {
|
||||
"TagsToAdd": [
|
||||
{
|
||||
"Tag": "Found-AzureResourceGraph"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"host": {
|
||||
"connection": {
|
||||
"name": "@parameters('$connections')['azuresentinel']['connectionId']"
|
||||
}
|
||||
},
|
||||
"method": "put",
|
||||
"path": "/Incidents"
|
||||
}
|
||||
}
|
||||
},
|
||||
"runAfter": {
|
||||
"For_each_Host": [
|
||||
"Succeeded"
|
||||
]
|
||||
},
|
||||
"else": {
|
||||
"actions": {
|
||||
"Update_incident_-_tag_notfound": {
|
||||
"runAfter": {},
|
||||
"type": "ApiConnection",
|
||||
"inputs": {
|
||||
"body": {
|
||||
"incidentArmId": "@triggerBody()?['object']?['id']",
|
||||
"tagsToAdd": {
|
||||
"TagsToAdd": [
|
||||
{
|
||||
"Tag": "NotFound-AzureResourceGraph"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"host": {
|
||||
"connection": {
|
||||
"name": "@parameters('$connections')['azuresentinel']['connectionId']"
|
||||
}
|
||||
},
|
||||
"method": "put",
|
||||
"path": "/Incidents"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"and": [
|
||||
{
|
||||
"not": {
|
||||
"equals": [
|
||||
"@variables('comment')",
|
||||
""
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"not": {
|
||||
"equals": [
|
||||
"@string(variables('comment'))",
|
||||
"[[]"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"type": "If"
|
||||
},
|
||||
"Entities_-_Get_Hosts": {
|
||||
"runAfter": {
|
||||
"Initialize_variable": [
|
||||
"Succeeded"
|
||||
]
|
||||
},
|
||||
"type": "ApiConnection",
|
||||
"inputs": {
|
||||
"body": "@triggerBody()?['object']?['properties']?['relatedEntities']",
|
||||
"host": {
|
||||
"connection": {
|
||||
"name": "@parameters('$connections')['azuresentinel']['connectionId']"
|
||||
}
|
||||
},
|
||||
"method": "post",
|
||||
"path": "/entities/host"
|
||||
}
|
||||
},
|
||||
"For_each_Host": {
|
||||
"foreach": "@body('Entities_-_Get_Hosts')?['Hosts']",
|
||||
"actions": {
|
||||
"Condition_have_resourcegraph_data": {
|
||||
"actions": {
|
||||
"Append_to_string_variable_comment": {
|
||||
"runAfter": {},
|
||||
"type": "AppendToStringVariable",
|
||||
"inputs": {
|
||||
"name": "comment",
|
||||
"value": "resource @{body('Parse_JSON_Host')?['friendlyName']}: @{body('Parse_JSON_output_Enrich-AzureResourceGraph')?['azureresourcegraph']}"
|
||||
}
|
||||
}
|
||||
},
|
||||
"runAfter": {
|
||||
"Parse_JSON_output_Enrich-AzureResourceGraph": [
|
||||
"Succeeded"
|
||||
]
|
||||
},
|
||||
"expression": {
|
||||
"and": [
|
||||
{
|
||||
"not": {
|
||||
"equals": [
|
||||
"@body('Parse_JSON_output_Enrich-AzureResourceGraph')?['azureresourcegraph']",
|
||||
""
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"not": {
|
||||
"equals": [
|
||||
"@string(body('Parse_JSON_output_Enrich-AzureResourceGraph')?['azureresourcegraph'])",
|
||||
"[[]"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"type": "If"
|
||||
},
|
||||
"Enrich-AzureResourceGraph": {
|
||||
"runAfter": {
|
||||
"Parse_JSON_Host": [
|
||||
"Succeeded"
|
||||
]
|
||||
},
|
||||
"type": "Workflow",
|
||||
"inputs": {
|
||||
"body": {
|
||||
"resourceName": "@body('Parse_JSON_Host')?['friendlyName']"
|
||||
},
|
||||
"host": {
|
||||
"triggerName": "request",
|
||||
"workflow": {
|
||||
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', resourceGroup().name, '/providers/Microsoft.Logic/workflows/', parameters('workflows_Enrich_AzureResourceGraph_name'))]"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Parse_JSON_Host": {
|
||||
"runAfter": {},
|
||||
"type": "ParseJson",
|
||||
"inputs": {
|
||||
"content": "@items('For_each_Host')",
|
||||
"schema": {
|
||||
"properties": {
|
||||
"Type": {
|
||||
"type": "string"
|
||||
},
|
||||
"additionalData": {
|
||||
"properties": {
|
||||
"AadDeviceId": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"AvStatus": {
|
||||
"type": "string"
|
||||
},
|
||||
"FQDN": {
|
||||
"type": "string"
|
||||
},
|
||||
"HealthStatus": {
|
||||
"type": "string"
|
||||
},
|
||||
"LastExternalIpAddress": {
|
||||
"type": "string"
|
||||
},
|
||||
"LastIpAddress": {
|
||||
"type": "string"
|
||||
},
|
||||
"LastSeen": {
|
||||
"type": "string"
|
||||
},
|
||||
"MdatpDeviceId": {
|
||||
"type": "string"
|
||||
},
|
||||
"OnboardingStatus": {
|
||||
"type": "string"
|
||||
},
|
||||
"RiskScore": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"dnsDomain": {
|
||||
"type": "string"
|
||||
},
|
||||
"friendlyName": {
|
||||
"type": "string"
|
||||
},
|
||||
"hostName": {
|
||||
"type": "string"
|
||||
},
|
||||
"osFamily": {
|
||||
"type": "string"
|
||||
},
|
||||
"osVersion": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Parse_JSON_output_Enrich-AzureResourceGraph": {
|
||||
"runAfter": {
|
||||
"Enrich-AzureResourceGraph": [
|
||||
"Succeeded"
|
||||
]
|
||||
},
|
||||
"type": "ParseJson",
|
||||
"inputs": {
|
||||
"content": "@body('Enrich-AzureResourceGraph')",
|
||||
"schema": {
|
||||
"properties": {
|
||||
"azureresourcegraph": {
|
||||
"type": "string"
|
||||
},
|
||||
"resourceName": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"runAfter": {
|
||||
"Condition_-_No_entities": [
|
||||
"Succeeded"
|
||||
]
|
||||
},
|
||||
"type": "Foreach"
|
||||
},
|
||||
"Initialize_variable": {
|
||||
"runAfter": {},
|
||||
"type": "InitializeVariable",
|
||||
"inputs": {
|
||||
"variables": [
|
||||
{
|
||||
"name": "comment",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"outputs": {}
|
||||
},
|
||||
"parameters": {
|
||||
"$connections": {
|
||||
"value": {
|
||||
"azuresentinel": {
|
||||
"connectionId": "[resourceId('Microsoft.Web/connections', variables('AzureSentinelConnectionName'))]",
|
||||
"connectionName": "[variables('AzureSentinelConnectionName')]",
|
||||
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', parameters('location'), '/managedApis/azuresentinel')]",
|
||||
"connectionProperties": {
|
||||
"authentication": {
|
||||
"type": "ManagedServiceIdentity"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
Двоичные данные
Playbooks/Enrich-AzureResourceGraph-Incident/images/Enrich-AzureResourceGraph-Incident.png
Normal file
Двоичные данные
Playbooks/Enrich-AzureResourceGraph-Incident/images/Enrich-AzureResourceGraph-Incident.png
Normal file
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 79 KiB |
|
@ -0,0 +1,27 @@
|
|||
# Enrich-AzureResourceGraph-Incident
|
||||
|
||||
This logicapp calls Enrich-AzureResourceGraph to comment Sentinel Incident based on ResourceGraph data
|
||||
|
||||
## Quick Deployment
|
||||
|
||||
After deployment, attach this playbook to an **automation rule** so it runs when the incident is created.
|
||||
|
||||
[Learn more about automation rules](https://docs.microsoft.com/azure/sentinel/automate-incident-handling-with-automation-rules#creating-and-managing-automation-rules)
|
||||
|
||||
[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2FAzure-Sentinel%2Fmaster%2FPlaybooks%2FEnrich-AzureResourceGraph-Incident%2Fazuredeploy.json)
|
||||
[![Deploy to Azure Gov](https://aka.ms/deploytoazuregovbutton)](https://portal.azure.us/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2FAzure-Sentinel%2Fmaster%2FPlaybooks%2FEnrich-AzureResourceGraph-Incident%2Fazuredeploy.json)
|
||||
|
||||
## Prerequisites
|
||||
|
||||
* Enrich-AzureResourceGraph logicapp
|
||||
* Adapt query to your context
|
||||
|
||||
## Screenshots
|
||||
![Enrich-AzureResourceGraph-Incident](./images/Enrich-AzureResourceGraph-Incident.png)
|
||||
|
||||
## Workflow explained
|
||||
|
||||
1. Azure Sentinel incident trigger
|
||||
2. Get Hosts entities
|
||||
3. For each host, call Enrich-AzureResourceGraph
|
||||
4. Add comment and tag found/notfound depending on output
|
Загрузка…
Ссылка в новой задаче