Skip to content

Commit 111a4a7

Browse files
committed
update default value of CROWDSEC_APPSEC_URL, update BW tags to 1.5.9 and add automatic tests for CS appsec
1 parent 62c7224 commit 111a4a7

File tree

11 files changed

+57
-29
lines changed

11 files changed

+57
-29
lines changed

.github/workflows/tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ jobs:
4747

4848
- name: Run CrowdSec stream tests
4949
run: ./.tests/crowdsec.sh stream
50+
51+
- name: Run CrowdSec appsec tests
52+
run: ./.tests/crowdsec.sh appsec
5053

5154
- name: Run VirusTotal tests
5255
run: ./.tests/virustotal.sh

.tests/crowdsec.sh

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ do_and_check_cmd cp .tests/crowdsec/docker-compose.yml /tmp/bunkerweb-plugins/cr
1919
# Edit compose
2020
do_and_check_cmd sed -i "s@bunkerity/bunkerweb:.*\$@bunkerweb:tests@g" /tmp/bunkerweb-plugins/crowdsec/docker-compose.yml
2121
do_and_check_cmd sed -i "s@bunkerity/bunkerweb-scheduler:.*\$@bunkerweb-scheduler:tests@g" /tmp/bunkerweb-plugins/crowdsec/docker-compose.yml
22-
do_and_check_cmd sed -i "s@CROWDSEC_MODE=.*\$@CROWDSEC_MODE=$1@g" /tmp/bunkerweb-plugins/crowdsec/docker-compose.yml
22+
if [ $1 == "appsec" ] ; then
23+
do_and_check_cmd sed -i "s@CROWDSEC_MODE=.*\$@CROWDSEC_MODE=live@g" /tmp/bunkerweb-plugins/crowdsec/docker-compose.yml
24+
do_and_check_cmd sed -i "s@CROWDSEC_APPSEC_URL=.*\$@CROWDSEC_APPSEC_URL=http://crowdsec:7422@g" /tmp/bunkerweb-plugins/crowdsec/docker-compose.yml
25+
else
26+
do_and_check_cmd sed -i "s@CROWDSEC_MODE=.*\$@CROWDSEC_MODE=$1@g" /tmp/bunkerweb-plugins/crowdsec/docker-compose.yml
27+
28+
fi
2329

2430
# Copy configs
2531
do_and_check_cmd cp .tests/crowdsec/acquis.yaml /tmp/bunkerweb-plugins/crowdsec
@@ -58,23 +64,35 @@ if [ "$success" == "ko" ] ; then
5864
exit 1
5965
fi
6066

61-
# Run basic attack with dirb
62-
echo "ℹ️ Executing dirb ..."
63-
do_and_check_cmd sudo apt install -y dirb
64-
dirb http://localhost -H "Host: www.example.com" -H "User-Agent: LegitOne" -f > /dev/null 2>&1
6567

66-
# Wait if are in stream mode
67-
if [ "$1" == "stream" ] ; then
68-
sleep 20
69-
fi
68+
if [ "$1" != "appsec" ] ; then
69+
# Run basic attack with dirb
70+
echo "ℹ️ Executing dirb ..."
71+
do_and_check_cmd sudo apt install -y dirb
72+
dirb http://localhost -H "Host: www.example.com" -H "User-Agent: LegitOne" -f > /dev/null 2>&1
7073

71-
# Expect a 403
72-
echo "ℹ️ Checking CS ..."
73-
success="ko"
74-
ret="$(curl -s -o /dev/null -w "%{http_code}" -H "Host: www.example.com" http://localhost)"
75-
# shellcheck disable=SC2181
76-
if [ $? -eq 0 ] && [ "$ret" -eq 403 ] ; then
77-
success="ok"
74+
# Wait if are in stream mode
75+
if [ "$1" == "stream" ] ; then
76+
sleep 20
77+
fi
78+
79+
# Expect a 403
80+
echo "ℹ️ Checking CS ..."
81+
success="ko"
82+
ret="$(curl -s -o /dev/null -w "%{http_code}" -H "Host: www.example.com" http://localhost)"
83+
# shellcheck disable=SC2181
84+
if [ $? -eq 0 ] && [ "$ret" -eq 403 ] ; then
85+
success="ok"
86+
fi
87+
else
88+
# Send an obvious pattern
89+
echo "ℹ️ Sending malicious pattern"
90+
success="ko"
91+
ret="$(curl -s -o /dev/null -w "%{http_code}" -H "Host: www.example.com" http://localhost/?id=/etc/passwd)"
92+
# shellcheck disable=SC2181
93+
if [ $? -eq 0 ] && [ "$ret" -eq 403 ] ; then
94+
success="ok"
95+
fi
7896
fi
7997

8098
# We're done

.tests/crowdsec/appsec.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
appsec_config: crowdsecurity/appsec-default
2+
labels:
3+
type: appsec
4+
listen_addr: 127.0.0.1:7422
5+
source: appsec

