Skip to content

Commit c26a9c2

Browse files
authored
Merge branch 'master' into apsw-with-sqlalchemy
Signed-off-by: Achintya Jai <[email protected]>
2 parents 8fca377 + 1ff4258 commit c26a9c2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+3116
-878
lines changed

.coderabbit.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
chat:
2+
auto_reply: true
3+
code_generation:
4+
docstrings:
5+
language: en-US
6+
early_access: true
7+
language: en-US
8+
reviews:
9+
assess_linked_issues: true
10+
auto_apply_labels: false
11+
auto_review:
12+
enabled: true
13+
drafts: true
14+
collapse_walkthrough: false
15+
high_level_summary: true
16+
high_level_summary_in_walkthrough: true
17+
labeling_instructions: []
18+
poem: false
19+
profile: chill
20+
request_changes_workflow: false
21+
review_status: true
22+
sequence_diagrams: false

.data/readme.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

.data/results/readme.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

.data/tmp/readme.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ Your PR description goes here.
2323
- [ ] Bugfix (non-breaking change which fixes an issue)
2424
- [ ] Code refactoring without any functionality changes
2525
- [ ] New or existing module/payload change
26-
- [ ] Localization improvement
26+
- [ ] Documentation/localization improvement
27+
- [ ] Test coverage improvement
2728
- [ ] Dependency upgrade
28-
- [ ] Documentation improvement
29+
- [ ] Other improvement (best practice, cleanup, optimization, etc)
2930

3031
## Checklist
3132

.github/workflows/ci_cd.yml

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
runs-on: ubuntu-24.04
2424
steps:
2525
- name: Check out repository
26-
uses: actions/checkout@v4
26+
uses: actions/checkout@v5
2727

2828
- name: Set up Python
2929
uses: actions/setup-python@v5
@@ -47,7 +47,7 @@ jobs:
4747
- python
4848
steps:
4949
- name: Check out repository
50-
uses: actions/checkout@v4
50+
uses: actions/checkout@v5
5151

5252
- name: Initialize CodeQL
5353
uses: github/codeql-action/init@v3
@@ -67,7 +67,7 @@ jobs:
6767
runs-on: ubuntu-24.04
6868
steps:
6969
- name: Check out repository
70-
uses: actions/checkout@v4
70+
uses: actions/checkout@v5
7171

7272
- name: Set up Python
7373
uses: actions/setup-python@v5
@@ -90,7 +90,7 @@ jobs:
9090
runs-on: ubuntu-24.04
9191
steps:
9292
- name: Check out repository
93-
uses: actions/checkout@v4
93+
uses: actions/checkout@v5
9494

9595
- name: Set up Python
9696
uses: actions/setup-python@v5
@@ -123,15 +123,15 @@ jobs:
123123
- ubuntu-24.04
124124
steps:
125125
- name: Check out repository
126-
uses: actions/checkout@v4
126+
uses: actions/checkout@v5
127127

128128
- name: Set up Python
129129
uses: actions/setup-python@v5
130130
with:
131131
python-version: '3.11'
132132

133133
- name: Get package artifacts
134-
uses: actions/download-artifact@v4
134+
uses: actions/download-artifact@v5
135135
with:
136136
name: dist
137137
path: dist
@@ -154,53 +154,49 @@ jobs:
154154
runs-on: ubuntu-24.04
155155
steps:
156156
- name: Check out repository
157-
uses: actions/checkout@v4
157+
uses: actions/checkout@v5
158158

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

