Skip to content
This repository was archived by the owner on May 14, 2020. It is now read-only.

Commit b154789

Browse files
authored
Merge pull request #1 from csanders-git/v3.0/dev-za
initial travis deployment
2 parents d8442ca + 07bcc8f commit b154789

File tree

10 files changed

+46
-18
lines changed

10 files changed

+46
-18
lines changed

.travis.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1+
sudo: required
2+
services:
3+
- docker
14
language: python
25
python:
3-
- "2.7"
4-
install: "pip install -r ./util/integration/requirements.txt"
6+
- 2.7
7+
before_install:
8+
- docker pull owasp/modsecurity-crs
9+
- docker run -ti -e PARANOIA=5 -d --rm -p 80:80 -v /var/log/httpd:/var/log/httpd/ owasp/modsecurity-crs
10+
install:
11+
- pip install -r ./util/integration/requirements.txt
12+
- pip install -r ./util/regression-tests/requirements.txt
513
script:
6-
- py.test -vs ./util/integration/format_tests.py
14+
- py.test -vs ./util/integration/format_tests.py
15+
- py.test -vs util/regression-tests/CRS_Tests.py --rule=util/regression-tests/tests/test.yaml
716
# safelist
817
branches:
918
only:

crs-setup.conf.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ SecDefaultAction "phase:2,log,auditlog,pass"
645645
#
646646
# Blocking based on reputation is permanent in the CRS. Unlike other rules,
647647
# which look at the indvidual request, the blocking of IPs is based on
648-
# a persistent record in the IP collection, which remains active for a
648+
# a persistent record in the IP collection, which remains active for a
649649
# certain amount of time.
650650
#
651651
# There are two ways an individual client can become flagged for blocking:

util/Dockerfile

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
1-
FROM owasp/modsecurity:latest
1+
FROM owasp/modsecurity:v2_master
22
MAINTAINER Chaim Sanders [email protected]
33

4+
ENV PARANOIA=1
5+
46
RUN dnf -y update
57

8+
RUN dnf -y install python
9+
610
RUN cd /opt && \
7-
wget https://github.com/SpiderLabs/owasp-modsecurity-crs/archive/v3.0.2.tar.gz && \
8-
tar -xvzf v3.0.2.tar.gz && \
11+
#wget https://github.com/SpiderLabs/owasp-modsecurity-crs/archive/v3.0.2.tar.gz && \
12+
#tar -xvzf v3.0.2.tar.gz && \
13+
git clone https://github.com/csanders-git/owasp-modsecurity-crs owasp-modsecurity-crs-3.0.2 && \
914
cp -R /opt/owasp-modsecurity-crs-3.0.2/ /etc/httpd/modsecurity.d/owasp-crs/ && \
1015
mv /etc/httpd/modsecurity.d/owasp-crs/crs-setup.conf.example /etc/httpd/modsecurity.d/owasp-crs/crs-setup.conf && \
16+
cd /etc/httpd/modsecurity.d/owasp-crs/ && \
17+
git checkout v3.0/dev-za && \
1118
cd /etc/httpd/modsecurity.d && \
1219
printf "include modsecurity.d/owasp-crs/crs-setup.conf\ninclude modsecurity.d/owasp-crs/rules/*.conf" > include.conf && \
1320
sed -i -e 's/SecRuleEngine DetectionOnly/SecRuleEngine On/g' /etc/httpd/modsecurity.d/modsecurity.conf
1421

22+
COPY docker-entrypoint.sh /
23+
1524
EXPOSE 80
1625

26+
ENTRYPOINT ["/docker-entrypoint.sh"]
1727
CMD ["httpd", "-k", "start", "-D", "FOREGROUND"]
18-
19-

util/README

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,12 @@
11
The util directory contains many supporting tools/scripts that may be used with
22
the OWASP ModSecurity CRS files.
3+
4+
Docker Support
5+
==============
6+
You can optionally specify
7+
the paranoia level
8+
of the resulting CRS image,
9+
using the PARANOIA build arg,
10+
as follows:
11+
```docker build -t owasp/modsecurity-crs .```
12+
```docker run -p 80:80 -ti -e PARANOIA=5 --rm owasp/modsecurity-crs```

util/docker-entrypoint.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
python -c "import re;import os;out=re.sub('(#SecAction[\S\s]*id:900000[\s\S]*paranoia_level=1\")','SecAction \\\\\n \"id:900000, \\\\\n phase:1, \\\\\n nolog, \\\\\n pass, \\\\\n t:none, \\\\\n setvar:tx.paranoia_level='+os.environ['PARANOIA']+'\"',open('/etc/httpd/modsecurity.d/owasp-crs/crs-setup.conf','r').read());open('/etc/httpd/modsecurity.d/owasp-crs/crs-setup.conf','w').write(out)" && \
3+
4+
exec "$@"

util/regression-tests/CRS_Tests.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
from ftw import ruleset, logchecker, testrunner
2+
import datetime
23
import pytest
34
import pdb
45
import sys
56
import re
67
import os
7-
import ConfigParser
8+
import config
89

910
def test_crs(ruleset, test, logchecker_obj):
1011
runner = testrunner.TestRunner()
@@ -30,10 +31,7 @@ def reverse_readline(self, filename):
3031
yield line[::-1]
3132

3233
def get_logs(self):
33-
import datetime
34-
config = ConfigParser.ConfigParser()
35-
config.read("settings.ini")
36-
log_location = config.get('settings', 'log_location')
34+
log_location = config.log_location_linux
3735
our_logs = []
3836
pattern = re.compile(r"\[([A-Z][a-z]{2} [A-z][a-z]{2} \d{1,2} \d{1,2}\:\d{1,2}\:\d{1,2}\.\d+? \d{4})\]")
3937
for lline in self.reverse_readline(log_location):

util/regression-tests/__init__.py

Whitespace-only changes.

util/regression-tests/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
log_location_linux = '/var/log/httpd/error_log'
2+
log_location_windows = 'C:\Apache24\logs\error.log'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ftw
1+
ftw==1.1.0

util/regression-tests/settings.ini

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)