Skip to content

Commit 813cbd9

Browse files
committed
feat: structure-change
1 parent d46990b commit 813cbd9

16 files changed

Lines changed: 1344 additions & 834 deletions
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Publish Docker Images
2+
on:
3+
release:
4+
types: [published]
5+
jobs:
6+
push_to_registry:
7+
name: Push Docker image to Docker Hub
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Check out the repo
11+
uses: actions/checkout@v2
12+
- name: Push to Docker Hub
13+
uses: docker/build-push-action@v1
14+
with:
15+
username: ${{ secrets.DOCKER_USERNAME }}
16+
password: ${{ secrets.DOCKER_PASSWORD }}
17+
repository: molu8bits/modsecurity-parser
18+
tags: latest
19+
tag_with_ref: true

.gitignore

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
################################
2+
########### FILES ############
3+
################################
4+
*.exe
5+
6+
################################
7+
########### FOLDERS ############
8+
################################
9+
build/
10+
html/
11+
.benchmarks/
12+
reports/
13+
lectures/
14+
15+
################################
16+
########### PYTHON #############
17+
################################
18+
19+
# Byte-compiled / optimized / DLL files
20+
__pycache__/
21+
*.py[cod]
22+
*$py.class
23+
24+
# C extensions
25+
*.so
26+
27+
# Distribution / packaging
28+
.Python
29+
build/
30+
develop-eggs/
31+
dist/
32+
downloads/
33+
eggs/
34+
.eggs/
35+
lib/
36+
lib64/
37+
parts/
38+
sdist/
39+
var/
40+
wheels/
41+
*.egg-info/
42+
.installed.cfg
43+
*.egg
44+
MANIFEST
45+
46+
# PyInstaller
47+
# Usually these files are written by a python script from a template
48+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
49+
*.manifest
50+
*.spec
51+
52+
# Installer logs
53+
pip-log.txt
54+
pip-delete-this-directory.txt
55+
56+
# Unit test / coverage reports
57+
htmlcov/
58+
.tox/
59+
.coverage
60+
.coverage.*
61+
.cache
62+
nosetests.xml
63+
coverage.xml
64+
*.cover
65+
.hypothesis/
66+
.pytest_cache/
67+
68+
# Translations
69+
*.mo
70+
*.pot
71+
72+
# Django stuff:
73+
*.log
74+
local_settings.py
75+
db.sqlite3
76+
77+
# Flask stuff:
78+
instance/
79+
.webassets-cache
80+
81+
# Scrapy stuff:
82+
.scrapy
83+
84+
# Sphinx documentation
85+
docs/build/
86+
87+
# PyBuilder
88+
target/
89+
90+
# Jupyter Notebook
91+
.ipynb_checkpoints
92+
93+
# pyenv
94+
.python-version
95+
96+
# celery beat schedule file
97+
celerybeat-schedule
98+
99+
# SageMath parsed files
100+
*.sage.py
101+
102+
# Environments
103+
.env
104+
.venv
105+
env/
106+
venv/
107+
ENV/
108+
env.bak/
109+
venv.bak/
110+
111+
# Spyder project settings
112+
.spyderproject
113+
.spyproject
114+
115+
# Rope project settings
116+
.ropeproject
117+
118+
# mkdocs documentation
119+
/site
120+
121+
# mypy
122+
.mypy_cache/
123+
.mypy_cache*
124+
125+
*.isorted
126+
127+
################################
128+
########### VS CODE ############
129+
################################
130+
.vscode
131+
*.code-workspace
132+
.history
133+
134+
135+
################################
136+
########### molu ############
137+
################################
138+
.molu
139+
sample_audit_log/modsec_output

Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
FROM ubuntu:18.04
1+
FROM ubuntu:20.04
2+
23
LABEL maintainer "molu8bits@gmail.com"
34
LABEL description "modsecurity parse and charts via Docker"
4-
LABEL version "2020.09 v0.3"
5+
LABEL version "2023.03 v0.4"
56

67
ENV DEBIAN_FRONTEND=noninteractive
78

@@ -15,7 +16,7 @@ RUN apt-get update && apt-get install -y git && \
1516

