652 строки
36 KiB
JSON
652 строки
36 KiB
JSON
{
|
|
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
|
|
"contentVersion": "1.0.0.0",
|
|
"metadata":{
|
|
"comments": "This playbook will export all incidents and comments and email them in an CSV file. The filter date is linked to the recurrence trigger settings.",
|
|
"author": "Bridewell Consulting - Robert Kitching"
|
|
},
|
|
"parameters": {
|
|
"PlaybookName": {
|
|
"defaultValue": "Export-Incidents-With-Comments-Report",
|
|
"type": "String"
|
|
},
|
|
"UserName": {
|
|
"defaultValue": "<username>@<domain>",
|
|
"type": "string"
|
|
},
|
|
"LogAnalyticWorkspaceName": {
|
|
"defaultValue": "",
|
|
"type": "string"
|
|
},
|
|
"FromMailAddress": {
|
|
"defaultValue": "",
|
|
"type": "string"
|
|
},
|
|
"ToMailAddress": {
|
|
"defaultValue": "",
|
|
"type": "string"
|
|
},
|
|
"RecurrenceFrequency": {
|
|
"defaultValue" : "Day",
|
|
"type" : "string",
|
|
"allowedValues" : ["Hour","Day","Week", "Month"]
|
|
},
|
|
"RecurrenceInterval": {
|
|
"defaultValue": 7,
|
|
"type": "int"
|
|
}
|
|
},
|
|
"variables": {
|
|
"Office365ConnectionName": "[concat('office365-', parameters('PlaybookName'))]"
|
|
},
|
|
"resources": [
|
|
{
|
|
"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.Logic/workflows",
|
|
"apiVersion": "2017-07-01",
|
|
"name": "[parameters('PlaybookName')]",
|
|
"location": "[resourceGroup().location]",
|
|
"dependsOn": [
|
|
"[resourceId('Microsoft.Web/connections', variables('Office365ConnectionName'))]"
|
|
],
|
|
"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": {
|
|
"Recurrence": {
|
|
"recurrence": {
|
|
"frequency": "[parameters('RecurrenceFrequency')]",
|
|
"interval": "[parameters('RecurrenceInterval')]"
|
|
},
|
|
"type": "Recurrence"
|
|
}
|
|
},
|
|
"actions": {
|
|
"Create_CSV_table": {
|
|
"runAfter": {
|
|
"For_each": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"type": "Table",
|
|
"inputs": {
|
|
"format": "CSV",
|
|
"from": "@variables('result')"
|
|
}
|
|
},
|
|
"For_each": {
|
|
"foreach": "@body('Parse_incidents')",
|
|
"actions": {
|
|
"Append_to_array_variable": {
|
|
"runAfter": {
|
|
"Loop_through_product_names_and_append_to_placeholder": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"type": "AppendToArrayVariable",
|
|
"inputs": {
|
|
"name": "result",
|
|
"value": {
|
|
"Additional Comments": "@{trim(variables('CommentHolder'))}",
|
|
"Alert Name": "@{items('For_each')?['properties']?['title']}",
|
|
"Alerts": "@{items('For_each')?['properties']?['additionalData']?['alertsCount']}",
|
|
"Clasification": "@{items('For_each')?['properties']?['classification']}",
|
|
"Closure Comment": "@{items('For_each')?['properties']?['classificationComment']}",
|
|
"Created Time": "@{items('For_each')?['properties']?['createdTimeUtc']}",
|
|
"Id": "@{items('For_each')?['properties']?['incidentNumber']}",
|
|
"Last Update Time": "@{items('For_each')?['properties']?['lastModifiedTimeUtc']}",
|
|
"Owner": "@{items('For_each')?['properties']?['owner']?['assignedTo']}",
|
|
"Product Name": "@{trim(variables('productNames'))}",
|
|
"Status": "@{items('For_each')?['properties']?['status']}"
|
|
}
|
|
}
|
|
},
|
|
"Check_if_incident_has_additional_comments": {
|
|
"actions": {
|
|
"For_each_3": {
|
|
"foreach": "@body('Parse_Comment_Data')?['value']",
|
|
"actions": {
|
|
"Append_to_string_variable": {
|
|
"runAfter": {},
|
|
"type": "AppendToStringVariable",
|
|
"inputs": {
|
|
"name": "CommentHolder",
|
|
"value": "Author: @{items('For_each_3')?['properties']?['author']?['name']} | Message: @{items('For_each_3')?['properties']?['message']}\n"
|
|
}
|
|
}
|
|
},
|
|
"runAfter": {
|
|
"Parse_Comment_Data": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"type": "Foreach"
|
|
},
|
|
"Get_Incident_Comments": {
|
|
"runAfter": {},
|
|
"type": "Http",
|
|
"inputs": {
|
|
"authentication": {
|
|
"audience": "https://management.azure.com",
|
|
"type": "ManagedServiceIdentity"
|
|
},
|
|
"method": "GET",
|
|
"uri": "https://management.azure.com/subscriptions/@{variables('Settings')['subscriptionId']}/resourcegroups/@{variables('Settings')['resourceGroup']}/providers/Microsoft.OperationalInsights/workspaces/@{variables('Settings')['logWorkspace']}/providers/Microsoft.SecurityInsights/incidents/@{items('For_each')?['name']}/comments?api-version=2019-01-01-preview"
|
|
}
|
|
},
|
|
"Parse_Comment_Data": {
|
|
"runAfter": {
|
|
"Get_Incident_Comments": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"type": "ParseJson",
|
|
"inputs": {
|
|
"content": "@body('Get_Incident_Comments')",
|
|
"schema": {
|
|
"properties": {
|
|
"value": {
|
|
"items": {
|
|
"properties": {
|
|
"id": {
|
|
"type": "string"
|
|
},
|
|
"name": {
|
|
"type": "string"
|
|
},
|
|
"properties": {
|
|
"properties": {
|
|
"author": {
|
|
"properties": {
|
|
"email": {
|
|
"type": "string"
|
|
},
|
|
"name": {
|
|
"type": "string"
|
|
},
|
|
"objectId": {
|
|
"type": "string"
|
|
},
|
|
"userPrincipalName": {}
|
|
},
|
|
"type": "object"
|
|
},
|
|
"createdTimeUtc": {
|
|
"type": "string"
|
|
},
|
|
"message": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"type": "object"
|
|
},
|
|
"type": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": [
|
|
"id",
|
|
"name",
|
|
"type",
|
|
"properties"
|
|
],
|
|
"type": "object"
|
|
},
|
|
"type": "array"
|
|
}
|
|
},
|
|
"type": "object"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"runAfter": {},
|
|
"expression": {
|
|
"and": [
|
|
{
|
|
"not": {
|
|
"equals": [
|
|
"@items('For_each')?['properties']?['additionalData']?['commentsCount']",
|
|
0
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"type": "If"
|
|
},
|
|
"Clear_CommentHolder_placeholder": {
|
|
"runAfter": {
|
|
"Append_to_array_variable": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"type": "SetVariable",
|
|
"inputs": {
|
|
"name": "CommentHolder",
|
|
"value": "@{null}"
|
|
}
|
|
},
|
|
"Clear_productNames_placeholder": {
|
|
"runAfter": {
|
|
"Clear_CommentHolder_placeholder": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"type": "SetVariable",
|
|
"inputs": {
|
|
"name": "productNames",
|
|
"value": "@{null}"
|
|
}
|
|
},
|
|
"Loop_through_product_names_and_append_to_placeholder": {
|
|
"foreach": "@items('For_each')?['properties']?['additionalData']?['alertProductNames']",
|
|
"actions": {
|
|
"Set_variable": {
|
|
"runAfter": {},
|
|
"type": "SetVariable",
|
|
"inputs": {
|
|
"name": "productNames",
|
|
"value": "@{items('Loop_through_product_names_and_append_to_placeholder')}\n"
|
|
}
|
|
}
|
|
},
|
|
"runAfter": {
|
|
"Check_if_incident_has_additional_comments": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"type": "Foreach"
|
|
}
|
|
},
|
|
"runAfter": {
|
|
"Initialise_productNames_placeholder_variable": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"type": "Foreach",
|
|
"runtimeConfiguration": {
|
|
"concurrency": {
|
|
"repetitions": 1
|
|
}
|
|
}
|
|
},
|
|
"Get_workspace_settings": {
|
|
"runAfter": {
|
|
"Subtract_from_time": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"type": "InitializeVariable",
|
|
"inputs": {
|
|
"variables": [
|
|
{
|
|
"name": "workflow",
|
|
"type": "object",
|
|
"value": "@workflow()"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"Initialise_commentHolder_placeholder_variable": {
|
|
"runAfter": {
|
|
"Initialise_output_array_placeholder": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"type": "InitializeVariable",
|
|
"inputs": {
|
|
"variables": [
|
|
{
|
|
"name": "commentHolder",
|
|
"type": "string"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"Initialise_incident_array": {
|
|
"runAfter": {
|
|
"Initialise_settings": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"type": "InitializeVariable",
|
|
"inputs": {
|
|
"variables": [
|
|
{
|
|
"name": "incidents",
|
|
"type": "array"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"Initialise_output_array_placeholder": {
|
|
"runAfter": {
|
|
"Parse_incidents": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"type": "InitializeVariable",
|
|
"inputs": {
|
|
"variables": [
|
|
{
|
|
"name": "result",
|
|
"type": "array"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"Initialise_productNames_placeholder_variable": {
|
|
"runAfter": {
|
|
"Initialise_commentHolder_placeholder_variable": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"type": "InitializeVariable",
|
|
"inputs": {
|
|
"variables": [
|
|
{
|
|
"name": "productNames",
|
|
"type": "string"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"Initialise_settings": {
|
|
"runAfter": {
|
|
"Get_workspace_settings": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"type": "InitializeVariable",
|
|
"inputs": {
|
|
"variables": [
|
|
{
|
|
"name": "Settings",
|
|
"type": "object",
|
|
"value": {
|
|
"logWorkspace": "[parameters('LogAnalyticWorkspaceName')]",
|
|
"resourceGroup": "@{substring(workflow()['id'],add(indexOf(workflow()['id'],'resourceGroups/'),15),sub(sub(indexOf(workflow()['id'],'/providers'),indexOf(workflow()['id'],'resourceGroups/')),15))}",
|
|
"subscriptionId": "@{substring(workflow()['id'],add(lastIndexOf(workflow()['id'],'subscriptions/'),14),sub(indexOf(workflow()['id'],'resourceGroups/'),16))}"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"Parse_incidents": {
|
|
"runAfter": {
|
|
"Until": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"type": "ParseJson",
|
|
"inputs": {
|
|
"content": "@variables('incidents')",
|
|
"schema": {
|
|
"items": {
|
|
"properties": {
|
|
"etag": {
|
|
"type": "string"
|
|
},
|
|
"id": {
|
|
"type": "string"
|
|
},
|
|
"name": {
|
|
"type": "string"
|
|
},
|
|
"properties": {
|
|
"properties": {
|
|
"additionalData": {
|
|
"properties": {
|
|
"alertProductNames": {
|
|
"items": {
|
|
"type": "string"
|
|
},
|
|
"type": "array"
|
|
},
|
|
"alertsCount": {
|
|
"type": "integer"
|
|
},
|
|
"bookmarksCount": {
|
|
"type": "integer"
|
|
},
|
|
"commentsCount": {
|
|
"type": "integer"
|
|
},
|
|
"tactics": {
|
|
"items": {
|
|
"type": "string"
|
|
},
|
|
"type": "array"
|
|
}
|
|
},
|
|
"type": "object"
|
|
},
|
|
"createdTimeUtc": {
|
|
"type": "string"
|
|
},
|
|
"description": {
|
|
"type": "string"
|
|
},
|
|
"firstActivityTimeGenerated": {
|
|
"type": "string"
|
|
},
|
|
"firstActivityTimeUtc": {
|
|
"type": "string"
|
|
},
|
|
"incidentNumber": {
|
|
"type": "integer"
|
|
},
|
|
"incidentUrl": {
|
|
"type": "string"
|
|
},
|
|
"labels": {
|
|
"type": "array"
|
|
},
|
|
"lastActivityTimeGenerated": {
|
|
"type": "string"
|
|
},
|
|
"lastActivityTimeUtc": {
|
|
"type": "string"
|
|
},
|
|
"lastModifiedTimeUtc": {
|
|
"type": "string"
|
|
},
|
|
"owner": {
|
|
"properties": {
|
|
"assignedTo": {},
|
|
"email": {},
|
|
"objectId": {},
|
|
"userPrincipalName": {}
|
|
},
|
|
"type": "object"
|
|
},
|
|
"relatedAnalyticRuleIds": {
|
|
"items": {
|
|
"type": "string"
|
|
},
|
|
"type": "array"
|
|
},
|
|
"severity": {
|
|
"type": "string"
|
|
},
|
|
"status": {
|
|
"type": "string"
|
|
},
|
|
"title": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"type": "object"
|
|
},
|
|
"type": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": [
|
|
"id",
|
|
"name",
|
|
"etag",
|
|
"type",
|
|
"properties"
|
|
],
|
|
"type": "object"
|
|
},
|
|
"type": "array"
|
|
}
|
|
}
|
|
},
|
|
"Send_an_email_from_a_shared_mailbox_(V2)": {
|
|
"runAfter": {
|
|
"Create_CSV_table": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"type": "ApiConnection",
|
|
"inputs": {
|
|
"body": {
|
|
"Attachments": [
|
|
{
|
|
"ContentBytes": "@{base64(body('Create_CSV_table'))}",
|
|
"Name": "@{formatDateTime(utcNow(),'ddMMyyyy HHmmss')} - Incident Logging.csv"
|
|
}
|
|
],
|
|
"Body": "<p>Please see attached automated incident report from Azure Sentinel</p>",
|
|
"MailboxAddress": "[parameters('FromMailAddress')]",
|
|
"Subject": "Sentinel Automated Incident Report - @{formatDateTime(utcNow(),'ddMMyyyy HHmmss')}",
|
|
"To": "[parameters('ToMailAddress')]"
|
|
},
|
|
"host": {
|
|
"connection": {
|
|
"name": "@parameters('$connections')['office365']['connectionId']"
|
|
}
|
|
},
|
|
"method": "post",
|
|
"path": "/v2/SharedMailbox/Mail"
|
|
}
|
|
},
|
|
"Set_request_URL": {
|
|
"runAfter": {
|
|
"Initialise_incident_array": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"type": "InitializeVariable",
|
|
"inputs": {
|
|
"variables": [
|
|
{
|
|
"name": "requestUrl",
|
|
"type": "string",
|
|
"value": "https://management.azure.com/subscriptions/@{variables('Settings')['subscriptionId']}/resourcegroups/@{variables('Settings')['resourceGroup']}/providers/Microsoft.OperationalInsights/workspaces/@{variables('Settings')['logWorkspace']}/providers/Microsoft.SecurityInsights/incidents/?api-version=2019-01-01-preview&$top=50&$filter=properties/lastModifiedTimeUtc ge @{body('Subtract_from_time')}"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"Subtract_from_time": {
|
|
"runAfter": {},
|
|
"type": "Expression",
|
|
"kind": "SubtractFromTime",
|
|
"inputs": {
|
|
"baseTime": "@{utcNow()}",
|
|
"interval": 7,
|
|
"timeUnit": "Day"
|
|
}
|
|
},
|
|
"Until": {
|
|
"actions": {
|
|
"Get_incidents": {
|
|
"runAfter": {},
|
|
"type": "Http",
|
|
"inputs": {
|
|
"authentication": {
|
|
"audience": "https://management.azure.com",
|
|
"type": "ManagedServiceIdentity"
|
|
},
|
|
"method": "GET",
|
|
"uri": "@variables('requestUrl')"
|
|
}
|
|
},
|
|
"Join_arrays": {
|
|
"runAfter": {
|
|
"Get_incidents": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"type": "Compose",
|
|
"inputs": "@union(variables('incidents'),body('Get_incidents')?['value'])"
|
|
},
|
|
"Set_next_page_url": {
|
|
"runAfter": {
|
|
"Set_output_array": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"type": "SetVariable",
|
|
"inputs": {
|
|
"name": "requestUrl",
|
|
"value": "@{if(not(equals(body('Get_incidents')?['nextLink'],null)),body('Get_incidents')?['nextLink'],null)}"
|
|
}
|
|
},
|
|
"Set_output_array": {
|
|
"runAfter": {
|
|
"Join_arrays": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"type": "SetVariable",
|
|
"inputs": {
|
|
"name": "incidents",
|
|
"value": "@outputs('Join_arrays')"
|
|
}
|
|
}
|
|
},
|
|
"runAfter": {
|
|
"Set_request_URL": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"expression": "@equals(body('Get_incidents')?['nextLink'], null)",
|
|
"limit": {
|
|
"count": 60,
|
|
"timeout": "PT1H"
|
|
},
|
|
"type": "Until"
|
|
}
|
|
},
|
|
"outputs": {}
|
|
},
|
|
"parameters": {
|
|
"$connections": {
|
|
"value": {
|
|
"office365": {
|
|
"connectionId": "[resourceId('Microsoft.Web/connections', variables('office365ConnectionName'))]",
|
|
"connectionName": "[variables('Office365ConnectionName')]",
|
|
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/office365')]"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
} |