.tests/crowdsec/docker-compose.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ services:
1515
- CROWDSEC_API=http://crowdsec:8080
1616
- CROWDSEC_API_KEY=s3cr3tb0unc3rk3y
1717
- CROWDSEC_MODE=
18+
- CROWDSEC_APPSEC_URL=
1819
- LOG_LEVEL=info
1920
- USE_MODSECURITY=no
2021
- USE_BLACKLIST=no
@@ -61,10 +62,11 @@ services:
6162
volumes:
6263
- cs-data:/var/lib/crowdsec/data
6364
- ./acquis.yaml:/etc/crowdsec/acquis.yaml
65+
- ./appsec.yaml:/etc/crowdsec/acquis.d/appsec.yaml
6466
- bw-logs:/var/log:ro
6567
environment:
6668
- BOUNCER_KEY_bunkerweb=s3cr3tb0unc3rk3y
67-
- COLLECTIONS=crowdsecurity/nginx
69+
- COLLECTIONS=crowdsecurity/nginx crowdsecurity/appsec-virtual-patching crowdsecurity/appsec-generic-rules crowdsecurity/appsec-crs
6870
- DISABLE_PARSERS=crowdsecurity/whitelists
6971
networks:
7072
- bw-universe

clamav/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ version: '3'
3434
services:
3535

3636
bunkerweb:
37-
image: bunkerity/bunkerweb:1.5.8
37+
image: bunkerity/bunkerweb:1.5.9
3838
...
3939
environment:
4040
- USE_CLAMAV=yes
@@ -59,7 +59,7 @@ version: '3'
5959
services:
6060

6161
mybunker:
62-
image: bunkerity/bunkerweb:1.5.8
62+
image: bunkerity/bunkerweb:1.5.9
6363
...
6464
environment:
6565
- USE_CLAMAV=yes

crowdsec/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ metadata:
273273
| `CROWDSEC_EXCLUDE_LOCATION` | | global | no | The locations to exclude while bouncing. It is a list of location, separated by commas. |
274274
| `CROWDSEC_CACHE_EXPIRATION` | `1` | global | no | The cache expiration, in second, for IPs that the bouncer store in cache in live mode. |
275275
| `CROWDSEC_UPDATE_FREQUENCY` | `10` | global | no | The frequency of update, in second, to pull new/old IPs from the CrowdSec local API. |
276-
| `CROWDSEC_APPSEC_URL` | `http://crowdsec:7422` | global | no | URL of the Application Security Component. |
276+
| `CROWDSEC_APPSEC_URL` | | global | no | URL of the Application Security Component. |
277277
| `CROWDSEC_APPSEC_FAILURE_ACTION` | `passthrough` | global | no | Behavior when the AppSec Component return a 500. Can let the request passthrough or deny it. |
278278
| `CROWDSEC_APPSEC_CONNECT_TIMEOUT` | `100` | global | no | The timeout in milliseconds of the connection between the remediation component and AppSec Component. |
279279
| `CROWDSEC_APPSEC_SEND_TIMEOUT` | `100` | global | no | The timeout in milliseconds to send data from the remediation component to the AppSec Component. |

crowdsec/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
},
8181
"CROWDSEC_APPSEC_URL": {
8282
"context": "global",
83-
"default": "http://crowdsec:7422",
83+
"default": "",
8484
"help": "URL of the Application Security Component.",
8585
"id": "crowdsec-appsec-url",
8686
"label": "AppSec URL",

discord/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ version: '3'
3838
services:
3939

4040
bunkerweb:
41-
image: bunkerity/bunkerweb:1.5.8
41+
image: bunkerity/bunkerweb:1.5.9
4242
...
4343
environment:
4444
- USE_DISCORD=yes
@@ -54,7 +54,7 @@ version: '3.5'
5454
services:
5555

5656
mybunker:
57-
image: bunkerity/bunkerweb:1.5.8
57+
image: bunkerity/bunkerweb:1.5.9
5858
...
5959
environment:
6060
- USE_DISCORD=yes

slack/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ version: '3'
3838
services:
3939

4040
bunkerweb:
41-
image: bunkerity/bunkerweb:1.5.8
41+
image: bunkerity/bunkerweb:1.5.9
4242
...
4343
environment:
4444
- USE_SLACK=yes
@@ -54,7 +54,7 @@ version: '3.5'
5454
services:
5555

5656
mybunker:
57-
image: bunkerity/bunkerweb:1.5.8
57+
image: bunkerity/bunkerweb:1.5.9
5858
...
5959
environment:
6060
- USE_SLACK=yes

virustotal/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ version: '3'
3737
services:
3838

3939
bunkerweb:
40-
image: bunkerity/bunkerweb:1.5.8
40+
image: bunkerity/bunkerweb:1.5.9
4141
...
4242
environment:
4343
- USE_VIRUSTOTAL=yes
@@ -53,7 +53,7 @@ version: '3'
5353
services:
5454

5555
mybunker:
56-
image: bunkerity/bunkerweb:1.5.8
56+
image: bunkerity/bunkerweb:1.5.9
5757
...
5858
environment:
5959
- USE_VIRUSTOTAL=yes

0 commit comments

Comments
 (0)