-
Notifications
You must be signed in to change notification settings - Fork 0
/
MX-L3-Block
187 lines (187 loc) · 8.08 KB
/
MX-L3-Block
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
{
"workflow": {
"unique_name": "definition_workflow_01P9LNQKO3D3P36RtQndY7maiXqWSe9t2vS",
"name": "Blocking URL/IP in Meraki MX L3 Firewall Rules",
"title": "Blocking URL/IP in Meraki MX L3 Firewall Rules",
"type": "generic.workflow",
"base_type": "workflow",
"variables": [
{
"schema_id": "datatype.string",
"properties": {
"value": "",
"scope": "input",
"name": "Network ID",
"type": "datatype.string",
"description": "Network ID of a Meraki Network\n\nFoe Example: N_6xxxxxxxxxxxxxx",
"is_required": false,
"is_invisible": false
},
"unique_name": "variable_workflow_01P9N7UAD584865ZmnURi6qB82qNdLyZjTi",
"object_type": "variable_workflow"
},
{
"schema_id": "datatype.string",
"properties": {
"value": "",
"scope": "input",
"name": "observable_value",
"type": "datatype.string",
"description": "This value will be extracted from SexureX Threat Response. It can be a domain name or a L3 Subnet. E.g: 192.168.x.0/24",
"is_required": true,
"is_invisible": false
},
"unique_name": "variable_workflow_01P9N4SZ62YVN4PgLxbmpbSYa8KSDFeMGED",
"object_type": "variable_workflow"
},
{
"schema_id": "datatype.string",
"properties": {
"value": "",
"scope": "input",
"name": "observable_type",
"type": "datatype.string",
"description": "This value will be extracted from SexureX Threat Response. It can be either URL or IP",
"is_required": true,
"is_invisible": false
},
"unique_name": "variable_workflow_01P9N4MIIWKIA4hPY8k00oLJ7QdXOYXQxW2",
"object_type": "variable_workflow"
},
{
"schema_id": "datatype.string",
"properties": {
"value": "",
"scope": "input",
"name": "Meraki API Key",
"type": "datatype.string",
"is_required": false,
"is_invisible": false
},
"unique_name": "variable_workflow_01P9N8HHNDBDK1PfGibacu4CmQeSshtC5Mf",
"object_type": "variable_workflow"
}
],
"properties": {
"atomic": {
"atomic_group": "Cisco Meraki",
"is_atomic": true
},
"delete_workflow_instance": false,
"description": "This workflow can be used to trigger an block action from a SecureX Threat response on an IP or domain. It will create a deny rule in L3 Firewall Rules inside Meraki dashboard for Meraki MX.\n\nBelow are the steps involved in the execution:\n\n1) Extract the existing Security Rules from Meraki Dashboard\n2) Merge/Append the new Rule with the Existing Rule\n3) Push the updated rule list to the Meraki Dashboard",
"display_name": "Blocking URL/IP in Meraki MX L3 Firewall Rules",
"runtime_user": {
"target_default": true
},
"target": {
"no_target": true
}
},
"object_type": "definition_workflow",
"actions": [
{
"unique_name": "definition_activity_01P9MXCMDUI9X79rKLx5xdae5ko1K3EZikb",
"name": "Execute Python Script",
"title": "Extracting existing L3 Rules",
"type": "python3.script",
"base_type": "activity",
"properties": {
"action_timeout": 180,
"continue_on_failure": false,
"display_name": "Extracting existing L3 Rules",
"script": "import requests, sys\nimport json\nmeraki_url = \"https://api.meraki.com/api/v1/networks/$workflow.definition_workflow_01P9LNQKO3D3P36RtQndY7maiXqWSe9t2vS.input.variable_workflow_01P9N7UAD584865ZmnURi6qB82qNdLyZjTi$/appliance/firewall/l3FirewallRules\"\nmeraki_payload = None\nmeraki_headers = {\"Content-Type\": \"application/json\",\"Accept\":\"application/json\",\"X-Cisco-Meraki-API-Key\":\"$workflow.definition_workflow_01P9LNQKO3D3P36RtQndY7maiXqWSe9t2vS.input.variable_workflow_01P9N8HHNDBDK1PfGibacu4CmQeSshtC5Mf$\"}\nmeraki_response = requests.request('GET', meraki_url, headers=meraki_headers, data = meraki_payload)\njson_content2 = meraki_response.json()\njson_content = json_content2[\"rules\"]\nfor rule in json_content:\n if rule[\"comment\"] == \"Default rule\":\n json_content.remove(rule)\nexistingrules = json.dumps({\"rules\":json_content})\nnewrule = '{\"rules\":[{\"comment\":\"Block any traffic to this subnet.\",\"policy\":\"deny\",\"protocol\":\"Any\",\"destPort\":\"Any\",\"destCidr\":\"$workflow.definition_workflow_01P9LNQKO3D3P36RtQndY7maiXqWSe9t2vS.input.variable_workflow_01P9N4SZ62YVN4PgLxbmpbSYa8KSDFeMGED$\",\"srcPort\":\"Any\",\"srcCidr\":\"Any\",\"syslogEnabled\":false}]}'\njson_newrule = json.loads(newrule)\nexistingrules = json.loads(existingrules)\njson_newrule['rules'].extend(existingrules['rules'])\nnewRules = json.dumps(json_newrule)",
"script_arguments": [
""
],
"script_queries": [
{
"script_query": "newRules",
"script_query_name": "newRules",
"script_query_type": "string"
}
],
"skip_execution": false
},
"object_type": "definition_activity"
},
{
"unique_name": "definition_activity_01P9NEOFPZEFO178RefDkgw1HHK4NQAk0Cr",
"name": "HTTP Request",
"title": "Pushing Updated L3 Rule to Meraki Network",
"type": "web-service.http_request",
"base_type": "activity",
"properties": {
"accept": "application/json",
"action_timeout": 180,
"allow_auto_redirect": true,
"body": "$activity.definition_activity_01P9MXCMDUI9X79rKLx5xdae5ko1K3EZikb.output.script_queries.newRules$",
"content_type": "application/json",
"continue_on_error_status_code": false,
"continue_on_failure": false,
"custom_headers": [
{
"name": "X-Cisco-Meraki-API-Key",
"value": "$workflow.definition_workflow_01P9LNQKO3D3P36RtQndY7maiXqWSe9t2vS.input.variable_workflow_01P9N8HHNDBDK1PfGibacu4CmQeSshtC5Mf$"
}
],
"display_name": "Pushing Updated L3 Rule to Meraki Network",
"method": "PUT",
"relative_url": "v1/networks/$workflow.definition_workflow_01P9LNQKO3D3P36RtQndY7maiXqWSe9t2vS.input.variable_workflow_01P9N7UAD584865ZmnURi6qB82qNdLyZjTi$/appliance/firewall/l3FirewallRules",
"runtime_user": {
"target_default": true
},
"skip_execution": false,
"target": {
"override_workflow_target": true,
"target_id": "definition_target_01ORWS3EZYWB41stcK67oyONHmDf3wCygV0"
}
},
"object_type": "definition_activity"
}
],
"categories": [
"category_01EI33LMFFL7N5eTQLsOOJIrxdlSOHb7r3r",
"category_01FM7CGPZZCMY0KcvgiGjVH5UaB4y4aDJ7m"
]
},
"categories": {
"category_01EI33LMFFL7N5eTQLsOOJIrxdlSOHb7r3r": {
"unique_name": "category_01EI33LMFFL7N5eTQLsOOJIrxdlSOHb7r3r",
"name": "SecureX",
"title": "SecureX",
"type": "basic.category",
"base_type": "category",
"category_type": "custom",
"object_type": "category"
},
"category_01FM7CGPZZCMY0KcvgiGjVH5UaB4y4aDJ7m": {
"unique_name": "category_01FM7CGPZZCMY0KcvgiGjVH5UaB4y4aDJ7m",
"name": "response",
"title": "response",
"type": "basic.category",
"base_type": "category",
"category_type": "custom",
"object_type": "category"
}
},
"targets": {
"definition_target_01ORWS3EZYWB41stcK67oyONHmDf3wCygV0": {
"unique_name": "definition_target_01ORWS3EZYWB41stcK67oyONHmDf3wCygV0",
"name": "Meraki Dashboard",
"title": "Meraki Dashboard",
"type": "web-service.endpoint",
"base_type": "target",
"object_type": "definition_target",
"properties": {
"disable_certificate_validation": false,
"display_name": "Meraki Dashboard",
"host": "api.meraki.com",
"ignore_proxy": false,
"no_runtime_user": true,
"path": "/api",
"port": 443,
"protocol": "https"
}
}
}
}