Skip to content

Commit

Permalink
Merge pull request #863 from arkid15r/code-base-refactoring
Browse files Browse the repository at this point in the history
Nettacker code base major refactoring
  • Loading branch information
securestep9 authored Aug 24, 2024
2 parents 6baee0f + 44bd2ab commit 477d520
Show file tree
Hide file tree
Showing 802 changed files with 7,203 additions and 5,561 deletions.
51 changes: 0 additions & 51 deletions .github/workflows/CI.yml

This file was deleted.

179 changes: 179 additions & 0 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
name: CI/CD
on: [push, pull_request]

jobs:
run-pytest:
name: Run pytest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m pip install --upgrade poetry
poetry install --with test
- name: Run tests
run: |
poetry run pytest
build-package:
name: Build package
needs: run-pytest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade poetry
poetry install
- name: Build package
run: |
poetry build --no-interaction
- name: Upload package artifacts
uses: actions/upload-artifact@v3
with:
name: dist
path: dist

publish-to-test-pypi:
name: Publish to Test PyPI

if: |
${{
github.repository == 'owasp/nettacker' &&
github.event_name == 'push' &&
github.ref_name == 'implement-package-publishing-poc' }}
# environment: test
needs:
- build-package
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
steps:
- name: Get package artifacts
uses: actions/download-artifact@v3
with:
name: dist
path: dist

- name: Publish package distributions to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/

publish-to-pypi:
name: Publish to PyPI
if: |
${{ github.repository == 'owasp/nettacker' &&
github.event_name == 'push' &&
github.ref_name == 'implement-package-publishing-poc' }}
# environment: release
needs:
- build-package
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
steps:
- name: Get package artifacts
uses: actions/download-artifact@v3
with:
name: dist
path: dist

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

test-docker-image:
name: Test Docker image
# needs: publish-to-pypi
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/[email protected]

- name: Build Docker image
run: docker build . -t nettacker

- name: Test help menu
run: |
docker run -e github_ci=true --rm nettacker \
poetry run python nettacker.py --help
- name: Test help menu in Persian
run: |
docker run -e github_ci=true --rm nettacker \
poetry run python nettacker.py --help -L fa
- name: Show all modules
run: |
docker run -e github_ci=true --rm nettacker \
poetry run python nettacker.py --show-all-modules
- name: Show all profiles
run: |
docker run -e github_ci=true --rm nettacker \
poetry run python nettacker.py --show-all-profiles
- name: Test all modules command + check if it's finish successfully + csv
run: |
docker run -e github_ci=true --rm -i nettacker \
poetry run python nettacker.py -i 127.0.0.1 -u user1,user2 -p pass1,pass2 -m all -g 21,25,80,443 \
-t 1000 -T 3 -o out.csv
- name: Test all modules command + check if it's finish successfully + csv
run: |
docker run -e github_ci=true --rm -i nettacker \
poetry run python nettacker.py -i 127.0.0.1 -u user1,user2 -p pass1,pass2 -m all -g 21,25,80,443 \
-t 1000 -T 3 -o out.csv --skip-service-discovery
- name: Test all modules command + check if it's finish successfully + with graph + Persian
run: |
docker run -e github_ci=true --rm -i nettacker \
poetry run python nettacker.py -i 127.0.0.1 -L fa -u user1,user2 -p pass1,pass2 --profile all \
-g 21,25,80,443 -t 1000 -T 3 --graph d3_tree_v2_graph -v
- name: Test all modules command + check if it's finish successfully + with graph + Persian
run: |
docker run -e github_ci=true --rm -i nettacker \
poetry run python nettacker.py -i 127.0.0.1 -L fa -u user1,user2 -p pass1,pass2 --profile all \
-g 21,25,80,443 -t 1000 -T 3 --graph d3_tree_v2_graph -v --skip-service-discovery
publish-to-docker-registry:
name: Publish Docker image
needs:
- test-docker-image
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
push: true
tags: owasp/nettacker:dev
File renamed without changes.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
*.code-workspace

#setup
build/*
dist/*
build
dist
*egg-info*

#tmp files
Expand All @@ -27,4 +27,4 @@ results.*
.coverage
coverage.xml

venv/*
venv
26 changes: 26 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-ast
- id: check-builtin-literals
- id: check-yaml
- id: fix-encoding-pragma
args:
- --remove
- id: mixed-line-ending
args:
- --fix=lf

- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.13
hooks:
- id: ruff
args:
- --fix
- id: ruff-format
9 changes: 4 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ WORKDIR /usr/src/owaspnettacker
COPY . .
RUN mkdir -p .data/results
RUN apt-get update
RUN apt-get install -y $(cat requirements-apt-get.txt)
RUN pip3 install --upgrade pip
RUN pip3 install -r requirements.txt
RUN pip3 install -r requirements-dev.txt
RUN apt-get install -y gcc libssl-dev
RUN pip3 install --upgrade poetry
RUN python -m poetry install
ENV docker_env=true
CMD [ "python3", "./nettacker.py" ]
CMD [ "poetry", "run", "python", "./nettacker.py" ]
3 changes: 0 additions & 3 deletions api/__init__.py

This file was deleted.

Loading

0 comments on commit 477d520

Please sign in to comment.