162162
- name: Test help menu
163163
run: |
164-
docker run -e github_ci=true --rm nettacker \
165-
poetry run python nettacker.py --help
164+
docker run -e github_ci=true --rm nettacker --help
166165
167166
- name: Test help menu in Persian
168167
run: |
169-
docker run -e github_ci=true --rm nettacker \
170-
poetry run python nettacker.py --help -L fa
168+
docker run -e github_ci=true --rm nettacker --help -L fa
171169
172170
- name: Show all modules
173171
run: |
174-
docker run -e github_ci=true --rm nettacker \
175-
poetry run python nettacker.py --show-all-modules
172+
docker run -e github_ci=true --rm nettacker --show-all-modules
176173
177174
- name: Show all profiles
178175
run: |
179-
docker run -e github_ci=true --rm nettacker \
180-
poetry run python nettacker.py --show-all-profiles
176+
docker run -e github_ci=true --rm nettacker --show-all-profiles
181177
182178
- name: Test all modules command + check if it's finish successfully + csv
183179
run: |
184-
docker run -e github_ci=true --rm -i nettacker \
185-
poetry run python nettacker.py -i 127.0.0.1 -u user1,user2 -p pass1,pass2 -m all -g 21,25,80,443 \
180+
docker run -e github_ci=true --rm -i --add-host=host.docker.internal:host-gateway nettacker \
181+
-i host.docker.internal -u user1,user2 -p pass1,pass2 -m all -g 21,25,80,443 \
186182
-t 1000 -T 3 -o out.csv
187183
188184
- name: Test all modules command + check if it's finish successfully + csv
189185
run: |
190-
docker run -e github_ci=true --rm -i nettacker \
191-
poetry run python nettacker.py -i 127.0.0.1 -u user1,user2 -p pass1,pass2 -m all -g 21,25,80,443 \
186+
docker run -e github_ci=true --rm -i --add-host=host.docker.internal:host-gateway nettacker \
187+
-i host.docker.internal -u user1,user2 -p pass1,pass2 -m all -g 21,25,80,443 \
192188
-t 1000 -T 3 -o out.csv --skip-service-discovery
193189
194190
- name: Test all modules command + check if it's finish successfully + with graph + Persian
195191
run: |
196-
docker run -e github_ci=true --rm -i nettacker \
197-
poetry run python nettacker.py -i 127.0.0.1 -L fa -u user1,user2 -p pass1,pass2 --profile all \
192+
docker run -e github_ci=true --rm -i --add-host=host.docker.internal:host-gateway nettacker \
193+
-i host.docker.internal -L fa -u user1,user2 -p pass1,pass2 --profile all \
198194
-g 21,25,80,443 -t 1000 -T 3 --graph d3_tree_v2_graph -v
199195
200196
- name: Test all modules command + check if it's finish successfully + with graph + Persian
201197
run: |
202-
docker run -e github_ci=true --rm -i nettacker \
203-
poetry run python nettacker.py -i 127.0.0.1 -L fa -u user1,user2 -p pass1,pass2 --profile all \
198+
docker run -e github_ci=true --rm -i --add-host=host.docker.internal:host-gateway nettacker \
199+
-i host.docker.internal -L fa -u user1,user2 -p pass1,pass2 --profile all \
204200
-g 21,25,80,443 -t 1000 -T 3 --graph d3_tree_v2_graph -v --skip-service-discovery
205201
206202
test-docker-image-build:
@@ -235,17 +231,14 @@ jobs:
235231
sudo apt-get install docker-ce=5:${{ matrix.docker-version }} docker-ce-cli=5:${{ matrix.docker-version }}
236232
237233
- name: Check out repository
238-
uses: actions/checkout@v4
234+
uses: actions/checkout@v5
239235

240236
- name: Print Docker version
241237
run: docker -v
242238

243239
- name: Build Nettacker image
244240
run: docker build . -t nettacker
245241

246-
- name: Run pip install
247-
run: docker run nettacker pip install .
248-
249242
publish-nettacker-dev-to-docker-registry:
250243
name: Publish nettacker:dev Docker image
251244
if: |
@@ -258,7 +251,7 @@ jobs:
258251
runs-on: ubuntu-24.04
259252
steps:
260253
- name: Check out repository
261-
uses: actions/checkout@v4
254+
uses: actions/checkout@v5
262255

