Skip to content

Commit

Permalink
feat: structure-change
Browse files Browse the repository at this point in the history
  • Loading branch information
molu8bits committed Mar 5, 2023
1 parent d46990b commit 813cbd9
Show file tree
Hide file tree
Showing 16 changed files with 1,344 additions and 834 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/docker-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Publish Docker Images
on:
release:
types: [published]
jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Push to Docker Hub
uses: docker/build-push-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: molu8bits/modsecurity-parser
tags: latest
tag_with_ref: true
139 changes: 139 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
################################
########### FILES ############
################################
*.exe

################################
########### FOLDERS ############
################################
build/
html/
.benchmarks/
reports/
lectures/

################################
########### PYTHON #############
################################

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.mypy_cache*

*.isorted

################################
########### VS CODE ############
################################
.vscode
*.code-workspace
.history


################################
########### molu ############
################################
.molu
sample_audit_log/modsec_output
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
FROM ubuntu:18.04
FROM ubuntu:20.04

LABEL maintainer "[email protected]"
LABEL description "modsecurity parse and charts via Docker"
LABEL version "2020.09 v0.3"
LABEL version "2023.03 v0.4"

ENV DEBIAN_FRONTEND=noninteractive

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

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

COPY modsecurity-parser.py /opt/mparser/
COPY modsecurity_parser.py /opt/mparser/
COPY run.sh /opt/mparser/

RUN chmod +x /opt/mparser/run.sh
Expand Down
59 changes: 59 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
MODULE := modsecurity_parser
BLUE='\033[0;34m'
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BYELLOW='\033[1;33m'
UYELLOW='\033[4;33m'
OYELLOW='\033[43m'
NC='\033[0m' # No color

run:
@python -m $(MODULE)

integration-v2:
@python -m ${MODULE} -f sample_audit_log/modsec_audit_v2.log -j out-v2.json -x out-v2.xlsx -g out-v2.png

integration-v3:
@python -m ${MODULE} -f sample_audit_log/modsec_audit_v3.log -j out-v3.json -x out-v3.xlsx -g out-v3.png --version3

integration-v2-json:
@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

integration-v2-timems:
@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

test-e2e:
@echo "\n${BLUE}Running E2E tests on sample_audit_log folder ${NC}\n"
@python -m ${MODULE} -f sample_audit_log/modsec_audit_v2.log -j out-v2.json -x out-v2.xlsx -g out-v2.png
@python -m ${MODULE} -f sample_audit_log/modsec_audit_v3.log -j out-v3.json -x out-v3.xlsx -g out-v3.png --version3
@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
@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
@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

test:
@echo "\n${OYELLOW}Running Pylint against source and test files...${NC}\n"
@pytest

lint:
# test comments
@echo "\n${BLUE}Running Pylint against source and test files...${NC}\n"
# @pylint --rcfile=setup.cfg **/*.py *.py
@pylint --rcfile=setup.cfg *.py
@echo "\n${BLUE}Running PyDocStyle against source files...${NC}\n"
@pydocstyle --config=setup.cfg modsecurity_parser.py
@echo "\n${BLUE}Running Flake8 against source and test files...${NC}\n"
@flake8
@echo "\n${BLUE}Running Bandit against source files...${NC}\n"
# @bandit -r --ini setup.cfg
@bandit -r --ini setup.cfg
@echo "\n${BLUE}Running pycodestyle against source files...${NC}\n"
@pycodestyle modsecurity_parser.py
@echo "\n${BLUE}Running Code Coverage against source files...${NC}\n"
@pytest --cov=modsecurity_parser tests --cov-report=html


clean:
rm -rf .pytest_cache .coverage .pytest_cache coverage.xml sample_audit_log/modsec_output

.PHONY: clean test
Loading

0 comments on commit 813cbd9

Please sign in to comment.