Repository navigation
Expand file tree
/
Copy pathagc_waf_workbook.json
More file actions
1030 lines (1030 loc) · 46.1 KB
/
Copy pathagc_waf_workbook.json
File metadata and controls
1030 lines (1030 loc) · 46.1 KB
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
"version": "Notebook/1.0",
"items": [
{
"type": 1,
"content": {
"json": "## Application Gateway WAF triage workbook\n---\n\nThis workbook will help you triage Application Gateway WAF violations."
},
"name": "text - 2"
},
{
"type": 9,
"content": {
"version": "KqlParameterItem/1.0",
"parameters": [
{
"id": "63ea93e5-3270-4447-9572-ad9e62095e7b",
"version": "KqlParameterItem/1.0",
"name": "subscription",
"label": "Subscription",
"type": 6,
"isRequired": true,
"multiSelect": true,
"quote": "'",
"delimiter": ",",
"value": [
"/subscriptions/4bfa4e52-8afd-4875-8c36-d126070a6333"
],
"typeSettings": {
"additionalResourceOptions": [],
"includeAll": false
}
},
{
"id": "12476248-81b7-46af-a9b4-790f93306442",
"version": "KqlParameterItem/1.0",
"name": "workspace",
"label": "Workspace",
"type": 5,
"isRequired": true,
"query": "where type =~ 'microsoft.operationalinsights/workspaces'\r\n| summarize by id, name\r\n| project id",
"crossComponentResources": [
"{subscription}"
],
"value": "/subscriptions/4bfa4e52-8afd-4875-8c36-d126070a6333/resourceGroups/agc/providers/Microsoft.OperationalInsights/workspaces/log8240",
"typeSettings": {
"additionalResourceOptions": []
},
"queryType": 1,
"resourceType": "microsoft.resourcegraph/resources"
},
{
"id": "f451ddc5-00e3-4fe7-908e-22d0be9ab59c",
"version": "KqlParameterItem/1.0",
"name": "detectionTime",
"label": "Detection Time",
"type": 4,
"isRequired": true,
"value": {
"durationMs": 14400000
},
"typeSettings": {
"selectableValues": [
{
"durationMs": 300000
},
{
"durationMs": 900000
},
{
"durationMs": 1800000
},
{
"durationMs": 3600000
},
{
"durationMs": 14400000
},
{
"durationMs": 43200000
},
{
"durationMs": 86400000
},
{
"durationMs": 172800000
},
{
"durationMs": 259200000
},
{
"durationMs": 604800000
},
{
"durationMs": 1209600000
},
{
"durationMs": 2419200000
},
{
"durationMs": 2592000000
},
{
"durationMs": 5184000000
},
{
"durationMs": 7776000000
}
]
},
"timeContext": {
"durationMs": 86400000
}
}
],
"style": "pills",
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces"
},
"name": "parameters - 2"
},
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "AGCFirewallLogs \n// |where Category == \"ApplicationGatewayFirewallLog\"\n| where TimeGenerated {detectionTime}\n| extend Id = new_guid()\n| project-reorder Id, _ResourceId, PolicyScopeName, Action\n//| summarize count() by _ResourceId, PolicyScopeName, Action\n| evaluate pivot(Action, count(), _ResourceId, PolicyScopeName)",
"size": 1,
"title": "Select the scope of the WAF policy",
"exportedParameters": [
{
"fieldName": "PolicyScopeName",
"parameterName": "PolicyScope",
"parameterType": 1
},
{
"fieldName": "_ResourceId",
"parameterName": "ResourceId",
"parameterType": 1
}
],
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces",
"crossComponentResources": [
"{workspace}"
],
"visualization": "table",
"gridSettings": {
"formatters": [
{
"columnMatch": "$gen_group",
"formatter": 13,
"formatOptions": {
"linkTarget": null,
"showIcon": true
}
},
{
"columnMatch": "_ResourceId",
"formatter": 5
},
{
"columnMatch": "Matched",
"formatter": 8,
"formatOptions": {
"palette": "greenRed"
}
},
{
"columnMatch": "Blocked",
"formatter": 8,
"formatOptions": {
"palette": "greenRed"
}
}
],
"rowLimit": 500,
"hierarchySettings": {
"treeType": 1,
"groupBy": [
"ResourceId"
]
},
"labelSettings": [
{
"columnId": "PolicyScopeName",
"label": "Policy Scope"
}
]
},
"tileSettings": {
"showBorder": false
}
},
"name": "query-app-gateway-resources"
},
{
"type": 11,
"content": {
"version": "LinkItem/1.0",
"style": "tabs",
"links": [
{
"id": "14e61d36-d59a-405d-8363-ac1aa8a2f491",
"cellValue": "SelectedTabPage",
"linkTarget": "parameter",
"linkLabel": "Triage by Rule",
"subTarget": "triage-by-rule",
"preText": "Triage by Rule",
"style": "link"
},
{
"id": "93464fc4-d183-4d74-9e06-111c6de081a9",
"cellValue": "SelectedTabPage",
"linkTarget": "parameter",
"linkLabel": "Triage by URL",
"subTarget": "triage-by-url",
"preText": "Triage ",
"style": "link"
}
]
},
"name": "TabNavigation"
},
{
"type": 12,
"content": {
"version": "NotebookGroup/1.0",
"groupType": "editable",
"items": [
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "AGCFirewallLogs \r\n// |where Category == \"ApplicationGatewayFirewallLog\"\r\n| where TimeGenerated {detectionTime}\r\n| where _ResourceId == '{ResourceId}' and PolicyScopeName == '{PolicyScope}'\r\n| summarize Count = count() by RuleSetType, RuleSetVersion, RuleId, FileDetails, LineDetails, Action\r\n| order by Count desc\r\n| project-reorder Count\r\n//| extend ruleidentif = RuleId\r\n//| extend ruleSetVersionss = RuleSetVersion, ruleSetTypess = RuleSetType\r\n| extend normalizedRuleSetVersion = case(isempty(RuleSetVersion), \"\",\r\n // old engine: RuleSetVersion looks like \"3.1.0\" while type is \"OWASP_CRS\" => leave untouched, can use this as-is\r\n // final url to GH is like: https://github.com/coreruleset/coreruleset/blob/v3.1.0/rules/REQUEST-913-SCANNER-DETECTION.conf#L56\r\n RuleSetVersion matches regex \"[0-9]+.[0-9]+.[0-9]+\", RuleSetVersion,\r\n // new engine: RuleSetVersion looks like \"3.2\" while type is \"OWASP CRS\" => need a version that looks like \"3.2.0\"\r\n // final url to GH is like: https://github.com/coreruleset/coreruleset/blob/v3.2.0/rules/REQUEST-920-PROTOCOL-ENFORCEMENT.conf#L56\r\n RuleSetVersion matches regex \"[0-9]+.[0-9]+\", strcat(RuleSetVersion, \".0\"),\r\n \"\")\r\n| extend normalizedDetailsFile = case( RuleSetType == \"OWASP_CRS\", replace(@'rules/', '', FileDetails), // old engine: details_files_s looks like \"rules/REQUEST-920-PROTOCOL-ENFORCEMENT.conf\" while type is \"OWASP_CRS\"\r\n RuleSetType == \"OWASP CRS\", FileDetails, // new engine: details_files_s looks like \"REQUEST-920-PROTOCOL-ENFORCEMENT.conf\" while type is \"OWASP CRS\"\r\n FileDetails)\r\n| extend Url = iif(isnotempty(RuleSetVersion), strcat('https://github.com/coreruleset/coreruleset/blob/', 'v', normalizedRuleSetVersion, '/rules/', normalizedDetailsFile, '#L', LineDetails), '')\r\n// add sparklines\r\n| join kind=inner (AGCFirewallLogs // |where Category == \"ApplicationGatewayFirewallLog\" | where TimeGenerated {detectionTime} | where _ResourceId == '{ResourceId}' and PolicyScopeName == '{PolicyScope}'\r\n | make-series Trend = count() on TimeGenerated from {detectionTime:start} to {detectionTime:end} step (time({detectionTime:seconds} seconds) / 20) by RuleId\r\n ) on RuleId\r\n| extend Id = new_guid()",
"size": 0,
"showAnalytics": true,
"title": "Rules that got triggered",
"exportedParameters": [
{
"fieldName": "RuleId",
"parameterName": "RuleId"
},
{
"fieldName": "Url",
"parameterName": "SpiderLabsUrl",
"parameterType": 1
},
{
"fieldName": "RuleSetVersion",
"parameterName": "RuleSetVersion",
"parameterType": 1
}
],
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces",
"crossComponentResources": [
"{workspace}"
],
"gridSettings": {
"formatters": [
{
"columnMatch": "Count",
"formatter": 8,
"formatOptions": {
"palette": "greenRed"
}
},
{
"columnMatch": "RuleSetType",
"formatter": 5
},
{
"columnMatch": "RuleId",
"formatter": 5
},
{
"columnMatch": "Url",
"formatter": 7,
"formatOptions": {
"linkTarget": "Url",
"linkLabel": "Go to Core Rule Set Project GitHub for this rule"
}
},
{
"columnMatch": "Trend",
"formatter": 10,
"formatOptions": {
"palette": "yellowOrangeRed"
}
},
{
"columnMatch": "TimeGenerated",
"formatter": 5
},
{
"columnMatch": "Id",
"formatter": 5
}
],
"sortBy": [
{
"itemKey": "$gen_heatmap_Count_0",
"sortOrder": 2
}
],
"labelSettings": [
{
"columnId": "RuleSetVersion",
"label": "Ruleset Version"
},
{
"columnId": "RuleId",
"label": "Rule Id"
}
]
},
"sortBy": [
{
"itemKey": "$gen_heatmap_Count_0",
"sortOrder": 2
}
]
},
"customWidth": "100",
"name": "query - violated rules"
},
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "AGCFirewallLogs\r\n// |where Category == \"ApplicationGatewayFirewallLog\"\r\n| where _ResourceId == '{ResourceId}' and PolicyScopeName == '{PolicyScope}' and RuleId == '{RuleId}' and RuleSetVersion == '{RuleSetVersion}'\r\n| where TimeGenerated {detectionTime}\r\n// at this point hostname_s can still contain both hostname and port; for example: www.myhost.com:80 -> we need to split this up to match on just the host later\r\n| extend splittedhost = split(hostname_s, ':')\r\n| extend hostname_s_noport = tostring(splittedhost[0]) //override hostname_s to just contain host; drop the port section\r\n| extend port = tostring(splittedhost[1])\r\n| distinct hostname_s, hostname_s_noport",
"size": 0,
"title": "Hosts Affected",
"exportedParameters": [
{
"fieldName": "hostname_s",
"parameterName": "HostName"
},
{
"fieldName": "hostname_s_noport",
"parameterName": "HostNameNoPort",
"parameterType": 1
}
],
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces",
"crossComponentResources": [
"{workspace}"
],
"visualization": "table",
"gridSettings": {
"formatters": [
{
"columnMatch": "hostname_s_noport",
"formatter": 5
}
]
}
},
"customWidth": "15",
"showPin": true,
"name": "Affected Hosts"
},
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "AGCFirewallLogs\r\n// |where Category == \"ApplicationGatewayFirewallLog\"\r\n| where TimeGenerated {detectionTime}\r\n| where _ResourceId == '{ResourceId}' and PolicyScopeName == '{PolicyScope}' and RuleId == '{RuleId}'\r\n| where hostname_s == '{HostName}'\r\n| project-reorder hostname_s, transactionId_g\r\n| join kind=inner (AGCFirewallLogs | where Category == \"ApplicationGatewayAccessLog\" | where TimeGenerated {detectionTime}) on transactionId_g\r\n| distinct host_s1, httpMethod_s1, requestUri_s1, originalRequestUriWithArgs_s1\r\n| order by host_s1, requestUri_s1, httpMethod_s1, originalRequestUriWithArgs_s1\r\n| extend id = new_guid()",
"size": 0,
"showAnalytics": true,
"title": "Hosts and urls impacted by selected rule",
"exportedParameters": [
{
"fieldName": "httpMethod_s1",
"parameterName": "Method",
"parameterType": 1
},
{
"fieldName": "originalRequestUriWithArgs_s1",
"parameterName": "FullUri",
"parameterType": 1
},
{
"fieldName": "requestUri_s1",
"parameterName": "RequestUri",
"parameterType": 1
}
],
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces",
"crossComponentResources": [
"{workspace}"
],
"visualization": "table",
"gridSettings": {
"formatters": [
{
"columnMatch": "requestUri_s",
"formatter": 5
},
{
"columnMatch": "encodedRequestUri",
"formatter": 5
},
{
"columnMatch": "id",
"formatter": 5
}
],
"rowLimit": 1000,
"hierarchySettings": {
"treeType": 1,
"groupBy": [
"requestUri_s1"
],
"expandTopLevel": true,
"finalBy": "requestUri_s"
}
}
},
"customWidth": "60",
"name": "affected urls"
},
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "AGCFirewallLogs\r\n// |where Category == \"ApplicationGatewayFirewallLog\"\r\n| where _ResourceId == '{ResourceId}' and PolicyScopeName == '{PolicyScope}'\r\n| where TimeGenerated {detectionTime}\r\n| distinct transactionId_g\r\n| join kind=inner (AGCFirewallLogs | where Category == \"ApplicationGatewayAccessLog\" | where TimeGenerated {detectionTime}) \r\n on transactionId_g\r\n| where originalHost_s == '{HostNameNoPort}' and httpMethod_s == '{Method}' and requestUri_s == ```{RequestUri}``` and originalRequestUriWithArgs_s == ```{FullUri}```\r\n| project transactionId_g\r\n| extend access_log = strcat(\"AGCFirewallLogs | where Category == \\\"ApplicationGatewayAccessLog\\\" | where TimeGenerated {detectionTime} | where transactionId_g == \\\"\", transactionId_g, \"\\\"\")\r\n| extend firewall_log = strcat(\"AGCFirewallLogs | where Category == \\\"ApplicationGatewayFirewallLog\\\" | where TimeGenerated {detectionTime} | where transactionId_g == \\\"\", transactionId_g, \"\\\"\")\r\n//let transIdsWithFirewallLog = AGCFirewallLogs\r\n//// |where Category == \"ApplicationGatewayFirewallLog\"\r\n//| where _ResourceId == '{ResourceId}' and PolicyScopeName == '{PolicyScope}'\r\n//| where TimeGenerated {detectionTime}\r\n//| distinct transactionId_g;\r\n//AGCFirewallLogs\r\n//| where Category == \"ApplicationGatewayAccessLog\"\r\n//| where TimeGenerated {detectionTime}\r\n//| where host_s == '{HostName}' and httpMethod_s == '{Method}' and requestUri_s == '{RequestUri}' and originalRequestUriWithArgs_s == '{FullUri}'\r\n//| distinct transactionId_g\r\n//| where transactionId_g in (transIdsWithFirewallLog) // TODO: how to get tenant id in here?\r\n//| extend access_log = strcat(\"AGCFirewallLogs | where Category == \\\"ApplicationGatewayAccessLog\\\" | where TimeGenerated {detectionTime} | where transactionId_g == \\\"\", transactionId_g, \"\\\"\")\r\n//| extend firewall_log = strcat(\"AGCFirewallLogs | where Category == \\\"ApplicationGatewayFirewallLog\\\" | where TimeGenerated {detectionTime} | where transactionId_g == \\\"\", transactionId_g, \"\\\"\")",
"size": 0,
"title": "Requests on selected host and url",
"exportFieldName": "transactionId_g",
"exportParameterName": "TransactionId",
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces",
"crossComponentResources": [
"{workspace}"
],
"gridSettings": {
"formatters": [
{
"columnMatch": "transactionId_g",
"formatter": 0,
"formatOptions": {
"customColumnWidthSetting": "40%"
}
},
{
"columnMatch": "access_log",
"formatter": 7,
"formatOptions": {
"linkTarget": "OpenBlade",
"linkLabel": "Find in Access Log",
"linkIsContextBlade": true,
"bladeOpenContext": {
"bladeName": "LogsBlade",
"extensionName": "Microsoft_Azure_Monitoring_Logs",
"bladeParameters": [
{
"name": "resourceId",
"source": "parameter",
"value": "workspace"
},
{
"name": "source",
"source": "static",
"value": "Microsoft_Azure_Monitoring_Logs/LogsBlade"
},
{
"name": "query",
"source": "cell",
"value": ""
}
]
}
}
},
{
"columnMatch": "firewall_log",
"formatter": 7,
"formatOptions": {
"linkTarget": "OpenBlade",
"linkLabel": "Find in Firewall Log",
"linkIsContextBlade": true,
"bladeOpenContext": {
"bladeName": "LogsBlade",
"extensionName": "Microsoft_Azure_Monitoring_Logs",
"bladeParameters": [
{
"name": "resourceId",
"source": "parameter",
"value": "workspace"
},
{
"name": "source",
"source": "static",
"value": "Microsoft_Azure_Monitoring_Logs/LogsBlade"
},
{
"name": "query",
"source": "cell",
"value": ""
}
]
}
}
}
]
}
},
"customWidth": "25",
"name": "ImpactedRequestsFromSelectedUri"
},
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "AGCFirewallLogs \r\n// |where Category == \"ApplicationGatewayFirewallLog\"\r\n| where transactionId_g == '{TransactionId}'\r\n| extend Id = new_guid()\r\n| project-reorder Id, Action, RuleSetType, RuleSetVersion, RuleId, Message, hostname_s, requestUri_s, details_message_s, details_data_s, FileDetails, LineDetails, transactionId_g\r\n| extend normalizedRuleSetVersion = case(isempty(RuleSetVersion), \"\",\r\n // old engine: RuleSetVersion looks like \"3.1.0\" while type is \"OWASP_CRS\" => leave untouched, can use this as-is\r\n // final url to GH is like: https://github.com/coreruleset/coreruleset/blob/v3.1.0/rules/REQUEST-913-SCANNER-DETECTION.conf#L56\r\n RuleSetVersion matches regex \"[0-9]+.[0-9]+.[0-9]+\", RuleSetVersion,\r\n // new engine: RuleSetVersion looks like \"3.2\" while type is \"OWASP CRS\" => need a version that looks like \"3.2.0\"\r\n // final url to GH is like: https://github.com/coreruleset/coreruleset/blob/v3.2.0/rules/REQUEST-920-PROTOCOL-ENFORCEMENT.conf#L56\r\n RuleSetVersion matches regex \"[0-9]+.[0-9]+\", strcat(RuleSetVersion, \".0\"),\r\n \"\")\r\n| extend normalizedDetailsFile = case( RuleSetType == \"OWASP_CRS\", replace(@'rules/', '', FileDetails), // old engine: details_files_s looks like \"rules/REQUEST-920-PROTOCOL-ENFORCEMENT.conf\" while type is \"OWASP_CRS\"\r\n RuleSetType == \"OWASP CRS\", FileDetails, // new engine: details_files_s looks like \"REQUEST-920-PROTOCOL-ENFORCEMENT.conf\" while type is \"OWASP CRS\"\r\n FileDetails)\r\n| extend Url = iif(isnotempty(RuleSetVersion), strcat('https://github.com/coreruleset/coreruleset/blob/', 'v', normalizedRuleSetVersion, '/rules/', normalizedDetailsFile, '#L', LineDetails), '')\r\n| project Action, RuleId, Message, details_message_s, details_data_s, Url, TimeGenerated\r\n",
"size": 0,
"title": "Rules that got triggered for selected request",
"exportedParameters": [
{
"fieldName": "transactionId_g",
"parameterName": "TransactionId"
},
{
"fieldName": "Message",
"parameterName": "message",
"parameterType": 1
},
{
"fieldName": "details_message_s",
"parameterName": "details",
"parameterType": 1
},
{
"fieldName": "details_data_s",
"parameterName": "matcheddata",
"parameterType": 1
}
],
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces",
"crossComponentResources": [
"{workspace}"
],
"visualization": "table",
"gridSettings": {
"formatters": [
{
"columnMatch": "Action",
"formatter": 18,
"formatOptions": {
"thresholdsOptions": "icons",
"thresholdsGrid": [
{
"operator": "==",
"thresholdValue": "Matched",
"representation": "2",
"text": "{0}{1}"
},
{
"operator": "==",
"thresholdValue": "Blocked",
"representation": "4",
"text": "{0}{1}"
},
{
"operator": "Default",
"thresholdValue": null,
"representation": "more",
"text": "{0}{1}"
}
]
}
},
{
"columnMatch": "RuleId",
"formatter": 18,
"formatOptions": {
"thresholdsOptions": "colors",
"thresholdsGrid": [
{
"operator": "==",
"thresholdValue": "{RuleId}",
"representation": "yellow",
"text": "{0}{1}"
},
{
"operator": "Default",
"thresholdValue": null,
"text": "{0}{1}"
}
]
}
},
{
"columnMatch": "Url",
"formatter": 7,
"formatOptions": {
"linkTarget": "Url",
"linkLabel": "Go to Core Rule Set Project GitHub for this rule"
}
},
{
"columnMatch": "statusFromAction",
"formatter": 5,
"numberFormat": {
"unit": 0,
"options": {
"style": "decimal"
}
}
}
],
"labelSettings": [
{
"columnId": "Action",
"label": "action"
},
{
"columnId": "RuleId",
"label": "rule id"
},
{
"columnId": "Message",
"label": "message"
},
{
"columnId": "details_message_s",
"label": "details"
},
{
"columnId": "details_data_s",
"label": "matched data"
},
{
"columnId": "TimeGenerated",
"label": "time generated"
}
]
}
},
"name": "TriggeredRules"
},
{
"type": 1,
"content": {
"json": "## Selection Summary:\r\n\r\nYou were looking for example requests which were impacted by WAF rule with id: **{RuleId}**. \r\n\r\nMore information on the selected rule which impacted this url, can be found on the [Core Rule Set Project](https://coreruleset.org/) GitHub page, here:, here: {SpiderLabsUrl}\r\n\r\nOn the host with name \"*{HostName}*\" and url \"*{FullUri}*\" you have found an HTTP request, impacted by this rule, with transaction id equal to *{TransactionId}*. \r\n\r\nMore info on this request and the selected rule:\r\n- Message: {message}\r\n- Details: {details}\r\n- Matched Data: {matcheddata}"
},
"name": "text - 7"
}
],
"exportParameters": true
},
"conditionalVisibility": {
"parameterName": "SelectedTabPage",
"comparison": "isEqualTo",
"value": "triage-by-rule"
},
"name": "Triage by rule"
},
{
"type": 12,
"content": {
"version": "NotebookGroup/1.0",
"groupType": "editable",
"items": [
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "AGCFirewallLogs \r\n// |where Category == \"ApplicationGatewayFirewallLog\"\r\n| where _ResourceId == '{ResourceId}' and PolicyScopeName == '{PolicyScope}'\r\n| where TimeGenerated {detectionTime}\r\n| distinct hostname_s",
"size": 0,
"title": "Hostnames with entries in Firewall Log",
"exportFieldName": "hostname_s",
"exportParameterName": "HostName",
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces",
"crossComponentResources": [
"{workspace}"
],
"gridSettings": {
"formatters": [
{
"columnMatch": "hostname_s",
"formatter": 0,
"formatOptions": {
"customColumnWidthSetting": "100%"
}
}
],
"sortBy": [
{
"itemKey": "hostname_s",
"sortOrder": 1
}
]
},
"sortBy": [
{
"itemKey": "hostname_s",
"sortOrder": 1
}
]
},
"customWidth": "10",
"name": "Hostnames with entries in Firewall Log"
},
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "AGCFirewallLogs\r\n// |where Category == \"ApplicationGatewayFirewallLog\"\r\n| where _ResourceId == '{ResourceId}' and PolicyScopeName == '{PolicyScope}'\r\n| where hostname_s == '{HostName}'\r\n| where TimeGenerated {detectionTime}\r\n| join kind=inner (AGCFirewallLogs | where Category == \"ApplicationGatewayAccessLog\" | where _ResourceId == '{ResourceId}')\r\n on transactionId_g\r\n| distinct requestUri_s, httpMethod_s1, originalRequestUriWithArgs_s1, httpStatus_d1\r\n| extend Id = new_guid()\r\n",
"size": 0,
"title": "Paths which have triggered firewall rules",
"exportedParameters": [
{
"fieldName": "requestUri_s",
"parameterName": "RequestUri"
},
{
"fieldName": "originalRequestUriWithArgs_s1",
"parameterName": "RequestUriWithArgs",
"parameterType": 1
},
{
"fieldName": "httpMethod_s1",
"parameterName": "HttpMethod",
"parameterType": 1
},
{
"fieldName": "httpStatus_d1",
"parameterName": "HttpStatus",
"parameterType": 1
},
{
"parameterType": 1
}
],
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces",
"crossComponentResources": [
"{workspace}"
],
"gridSettings": {
"formatters": [
{
"columnMatch": "encodedRequestUriWithArgs",
"formatter": 5
},
{
"columnMatch": "Id",
"formatter": 5
}
],
"filter": true,
"hierarchySettings": {
"treeType": 1,
"groupBy": [
"requestUri_s",
"httpMethod_s1"
],
"finalBy": "httpStatus_d1"
},
"sortBy": [
{
"itemKey": "httpStatus_d1",
"sortOrder": 1
}
]
},
"sortBy": [
{
"itemKey": "httpStatus_d1",
"sortOrder": 1
}
]
},
"customWidth": "60",
"name": "Paths which have triggered firewall rules"
},
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "AGCFirewallLogs\r\n// |where Category == \"ApplicationGatewayFirewallLog\"\r\n| where _ResourceId == '{ResourceId}' and PolicyScopeName == '{PolicyScope}'\r\n| where hostname_s == '{HostName}'\r\n| where TimeGenerated {detectionTime}\r\n| join kind=inner (AGCFirewallLogs | where Category == \"ApplicationGatewayAccessLog\" | where _ResourceId == '{ResourceId}')\r\n on transactionId_g\r\n| where originalRequestUriWithArgs_s1 == ```{RequestUriWithArgs}``` and httpMethod_s1 == '{HttpMethod}' and httpStatus_d1 == '{HttpStatus}'\r\n| distinct transactionId_g\r\n| extend access_log = strcat(\"AGCFirewallLogs | where Category == \\\"ApplicationGatewayAccessLog\\\" | where TimeGenerated {detectionTime} | where transactionId_g == \\\"\", transactionId_g, \"\\\"\")\r\n| extend firewall_log = strcat(\"AGCFirewallLogs | where Category == \\\"ApplicationGatewayFirewallLog\\\" | where TimeGenerated {detectionTime} | where transactionId_g == \\\"\", transactionId_g, \"\\\"\")",
"size": 0,
"title": "Requests on selected host and url",
"exportFieldName": "transactionId_g",
"exportParameterName": "TransactionId",
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces",
"crossComponentResources": [
"{workspace}"
],
"gridSettings": {
"formatters": [
{
"columnMatch": "transactionId_g",
"formatter": 0,
"formatOptions": {
"customColumnWidthSetting": "40%"
}
},
{
"columnMatch": "access_log",
"formatter": 7,
"formatOptions": {
"linkTarget": "OpenBlade",
"linkLabel": "Find in Access Log",
"linkIsContextBlade": true,
"bladeOpenContext": {
"bladeName": "LogsBlade",
"extensionName": "Microsoft_Azure_Monitoring_Logs",
"bladeParameters": [
{
"name": "resourceId",
"source": "parameter",
"value": "workspace"
},
{
"name": "source",
"source": "static",
"value": "Microsoft_Azure_Monitoring_Logs/LogsBlade"
},
{
"name": "query",
"source": "cell",
"value": ""
}
]
}
}
},
{
"columnMatch": "firewall_log",
"formatter": 7,
"formatOptions": {
"linkTarget": "OpenBlade",
"linkLabel": "Find in Firewall Log",
"linkIsContextBlade": true,
"bladeOpenContext": {
"bladeName": "LogsBlade",
"extensionName": "Microsoft_Azure_Monitoring_Logs",
"bladeParameters": [
{
"name": "resourceId",
"source": "parameter",
"value": "workspace"
},
{
"name": "source",
"source": "static",
"value": "Microsoft_Azure_Monitoring_Logs/LogsBlade"
},
{
"name": "query",
"source": "cell",
"value": ""
}
]
}
}
}
]
}
},
"customWidth": "25",
"name": "query - 3"
},
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "AGCFirewallLogs \r\n// |where Category == \"ApplicationGatewayFirewallLog\"\r\n//| where TimeGenerated {detectionTime}\r\n| where transactionId_g == '{TransactionId}'\r\n| extend Id = new_guid()\r\n| project-reorder Id, Action, RuleSetType, RuleSetVersion, RuleId, Message, hostname_s, requestUri_s, details_message_s, details_data_s, FileDetails, LineDetails, transactionId_g\r\n| extend normalizedRuleSetVersion = case(isempty(RuleSetVersion), \"\",\r\n // old engine: RuleSetVersion looks like \"3.1.0\" while type is \"OWASP_CRS\" => leave untouched, can use this as-is\r\n // final url to GH is like: https://github.com/coreruleset/coreruleset/blob/v3.1.0/rules/REQUEST-913-SCANNER-DETECTION.conf#L56\r\n RuleSetVersion matches regex \"[0-9]+.[0-9]+.[0-9]+\", RuleSetVersion,\r\n // new engine: RuleSetVersion looks like \"3.2\" while type is \"OWASP CRS\" => need a version that looks like \"3.2.0\"\r\n // final url to GH is like: https://github.com/coreruleset/coreruleset/blob/v3.2.0/rules/REQUEST-920-PROTOCOL-ENFORCEMENT.conf#L56\r\n RuleSetVersion matches regex \"[0-9]+.[0-9]+\", strcat(RuleSetVersion, \".0\"),\r\n \"\")\r\n| extend normalizedDetailsFile = case( RuleSetType == \"OWASP_CRS\", replace(@'rules/', '', FileDetails), // old engine: details_files_s looks like \"rules/REQUEST-920-PROTOCOL-ENFORCEMENT.conf\" while type is \"OWASP_CRS\"\r\n RuleSetType == \"OWASP CRS\", FileDetails, // new engine: details_files_s looks like \"REQUEST-920-PROTOCOL-ENFORCEMENT.conf\" while type is \"OWASP CRS\"\r\n FileDetails)\r\n| extend Url = iif(isnotempty(RuleSetVersion), strcat('https://github.com/coreruleset/coreruleset/blob/', 'v', normalizedRuleSetVersion, '/rules/', normalizedDetailsFile, '#L', LineDetails), '')\r\n| project Action, RuleId, Message, details_message_s, details_data_s, Url, TimeGenerated, RuleSetType, normalizedRuleSetVersion\r\n",
"size": 0,
"title": "Rules that got triggered for selected request",
"exportedParameters": [
{
"fieldName": "transactionId_g",
"parameterName": "TransactionId"
},
{
"fieldName": "Message",
"parameterName": "message",
"parameterType": 1
},
{
"fieldName": "details_message_s",
"parameterName": "details",
"parameterType": 1
},
{
"fieldName": "details_data_s",
"parameterName": "matcheddata",
"parameterType": 1
},
{
"fieldName": "Url",
"parameterName": "SpiderLabsUrl",
"parameterType": 1
}
],
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces",
"crossComponentResources": [
"{workspace}"
],
"visualization": "table",
"gridSettings": {
"formatters": [
{
"columnMatch": "Action",
"formatter": 18,
"formatOptions": {
"thresholdsOptions": "icons",
"thresholdsGrid": [
{
"operator": "==",
"thresholdValue": "Matched",
"representation": "2",
"text": "{0}{1}"
},
{
"operator": "==",
"thresholdValue": "Blocked",
"representation": "4",
"text": "{0}{1}"
},
{
"operator": "Default",
"thresholdValue": null,
"representation": "more",
"text": "{0}{1}"
}
]
}
},
{
"columnMatch": "RuleId",
"formatter": 18,
"formatOptions": {
"thresholdsOptions": "colors",
"thresholdsGrid": [
{
"operator": "==",
"thresholdValue": "{RuleId}",
"representation": "yellow",
"text": "{0}{1}"
},
{
"operator": "Default",
"thresholdValue": null,
"text": "{0}{1}"
}
]
}
},
{
"columnMatch": "Url",
"formatter": 7,
"formatOptions": {
"linkTarget": "Url",
"linkLabel": "Go to Core Rule Set Project GitHub for this rule"
}
},
{
"columnMatch": "statusFromAction",
"formatter": 5,
"numberFormat": {
"unit": 0,
"options": {
"style": "decimal"
}
}
}
],
"labelSettings": [
{
"columnId": "Action",
"label": "action"
},
{
"columnId": "RuleId",
"label": "rule id"
},
{
"columnId": "Message",
"label": "message"
},
{
"columnId": "details_message_s",
"label": "details"
},
{
"columnId": "details_data_s",
"label": "matched data"
},
{
"columnId": "TimeGenerated",