-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
398 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
FROM debian | ||
|
||
COPY e2e/Caddyfile /etc/caddy/Caddyfile | ||
COPY example/Caddyfile /etc/caddy/Caddyfile | ||
|
||
COPY build/caddy-linux /usr/bin/caddy | ||
|
||
CMD ["/usr/bin/caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"] | ||
CMD ["/usr/bin/caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,6 @@ services: | |
build: | ||
context: .. | ||
dockerfile: ./e2e/Dockerfile | ||
|
||
tests: | ||
depends_on: | ||
- caddy | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM debian | ||
|
||
COPY ../example/Caddyfile /etc/caddy/Caddyfile | ||
|
||
COPY build/caddy-linux /usr/bin/caddy | ||
|
||
CMD /usr/bin/caddy run --config /etc/caddy/Caddyfile --adapter caddyfile 2>&1 | tee /home/caddy/logs/caddy.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
services: | ||
httpbin: | ||
image: mccutchen/go-httpbin:v2.5.0 | ||
environment: | ||
- MAX_BODY_SIZE=15728640 # 15 MiB | ||
command: [ "/bin/go-httpbin", "-port", "8081" ] | ||
ports: | ||
- 8081:8081 | ||
|
||
chown: | ||
image: alpine:3.16 | ||
command: | ||
- /bin/sh | ||
- -c | ||
- chown -R 101:101 /home/caddy/logs | ||
volumes: | ||
- logs:/home/caddy/logs:rw | ||
|
||
caddy: | ||
depends_on: | ||
- httpbin | ||
build: | ||
context: .. | ||
dockerfile: ./example/Dockerfile | ||
volumes: | ||
- logs:/home/caddy/logs:rw | ||
ports: | ||
- 8080:8080 | ||
|
||
caddy-logs: | ||
depends_on: | ||
- caddy | ||
- coraza-logs | ||
image: debian:11-slim | ||
entrypoint: bash | ||
command: | ||
- -c | ||
- tail -c +0 -f /home/caddy/logs/caddy.log | ||
volumes: | ||
- logs:/home/caddy/logs:ro | ||
|
||
coraza-logs: | ||
depends_on: | ||
- caddy | ||
image: debian:11-slim | ||
entrypoint: bash | ||
command: | ||
- -c | ||
- tail -c +0 -f /home/caddy/logs/caddy.log | grep --line-buffered "http.handlers.waf" | ||
volumes: | ||
- logs:/home/caddy/logs:ro | ||
|
||
volumes: | ||
logs: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{ | ||
debug | ||
auto_https off | ||
order coraza_waf first | ||
} | ||
|
||
:8080 { | ||
coraza_waf { | ||
directives ` | ||
Include @coraza.conf-recommended | ||
# FTW config | ||
SecDefaultAction "phase:3,log,auditlog,pass" | ||
SecDefaultAction "phase:4,log,auditlog,pass" | ||
SecDefaultAction "phase:5,log,auditlog,pass" | ||
SecDebugLogLevel 3 | ||
SecAction "id:900005,\ | ||
phase:1,\ | ||
nolog,\ | ||
pass,\ | ||
ctl:ruleEngine=DetectionOnly,\ | ||
ctl:ruleRemoveById=910000,\ | ||
setvar:tx.blocking_paranoia_level=4,\ | ||
setvar:tx.crs_validate_utf8_encoding=1,\ | ||
setvar:tx.arg_name_length=100,\ | ||
setvar:tx.arg_length=400,\ | ||
setvar:tx.total_arg_length=64000,\ | ||
setvar:tx.max_num_args=255,\ | ||
setvar:tx.max_file_size=64100,\ | ||
setvar:tx.combined_file_sizes=65535" | ||
SecRule REQUEST_HEADERS:X-CRS-Test "@rx ^.*$" \ | ||
"id:999999,\ | ||
phase:1,\ | ||
pass,\ | ||
t:none,\ | ||
log,\ | ||
msg:'X-CRS-Test %{MATCHED_VAR}',\ | ||
ctl:ruleRemoveById=1-999999" | ||
Include @crs-setup.conf.example | ||
Include @owasp_crs/*.conf | ||
` | ||
} | ||
# Only access logs are logged via log directive, ftw is looking for error logs | ||
# log { | ||
# output file /home/caddy/logs/caddy.log | ||
# level error | ||
# } | ||
reverse_proxy httpbin:8081 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM debian | ||
|
||
COPY ftw/Caddyfile /etc/caddy/Caddyfile | ||
|
||
COPY build/caddy-linux /usr/bin/caddy | ||
|
||
CMD /usr/bin/caddy run --config /etc/caddy/Caddyfile --adapter caddyfile 2>&1 | tee /home/caddy/logs/caddy.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Copyright 2022 The OWASP Coraza contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
FROM ghcr.io/coreruleset/go-ftw:0.4.9 | ||
|
||
RUN apk update && apk add curl | ||
|
||
WORKDIR /workspace | ||
|
||
# TODOs: | ||
# - update when new CRS version is tagged: https://github.com/coreruleset/coreruleset/archive/refs/tags/v4.0.0-rc1.tar.gz | ||
# - keep it aligned with the https://github.com/corazawaf/coraza-coreruleset commit used | ||
ADD https://github.com/coreruleset/coreruleset/tarball/477d8c3431d042294af2651f08d63d10b6f3fd60 /workspace/coreruleset/ | ||
RUN cd coreruleset && tar -xf 477d8c3431d042294af2651f08d63d10b6f3fd60 --strip-components 1 | ||
|
||
# Logs are written in json format, therefore we need to tweak the tests to match this output format | ||
# Replaces `id rule-id` with `id \"rule-id\"` across all tests | ||
RUN cd coreruleset/tests/regression/tests/ && find . -type f -name "*.yaml" -exec sed -r -i 's/id "([0-9]*)"/id \\\\"\1\\\\"/g' {} + | ||
# Replaces `"id \"rule-id\""` with `id \"rule-id\"` across all tests | ||
RUN cd coreruleset/tests/regression/tests/ && find . -type f -name "*.yaml" -exec sed -r -i 's/"id \\"([0-9]*)\\""/id \\\\\"\1\\\\\"/g' {} + | ||
|
||
COPY ftw.yml /workspace/ftw.yml | ||
COPY tests.sh /workspace/tests.sh | ||
|
||
ENTRYPOINT ["sh"] | ||
CMD ["-c", "/workspace/tests.sh"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
services: | ||
httpbin: | ||
image: mccutchen/go-httpbin:v2.5.0 | ||
command: [ "/bin/go-httpbin", "-port", "8081" ] | ||
ports: | ||
- 8081:8081 | ||
|
||
chown: | ||
image: alpine:3.16 | ||
command: | ||
- /bin/sh | ||
- -c | ||
- chown -R 101:101 /home/caddy/logs | ||
volumes: | ||
- logs:/home/caddy/logs:rw | ||
caddy: | ||
depends_on: | ||
- chown | ||
- httpbin | ||
build: | ||
context: .. | ||
dockerfile: ./ftw/Dockerfile.caddy | ||
volumes: | ||
- ../build:/build | ||
- .:/conf | ||
- logs:/home/caddy/logs:rw | ||
ports: | ||
- 8080:8080 | ||
coraza-logs: | ||
depends_on: | ||
- caddy | ||
image: debian:11-slim | ||
entrypoint: bash | ||
command: | ||
- -c | ||
- tail -c +0 -f /home/caddy/logs/caddy.log | grep --line-buffered "http.handlers.waf" > /home/caddy/logs/ftw.log | ||
volumes: | ||
- logs:/home/caddy/logs:rw | ||
caddy-logs: | ||
depends_on: | ||
- caddy | ||
image: debian:11-slim | ||
entrypoint: bash | ||
command: | ||
- -c | ||
- tail -c +0 -f /home/caddy/logs/caddy.log > /build/ftw-caddy.log | ||
volumes: | ||
- logs:/home/caddy/logs:ro | ||
- ../build:/build | ||
ftw: | ||
depends_on: | ||
- caddy-logs | ||
- coraza-logs | ||
build: | ||
dockerfile: Dockerfile.ftw | ||
environment: | ||
- FTW_CLOUDMODE | ||
- FTW_INCLUDE | ||
volumes: | ||
- logs:/home/caddy/logs:ro | ||
- ../build:/build | ||
volumes: | ||
logs: |
Oops, something went wrong.