Skip to content

Commit b3f9ae4

Browse files
authored
Merge pull request coreruleset#339 from theseion/fix-default-paranoia-settings
fix: default paranoia settings break CRS
2 parents fd3708b + 6230042 commit b3f9ae4

File tree

7 files changed

+61
-25
lines changed

7 files changed

+61
-25
lines changed

.github/workflows/verifyimage.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
env:
88
# sha256sum format: <hash><space><format (space for text)><file name>
99
MODSECURITY_RECOMMENDED: "ccff8ba1f12428b34ff41960d8bf773dd9f62b9a7c77755247a027cb01896d4f modsecurity.conf-recommended"
10+
GO_FTW_VERSION: '1.3.0'
1011

1112
jobs:
1213
prepare:
@@ -107,3 +108,41 @@ jobs:
107108
grep -q "Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS" headers.txt
108109
grep -q "Access-Control-Allow-Headers: *" headers.txt
109110
fi
111+
112+
- name: Checkout CRS
113+
uses: actions/checkout@v4
114+
with:
115+
fetch-depth: 1
116+
repository: coreruleset/coreruleset
117+
path: crs
118+
- name: "Install go-ftw"
119+
env:
120+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
121+
run: |
122+
cd crs
123+
gh release download -R coreruleset/go-ftw "v${{ env.GO_FTW_VERSION }}" \
124+
-p "ftw_${{ env.GO_FTW_VERSION }}_linux_amd64.tar.gz" -O - | tar -xzvf - ftw
125+
- name: Patch CRS compose file to use verification image
126+
run: |
127+
sed -i \
128+
's#image: owasp/modsecurity-crs:${{ contains(matrix.target, 'apache') && 'apache' || 'nginx' }}.*#image: ${{ matrix.target }}-verification#' \
129+
crs/tests/docker-compose.yml
130+
- name: Run CRS tests for ${{ matrix.target }}
131+
run: |
132+
cd crs
133+
modsec_version="${{ contains(matrix.target, 'apache') && 'modsec2-apache' || 'modsec3-nginx' }}"
134+
backend="${{ contains(matrix.target, 'apache') && 'httpd' || 'nginx' }}"
135+
mkdir -p "tests/logs/${modsec_version}/{nginx,apache2}"
136+
docker compose -f ./tests/docker-compose.yml up -d "${modsec_version}"
137+
docker compose -f ./tests/docker-compose.yml logs
138+
if ! [ "$(docker inspect ${modsec_version} --format='{{.State.Running}}')" = "true" ]; then
139+
echo "Web server failed to start. Aborting."
140+
exit 1
141+
fi
142+
143+
./ftw check -d tests/regression/tests
144+
./ftw run \
145+
-d tests/regression/tests \
146+
--log-file "tests/logs/${modsec_version}/error.log" \
147+
--overrides "tests/regression/${backend}-overrides.yaml" \
148+
--show-failures-only

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ You can achieve the same results just by getting any version you want, and using
119119
git clone https://github.com/coreruleset/coreruleset.git myrules
120120
cd myrules
121121
git checkout ac2a0d1
122-
docker run -p 8080:8080 -ti -e PARANOIA=4 -v rules:/opt/owasp-crs/rules:ro --rm owasp/modsecurity-crs
122+
docker run -p 8080:8080 -ti -e BLOCKING_PARANOIA=4 -v rules:/opt/owasp-crs/rules:ro --rm owasp/modsecurity-crs
123123
```
124124

125125
## Quick reference
@@ -412,8 +412,8 @@ docker run \
412412
-e MODSEC_AUDIT_LOG=/var/log/modsec_audit.log \
413413
-e LOGLEVEL=warn \
414414
-e ERRORLOG=/var/log/modsec_error.log \
415-
-e PARANOIA=1 \
416-
-e EXECUTING_PARANOIA=2 \
415+
-e BLOCKING_PARANOIA=2 \
416+
-e DETECTION_PARANOIA=2 \
417417
-e ENFORCE_BODYPROC_URLENCODED=1 \
418418
-e ANOMALY_INBOUND=10 \
419419
-e ANOMALY_OUTBOUND=5 \

apache/Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ ENV \
146146
TIMEOUT=60 \
147147
WORKER_CONNECTIONS=400 \
148148
# CRS specific variables
149-
PARANOIA=1 \
150149
ANOMALY_INBOUND=5 \
151150
ANOMALY_OUTBOUND=4 \
152151
BLOCKING_PARANOIA=1

apache/Dockerfile-alpine

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ ENV \
156156
TIMEOUT=60 \
157157
WORKER_CONNECTIONS=400 \
158158
# CRS specific variables
159-
PARANOIA=1 \
160159
ANOMALY_INBOUND=5 \
161160
ANOMALY_OUTBOUND=4 \
162161
BLOCKING_PARANOIA=1

docker-bake.hcl

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,13 @@ target "apache" {
125125
lua_modules = join(" ", lua-modules-debian)
126126
tag_base = "apache"
127127
},
128-
{
129-
name = "alpine"
130-
dockerfile = "apache/Dockerfile-alpine"
131-
image = "docker-image://httpd:${httpd-version}-alpine"
132-
lua_modules = join(" ", lua-modules-alpine)
133-
tag_base = "apache-alpine"
134-
}
128+
# {
129+
# name = "alpine"
130+
# dockerfile = "apache/Dockerfile-alpine"
131+
# image = "docker-image://httpd:${httpd-version}-alpine"
132+
# lua_modules = join(" ", lua-modules-alpine)
133+
# tag_base = "apache-alpine"
134+
# }
135135
]
136136
}
137137

@@ -159,23 +159,23 @@ target "nginx" {
159159
lua_modules = join(" ", lua-modules-debian)
160160
tag_base = "nginx"
161161
},
162-
{
163-
name = "alpine"
164-
dockerfile = "nginx/Dockerfile-alpine"
165-
image = "docker-image://nginxinc/nginx-unprivileged:${nginx-version}-alpine"
166-
lua_modules = join(" ", lua-modules-alpine)
167-
tag_base = "nginx-alpine"
168-
}
162+
# {
163+
# name = "alpine"
164+
# dockerfile = "nginx/Dockerfile-alpine"
165+
# image = "docker-image://nginxinc/nginx-unprivileged:${nginx-version}-alpine"
166+
# lua_modules = join(" ", lua-modules-alpine)
167+
# tag_base = "nginx-alpine"
168+
# }
169169
],
170170
read-only-fs = [
171171
{
172172
name = "writable"
173173
read-only = "false"
174174
},
175-
{
176-
name = "read-only"
177-
read-only = "true"
178-
}
175+
# {
176+
# name = "read-only"
177+
# read-only = "true"
178+
# }
179179
]
180180
}
181181
inherits = ["platforms-base"]

nginx/Dockerfile-alpine

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ ENV \
203203
SSL_VERIFY=off \
204204
WORKER_CONNECTIONS=1024 \
205205
# CRS specific variables
206-
PARANOIA=1 \
207206
ANOMALY_INBOUND=5 \
208207
ANOMALY_OUTBOUND=4 \
209208
BLOCKING_PARANOIA=1

src/opt/modsecurity/configure-rules.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ false|RESTRICTED_HEADERS_BASIC|900250|restricted_headers_basic|/if/
2121
false|RESTRICTED_HEADERS_EXTENDED|900255|restricted_headers_extended|/x-some-header/
2222
false|MAX_NUM_ARGS|900300|max_num_args|100
2323
false|ARG_NAME_LENGTH|900310|arg_name_length|200
24-
false|ARG_LENGTH|900230|arg_length|300
24+
false|ARG_LENGTH|900320|arg_length|300
2525
false|TOTAL_ARG_LENGTH|900330|total_arg_length|400
2626
false|MAX_FILE_SIZE|900340|max_file_size|500
2727
false|COMBINED_FILE_SIZES|900350|combined_file_sizes|600

0 commit comments

Comments
 (0)