Skip to content

Commit 357aa0e

Browse files
committed
feat(tests): Add CSRF query tests
1 parent 4e47613 commit 357aa0e

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| app.bicep:12:26:12:30 | false | CSRF protection (csrfAlwaysCheck) is explicitly disabled in Grafana configuration, which can lead to cross-site request forgery attacks. |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
security/CWE-352/GrafanaCsrfDisabled.ql
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Test file for GrafanaCsrfDisabled.ql
2+
// Contains examples of secure and insecure configurations
3+
4+
// TEST CASE: Insecure - Grafana with CSRF protection explicitly disabled
5+
// This should be detected by the query
6+
resource insecureGrafanaCsrf 'Microsoft.Dashboard/grafana@2024-11-01-preview' = {
7+
name: 'insecure-grafana-csrf'
8+
location: 'eastus'
9+
properties: {
10+
grafanaConfigurations: {
11+
security: {
12+
csrfAlwaysCheck: false // ALERT: CSRF protection explicitly disabled
13+
}
14+
}
15+
}
16+
sku: {
17+
name: 'Standard'
18+
}
19+
}
20+
21+
// TEST CASE: Secure - Grafana with CSRF protection explicitly enabled
22+
// This should NOT be detected by the query
23+
resource secureGrafanaCsrf 'Microsoft.Dashboard/grafana@2024-11-01-preview' = {
24+
name: 'secure-grafana-csrf'
25+
location: 'eastus'
26+
properties: {
27+
grafanaConfigurations: {
28+
security: {
29+
csrfAlwaysCheck: true // Secure: CSRF protection always enabled
30+
}
31+
}
32+
}
33+
sku: {
34+
name: 'Standard'
35+
}
36+
}
37+
38+
// TEST CASE: Secure - Grafana with no explicit security configuration (defaults)
39+
// This should NOT be detected by the query
40+
resource defaultGrafanaCsrf 'Microsoft.Dashboard/grafana@2024-11-01-preview' = {
41+
name: 'default-grafana-security'
42+
location: 'eastus'
43+
properties: {
44+
// No explicit security configuration - using Grafana defaults
45+
grafanaConfigurations: {
46+
// Security block omitted
47+
}
48+
}
49+
sku: {
50+
name: 'Standard'
51+
}
52+
}

0 commit comments

Comments
 (0)