pentrep 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pentrep-0.1.0/.dockerignore +21 -0
- pentrep-0.1.0/.github/workflows/ci.yml +120 -0
- pentrep-0.1.0/.github/workflows/docker.yml +71 -0
- pentrep-0.1.0/.github/workflows/pages.yml +76 -0
- pentrep-0.1.0/.github/workflows/release.yml +131 -0
- pentrep-0.1.0/.gitignore +33 -0
- pentrep-0.1.0/.pre-commit-config.yaml +31 -0
- pentrep-0.1.0/CHANGELOG.md +57 -0
- pentrep-0.1.0/CLAUDE.md +70 -0
- pentrep-0.1.0/Dockerfile +29 -0
- pentrep-0.1.0/LICENSE +21 -0
- pentrep-0.1.0/PKG-INFO +142 -0
- pentrep-0.1.0/README.md +110 -0
- pentrep-0.1.0/docs/PLAN.md +406 -0
- pentrep-0.1.0/docs/PRD.md +738 -0
- pentrep-0.1.0/docs/errors.md +301 -0
- pentrep-0.1.0/docs/img/cover.png +0 -0
- pentrep-0.1.0/docs/img/finding.png +0 -0
- pentrep-0.1.0/docs/schema.md +107 -0
- pentrep-0.1.0/docs/templates.md +130 -0
- pentrep-0.1.0/examples/assets/logo.png +0 -0
- pentrep-0.1.0/examples/evidence/pt-001-sqlmap.png +0 -0
- pentrep-0.1.0/examples/findings.yaml +119 -0
- pentrep-0.1.0/pyproject.toml +101 -0
- pentrep-0.1.0/src/pentrep/__init__.py +3 -0
- pentrep-0.1.0/src/pentrep/__main__.py +6 -0
- pentrep-0.1.0/src/pentrep/cli.py +353 -0
- pentrep-0.1.0/src/pentrep/cvss.py +313 -0
- pentrep-0.1.0/src/pentrep/diagnostics.py +142 -0
- pentrep-0.1.0/src/pentrep/loader.py +532 -0
- pentrep-0.1.0/src/pentrep/models.py +358 -0
- pentrep-0.1.0/src/pentrep/redact.py +320 -0
- pentrep-0.1.0/src/pentrep/render/__init__.py +54 -0
- pentrep-0.1.0/src/pentrep/render/context.py +200 -0
- pentrep-0.1.0/src/pentrep/render/highlight.py +62 -0
- pentrep-0.1.0/src/pentrep/render/html.py +34 -0
- pentrep-0.1.0/src/pentrep/render/markdown.py +58 -0
- pentrep-0.1.0/src/pentrep/render/md.py +172 -0
- pentrep-0.1.0/src/pentrep/render/pdf.py +116 -0
- pentrep-0.1.0/src/pentrep/scaffold/assets/logo.png +0 -0
- pentrep-0.1.0/src/pentrep/scaffold/evidence/pt-001-sqlmap.png +0 -0
- pentrep-0.1.0/src/pentrep/scaffold/findings.yaml +119 -0
- pentrep-0.1.0/src/pentrep/stats.py +70 -0
- pentrep-0.1.0/src/pentrep/themes/classic/fonts/OFL.txt +104 -0
- pentrep-0.1.0/src/pentrep/themes/classic/fonts/SourceCodePro-Regular.ttf +0 -0
- pentrep-0.1.0/src/pentrep/themes/classic/fonts/SourceSans3-Bold.ttf +0 -0
- pentrep-0.1.0/src/pentrep/themes/classic/fonts/SourceSans3-It.ttf +0 -0
- pentrep-0.1.0/src/pentrep/themes/classic/fonts/SourceSans3-Regular.ttf +0 -0
- pentrep-0.1.0/src/pentrep/themes/classic/fonts.css +7 -0
- pentrep-0.1.0/src/pentrep/themes/classic/partials/appendix.html.j2 +38 -0
- pentrep-0.1.0/src/pentrep/themes/classic/partials/cover.html.j2 +17 -0
- pentrep-0.1.0/src/pentrep/themes/classic/partials/document_control.html.j2 +22 -0
- pentrep-0.1.0/src/pentrep/themes/classic/partials/executive_summary.html.j2 +17 -0
- pentrep-0.1.0/src/pentrep/themes/classic/partials/finding.html.j2 +56 -0
- pentrep-0.1.0/src/pentrep/themes/classic/partials/macros.html.j2 +7 -0
- pentrep-0.1.0/src/pentrep/themes/classic/partials/scope.html.j2 +27 -0
- pentrep-0.1.0/src/pentrep/themes/classic/partials/summary_table.html.j2 +13 -0
- pentrep-0.1.0/src/pentrep/themes/classic/partials/toc.html.j2 +19 -0
- pentrep-0.1.0/src/pentrep/themes/classic/report.html.j2 +35 -0
- pentrep-0.1.0/src/pentrep/themes/classic/report.md.j2 +187 -0
- pentrep-0.1.0/src/pentrep/themes/classic/style.css +97 -0
- pentrep-0.1.0/tests/cli/test_build.py +230 -0
- pentrep-0.1.0/tests/cli/test_cli.py +68 -0
- pentrep-0.1.0/tests/cli/test_errors.py +117 -0
- pentrep-0.1.0/tests/cli/test_init.py +101 -0
- pentrep-0.1.0/tests/cli/test_schema.py +100 -0
- pentrep-0.1.0/tests/cli/test_validate.py +164 -0
- pentrep-0.1.0/tests/conftest.py +148 -0
- pentrep-0.1.0/tests/fixtures/cvss_vectors.json +202 -0
- pentrep-0.1.0/tests/fixtures/invalid/e100_syntax_error.expected.txt +3 -0
- pentrep-0.1.0/tests/fixtures/invalid/e100_syntax_error.yaml +33 -0
- pentrep-0.1.0/tests/fixtures/invalid/e101_unknown_field.expected.txt +4 -0
- pentrep-0.1.0/tests/fixtures/invalid/e101_unknown_field.yaml +33 -0
- pentrep-0.1.0/tests/fixtures/invalid/e102_missing_field.expected.txt +2 -0
- pentrep-0.1.0/tests/fixtures/invalid/e102_missing_field.yaml +32 -0
- pentrep-0.1.0/tests/fixtures/invalid/e103_evidence_field.expected.txt +3 -0
- pentrep-0.1.0/tests/fixtures/invalid/e103_evidence_field.yaml +32 -0
- pentrep-0.1.0/tests/fixtures/invalid/e103_wrong_type.expected.txt +2 -0
- pentrep-0.1.0/tests/fixtures/invalid/e103_wrong_type.yaml +33 -0
- pentrep-0.1.0/tests/fixtures/invalid/e104_duplicate_id.expected.txt +3 -0
- pentrep-0.1.0/tests/fixtures/invalid/e104_duplicate_id.yaml +49 -0
- pentrep-0.1.0/tests/fixtures/invalid/e105_end_before_start.expected.txt +2 -0
- pentrep-0.1.0/tests/fixtures/invalid/e105_end_before_start.yaml +33 -0
- pentrep-0.1.0/tests/fixtures/invalid/e106_schema_version.expected.txt +2 -0
- pentrep-0.1.0/tests/fixtures/invalid/e106_schema_version.yaml +33 -0
- pentrep-0.1.0/tests/fixtures/invalid/e201_cvss_3_0_prefix.expected.txt +3 -0
- pentrep-0.1.0/tests/fixtures/invalid/e201_cvss_3_0_prefix.yaml +33 -0
- pentrep-0.1.0/tests/fixtures/invalid/e202_unknown_metric.expected.txt +3 -0
- pentrep-0.1.0/tests/fixtures/invalid/e202_unknown_metric.yaml +33 -0
- pentrep-0.1.0/tests/fixtures/invalid/e203_invalid_value.expected.txt +3 -0
- pentrep-0.1.0/tests/fixtures/invalid/e203_invalid_value.yaml +33 -0
- pentrep-0.1.0/tests/fixtures/invalid/e204_missing_metric.expected.txt +3 -0
- pentrep-0.1.0/tests/fixtures/invalid/e204_missing_metric.yaml +33 -0
- pentrep-0.1.0/tests/fixtures/invalid/e205_duplicate_metric.expected.txt +3 -0
- pentrep-0.1.0/tests/fixtures/invalid/e205_duplicate_metric.yaml +33 -0
- pentrep-0.1.0/tests/fixtures/invalid/e206_vector_and_severity.expected.txt +3 -0
- pentrep-0.1.0/tests/fixtures/invalid/e206_vector_and_severity.yaml +34 -0
- pentrep-0.1.0/tests/fixtures/invalid/e301_file_not_found.expected.txt +2 -0
- pentrep-0.1.0/tests/fixtures/invalid/e301_file_not_found.yaml +31 -0
- pentrep-0.1.0/tests/fixtures/invalid/e302_path_traversal.expected.txt +2 -0
- pentrep-0.1.0/tests/fixtures/invalid/e302_path_traversal.yaml +31 -0
- pentrep-0.1.0/tests/fixtures/invalid/e303_unsupported_type.expected.txt +2 -0
- pentrep-0.1.0/tests/fixtures/invalid/e303_unsupported_type.yaml +31 -0
- pentrep-0.1.0/tests/fixtures/invalid/e304_bad_name.expected.txt +5 -0
- pentrep-0.1.0/tests/fixtures/invalid/e304_bad_name.yaml +40 -0
- pentrep-0.1.0/tests/fixtures/invalid/e304_bad_regex.expected.txt +3 -0
- pentrep-0.1.0/tests/fixtures/invalid/e304_bad_regex.yaml +38 -0
- pentrep-0.1.0/tests/fixtures/invalid/evidence/not-an-image.png +1 -0
- pentrep-0.1.0/tests/fixtures/invalid/evidence/shot.png +0 -0
- pentrep-0.1.0/tests/fixtures/invalid/w101_placeholder.expected.txt +3 -0
- pentrep-0.1.0/tests/fixtures/invalid/w101_placeholder.yaml +33 -0
- pentrep-0.1.0/tests/fixtures/invalid/w102_no_evidence.expected.txt +2 -0
- pentrep-0.1.0/tests/fixtures/invalid/w102_no_evidence.yaml +27 -0
- pentrep-0.1.0/tests/fixtures/invalid/w201_temporal_metrics.expected.txt +3 -0
- pentrep-0.1.0/tests/fixtures/invalid/w201_temporal_metrics.yaml +33 -0
- pentrep-0.1.0/tests/fixtures/redaction/aws_key.json +32 -0
- pentrep-0.1.0/tests/fixtures/redaction/bearer.json +31 -0
- pentrep-0.1.0/tests/fixtures/redaction/card.json +32 -0
- pentrep-0.1.0/tests/fixtures/redaction/cookie.json +31 -0
- pentrep-0.1.0/tests/fixtures/redaction/email.json +31 -0
- pentrep-0.1.0/tests/fixtures/redaction/jwt.json +31 -0
- pentrep-0.1.0/tests/fixtures/redaction/private_ip.json +32 -0
- pentrep-0.1.0/tests/fixtures/redaction/private_key.json +32 -0
- pentrep-0.1.0/tests/fixtures/redaction/secret.json +45 -0
- pentrep-0.1.0/tests/fixtures/templates/partials/cover.html.j2 +5 -0
- pentrep-0.1.0/tests/fixtures/valid/assets/logo.png +0 -0
- pentrep-0.1.0/tests/fixtures/valid/evidence/pt-001-sqlmap.png +0 -0
- pentrep-0.1.0/tests/fixtures/valid/full.yaml +119 -0
- pentrep-0.1.0/tests/fixtures/valid/leaky.yaml +81 -0
- pentrep-0.1.0/tests/fixtures/valid/minimal.yaml +34 -0
- pentrep-0.1.0/tests/golden/report.html +356 -0
- pentrep-0.1.0/tests/golden/report.md +209 -0
- pentrep-0.1.0/tests/perf/conftest.py +115 -0
- pentrep-0.1.0/tests/perf/test_benchmarks.py +104 -0
- pentrep-0.1.0/tests/render/test_context.py +139 -0
- pentrep-0.1.0/tests/render/test_env.py +59 -0
- pentrep-0.1.0/tests/render/test_golden.py +57 -0
- pentrep-0.1.0/tests/render/test_highlight.py +50 -0
- pentrep-0.1.0/tests/render/test_html.py +114 -0
- pentrep-0.1.0/tests/render/test_markdown_helper.py +89 -0
- pentrep-0.1.0/tests/render/test_md.py +205 -0
- pentrep-0.1.0/tests/render/test_override.py +60 -0
- pentrep-0.1.0/tests/render/test_parity.py +75 -0
- pentrep-0.1.0/tests/render/test_pdf.py +207 -0
- pentrep-0.1.0/tests/render/test_theme.py +255 -0
- pentrep-0.1.0/tests/security/test_hardening.py +325 -0
- pentrep-0.1.0/tests/security/test_leaks.py +109 -0
- pentrep-0.1.0/tests/unit/test_cvss.py +379 -0
- pentrep-0.1.0/tests/unit/test_cvss_properties.py +79 -0
- pentrep-0.1.0/tests/unit/test_diagnostics.py +128 -0
- pentrep-0.1.0/tests/unit/test_docs.py +91 -0
- pentrep-0.1.0/tests/unit/test_fixtures.py +69 -0
- pentrep-0.1.0/tests/unit/test_loader.py +497 -0
- pentrep-0.1.0/tests/unit/test_models.py +515 -0
- pentrep-0.1.0/tests/unit/test_package_size.py +67 -0
- pentrep-0.1.0/tests/unit/test_pdf_policy.py +17 -0
- pentrep-0.1.0/tests/unit/test_redact.py +408 -0
- pentrep-0.1.0/tests/unit/test_redact_example.py +70 -0
- pentrep-0.1.0/tests/unit/test_redact_patterns.py +66 -0
- pentrep-0.1.0/tests/unit/test_stats.py +126 -0
- pentrep-0.1.0/uv.lock +1924 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Only pyproject.toml, uv.lock, README.md, LICENSE and src/ are needed to build the image.
|
|
2
|
+
.git
|
|
3
|
+
.github
|
|
4
|
+
.venv
|
|
5
|
+
.mypy_cache
|
|
6
|
+
.pytest_cache
|
|
7
|
+
.ruff_cache
|
|
8
|
+
.hypothesis
|
|
9
|
+
**/__pycache__
|
|
10
|
+
*.py[cod]
|
|
11
|
+
.coverage*
|
|
12
|
+
htmlcov
|
|
13
|
+
dist
|
|
14
|
+
build
|
|
15
|
+
tmp
|
|
16
|
+
report
|
|
17
|
+
output
|
|
18
|
+
.env*
|
|
19
|
+
tests
|
|
20
|
+
docs
|
|
21
|
+
examples
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
concurrency:
|
|
13
|
+
group: ci-${{ github.ref }}
|
|
14
|
+
cancel-in-progress: true
|
|
15
|
+
|
|
16
|
+
env:
|
|
17
|
+
UV_FROZEN: "1"
|
|
18
|
+
|
|
19
|
+
jobs:
|
|
20
|
+
lint:
|
|
21
|
+
name: Lint & type-check
|
|
22
|
+
runs-on: ubuntu-24.04
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@v7
|
|
25
|
+
- uses: astral-sh/setup-uv@v7
|
|
26
|
+
with:
|
|
27
|
+
python-version: "3.12"
|
|
28
|
+
enable-cache: true
|
|
29
|
+
- run: uv sync --locked
|
|
30
|
+
- name: ruff check
|
|
31
|
+
run: uv run ruff check --output-format=github .
|
|
32
|
+
- name: ruff format
|
|
33
|
+
run: uv run ruff format --check .
|
|
34
|
+
- name: mypy (strict)
|
|
35
|
+
run: uv run mypy
|
|
36
|
+
|
|
37
|
+
test:
|
|
38
|
+
name: Tests (py${{ matrix.python }}, ${{ matrix.os }})
|
|
39
|
+
runs-on: ${{ matrix.os }}
|
|
40
|
+
strategy:
|
|
41
|
+
fail-fast: false
|
|
42
|
+
matrix:
|
|
43
|
+
os: [ubuntu-22.04, ubuntu-24.04, macos-latest]
|
|
44
|
+
python: ["3.11", "3.12", "3.13", "3.14"]
|
|
45
|
+
steps:
|
|
46
|
+
- uses: actions/checkout@v7
|
|
47
|
+
# WeasyPrint system libraries for the pdf tests (required in CI, see PENTREP_REQUIRE_PDF).
|
|
48
|
+
- name: Install Pango (Linux)
|
|
49
|
+
if: runner.os == 'Linux'
|
|
50
|
+
run: |
|
|
51
|
+
sudo apt-get update
|
|
52
|
+
# libharfbuzz-subset0 exists from Ubuntu 24.04; on 22.04 subsetting ships in libharfbuzz0b.
|
|
53
|
+
extra=""
|
|
54
|
+
if apt-cache show libharfbuzz-subset0 >/dev/null 2>&1; then extra="libharfbuzz-subset0"; fi
|
|
55
|
+
sudo apt-get install -y --no-install-recommends libpango-1.0-0 libpangoft2-1.0-0 libharfbuzz0b $extra
|
|
56
|
+
- name: Install Pango (macOS)
|
|
57
|
+
if: runner.os == 'macOS'
|
|
58
|
+
run: brew install pango
|
|
59
|
+
- uses: astral-sh/setup-uv@v7
|
|
60
|
+
with:
|
|
61
|
+
python-version: ${{ matrix.python }}
|
|
62
|
+
enable-cache: true
|
|
63
|
+
- run: uv sync --locked
|
|
64
|
+
- name: pytest (with coverage gate)
|
|
65
|
+
# Benchmarks run in the "perf" job, so timing noise cannot make this matrix flaky.
|
|
66
|
+
run: uv run pytest -m "not perf" --cov --cov-report=term-missing
|
|
67
|
+
env:
|
|
68
|
+
# A missing WeasyPrint library must fail CI, not silently skip the pdf tests (M6.7).
|
|
69
|
+
PENTREP_REQUIRE_PDF: "1"
|
|
70
|
+
# cffi does not search Homebrew's lib directory on Apple Silicon by default.
|
|
71
|
+
DYLD_FALLBACK_LIBRARY_PATH: ${{ runner.os == 'macOS' && '/opt/homebrew/lib' || '' }}
|
|
72
|
+
|
|
73
|
+
perf:
|
|
74
|
+
name: Performance (NFR-01..04)
|
|
75
|
+
runs-on: ubuntu-latest
|
|
76
|
+
steps:
|
|
77
|
+
- uses: actions/checkout@v7
|
|
78
|
+
- name: Install Pango
|
|
79
|
+
run: |
|
|
80
|
+
sudo apt-get update
|
|
81
|
+
sudo apt-get install -y --no-install-recommends libpango-1.0-0 libpangoft2-1.0-0 libharfbuzz0b libharfbuzz-subset0
|
|
82
|
+
- uses: astral-sh/setup-uv@v7
|
|
83
|
+
with:
|
|
84
|
+
python-version: "3.12"
|
|
85
|
+
enable-cache: true
|
|
86
|
+
- run: uv sync --locked
|
|
87
|
+
- name: pytest -m perf
|
|
88
|
+
run: uv run pytest -m perf -v --durations=0
|
|
89
|
+
env:
|
|
90
|
+
PENTREP_REQUIRE_PDF: "1"
|
|
91
|
+
|
|
92
|
+
package:
|
|
93
|
+
name: Packaging smoke (wheel in a fresh venv)
|
|
94
|
+
runs-on: ubuntu-latest
|
|
95
|
+
steps:
|
|
96
|
+
- uses: actions/checkout@v7
|
|
97
|
+
- name: Install Pango
|
|
98
|
+
run: |
|
|
99
|
+
sudo apt-get update
|
|
100
|
+
sudo apt-get install -y --no-install-recommends libpango-1.0-0 libpangoft2-1.0-0 libharfbuzz0b libharfbuzz-subset0
|
|
101
|
+
- uses: astral-sh/setup-uv@v7
|
|
102
|
+
with:
|
|
103
|
+
python-version: "3.12"
|
|
104
|
+
- name: Build the wheel (at most 2 MB, NFR-12)
|
|
105
|
+
run: |
|
|
106
|
+
uv build --wheel --out-dir dist
|
|
107
|
+
size=$(stat -c %s dist/*.whl)
|
|
108
|
+
echo "wheel size: $size bytes"
|
|
109
|
+
test "$size" -le $((2 * 1024 * 1024))
|
|
110
|
+
- name: Install into a fresh venv and build a report
|
|
111
|
+
run: |
|
|
112
|
+
work=$(mktemp -d)
|
|
113
|
+
python -m venv "$work/venv"
|
|
114
|
+
"$work/venv/bin/python" -m pip install --quiet dist/*.whl
|
|
115
|
+
cd "$work"
|
|
116
|
+
"$work/venv/bin/pentrep" --version
|
|
117
|
+
"$work/venv/bin/pentrep" init project
|
|
118
|
+
"$work/venv/bin/pentrep" build project/findings.yaml -f all -o out
|
|
119
|
+
for ext in html md pdf; do test -s "out/pentest-report.$ext"; done
|
|
120
|
+
ls -l out
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
name: Docker
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
tags: ["v*"]
|
|
7
|
+
pull_request:
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read
|
|
12
|
+
|
|
13
|
+
concurrency:
|
|
14
|
+
group: docker-${{ github.ref }}
|
|
15
|
+
cancel-in-progress: true
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
image:
|
|
19
|
+
name: Build, check and publish the image
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
permissions:
|
|
22
|
+
contents: read
|
|
23
|
+
packages: write # push to ghcr.io on tags only
|
|
24
|
+
env:
|
|
25
|
+
LOCAL_TAG: pentrep:ci
|
|
26
|
+
steps:
|
|
27
|
+
- uses: actions/checkout@v7
|
|
28
|
+
|
|
29
|
+
- name: Build
|
|
30
|
+
run: docker build --pull -t "$LOCAL_TAG" .
|
|
31
|
+
|
|
32
|
+
- name: Image is at most 400 MB uncompressed (FR-61)
|
|
33
|
+
run: |
|
|
34
|
+
size=$(docker image inspect --format '{{.Size}}' "$LOCAL_TAG")
|
|
35
|
+
echo "image size: $((size / 1024 / 1024)) MB"
|
|
36
|
+
test "$size" -le $((400 * 1024 * 1024))
|
|
37
|
+
|
|
38
|
+
- name: Runs as a non-root user in /work
|
|
39
|
+
run: |
|
|
40
|
+
test "$(docker run --rm --entrypoint id "$LOCAL_TAG" -u)" != "0"
|
|
41
|
+
test "$(docker run --rm --entrypoint pwd "$LOCAL_TAG")" = "/work"
|
|
42
|
+
|
|
43
|
+
- name: Smoke test (init + build writes HTML, Markdown and PDF)
|
|
44
|
+
run: |
|
|
45
|
+
mkdir smoke
|
|
46
|
+
docker run --rm --user "$(id -u):$(id -g)" -v "$PWD/smoke:/work" "$LOCAL_TAG" init
|
|
47
|
+
docker run --rm --user "$(id -u):$(id -g)" -v "$PWD/smoke:/work" "$LOCAL_TAG" build findings.yaml
|
|
48
|
+
for ext in html md pdf; do test -s "smoke/report/pentest-report.$ext"; done
|
|
49
|
+
ls -l smoke/report
|
|
50
|
+
|
|
51
|
+
- name: Push to GHCR (tags only)
|
|
52
|
+
if: startsWith(github.ref, 'refs/tags/v')
|
|
53
|
+
env:
|
|
54
|
+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
55
|
+
run: |
|
|
56
|
+
version=$(docker run --rm "$LOCAL_TAG" --version | awk '{print $2}')
|
|
57
|
+
# The git tag (v0.1.0-rc1, v0.1.0) must match the package version (0.1.0rc1, 0.1.0).
|
|
58
|
+
tag_version=$(echo "${GITHUB_REF_NAME#v}" | tr -d '-')
|
|
59
|
+
if [ "$version" != "$tag_version" ]; then
|
|
60
|
+
echo "::error::tag $GITHUB_REF_NAME does not match package version $version"
|
|
61
|
+
exit 1
|
|
62
|
+
fi
|
|
63
|
+
image="ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/pentrep"
|
|
64
|
+
echo "$GH_TOKEN" | docker login ghcr.io -u "$GITHUB_ACTOR" --password-stdin
|
|
65
|
+
docker tag "$LOCAL_TAG" "$image:$version"
|
|
66
|
+
docker push "$image:$version"
|
|
67
|
+
# :latest only for final releases, not release candidates.
|
|
68
|
+
if [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
|
69
|
+
docker tag "$LOCAL_TAG" "$image:latest"
|
|
70
|
+
docker push "$image:latest"
|
|
71
|
+
fi
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
name: Pages
|
|
2
|
+
|
|
3
|
+
# Builds the sample report from examples/ (HTML, PDF and Markdown) and publishes it with GitHub Pages.
|
|
4
|
+
on:
|
|
5
|
+
push:
|
|
6
|
+
branches: [main]
|
|
7
|
+
pull_request:
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read
|
|
12
|
+
|
|
13
|
+
concurrency:
|
|
14
|
+
group: pages-${{ github.ref }}
|
|
15
|
+
cancel-in-progress: true
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
build:
|
|
19
|
+
name: Build the sample report
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
steps:
|
|
22
|
+
- uses: actions/checkout@v7
|
|
23
|
+
- name: Install Pango
|
|
24
|
+
run: |
|
|
25
|
+
sudo apt-get update
|
|
26
|
+
sudo apt-get install -y --no-install-recommends libpango-1.0-0 libpangoft2-1.0-0 libharfbuzz0b libharfbuzz-subset0
|
|
27
|
+
- uses: astral-sh/setup-uv@v7
|
|
28
|
+
with:
|
|
29
|
+
python-version: "3.12"
|
|
30
|
+
enable-cache: true
|
|
31
|
+
- run: uv sync --locked --no-dev
|
|
32
|
+
- name: Build the report
|
|
33
|
+
run: |
|
|
34
|
+
uv run --no-dev pentrep build examples/findings.yaml -f all -o site
|
|
35
|
+
for ext in html md pdf; do test -s "site/pentest-report.$ext"; done
|
|
36
|
+
- name: Add an index page
|
|
37
|
+
run: |
|
|
38
|
+
version=$(uv run --no-dev pentrep --version)
|
|
39
|
+
cat > site/index.html <<HTML
|
|
40
|
+
<!DOCTYPE html>
|
|
41
|
+
<html lang="en">
|
|
42
|
+
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
|
|
43
|
+
<title>pentrep sample report</title>
|
|
44
|
+
<style>body{font-family:system-ui,sans-serif;max-width:40rem;margin:3rem auto;padding:0 1rem;line-height:1.5}</style>
|
|
45
|
+
</head>
|
|
46
|
+
<body>
|
|
47
|
+
<h1>pentrep sample report</h1>
|
|
48
|
+
<p>Generated by ${version} from <a href="https://github.com/${GITHUB_REPOSITORY}/blob/main/examples/findings.yaml">examples/findings.yaml</a>.
|
|
49
|
+
Secrets in the evidence are redacted.</p>
|
|
50
|
+
<ul>
|
|
51
|
+
<li><a href="pentest-report.html">HTML report</a></li>
|
|
52
|
+
<li><a href="pentest-report.pdf">PDF report</a></li>
|
|
53
|
+
<li><a href="pentest-report.md">Markdown report</a></li>
|
|
54
|
+
</ul>
|
|
55
|
+
<p><a href="https://github.com/${GITHUB_REPOSITORY}">Source on GitHub</a></p>
|
|
56
|
+
</body>
|
|
57
|
+
</html>
|
|
58
|
+
HTML
|
|
59
|
+
- uses: actions/upload-pages-artifact@v3
|
|
60
|
+
with:
|
|
61
|
+
path: site
|
|
62
|
+
|
|
63
|
+
deploy:
|
|
64
|
+
name: Deploy to GitHub Pages
|
|
65
|
+
if: github.ref == 'refs/heads/main'
|
|
66
|
+
needs: build
|
|
67
|
+
runs-on: ubuntu-latest
|
|
68
|
+
permissions:
|
|
69
|
+
pages: write
|
|
70
|
+
id-token: write
|
|
71
|
+
environment:
|
|
72
|
+
name: github-pages
|
|
73
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
74
|
+
steps:
|
|
75
|
+
- id: deployment
|
|
76
|
+
uses: actions/deploy-pages@v4
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
# PyPI Trusted Publishing (FR-60): no API token is stored in the repository.
|
|
4
|
+
# v0.1.0-rc1 (any v*-rc* tag) -> TestPyPI, GitHub environment "testpypi", then an install test
|
|
5
|
+
# v0.1.0 (vX.Y.Z) -> PyPI, GitHub environment "pypi" (required reviewer)
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
tags: ["v*"]
|
|
9
|
+
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
build:
|
|
15
|
+
name: Build sdist and wheel
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
outputs:
|
|
18
|
+
target: ${{ steps.check.outputs.target }}
|
|
19
|
+
version: ${{ steps.check.outputs.version }}
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v7
|
|
22
|
+
- uses: astral-sh/setup-uv@v7
|
|
23
|
+
with:
|
|
24
|
+
python-version: "3.12"
|
|
25
|
+
- run: uv build
|
|
26
|
+
- name: Check the tag against the package version
|
|
27
|
+
id: check
|
|
28
|
+
run: |
|
|
29
|
+
wheel=$(ls dist/*.whl)
|
|
30
|
+
version=$(basename "$wheel" | cut -d- -f2)
|
|
31
|
+
tag="$GITHUB_REF_NAME"
|
|
32
|
+
if [[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]+$ ]]; then
|
|
33
|
+
target=testpypi
|
|
34
|
+
elif [[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
|
35
|
+
target=pypi
|
|
36
|
+
else
|
|
37
|
+
echo "::error::tag $tag is neither vX.Y.Z nor vX.Y.Z-rcN"
|
|
38
|
+
exit 1
|
|
39
|
+
fi
|
|
40
|
+
# v0.1.0-rc1 must build 0.1.0rc1; v0.1.0 must build 0.1.0.
|
|
41
|
+
expected=$(echo "${tag#v}" | tr -d '-')
|
|
42
|
+
if [ "$version" != "$expected" ]; then
|
|
43
|
+
echo "::error::tag $tag does not match package version $version"
|
|
44
|
+
exit 1
|
|
45
|
+
fi
|
|
46
|
+
echo "target=$target" >> "$GITHUB_OUTPUT"
|
|
47
|
+
echo "version=$version" >> "$GITHUB_OUTPUT"
|
|
48
|
+
echo "Publishing $version to $target"
|
|
49
|
+
- uses: actions/upload-artifact@v4
|
|
50
|
+
with:
|
|
51
|
+
name: dist
|
|
52
|
+
path: dist/
|
|
53
|
+
if-no-files-found: error
|
|
54
|
+
|
|
55
|
+
testpypi:
|
|
56
|
+
name: Publish to TestPyPI
|
|
57
|
+
needs: build
|
|
58
|
+
if: needs.build.outputs.target == 'testpypi'
|
|
59
|
+
runs-on: ubuntu-latest
|
|
60
|
+
environment:
|
|
61
|
+
name: testpypi
|
|
62
|
+
url: https://test.pypi.org/project/pentrep/
|
|
63
|
+
permissions:
|
|
64
|
+
id-token: write # Trusted Publishing
|
|
65
|
+
steps:
|
|
66
|
+
- uses: actions/download-artifact@v4
|
|
67
|
+
with:
|
|
68
|
+
name: dist
|
|
69
|
+
path: dist/
|
|
70
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
71
|
+
with:
|
|
72
|
+
repository-url: https://test.pypi.org/legacy/
|
|
73
|
+
|
|
74
|
+
verify-testpypi:
|
|
75
|
+
name: Install from TestPyPI in a clean python:3.12 container
|
|
76
|
+
needs: [build, testpypi]
|
|
77
|
+
runs-on: ubuntu-latest
|
|
78
|
+
container: python:3.12
|
|
79
|
+
env:
|
|
80
|
+
VERSION: ${{ needs.build.outputs.version }}
|
|
81
|
+
PIPX_BIN_DIR: /usr/local/bin
|
|
82
|
+
steps:
|
|
83
|
+
- uses: actions/download-artifact@v4
|
|
84
|
+
with:
|
|
85
|
+
name: dist
|
|
86
|
+
path: built/
|
|
87
|
+
- name: Download pentrep from TestPyPI and compare it with the built wheel
|
|
88
|
+
run: |
|
|
89
|
+
# Only pentrep comes from TestPyPI; dependencies come from PyPI below. Mixing both indexes
|
|
90
|
+
# for dependencies would let any TestPyPI upload shadow a real package (dependency confusion).
|
|
91
|
+
for attempt in 1 2 3 4 5 6 7 8 9 10; do
|
|
92
|
+
if python -m pip download --quiet --no-deps --only-binary=:all: \
|
|
93
|
+
--index-url https://test.pypi.org/simple/ -d testpypi "pentrep==$VERSION"; then
|
|
94
|
+
break
|
|
95
|
+
fi
|
|
96
|
+
echo "attempt $attempt: TestPyPI does not serve pentrep $VERSION yet, retrying in 30 s"
|
|
97
|
+
sleep 30
|
|
98
|
+
done
|
|
99
|
+
ls -l testpypi built
|
|
100
|
+
test "$(sha256sum testpypi/*.whl | cut -d' ' -f1)" = "$(sha256sum built/*.whl | cut -d' ' -f1)"
|
|
101
|
+
- name: pipx install (pentrep from the TestPyPI download, dependencies from PyPI)
|
|
102
|
+
run: |
|
|
103
|
+
python -m pip install --quiet pipx
|
|
104
|
+
pipx install --index-url https://pypi.org/simple/ \
|
|
105
|
+
--pip-args="--find-links $PWD/testpypi" "pentrep==$VERSION"
|
|
106
|
+
- name: init + build -f html -f md (PRD M7 acceptance criterion)
|
|
107
|
+
run: |
|
|
108
|
+
test "$(pentrep --version)" = "pentrep $VERSION"
|
|
109
|
+
cd "$(mktemp -d)"
|
|
110
|
+
pentrep init
|
|
111
|
+
pentrep build findings.yaml -f html -f md
|
|
112
|
+
test -s report/pentest-report.html
|
|
113
|
+
test -s report/pentest-report.md
|
|
114
|
+
ls -l report
|
|
115
|
+
|
|
116
|
+
pypi:
|
|
117
|
+
name: Publish to PyPI
|
|
118
|
+
needs: build
|
|
119
|
+
if: needs.build.outputs.target == 'pypi'
|
|
120
|
+
runs-on: ubuntu-latest
|
|
121
|
+
environment:
|
|
122
|
+
name: pypi
|
|
123
|
+
url: https://pypi.org/project/pentrep/
|
|
124
|
+
permissions:
|
|
125
|
+
id-token: write # Trusted Publishing
|
|
126
|
+
steps:
|
|
127
|
+
- uses: actions/download-artifact@v4
|
|
128
|
+
with:
|
|
129
|
+
name: dist
|
|
130
|
+
path: dist/
|
|
131
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
pentrep-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# pentrep outputs & scratch
|
|
2
|
+
output/
|
|
3
|
+
report/
|
|
4
|
+
tmp/
|
|
5
|
+
|
|
6
|
+
# secrets / local env
|
|
7
|
+
.env
|
|
8
|
+
.env.*
|
|
9
|
+
!.env.example
|
|
10
|
+
|
|
11
|
+
# Python
|
|
12
|
+
__pycache__/
|
|
13
|
+
*.py[cod]
|
|
14
|
+
.venv/
|
|
15
|
+
venv/
|
|
16
|
+
build/
|
|
17
|
+
dist/
|
|
18
|
+
*.egg-info/
|
|
19
|
+
|
|
20
|
+
# tooling caches & coverage
|
|
21
|
+
.pytest_cache/
|
|
22
|
+
.mypy_cache/
|
|
23
|
+
.ruff_cache/
|
|
24
|
+
.hypothesis/
|
|
25
|
+
.coverage
|
|
26
|
+
.coverage.*
|
|
27
|
+
coverage.xml
|
|
28
|
+
htmlcov/
|
|
29
|
+
|
|
30
|
+
# OS / editors
|
|
31
|
+
.DS_Store
|
|
32
|
+
.idea/
|
|
33
|
+
.vscode/
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# ruff and mypy run through uv so their versions come from uv.lock (same as CI).
|
|
2
|
+
repos:
|
|
3
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
4
|
+
rev: v6.0.0
|
|
5
|
+
hooks:
|
|
6
|
+
- id: check-yaml
|
|
7
|
+
exclude: ^tests/fixtures/invalid/e100_ # deliberately invalid YAML (E100 fixtures)
|
|
8
|
+
- id: check-toml
|
|
9
|
+
- id: end-of-file-fixer
|
|
10
|
+
- id: trailing-whitespace
|
|
11
|
+
- id: check-added-large-files
|
|
12
|
+
args: ["--maxkb=1024"]
|
|
13
|
+
- id: detect-private-key
|
|
14
|
+
- repo: local
|
|
15
|
+
hooks:
|
|
16
|
+
- id: ruff-check
|
|
17
|
+
name: ruff check
|
|
18
|
+
entry: uv run --frozen ruff check --fix
|
|
19
|
+
language: system
|
|
20
|
+
types_or: [python, pyi]
|
|
21
|
+
- id: ruff-format
|
|
22
|
+
name: ruff format
|
|
23
|
+
entry: uv run --frozen ruff format
|
|
24
|
+
language: system
|
|
25
|
+
types_or: [python, pyi]
|
|
26
|
+
- id: mypy
|
|
27
|
+
name: mypy (strict)
|
|
28
|
+
entry: uv run --frozen mypy
|
|
29
|
+
language: system
|
|
30
|
+
types_or: [python, pyi]
|
|
31
|
+
pass_filenames: false
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
5
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
## [0.1.0] - 2026-11-29
|
|
10
|
+
|
|
11
|
+
First stable release, published to PyPI and as `ghcr.io/rayhan212/pentrep:0.1.0` (and `:latest`). The code is the
|
|
12
|
+
same as 0.1.0rc1; only the version changed. See [0.1.0rc1] for everything that is included.
|
|
13
|
+
|
|
14
|
+
## [0.1.0rc1] - 2026-11-29
|
|
15
|
+
|
|
16
|
+
First release candidate of v0.1.0, published to TestPyPI and as `ghcr.io/rayhan212/pentrep:0.1.0rc1`.
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
- Project skeleton: `pentrep` CLI with `--version`, `--help` and `--debug`.
|
|
20
|
+
- Tooling: uv, ruff, mypy (strict), pytest with coverage gate, pre-commit, GitHub Actions CI.
|
|
21
|
+
- `findings.yaml` schema v1 as Pydantic models, with safe YAML loading (no custom tags, alias-expansion
|
|
22
|
+
limit, 10 MB limit) and a line/column for every value.
|
|
23
|
+
- `pentrep init [DIR] [--force]` creates an example project.
|
|
24
|
+
- `pentrep validate FILE [--strict] [--format text|json]` reports every error and warning with
|
|
25
|
+
`file:line:col`, a stable code (E100–E106, E206, E301–E303, W101, W102) and a hint.
|
|
26
|
+
- `pentrep schema [-o FILE]` prints the JSON Schema (draft 2020-12).
|
|
27
|
+
- Docs: `docs/errors.md` and `docs/schema.md`.
|
|
28
|
+
- CVSS 3.1 base-score calculator (`pentrep.cvss`): vector parser with E201–E205 errors and W201 for
|
|
29
|
+
ignored temporal/environmental metrics, canonical vectors, Roundup from spec Appendix A, sub-scores and
|
|
30
|
+
severity bands. Checked against FIRST's published CVSS v3.1 examples and with property-based tests.
|
|
31
|
+
- `Finding.cvss` computed field; `stats` module with finding order, severity counts and overall risk.
|
|
32
|
+
- `validate` success line shows the severity breakdown, e.g. `2 findings (1 critical, 1 medium)`.
|
|
33
|
+
- Redaction engine (`pentrep.redact`): 9 built-in patterns (PRIVATE_KEY, JWT, BEARER, COOKIE, AWS_KEY,
|
|
34
|
+
SECRET, CARD with Luhn, EMAIL, PRIVATE_IP), with priority/overlap rules, custom patterns with optional
|
|
35
|
+
`value` groups (E304 for a bad name or regex), and an allowlist. Output is deterministic.
|
|
36
|
+
- `validate` prints a redaction preview with counts per pattern (never the values).
|
|
37
|
+
- `pentrep build FILE` with `-f html|md`, `-o`, `-n`, `--template-dir`, `--no-redact`, `--strict` and `-q`:
|
|
38
|
+
a self-contained HTML report (inline CSS, `data:` images, no scripts, Pygments highlighting) and a GFM
|
|
39
|
+
Markdown report with copied image assets, both from the `classic` theme. Output is deterministic and covered
|
|
40
|
+
by golden files.
|
|
41
|
+
- Docs: `docs/templates.md` (template context, filters and partials for `--template-dir`).
|
|
42
|
+
- PDF output (`-f pdf`, part of the default `-f all`) with WeasyPrint: A4 or Letter (`--paper`), a
|
|
43
|
+
classification header, `Page X of Y` footers, TOC page numbers, bookmarks and a new page per finding. It embeds
|
|
44
|
+
only the bundled OFL fonts (Source Sans 3, Source Code Pro) and loads no external resources. If WeasyPrint's
|
|
45
|
+
libraries are missing, the other formats are still written and the CLI exits 3 with an install hint.
|
|
46
|
+
- Performance benchmarks for NFR-01..04 (`pytest -m perf`, own CI job) and a check that `--help` does not import
|
|
47
|
+
WeasyPrint or Jinja2.
|
|
48
|
+
- CI packaging smoke job: build the wheel (≤ 2 MB), install it into a fresh venv, run `init` + `build -f all`.
|
|
49
|
+
- Docker image (`python:3.12-slim`, Pango/HarfBuzz, non-root, `/work`); a workflow builds it, checks size ≤ 400 MB,
|
|
50
|
+
smoke-tests it and pushes `ghcr.io/rayhan212/pentrep:<version>` (and `:latest` for final releases) on tags.
|
|
51
|
+
- GitHub Pages workflow publishing the sample report built from `examples/`.
|
|
52
|
+
- Release workflow with PyPI Trusted Publishing: `vX.Y.Z-rcN` tags go to TestPyPI, `vX.Y.Z` tags to PyPI.
|
|
53
|
+
- README: quickstart, Docker usage, screenshots and links to the sample report.
|
|
54
|
+
|
|
55
|
+
[Unreleased]: https://github.com/Rayhan212/pentrep/compare/v0.1.0...HEAD
|
|
56
|
+
[0.1.0]: https://github.com/Rayhan212/pentrep/compare/v0.1.0-rc1...v0.1.0
|
|
57
|
+
[0.1.0rc1]: https://github.com/Rayhan212/pentrep/releases/tag/v0.1.0-rc1
|
pentrep-0.1.0/CLAUDE.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# CLAUDE.md — working rules for pentrep
|
|
2
|
+
|
|
3
|
+
## Project
|
|
4
|
+
pentrep is a Python CLI that turns a `findings.yaml` file (pentest results) into a professional report in HTML, PDF and Markdown.
|
|
5
|
+
It validates the file with line-numbered errors, computes CVSS 3.1 scores from vectors, and redacts secrets/PII in evidence by default.
|
|
6
|
+
Target user: solo/freelance pentesters. It is also a portfolio project, so quality and tests matter more than feature count.
|
|
7
|
+
|
|
8
|
+
- Requirements (source of truth): [docs/PRD.md](docs/PRD.md)
|
|
9
|
+
- Task checklist & progress: [docs/PLAN.md](docs/PLAN.md)
|
|
10
|
+
|
|
11
|
+
## Stack
|
|
12
|
+
- Python **>= 3.11** (CI: 3.11–3.14, Ubuntu + macOS). Build backend: hatchling. Env/lock: **uv**.
|
|
13
|
+
- Runtime: Typer, Pydantic v2, ruamel.yaml, Jinja2, markdown-it-py, Pygments, WeasyPrint (PDF only, import lazily).
|
|
14
|
+
- Dev: pytest, pytest-cov, hypothesis, pypdf, pytest-socket, ruff, mypy (strict), pre-commit.
|
|
15
|
+
|
|
16
|
+
## Setup, run, test
|
|
17
|
+
```bash
|
|
18
|
+
uv sync --all-extras # create .venv + install deps from uv.lock
|
|
19
|
+
uv run pre-commit install
|
|
20
|
+
uv run pentrep --help
|
|
21
|
+
uv run pentrep init tmp/ && uv run pentrep build tmp/findings.yaml -o tmp/report
|
|
22
|
+
uv run pytest # full suite (pdf tests auto-skip without Pango)
|
|
23
|
+
uv run pytest -m "not perf" # skip benchmarks
|
|
24
|
+
uv run pytest --update-golden # regenerate golden files, then review the diff
|
|
25
|
+
uv run ruff check . && uv run ruff format --check . && uv run mypy src
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Conventions
|
|
29
|
+
- Layout: code in `src/pentrep/` (one module per concern: `cli`, `models`, `loader`, `diagnostics`,
|
|
30
|
+
`cvss`, `redact`, `stats`, `render/`), templates in `src/pentrep/themes/classic/`,
|
|
31
|
+
tests in `tests/{unit,cli,render,security,perf}/` and fixtures in `tests/fixtures/`. Follow PRD §7.
|
|
32
|
+
- Naming: `snake_case` modules/functions, `PascalCase` classes, `UPPER_SNAKE` constants;
|
|
33
|
+
tests are `test_<module>.py` / `test_<behaviour>()`; invalid fixtures are named after their code (`e203_bad_metric_value.yaml`).
|
|
34
|
+
- Type hints on every function signature and public attribute; `mypy --strict` must pass. Avoid `Any`;
|
|
35
|
+
if it's unavoidable, add a comment explaining why.
|
|
36
|
+
- Docstrings: one-line summary for every public function/class; add Args/Returns only when not obvious.
|
|
37
|
+
- Errors: raise or collect `Diagnostic` with an `ErrorCode` from `diagnostics.py`. Never show bare
|
|
38
|
+
exceptions to the user. New codes must be added to PRD §4.2.4 and `docs/errors.md`.
|
|
39
|
+
- Security defaults: safe YAML loading, Jinja autoescape for HTML, markdown-it with `html=False`,
|
|
40
|
+
never render YAML values as templates, confine file paths to the project directory, no network calls.
|
|
41
|
+
- Output must be deterministic (FR-49): no timestamps or random values outside `report_date` / `SOURCE_DATE_EPOCH`.
|
|
42
|
+
|
|
43
|
+
## Workflow (every task)
|
|
44
|
+
1. Pick the next unchecked task in `docs/PLAN.md` and re-read the PRD sections it references.
|
|
45
|
+
2. **Write failing tests first** (TDD): unit test, fixture, or golden file.
|
|
46
|
+
3. Implement the minimum code that makes them pass, then refactor.
|
|
47
|
+
4. Run `uv run pytest` and `uv run ruff check . && uv run ruff format --check . && uv run mypy src`. All must be green.
|
|
48
|
+
5. Tick the task in `docs/PLAN.md` (add a short note if the scope changed).
|
|
49
|
+
6. Commit with Conventional Commits: `feat(cvss): compute base score from vector`, `fix(redact): …`,
|
|
50
|
+
`test: …`, `docs: …`, `refactor: …`, `chore: …`, `ci: …`. One logical change per commit, in the imperative mood.
|
|
51
|
+
|
|
52
|
+
## Don'ts
|
|
53
|
+
- Do **not** add, remove or upgrade a dependency (runtime or dev) without asking first.
|
|
54
|
+
- Do **not** change the `findings.yaml` schema (fields, types, constraints, defaults) without first
|
|
55
|
+
updating PRD §4.2 and bumping/justifying `schema_version` — and then the JSON Schema, scaffold and fixtures.
|
|
56
|
+
- Do **not** commit `output/`, `report/`, `tmp/`, `.env*`, `.venv/`, coverage or build artifacts
|
|
57
|
+
(they must be in `.gitignore`).
|
|
58
|
+
- Do **not** weaken tests, coverage gates or lint rules to get green. Do not regenerate golden files without reviewing the diff.
|
|
59
|
+
- Do **not** commit real client data or real secrets. Fixtures use `example`/`.test` domains and RFC 5737 IPs.
|
|
60
|
+
- Do **not** expand scope beyond PRD §2 non-goals; log ideas as roadmap items instead.
|
|
61
|
+
|
|
62
|
+
## Definition of Done (per task)
|
|
63
|
+
- [ ] Acceptance criteria of the task / PRD milestone are met, and each one is covered by a test.
|
|
64
|
+
- [ ] Tests written before implementation; `pytest` green locally.
|
|
65
|
+
- [ ] Coverage gate holds (≥ 85 % overall, ≥ 95 % line+branch for `cvss.py` and `redact.py`).
|
|
66
|
+
- [ ] `ruff check`, `ruff format --check`, `mypy --strict` clean.
|
|
67
|
+
- [ ] Every user-facing error has a code, file:line:col, and a hint where applicable; no traceback without `--debug`.
|
|
68
|
+
- [ ] Docs updated where behaviour changed (README, `docs/errors.md`, `docs/templates.md`, PRD if spec changed).
|
|
69
|
+
- [ ] `docs/PLAN.md` checkbox ticked.
|
|
70
|
+
- [ ] Committed with a Conventional Commit message; no ignored or secret files staged.
|
pentrep-0.1.0/Dockerfile
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# pentrep container image (FR-61): docker run --rm -v "$PWD:/work" ghcr.io/rayhan212/pentrep build findings.yaml
|
|
2
|
+
|
|
3
|
+
# --- Build stage: the wheel plus runtime requirements pinned by uv.lock (with hashes) -------------
|
|
4
|
+
FROM python:3.12-slim AS build
|
|
5
|
+
RUN pip install --no-cache-dir uv==0.11.32
|
|
6
|
+
WORKDIR /src
|
|
7
|
+
COPY pyproject.toml uv.lock README.md LICENSE ./
|
|
8
|
+
COPY src ./src
|
|
9
|
+
RUN uv build --wheel --out-dir /dist \
|
|
10
|
+
&& uv export --frozen --no-dev --no-emit-project --format requirements-txt -o /dist/requirements.txt
|
|
11
|
+
|
|
12
|
+
# --- Runtime stage --------------------------------------------------------------------------------
|
|
13
|
+
FROM python:3.12-slim
|
|
14
|
+
# Pango/HarfBuzz are the system libraries WeasyPrint needs for PDF output.
|
|
15
|
+
RUN apt-get update \
|
|
16
|
+
&& apt-get install -y --no-install-recommends \
|
|
17
|
+
libpango-1.0-0 libpangoft2-1.0-0 libharfbuzz0b libharfbuzz-subset0 fontconfig \
|
|
18
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
19
|
+
COPY --from=build /dist /tmp/dist
|
|
20
|
+
RUN pip install --no-cache-dir --require-hashes -r /tmp/dist/requirements.txt \
|
|
21
|
+
&& pip install --no-cache-dir --no-deps /tmp/dist/*.whl \
|
|
22
|
+
&& rm -rf /tmp/dist
|
|
23
|
+
RUN useradd --create-home --uid 1000 pentrep \
|
|
24
|
+
&& mkdir /work && chown pentrep:pentrep /work
|
|
25
|
+
USER pentrep
|
|
26
|
+
WORKDIR /work
|
|
27
|
+
ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
|
|
28
|
+
ENTRYPOINT ["pentrep"]
|
|
29
|
+
CMD ["--help"]
|
pentrep-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Rayhan212
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|