Skip to content

Commit

Permalink
test: create regression tests for all rules (#1)
Browse files Browse the repository at this point in the history
* test: create 9520100 regression test

* test: fix folder location

* test: create 9520101 regression test

* test: create 9520102 regression test

* test: create 9520141, 9520142 and 9520143 regression tests

* test: create 9520133, 9520110, 9502104 regression tests

* test: create 9520140 regression test

* test: create regression tests 9520130 9520131 9520132

* test: create 9520121 and 9520120 regression tests

* fix: add blank newline to actions

* fix: typos
  • Loading branch information
EsadCetiner authored Jan 9, 2024
1 parent 6d46b65 commit 905cad8
Show file tree
Hide file tree
Showing 19 changed files with 744 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
on: [push, pull_request]

jobs:
integration-tests:
uses: coreruleset/crs-plugin-test-action/.github/workflows/integration.yaml@main
6 changes: 6 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
on: [push, pull_request]

jobs:
plugin-lint:
uses: coreruleset/crs-plugin-test-action/.github/workflows/lint.yaml@main
6 changes: 5 additions & 1 deletion plugins/sogo-rule-exclusions-before.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ----------------------------------------------------------------------------------------------
# sogo rule exclusions plugin
# Copyright (c) 2023 Esad Cetiner
# Copyright (c) 2023-2024 Esad Cetiner
#
# This plugin is distributed under GPLv2
# Please see the included LICENSE file for full details
Expand Down Expand Up @@ -132,6 +132,7 @@ SecRule REQUEST_FILENAME "@rx ^/SOGo/so/[^/]+/Preferences/save$" \
#

# When creating/modifying contacts
# Adding websites for contacts
SecRule REQUEST_FILENAME "@rx ^/SOGo/so/[^/]+/Contacts/[^/]+/[^/]+\.vcf/saveAsContact$" \
"id:9520120,\
phase:1,\
Expand Down Expand Up @@ -163,6 +164,7 @@ SecRule REQUEST_FILENAME "@rx ^/SOGo/so/[^/]+/Contacts/[^/]+/save$" \
#

# When creating/modifying a calendar task
# Attaching external URLs to a calendar task
SecRule REQUEST_FILENAME "@rx ^/SOGo/so/[^/]+/Calendar/[^/]+/[^/]+\.ics/(?:saveAsTask|save)$" \
"id:9520130,\
phase:1,\
Expand All @@ -180,6 +182,7 @@ SecRule REQUEST_FILENAME "@rx ^/SOGo/so/[^/]+/Calendar/[^/]+/[^/]+\.ics/(?:saveA
ver:'sogo-rule-exclusions-plugin/1.0.0'"

# When creating/modifying a calendar event
# Attaching external URLs to a calendar event
SecRule REQUEST_FILENAME "@rx ^/SOGo/so/[^/]+/Calendar/[^/]+/[^/]+\.ics/(?:saveAsAppointment|occurence[0-9]+/save)$" \
"id:9520131,\
phase:1,\
Expand All @@ -198,6 +201,7 @@ SecRule REQUEST_FILENAME "@rx ^/SOGo/so/[^/]+/Calendar/[^/]+/[^/]+\.ics/(?:saveA
ver:'sogo-rule-exclusions-plugin/1.0.0'"

# When modifying properties for Calendars
# Adding a remote webcal
SecRule REQUEST_FILENAME "@rx ^/SOGo/so/[^/]+/Calendar/[^/]+/save$" \
"id:9520132,\
phase:1,\
Expand Down
2 changes: 1 addition & 1 deletion plugins/sogo-rule-exclusions-config.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ----------------------------------------------------------------------------------------------
# sogo rule exclusions plugin
# Copyright (c) 2023 Esad Cetiner
# Copyright (c) 2023-2024 Esad Cetiner
#
# This plugin is distributed under GPLv2
# Please see the included LICENSE file for full details
Expand Down
55 changes: 55 additions & 0 deletions tests/regression/sogo-rule-exclusions-plugin/9520100.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
meta:
author: "Esad Cetiner"
description: "SOGo Rule Exclusions Plugin"
enabled: true
name: 9520100.yaml
tests:
- test_title: 9520100-1
desc: Disable 920272 for cookie header
stages:
- stage:
input:
dest_addr: 127.0.0.1
headers:
Host: localhost
User-Agent: SOGo rule exclusions plugin
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
cookie: \%
port: 80
method: POST
uri: /SOGo/
output:
no_log_contains: id "920272"
- test_title: 9520100-2
desc: Disable 942450 for XSRF-TOKEN cookie
stages:
- stage:
input:
dest_addr: 127.0.0.1
headers:
Host: localhost
User-Agent: SOGo rule exclusions plugin
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
cookie: XSRF-TOKEN=0x0806
port: 80
method: POST
uri: /SOGo/
output:
no_log_contains: id "942450"
- test_title: 9520100-3
desc: Disable 942450 for 0xHIGHFLYxSOGo cookie
stages:
- stage:
input:
dest_addr: 127.0.0.1
headers:
Host: localhost
User-Agent: SOGo rule exclusions plugin
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
cookie: 0xHIGHFLYxSOGo=0x0800
port: 80
method: POST
uri: /SOGo/
output:
no_log_contains: id "942450"
22 changes: 22 additions & 0 deletions tests/regression/sogo-rule-exclusions-plugin/9520101.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
meta:
author: "Esad Cetiner"
description: "SOGo Rule Exclusions Plugin"
enabled: true
name: 9520101.yaml
tests:
- test_title: 9520101-1
desc: Disable OWASP_CRS for password box when logging in
stages:
- stage:
input:
dest_addr: 127.0.0.1
headers:
Host: localhost
User-Agent: SOGo rule exclusions plugin
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
port: 80
method: POST
uri: /SOGo/connect?json.password=<script>
output:
no_log_contains: id "941110"
97 changes: 97 additions & 0 deletions tests/regression/sogo-rule-exclusions-plugin/9520102.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
---
meta:
author: "Esad Cetiner"
description: "SOGo Rule Exclusions Plugin"
enabled: true
name: 9520102.yaml
tests:
- test_title: 9520102-1
desc: Disable 920440 if uri ends in com
stages:
- stage:
input:
dest_addr: 127.0.0.1
headers:
Host: localhost
User-Agent: SOGo rule exclusions plugin
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
port: 80
method: POST
uri: /SOGo/example.com
output:
no_log_contains: id "920440"
- test_title: 9520102-2
desc: Disable 920440 if uri ends in com
stages:
- stage:
input:
dest_addr: 127.0.0.1
headers:
Host: localhost
User-Agent: SOGo rule exclusions plugin
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
port: 80
method: POST
uri: /SOGo/so/example.com
output:
no_log_contains: id "920440"
- test_title: 9520102-3
desc: Disable 920440 if uri ends in com
stages:
- stage:
input:
dest_addr: 127.0.0.1
headers:
Host: localhost
User-Agent: SOGo rule exclusions plugin
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
port: 80
method: POST
uri: /SOGo/dav/example.com
output:
no_log_contains: id "920440"
- test_title: 9520102-4
desc: Disable 920440 if uri ends in inc
stages:
- stage:
input:
dest_addr: 127.0.0.1
headers:
Host: localhost
User-Agent: SOGo rule exclusions plugin
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
port: 80
method: POST
uri: /SOGo/example.inc
output:
no_log_contains: id "920440"
- test_title: 9520102-5
desc: Disable 920440 if uri ends in inc
stages:
- stage:
input:
dest_addr: 127.0.0.1
headers:
Host: localhost
User-Agent: SOGo rule exclusions plugin
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
port: 80
method: POST
uri: /SOGo/so/example.inc
output:
no_log_contains: id "920440"
- test_title: 9520102-6
desc: Disable 920440 if uri ends in inc
stages:
- stage:
input:
dest_addr: 127.0.0.1
headers:
Host: localhost
User-Agent: SOGo rule exclusions plugin
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
port: 80
method: POST
uri: /SOGo/dav/example.inc
output:
no_log_contains: id "920440"
135 changes: 135 additions & 0 deletions tests/regression/sogo-rule-exclusions-plugin/9520104.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
---
meta:
author: "Esad Cetiner"
description: "SOGo Rule Exclusions Plugin"
enabled: true
name: 9520104.yaml
tests:
- test_title: 9520104-1
desc: Disable OWASP CRS for email body when sending an email
stages:
- stage:
input:
dest_addr: 127.0.0.1
headers:
Host: localhost
User-Agent: SOGo rule exclusions plugin
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Content-Type: text/vcard
port: 80
method: GET
uri: /SOGo/so/[email protected]/Mail/4/folderDrafts/newDraft-4/send?json.text=<script>
output:
no_log_contains: id "941110"
- test_title: 9520104-2
desc: Disable OWASP CRS for email body when saving an email
stages:
- stage:
input:
dest_addr: 127.0.0.1
headers:
Host: localhost
User-Agent: SOGo rule exclusions plugin
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Content-Type: text/vcard
port: 80
method: GET
uri: /SOGo/so/[email protected]/Mail/4/folderDrafts/newDraft-4/save?json.text=<script>
output:
no_log_contains: id "941110"
- test_title: 9520104-3
desc: Disable OWASP CRS for email subject when sending an email
stages:
- stage:
input:
dest_addr: 127.0.0.1
headers:
Host: localhost
User-Agent: SOGo rule exclusions plugin
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Content-Type: text/vcard
port: 80
method: GET
uri: /SOGo/so/[email protected]/Mail/4/folderDrafts/newDraft-4/send?json.subject=<script>
output:
no_log_contains: id "941110"
- test_title: 9520104-4
desc: Disable OWASP CRS for email subject when saving an email
stages:
- stage:
input:
dest_addr: 127.0.0.1
headers:
Host: localhost
User-Agent: SOGo rule exclusions plugin
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Content-Type: text/vcard
port: 80
method: GET
uri: /SOGo/so/[email protected]/Mail/4/folderDrafts/newDraft-4/save?json.subject=<script>
output:
no_log_contains: id "941110"
- test_title: 9520104-5
desc: Disable 942131 for source email address when saving an email
stages:
- stage:
input:
dest_addr: 127.0.0.1
headers:
Host: localhost
User-Agent: SOGo rule exclusions plugin
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Content-Type: text/vcard
port: 80
method: GET
uri: /SOGo/so/[email protected]/Mail/4/folderDrafts/newDraft-4/save?json.from=<[email protected]>Postmaster
output:
no_log_contains: id "942131"
- test_title: 9520104-6
desc: Disable 942131 for source email address when sending an email
stages:
- stage:
input:
dest_addr: 127.0.0.1
headers:
Host: localhost
User-Agent: SOGo rule exclusions plugin
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Content-Type: text/vcard
port: 80
method: GET
uri: /SOGo/so/[email protected]/Mail/4/folderDrafts/newDraft-4/send?json.from=<[email protected]>Postmaster
output:
no_log_contains: id "942131"
- test_title: 9520104-7
desc: Disable 942131 for destination email address when saving an email
stages:
- stage:
input:
dest_addr: 127.0.0.1
headers:
Host: localhost
User-Agent: SOGo rule exclusions plugin
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Content-Type: text/vcard
port: 80
method: GET
uri: /SOGo/so/[email protected]/Mail/4/folderDrafts/newDraft-4/save?json.to.array_0=<[email protected]>Postmaster
output:
no_log_contains: id "942131"
- test_title: 9520104-8
desc: Disable 942131 for destination email address when sending an email
stages:
- stage:
input:
dest_addr: 127.0.0.1
headers:
Host: localhost
User-Agent: SOGo rule exclusions plugin
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Content-Type: text/vcard
port: 80
method: GET
uri: /SOGo/so/[email protected]/Mail/4/folderDrafts/newDraft-4/send?json.to.array_0=<[email protected]>Postmaster
output:
no_log_contains: id "942131"
Loading

0 comments on commit 905cad8

Please sign in to comment.