1617
RUN pip3 install -r /opt/mparser/requirements.txt
1718

18-
COPY modsecurity-parser.py /opt/mparser/
19+
COPY modsecurity_parser.py /opt/mparser/
1920
COPY run.sh /opt/mparser/
2021

2122
RUN chmod +x /opt/mparser/run.sh

Makefile

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
MODULE := modsecurity_parser
2+
BLUE='\033[0;34m'
3+
RED='\033[0;31m'
4+
GREEN='\033[0;32m'
5+
YELLOW='\033[0;33m'
6+
BYELLOW='\033[1;33m'
7+
UYELLOW='\033[4;33m'
8+
OYELLOW='\033[43m'
9+
NC='\033[0m' # No color
10+
11+
run:
12+
@python -m $(MODULE)
13+
14+
integration-v2:
15+
@python -m ${MODULE} -f sample_audit_log/modsec_audit_v2.log -j out-v2.json -x out-v2.xlsx -g out-v2.png
16+
17+
integration-v3:
18+
@python -m ${MODULE} -f sample_audit_log/modsec_audit_v3.log -j out-v3.json -x out-v3.xlsx -g out-v3.png --version3
19+
20+
integration-v2-json:
21+
@python -m ${MODULE} -f sample_audit_log/modsec_audit_v2_json.log -j out-v2-json.json -x out-v2-json.xlsx -g out-v2-json.png --jsonaudit
22+
23+
integration-v2-timems:
24+
@python -m ${MODULE} -f sample_audit_log/modsec_audit_v2_timems.log -j out-v2-timems.json -x out-v2-timems.xlsx -g out-v2-timems.png
25+
26+
test-e2e:
27+
@echo "\n${BLUE}Running E2E tests on sample_audit_log folder ${NC}\n"
28+
@python -m ${MODULE} -f sample_audit_log/modsec_audit_v2.log -j out-v2.json -x out-v2.xlsx -g out-v2.png
29+
@python -m ${MODULE} -f sample_audit_log/modsec_audit_v3.log -j out-v3.json -x out-v3.xlsx -g out-v3.png --version3
30+
@python -m ${MODULE} -f sample_audit_log/modsec_audit_v2_json.log -j out-v2-json.json -x out-v2-json.xlsx -g out-v2-json.png --jsonaudit
31+
@python -m ${MODULE} -f sample_audit_log/modsec_audit_v2_utc_minus.log -j out-v2-utc-minus -x out-v2-utc-minus.xlsx -g out-v2-utc-minus.png
32+
@python -m ${MODULE} -f sample_audit_log/modsec_audit_v2_timems.log -j out-v2-timems.json -x out-v2-timems.xlsx -g out-v2-timems.png
33+
34+
test:
35+
@echo "\n${OYELLOW}Running Pylint against source and test files...${NC}\n"
36+
@pytest
37+
38+
lint:
39+
# test comments
40+
@echo "\n${BLUE}Running Pylint against source and test files...${NC}\n"
41+
# @pylint --rcfile=setup.cfg **/*.py *.py
42+
@pylint --rcfile=setup.cfg *.py
43+
@echo "\n${BLUE}Running PyDocStyle against source files...${NC}\n"
44+
@pydocstyle --config=setup.cfg modsecurity_parser.py
45+
@echo "\n${BLUE}Running Flake8 against source and test files...${NC}\n"
46+
@flake8
47+
@echo "\n${BLUE}Running Bandit against source files...${NC}\n"
48+
# @bandit -r --ini setup.cfg
49+
@bandit -r --ini setup.cfg
50+
@echo "\n${BLUE}Running pycodestyle against source files...${NC}\n"
51+
@pycodestyle modsecurity_parser.py
52+
@echo "\n${BLUE}Running Code Coverage against source files...${NC}\n"
53+
@pytest --cov=modsecurity_parser tests --cov-report=html
54+
55+
56+
clean:
57+
rm -rf .pytest_cache .coverage .pytest_cache coverage.xml sample_audit_log/modsec_output
58+
59+
.PHONY: clean test

0 commit comments

Comments
 (0)