263256
- name: Login to Docker Hub
264257
uses: docker/login-action@v3
@@ -289,7 +282,7 @@ jobs:
289282
runs-on: ubuntu-24.04
290283
steps:
291284
- name: Check out repository
292-
uses: actions/checkout@v4
285+
uses: actions/checkout@v5
293286

294287
- name: Set up QEMU
295288
uses: docker/setup-qemu-action@v3
@@ -326,7 +319,7 @@ jobs:
326319
runs-on: ubuntu-24.04
327320
steps:
328321
- name: Get package artifacts
329-
uses: actions/download-artifact@v4
322+
uses: actions/download-artifact@v5
330323
with:
331324
name: dist
332325
path: dist
@@ -352,7 +345,7 @@ jobs:
352345
runs-on: ubuntu-24.04
353346
steps:
354347
- name: Get package artifacts
355-
uses: actions/download-artifact@v4
348+
uses: actions/download-artifact@v5
356349
with:
357350
name: dist
358351
path: dist

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ logs.txt
1919
*.log
2020
results.*
2121
.owasp-nettacker*
22-
.data*
22+
.nettacker/data*
2323
*.DS_Store
2424
*.swp
2525

Dockerfile

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
FROM python:3.11.11-slim
2-
1+
### Multi-stage Dockerfile
2+
# Define the base image only once as a build argument
3+
ARG PYTHON_IMAGE=python:3.11.13-slim
4+
5+
### Build stage
6+
FROM ${PYTHON_IMAGE} AS builder
7+
### Install OS dependencies and poetry package manager
38
RUN apt-get update && \
49
apt-get install -y gcc libssl-dev && \
510
apt-get clean && \
@@ -8,11 +13,41 @@ RUN apt-get update && \
813

914
WORKDIR /usr/src/owaspnettacker
1015

16+
# Copy dependency files first to maximize Docker cache usage for installing dependencies
17+
COPY poetry.lock pyproject.toml ./
18+
19+
# Install dependencies
20+
RUN poetry config virtualenvs.in-project true && \
21+
poetry install --no-cache --no-root --without dev --without test
22+
23+
# Now copy the rest of the required source code
1124
COPY nettacker nettacker
12-
COPY nettacker.py poetry.lock pyproject.toml README.md ./
25+
COPY nettacker.py README.md ./
1326

14-
RUN poetry install --no-cache --no-root --without dev --without test
27+
# Build the project only after all code is present
28+
RUN poetry build
1529

16-
ENV docker_env=true
30+
### Runtime stage - start from a clean Python image
31+
FROM ${PYTHON_IMAGE} AS runtime
32+
WORKDIR /usr/src/owaspnettacker
33+
34+
# OCI Labels (attach to final image)
35+
LABEL org.opencontainers.image.title="OWASP Nettacker" \
36+
org.opencontainers.image.description="Automated Penetration Testing Framework" \
37+
org.opencontainers.image.url="https://owasp.org/nettacker" \
38+
org.opencontainers.image.source="https://github.com/OWASP/Nettacker" \
39+
org.opencontainers.image.licenses="Apache-2.0"
40+
41+
### Bring from 'builder' just the virtualenv and the packaged Nettacker as a wheel
42+
COPY --from=builder /usr/src/owaspnettacker/.venv ./.venv
43+
COPY --from=builder /usr/src/owaspnettacker/dist/*.whl .
1744

18-
CMD [ "poetry", "run", "python", "./nettacker.py" ]
45+
ENV PATH=/usr/src/owaspnettacker/.venv/bin:$PATH
46+
### Use pip inside the venv to install just the nettacker wheel saving 50%+ space
47+
RUN pip install --no-deps --no-cache-dir nettacker-*.whl && \
48+
rm -f nettacker-*.whl
49+
50+
### We now have Nettacker installed in the virtualenv with 'nettacker' command which is the new entrypoint
51+
ENV docker_env=true
52+
ENTRYPOINT [ "nettacker" ]
53+
CMD ["--help"]

0 commit comments

Comments
 (0)