Skip to content

Commit 13aa912

Browse files
authored
Merge pull request #31 from Sebitosh/test-target-response-body
Test: target RESPONSE_BODY - 069
2 parents ca0e571 + 49ae971 commit 13aa912

File tree

8 files changed

+287
-11
lines changed

8 files changed

+287
-11
lines changed

config_tests/CONF_000_GLOBAL.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ global:
1313
log,\
1414
msg:'%{MATCHED_VAR_NAME} was caught in phase:${PHASE}$',\
1515
ver:'${VERSION}$'"
16+
- name: "Non-disruptive SecRule for TARGETS"
17+
template: |
18+
SecRule ${TARGET}$ "${OPERATOR}$ ${OPARG}$" \
19+
"id:${CURRID}$,\
20+
phase:${PHASE}$,\
21+
t:none,\
22+
log,\
23+
msg:'%{MATCHED_VAR_NAME} was caught in phase:${PHASE}$',\
24+
ver:'${VERSION}$'"
1625
default_tests_phase_methods:
1726
- 1: get
1827
- 2: post
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
target: RESPONSE_BODY
2+
rulefile: MRTS_069_RESPONSE_BODY.conf
3+
testfile: MRTS_069_RESPONSE_BODY.yaml
4+
templates:
5+
- Non-disruptive SecRule for TARGETS
6+
colkey:
7+
- - ''
8+
operator:
9+
- '@contains'
10+
oparg:
11+
- attack
12+
phase:
13+
- 4
14+
- 5
15+
testdata:
16+
phase_methods:
17+
4: post
18+
5: post
19+
targets:
20+
- target: ''
21+
test:
22+
data: '{"status": 200, "headers": {"Content-Type":"text/plain"}, "body": "attack"}'
23+
input:
24+
headers:
25+
- name: Content-Type
26+
value: application/json
27+
uri: '/reflect'
28+
- target: ''
29+
test:
30+
data: '{"status": 200, "headers": {"Content-Type":"text/html"}, "body": "<html>attack</html>"}'
31+
input:
32+
headers:
33+
- name: Content-Type
34+
value: application/json
35+
uri: '/reflect'
36+
- target: ''
37+
test:
38+
data: '{"status": 200, "headers": {"Content-Type":"text/xml"}, "body": "<level1><level2>attack</level2><level2>foo</level2></level1>"}'
39+
input:
40+
headers:
41+
- name: Content-Type
42+
value: application/json
43+
uri: '/reflect'
44+
- target: ''
45+
test:
46+
data: '{"status": 200, "headers": {"Content-Type":"application/json"}, "body": "{test:attack}"}'
47+
input:
48+
headers:
49+
- name: Content-Type
50+
value: application/json
51+
uri: '/reflect'
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
SecRule RESPONSE_BODY "@contains attack" \
2+
"id:100152,\
3+
phase:4,\
4+
t:none,\
5+
log,\
6+
msg:'%{MATCHED_VAR_NAME} was caught in phase:4',\
7+
ver:'MRTS/0.1'"
8+
9+
SecRule RESPONSE_BODY "@contains attack" \
10+
"id:100153,\
11+
phase:5,\
12+
t:none,\
13+
log,\
14+
msg:'%{MATCHED_VAR_NAME} was caught in phase:5',\
15+
ver:'MRTS/0.1'"
16+

generated/rules/MRTS_110_XML.conf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
SecRule XML:/* "@beginsWith foo" \
2-
"id:100152,\
2+
"id:100154,\
33
phase:2,\
44
deny,\
55
t:none,\
@@ -8,7 +8,7 @@ SecRule XML:/* "@beginsWith foo" \
88
ver:'MRTS/0.1'"
99

1010
SecRule XML:/* "@beginsWith foo" \
11-
"id:100153,\
11+
"id:100155,\
1212
phase:3,\
1313
deny,\
1414
t:none,\
@@ -17,7 +17,7 @@ SecRule XML:/* "@beginsWith foo" \
1717
ver:'MRTS/0.1'"
1818

1919
SecRule XML:/* "@beginsWith foo" \
20-
"id:100154,\
20+
"id:100156,\
2121
phase:4,\
2222
deny,\
2323
t:none,\
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
---
2+
meta:
3+
author: MRTS generate-rules.py
4+
enabled: true
5+
name: MRTS_069_RESPONSE_BODY.yaml
6+
description: Desc
7+
tests:
8+
- test_title: 100152-1
9+
ruleid: 100152
10+
test_id: 1
11+
desc: 'Test case for rule 100152, #1'
12+
stages:
13+
- description: Send request
14+
input:
15+
dest_addr: 127.0.0.1
16+
port: 80
17+
protocol: http
18+
method: POST
19+
headers:
20+
User-Agent: OWASP MRTS test agent
21+
Host: localhost
22+
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
23+
Content-Type: application/json
24+
uri: /reflect
25+
version: HTTP/1.1
26+
data: '{"status": 200, "headers": {"Content-Type":"text/plain"}, "body": "attack"}'
27+
output:
28+
log:
29+
expect_ids:
30+
- 100152
31+
- test_title: 100152-2
32+
ruleid: 100152
33+
test_id: 2
34+
desc: 'Test case for rule 100152, #2'
35+
stages:
36+
- description: Send request
37+
input:
38+
dest_addr: 127.0.0.1
39+
port: 80
40+
protocol: http
41+
method: POST
42+
headers:
43+
User-Agent: OWASP MRTS test agent
44+
Host: localhost
45+
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
46+
Content-Type: application/json
47+
uri: /reflect
48+
version: HTTP/1.1
49+
data: '{"status": 200, "headers": {"Content-Type":"text/html"}, "body": "<html>attack</html>"}'
50+
output:
51+
log:
52+
expect_ids:
53+
- 100152
54+
- test_title: 100152-3
55+
ruleid: 100152
56+
test_id: 3
57+
desc: 'Test case for rule 100152, #3'
58+
stages:
59+
- description: Send request
60+
input:
61+
dest_addr: 127.0.0.1
62+
port: 80
63+
protocol: http
64+
method: POST
65+
headers:
66+
User-Agent: OWASP MRTS test agent
67+
Host: localhost
68+
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
69+
Content-Type: application/json
70+
uri: /reflect
71+
version: HTTP/1.1
72+
data: '{"status": 200, "headers": {"Content-Type":"text/xml"}, "body": "<level1><level2>attack</level2><level2>foo</level2></level1>"}'
73+
output:
74+
log:
75+
expect_ids:
76+
- 100152
77+
- test_title: 100152-4
78+
ruleid: 100152
79+
test_id: 4
80+
desc: 'Test case for rule 100152, #4'
81+
stages:
82+
- description: Send request
83+
input:
84+
dest_addr: 127.0.0.1
85+
port: 80
86+
protocol: http
87+
method: POST
88+
headers:
89+
User-Agent: OWASP MRTS test agent
90+
Host: localhost
91+
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
92+
Content-Type: application/json
93+
uri: /reflect
94+
version: HTTP/1.1
95+
data: '{"status": 200, "headers": {"Content-Type":"application/json"}, "body":
96+
"{test:attack}"}'
97+
output:
98+
log:
99+
expect_ids:
100+
- 100152
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
---
2+
meta:
3+
author: MRTS generate-rules.py
4+
enabled: true
5+
name: MRTS_069_RESPONSE_BODY.yaml
6+
description: Desc
7+
tests:
8+
- test_title: 100153-1
9+
ruleid: 100153
10+
test_id: 1
11+
desc: 'Test case for rule 100153, #1'
12+
stages:
13+
- description: Send request
14+
input:
15+
dest_addr: 127.0.0.1
16+
port: 80
17+
protocol: http
18+
method: POST
19+
headers:
20+
User-Agent: OWASP MRTS test agent
21+
Host: localhost
22+
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
23+
Content-Type: application/json
24+
uri: /reflect
25+
version: HTTP/1.1
26+
data: '{"status": 200, "headers": {"Content-Type":"text/plain"}, "body": "attack"}'
27+
output:
28+
log:
29+
expect_ids:
30+
- 100153
31+
- test_title: 100153-2
32+
ruleid: 100153
33+
test_id: 2
34+
desc: 'Test case for rule 100153, #2'
35+
stages:
36+
- description: Send request
37+
input:
38+
dest_addr: 127.0.0.1
39+
port: 80
40+
protocol: http
41+
method: POST
42+
headers:
43+
User-Agent: OWASP MRTS test agent
44+
Host: localhost
45+
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
46+
Content-Type: application/json
47+
uri: /reflect
48+
version: HTTP/1.1
49+
data: '{"status": 200, "headers": {"Content-Type":"text/html"}, "body": "<html>attack</html>"}'
50+
output:
51+
log:
52+
expect_ids:
53+
- 100153
54+
- test_title: 100153-3
55+
ruleid: 100153
56+
test_id: 3
57+
desc: 'Test case for rule 100153, #3'
58+
stages:
59+
- description: Send request
60+
input:
61+
dest_addr: 127.0.0.1
62+
port: 80
63+
protocol: http
64+
method: POST
65+
headers:
66+
User-Agent: OWASP MRTS test agent
67+
Host: localhost
68+
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
69+
Content-Type: application/json
70+
uri: /reflect
71+
version: HTTP/1.1
72+
data: '{"status": 200, "headers": {"Content-Type":"text/xml"}, "body": "<level1><level2>attack</level2><level2>foo</level2></level1>"}'
73+
output:
74+
log:
75+
expect_ids:
76+
- 100153
77+
- test_title: 100153-4
78+
ruleid: 100153
79+
test_id: 4
80+
desc: 'Test case for rule 100153, #4'
81+
stages:
82+
- description: Send request
83+
input:
84+
dest_addr: 127.0.0.1
85+
port: 80
86+
protocol: http
87+
method: POST
88+
headers:
89+
User-Agent: OWASP MRTS test agent
90+
Host: localhost
91+
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
92+
Content-Type: application/json
93+
uri: /reflect
94+
version: HTTP/1.1
95+
data: '{"status": 200, "headers": {"Content-Type":"application/json"}, "body":
96+
"{test:attack}"}'
97+
output:
98+
log:
99+
expect_ids:
100+
- 100153

generated/tests/regression/tests/100152_MRTS_110_XML.yaml renamed to generated/tests/regression/tests/100155_MRTS_110_XML.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ meta:
55
name: MRTS_110_XML.yaml
66
description: Desc
77
tests:
8-
- test_title: 100152-1
9-
ruleid: 100152
8+
- test_title: 100155-1
9+
ruleid: 100155
1010
test_id: 1
11-
desc: 'Test case for rule 100152, #1'
11+
desc: 'Test case for rule 100155, #1'
1212
stages:
1313
- description: Send request
1414
input:
@@ -27,4 +27,4 @@ tests:
2727
output:
2828
log:
2929
expect_ids:
30-
- 100152
30+
- 100155

generated/tests/regression/tests/100153_MRTS_110_XML.yaml renamed to generated/tests/regression/tests/100156_MRTS_110_XML.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ meta:
55
name: MRTS_110_XML.yaml
66
description: Desc
77
tests:
8-
- test_title: 100153-1
9-
ruleid: 100153
8+
- test_title: 100156-1
9+
ruleid: 100156
1010
test_id: 1
11-
desc: 'Test case for rule 100153, #1'
11+
desc: 'Test case for rule 100156, #1'
1212
stages:
1313
- description: Send request
1414
input:
@@ -27,4 +27,4 @@ tests:
2727
output:
2828
log:
2929
expect_ids:
30-
- 100153
30+
- 100156

0 commit comments

Comments
 (0)