pentrep 0.1.0__py3-none-any.whl

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.
Files changed (42) hide show
  1. pentrep/__init__.py +3 -0
  2. pentrep/__main__.py +6 -0
  3. pentrep/cli.py +353 -0
  4. pentrep/cvss.py +313 -0
  5. pentrep/diagnostics.py +142 -0
  6. pentrep/loader.py +532 -0
  7. pentrep/models.py +358 -0
  8. pentrep/redact.py +320 -0
  9. pentrep/render/__init__.py +54 -0
  10. pentrep/render/context.py +200 -0
  11. pentrep/render/highlight.py +62 -0
  12. pentrep/render/html.py +34 -0
  13. pentrep/render/markdown.py +58 -0
  14. pentrep/render/md.py +172 -0
  15. pentrep/render/pdf.py +116 -0
  16. pentrep/scaffold/assets/logo.png +0 -0
  17. pentrep/scaffold/evidence/pt-001-sqlmap.png +0 -0
  18. pentrep/scaffold/findings.yaml +119 -0
  19. pentrep/stats.py +70 -0
  20. pentrep/themes/classic/fonts/OFL.txt +104 -0
  21. pentrep/themes/classic/fonts/SourceCodePro-Regular.ttf +0 -0
  22. pentrep/themes/classic/fonts/SourceSans3-Bold.ttf +0 -0
  23. pentrep/themes/classic/fonts/SourceSans3-It.ttf +0 -0
  24. pentrep/themes/classic/fonts/SourceSans3-Regular.ttf +0 -0
  25. pentrep/themes/classic/fonts.css +7 -0
  26. pentrep/themes/classic/partials/appendix.html.j2 +38 -0
  27. pentrep/themes/classic/partials/cover.html.j2 +17 -0
  28. pentrep/themes/classic/partials/document_control.html.j2 +22 -0
  29. pentrep/themes/classic/partials/executive_summary.html.j2 +17 -0
  30. pentrep/themes/classic/partials/finding.html.j2 +56 -0
  31. pentrep/themes/classic/partials/macros.html.j2 +7 -0
  32. pentrep/themes/classic/partials/scope.html.j2 +27 -0
  33. pentrep/themes/classic/partials/summary_table.html.j2 +13 -0
  34. pentrep/themes/classic/partials/toc.html.j2 +19 -0
  35. pentrep/themes/classic/report.html.j2 +35 -0
  36. pentrep/themes/classic/report.md.j2 +187 -0
  37. pentrep/themes/classic/style.css +97 -0
  38. pentrep-0.1.0.dist-info/METADATA +142 -0
  39. pentrep-0.1.0.dist-info/RECORD +42 -0
  40. pentrep-0.1.0.dist-info/WHEEL +4 -0
  41. pentrep-0.1.0.dist-info/entry_points.txt +2 -0
  42. pentrep-0.1.0.dist-info/licenses/LICENSE +21 -0
pentrep/render/pdf.py ADDED
@@ -0,0 +1,116 @@
1
+ """PDF output with WeasyPrint (FR-03, FR-46).
2
+
3
+ WeasyPrint is imported lazily: it is slow to import and needs system libraries (Pango, HarfBuzz)
4
+ that may be missing, in which case a :class:`RenderError` with an install hint is raised.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import importlib
10
+ import logging
11
+ import re
12
+ import sys
13
+ from importlib import resources
14
+ from pathlib import Path
15
+ from types import ModuleType
16
+ from typing import Final
17
+ from urllib.parse import urlparse
18
+ from urllib.request import url2pathname
19
+
20
+ DOCKER_HINT: Final = (
21
+ 'or use the Docker image: docker run --rm -v "$PWD:/work" ghcr.io/rayhan212/pentrep '
22
+ "build findings.yaml"
23
+ )
24
+ _INSTALL_HINTS: Final = {
25
+ "linux": "install the libraries: sudo apt install libpango-1.0-0 libpangoft2-1.0-0 "
26
+ "libharfbuzz0b (Debian/Ubuntu)",
27
+ "darwin": "install the libraries: brew install pango",
28
+ }
29
+ _MISSING_LIBRARY: Final = re.compile(r"cannot load library '([^']+)'")
30
+ PAPER_SIZES: Final = {"a4": "A4", "letter": "letter"}
31
+
32
+
33
+ class RenderError(Exception):
34
+ """A report could not be rendered; ``hint`` says how to fix it."""
35
+
36
+ def __init__(self, message: str, hint: str) -> None:
37
+ super().__init__(message)
38
+ self.hint = hint
39
+
40
+
41
+ def install_hint(platform: str = sys.platform) -> str:
42
+ """How to get WeasyPrint's system libraries on this OS, plus the Docker alternative."""
43
+ for prefix, hint in _INSTALL_HINTS.items():
44
+ if platform.startswith(prefix):
45
+ return f"{hint}; {DOCKER_HINT}"
46
+ return f"PDF output is supported on Linux and macOS; {DOCKER_HINT}"
47
+
48
+
49
+ def load_weasyprint() -> ModuleType:
50
+ """Import WeasyPrint, turning a missing package or system library into a RenderError."""
51
+ try:
52
+ return importlib.import_module("weasyprint")
53
+ except (ImportError, OSError) as exc:
54
+ match = _MISSING_LIBRARY.search(str(exc))
55
+ what = f"the system library {match.group(1)}" if match else "WeasyPrint"
56
+ raise RenderError(
57
+ f"PDF output is unavailable: cannot load {what}", install_hint()
58
+ ) from None
59
+
60
+
61
+ def _theme_dir() -> Path:
62
+ path = Path(str(resources.files("pentrep") / "themes" / "classic"))
63
+ return path.resolve()
64
+
65
+
66
+ def render_pdf(html: str, paper: str = "a4") -> bytes:
67
+ """Render report HTML to PDF with the bundled fonts. No network access (NFR-09).
68
+
69
+ Only ``data:`` URIs and files inside the built-in theme (the fonts) may be loaded; anything
70
+ else stops the rendering with a RenderError.
71
+ """
72
+ weasyprint = load_weasyprint()
73
+ urls = importlib.import_module("weasyprint.urls")
74
+ theme = _theme_dir()
75
+
76
+ class LocalOnlyFetcher(urls.URLFetcher): # type: ignore[misc,name-defined] # untyped library
77
+ """Allow data: URIs and the theme's own files; refuse everything else."""
78
+
79
+ def fetch(self, url: str, headers: object = None) -> object:
80
+ if url.startswith("data:"):
81
+ return super().fetch(url, headers)
82
+ if url.startswith("file:"):
83
+ local = Path(url2pathname(urlparse(url).path)).resolve()
84
+ if local.is_relative_to(theme):
85
+ return super().fetch(url, headers)
86
+ raise urls.FatalURLFetchingError(f"external resource blocked: {url}")
87
+
88
+ fonts_css = (theme / "fonts.css").read_text(encoding="utf-8")
89
+ page_css = f"@page {{ size: {PAPER_SIZES[paper]}; }}"
90
+ fetcher = LocalOnlyFetcher()
91
+ base_url = theme.as_uri() + "/"
92
+ logger = logging.getLogger("weasyprint")
93
+ previous_propagate, previous_level = logger.propagate, logger.level
94
+ logger.propagate = False # keep CSS warnings off the console
95
+ logger.setLevel(logging.ERROR)
96
+ # @font-face rules only take effect with one FontConfiguration shared by CSS and write_pdf.
97
+ font_config = importlib.import_module("weasyprint.text.fonts").FontConfiguration()
98
+ try:
99
+ document = weasyprint.HTML(string=html, base_url=base_url, url_fetcher=fetcher)
100
+ stylesheet = weasyprint.CSS(
101
+ string=fonts_css + "\n" + page_css,
102
+ base_url=base_url,
103
+ url_fetcher=fetcher,
104
+ font_config=font_config,
105
+ )
106
+ data: bytes = document.write_pdf(stylesheets=[stylesheet], font_config=font_config)
107
+ except urls.FatalURLFetchingError as exc:
108
+ raise RenderError(
109
+ f"PDF rendering stopped: {exc}",
110
+ "templates must embed images as data: URIs (use image_src) and must not load "
111
+ "external resources",
112
+ ) from None
113
+ finally:
114
+ logger.propagate = previous_propagate
115
+ logger.setLevel(previous_level)
116
+ return data
Binary file
@@ -0,0 +1,119 @@
1
+ schema_version: 1
2
+
3
+ engagement:
4
+ title: "Web Application Penetration Test – Acme Customer Portal"
5
+ client:
6
+ name: "Acme Corp"
7
+ contact: "Jane Doe, CISO"
8
+ testers:
9
+ - name: "Alex Tester"
10
+ email: "alex@example-security.test"
11
+ role: "Lead Penetration Tester"
12
+ start_date: 2026-11-02
13
+ end_date: 2026-11-13
14
+ report_date: 2026-11-20
15
+ report_version: "1.0"
16
+ classification: "CONFIDENTIAL"
17
+ scope:
18
+ in_scope:
19
+ - asset: "https://portal.acme.example"
20
+ type: url
21
+ - asset: "203.0.113.10"
22
+ type: ip
23
+ notes: "Production API host"
24
+ out_of_scope:
25
+ - asset: "https://status.acme.example"
26
+ type: url
27
+ notes: "Hosted by a third party"
28
+ methodology: |
29
+ Testing followed the **OWASP Web Security Testing Guide v4.2** as a
30
+ grey-box assessment with two standard-user accounts supplied by Acme.
31
+ executive_summary: |
32
+ The portal's authentication layer is vulnerable to SQL injection, which
33
+ allows an unauthenticated attacker to take over any account. Immediate
34
+ remediation of PT-001 is recommended.
35
+
36
+ branding:
37
+ company_name: "Example Security Labs"
38
+ logo: assets/logo.png
39
+ accent_color: "#1F4E79"
40
+
41
+ redaction:
42
+ enabled: true
43
+ custom_patterns:
44
+ - name: ACME_EMPLOYEE_ID
45
+ regex: 'ACME-\d{6}'
46
+ allowlist:
47
+ - "attacker@example-security.test"
48
+
49
+ findings:
50
+ - id: PT-001
51
+ title: "SQL Injection in Login Endpoint"
52
+ cvss_vector: "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
53
+ status: open
54
+ cwe: [89]
55
+ affected_assets:
56
+ - "https://portal.acme.example/api/v1/login"
57
+ description: |
58
+ The `username` field of the JSON login request is concatenated into a
59
+ SQL query without parameterisation.
60
+ impact: |
61
+ An unauthenticated attacker can bypass authentication as any user,
62
+ including administrators, and read or modify the entire database.
63
+ steps_to_reproduce:
64
+ - "Send the request shown in Evidence 1 to `/api/v1/login`."
65
+ - "Observe that a valid session for the `admin` user is returned."
66
+ evidence:
67
+ - type: http
68
+ caption: "Boolean-based payload returns an admin session"
69
+ content: |
70
+ POST /api/v1/login HTTP/1.1
71
+ Host: portal.acme.example
72
+ Content-Type: application/json
73
+
74
+ {"username":"admin' OR '1'='1' -- ","password":"x"}
75
+
76
+ HTTP/1.1 200 OK
77
+ Set-Cookie: session=9f8e7d6c5b4a3921; Path=/; HttpOnly; Secure
78
+ Content-Type: application/json
79
+
80
+ {"token":"eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbiJ9.c2lnbmF0dXJl","email":"admin@acme.example","staff_id":"ACME-104233"}
81
+ - type: image
82
+ caption: "sqlmap enumerating database tables"
83
+ path: evidence/pt-001-sqlmap.png
84
+ remediation: |
85
+ Use parameterised queries (prepared statements) for all database access
86
+ and add a WAF rule as defence in depth until the fix is deployed.
87
+ references:
88
+ - "https://owasp.org/www-community/attacks/SQL_Injection"
89
+ - "https://cheatsheetseries.owasp.org/cheatsheets/SQL_Injection_Prevention_Cheat_Sheet.html"
90
+
91
+ - id: PT-002
92
+ title: "Reflected Cross-Site Scripting in Search"
93
+ cvss_vector: "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N"
94
+ status: open
95
+ cwe: [79]
96
+ affected_assets:
97
+ - "https://portal.acme.example/search?q="
98
+ description: |
99
+ The `q` parameter is reflected into the results page without output
100
+ encoding, allowing arbitrary JavaScript to run in the victim's browser.
101
+ impact: |
102
+ An attacker who tricks a logged-in user into opening a crafted link can
103
+ perform actions as that user and read data shown in the page.
104
+ steps_to_reproduce:
105
+ - "Log in as any user."
106
+ - "Open `https://portal.acme.example/search?q=<svg/onload=alert(document.domain)>`."
107
+ - "Observe the alert box showing `portal.acme.example`."
108
+ evidence:
109
+ - type: text
110
+ caption: "Reflected payload in the HTML response (internal debug header included)"
111
+ language: html
112
+ content: |
113
+ X-Backend-Host: 10.20.0.15
114
+ <div class="results">No results for <svg/onload=alert(document.domain)></div>
115
+ remediation: |
116
+ Apply context-aware output encoding to all reflected input and deploy a
117
+ Content-Security-Policy that disallows inline scripts.
118
+ references:
119
+ - "https://owasp.org/www-community/attacks/xss/"
pentrep/stats.py ADDED
@@ -0,0 +1,70 @@
1
+ """Finding order, severity counts and overall risk (PRD FR-42, FR-43)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import Sequence
6
+ from dataclasses import dataclass
7
+ from typing import Final
8
+
9
+ from pentrep.cvss import Severity
10
+ from pentrep.models import Finding
11
+
12
+ # Count buckets in report order; None and Informational share one bucket (FR-43).
13
+ BUCKETS: Final = ("Critical", "High", "Medium", "Low", "Informational/None")
14
+ _BUCKET_OF: Final = {
15
+ Severity.CRITICAL: "Critical",
16
+ Severity.HIGH: "High",
17
+ Severity.MEDIUM: "Medium",
18
+ Severity.LOW: "Low",
19
+ Severity.INFORMATIONAL: "Informational/None",
20
+ Severity.NONE: "Informational/None",
21
+ }
22
+
23
+
24
+ def finding_severity(finding: Finding) -> Severity:
25
+ """Informational for ``severity: informational``, else the CVSS severity band."""
26
+ return finding.cvss.severity if finding.cvss else Severity.INFORMATIONAL
27
+
28
+
29
+ def _score(finding: Finding) -> float:
30
+ return finding.cvss.base_score if finding.cvss else 0.0
31
+
32
+
33
+ def sort_findings(findings: Sequence[Finding]) -> list[Finding]:
34
+ """Score descending, then id ascending; 0.0 and informational findings last (FR-42)."""
35
+ return sorted(findings, key=lambda f: (_score(f) == 0.0, -_score(f), f.id))
36
+
37
+
38
+ @dataclass(frozen=True)
39
+ class Stats:
40
+ """Severity counts per bucket (plus ``Total``) and the overall risk rating."""
41
+
42
+ counts: dict[str, int]
43
+ overall_risk: Severity
44
+
45
+
46
+ def compute_stats(findings: Sequence[Finding]) -> Stats:
47
+ """Count findings per severity bucket and rate the overall risk (FR-43).
48
+
49
+ Overall risk is the highest severity among ``open`` findings, or None if nothing is open.
50
+ At the lowest rank, Informational wins over None.
51
+ """
52
+ counts = dict.fromkeys(BUCKETS, 0)
53
+ for finding in findings:
54
+ counts[_BUCKET_OF[finding_severity(finding)]] += 1
55
+ counts["Total"] = len(findings)
56
+ open_severities = [finding_severity(f) for f in findings if f.status == "open"]
57
+ risk = max(open_severities, default=Severity.NONE)
58
+ if risk.rank == 0 and Severity.INFORMATIONAL in open_severities:
59
+ risk = Severity.INFORMATIONAL
60
+ return Stats(counts, risk)
61
+
62
+
63
+ def breakdown(stats: Stats) -> str:
64
+ """Non-zero bucket counts for the CLI, for example ``1 critical, 1 medium``."""
65
+ parts = []
66
+ for bucket in BUCKETS:
67
+ if stats.counts[bucket]:
68
+ label = "informational" if bucket == "Informational/None" else bucket.lower()
69
+ parts.append(f"{stats.counts[bucket]} {label}")
70
+ return ", ".join(parts)
@@ -0,0 +1,104 @@
1
+ Fonts bundled with pentrep (src/pentrep/themes/classic/fonts/):
2
+
3
+ - Source Sans 3 (SourceSans3-Regular.ttf, SourceSans3-It.ttf, SourceSans3-Bold.ttf), from the
4
+ npm package source-sans 3.52.0 (https://github.com/adobe-fonts/source-sans)
5
+ - Source Code Pro (SourceCodePro-Regular.ttf), from the npm package source-code-pro 2.42.0
6
+ (https://github.com/adobe-fonts/source-code-pro)
7
+
8
+ Copyright notices, as published with each font:
9
+
10
+ Source Sans 3: Copyright 2010-2024 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe in the United States and/or other countries.
11
+
12
+ Source Code Pro: © 2023 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe in the United States and/or other countries.
13
+
14
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
15
+
16
+ This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
17
+
18
+
19
+ -----------------------------------------------------------
20
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
21
+ -----------------------------------------------------------
22
+
23
+ PREAMBLE
24
+ The goals of the Open Font License (OFL) are to stimulate worldwide
25
+ development of collaborative font projects, to support the font creation
26
+ efforts of academic and linguistic communities, and to provide a free and
27
+ open framework in which fonts may be shared and improved in partnership
28
+ with others.
29
+
30
+ The OFL allows the licensed fonts to be used, studied, modified and
31
+ redistributed freely as long as they are not sold by themselves. The
32
+ fonts, including any derivative works, can be bundled, embedded,
33
+ redistributed and/or sold with any software provided that any reserved
34
+ names are not used by derivative works. The fonts and derivatives,
35
+ however, cannot be released under any other type of license. The
36
+ requirement for fonts to remain under this license does not apply
37
+ to any document created using the fonts or their derivatives.
38
+
39
+ DEFINITIONS
40
+ "Font Software" refers to the set of files released by the Copyright
41
+ Holder(s) under this license and clearly marked as such. This may
42
+ include source files, build scripts and documentation.
43
+
44
+ "Reserved Font Name" refers to any names specified as such after the
45
+ copyright statement(s).
46
+
47
+ "Original Version" refers to the collection of Font Software components as
48
+ distributed by the Copyright Holder(s).
49
+
50
+ "Modified Version" refers to any derivative made by adding to, deleting,
51
+ or substituting -- in part or in whole -- any of the components of the
52
+ Original Version, by changing formats or by porting the Font Software to a
53
+ new environment.
54
+
55
+ "Author" refers to any designer, engineer, programmer, technical
56
+ writer or other person who contributed to the Font Software.
57
+
58
+ PERMISSION & CONDITIONS
59
+ Permission is hereby granted, free of charge, to any person obtaining
60
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
61
+ redistribute, and sell modified and unmodified copies of the Font
62
+ Software, subject to the following conditions:
63
+
64
+ 1) Neither the Font Software nor any of its individual components,
65
+ in Original or Modified Versions, may be sold by itself.
66
+
67
+ 2) Original or Modified Versions of the Font Software may be bundled,
68
+ redistributed and/or sold with any software, provided that each copy
69
+ contains the above copyright notice and this license. These can be
70
+ included either as stand-alone text files, human-readable headers or
71
+ in the appropriate machine-readable metadata fields within text or
72
+ binary files as long as those fields can be easily viewed by the user.
73
+
74
+ 3) No Modified Version of the Font Software may use the Reserved Font
75
+ Name(s) unless explicit written permission is granted by the corresponding
76
+ Copyright Holder. This restriction only applies to the primary font name as
77
+ presented to the users.
78
+
79
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
80
+ Software shall not be used to promote, endorse or advertise any
81
+ Modified Version, except to acknowledge the contribution(s) of the
82
+ Copyright Holder(s) and the Author(s) or with their explicit written
83
+ permission.
84
+
85
+ 5) The Font Software, modified or unmodified, in part or in whole,
86
+ must be distributed entirely under this license, and must not be
87
+ distributed under any other license. The requirement for fonts to
88
+ remain under this license does not apply to any document created
89
+ using the Font Software.
90
+
91
+ TERMINATION
92
+ This license becomes null and void if any of the above conditions are
93
+ not met.
94
+
95
+ DISCLAIMER
96
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
97
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
98
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
99
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
100
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
101
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
102
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
103
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
104
+ OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -0,0 +1,7 @@
1
+ /* Bundled OFL fonts (licence: fonts/OFL.txt). Used only for PDF output, so that PDFs look the same on
2
+ every machine (FR-46). The HTML report does not load them: it stays self-contained (FR-45) and uses
3
+ the font stacks in style.css. */
4
+ @font-face { font-family: "Source Sans 3"; font-weight: 400; font-style: normal; src: url("fonts/SourceSans3-Regular.ttf"); }
5
+ @font-face { font-family: "Source Sans 3"; font-weight: 400; font-style: italic; src: url("fonts/SourceSans3-It.ttf"); }
6
+ @font-face { font-family: "Source Sans 3"; font-weight: 600 700; font-style: normal; src: url("fonts/SourceSans3-Bold.ttf"); }
7
+ @font-face { font-family: "Source Code Pro"; font-weight: 400; font-style: normal; src: url("fonts/SourceCodePro-Regular.ttf"); }
@@ -0,0 +1,38 @@
1
+ {% from "partials/macros.html.j2" import draft_banner %}
2
+ <section id="appendix-a">
3
+ <h2>Appendix A: CVSS 3.1 severity scale</h2>
4
+ {{ draft_banner(redaction) }}
5
+ <p>Scores are CVSS 3.1 base scores calculated from each finding's vector. Informational findings have no score.</p>
6
+ <table>
7
+ <thead><tr><th scope="col">Severity</th><th scope="col">Base score</th></tr></thead>
8
+ <tbody>
9
+ <tr><td><span class="badge badge-none">None</span></td><td>0.0</td></tr>
10
+ <tr><td><span class="badge badge-low">Low</span></td><td>0.1 – 3.9</td></tr>
11
+ <tr><td><span class="badge badge-medium">Medium</span></td><td>4.0 – 6.9</td></tr>
12
+ <tr><td><span class="badge badge-high">High</span></td><td>7.0 – 8.9</td></tr>
13
+ <tr><td><span class="badge badge-critical">Critical</span></td><td>9.0 – 10.0</td></tr>
14
+ </tbody>
15
+ </table>
16
+ </section>
17
+ <section id="appendix-b">
18
+ <h2>Appendix B: Redaction</h2>
19
+ {{ draft_banner(redaction) }}
20
+ {% if redaction.unredacted %}
21
+ <p>This report was not redacted. It may contain secrets and personal data from the evidence. Do not distribute it.</p>
22
+ {% else %}
23
+ <p>Secrets and personal data in evidence and reproduction steps were replaced with <code>[REDACTED:NAME]</code> tokens. Redaction is pattern-based and is a safety net, not a guarantee.</p>
24
+ {% if redaction.counts %}
25
+ <table>
26
+ <thead><tr><th scope="col">Pattern</th><th scope="col">Values redacted</th></tr></thead>
27
+ <tbody>
28
+ {% for name, count in redaction.counts %}
29
+ <tr><td>{{ name }}</td><td>{{ count }}</td></tr>
30
+ {% endfor %}
31
+ </tbody>
32
+ </table>
33
+ {% endif %}
34
+ {% for line in redaction.lines[1:] %}
35
+ <p>{{ line }}</p>
36
+ {% endfor %}
37
+ {% endif %}
38
+ </section>
@@ -0,0 +1,17 @@
1
+ {% from "partials/macros.html.j2" import draft_banner %}
2
+ <header class="cover" id="cover">
3
+ {% if branding.logo_path %}
4
+ <img class="logo" src="{{ image_src(branding.logo_path, branding.logo_mime, branding.logo_asset_name) }}" alt="{{ branding.company_name or engagement.client.name }} logo">
5
+ {% endif %}
6
+ {% if branding.company_name %}
7
+ <p class="company">{{ branding.company_name }}</p>
8
+ {% endif %}
9
+ {{ draft_banner(redaction) }}
10
+ <h1>{{ engagement.title }}</h1>
11
+ <dl>
12
+ <dt>Client</dt><dd>{{ engagement.client.name }}</dd>
13
+ <dt>Report date</dt><dd>{{ engagement.report_date }}</dd>
14
+ <dt>Version</dt><dd>Version {{ engagement.report_version }}</dd>
15
+ <dt>Classification</dt><dd class="classification">{{ engagement.classification }}</dd>
16
+ </dl>
17
+ </header>
@@ -0,0 +1,22 @@
1
+ {% from "partials/macros.html.j2" import draft_banner %}
2
+ <section id="document-control">
3
+ <h2>Document control</h2>
4
+ {{ draft_banner(redaction) }}
5
+ <table>
6
+ <tbody>
7
+ <tr><th scope="row">Report version</th><td>{{ engagement.report_version }}</td></tr>
8
+ <tr><th scope="row">Report date</th><td>{{ engagement.report_date }}</td></tr>
9
+ <tr><th scope="row">Classification</th><td>{{ engagement.classification }}</td></tr>
10
+ <tr><th scope="row">Client</th><td>{{ engagement.client.name }}{% if engagement.client.contact %} ({{ engagement.client.contact }}){% endif %}</td></tr>
11
+ <tr><th scope="row">Testing period</th><td>{{ engagement.start_date }} to {{ engagement.end_date }}</td></tr>
12
+ </tbody>
13
+ </table>
14
+ <table>
15
+ <thead><tr><th scope="col">Tester</th><th scope="col">Role</th><th scope="col">Email</th></tr></thead>
16
+ <tbody>
17
+ {% for tester in engagement.testers %}
18
+ <tr><td>{{ tester.name }}</td><td>{{ tester.role or "" }}</td><td>{{ tester.email or "" }}</td></tr>
19
+ {% endfor %}
20
+ </tbody>
21
+ </table>
22
+ </section>
@@ -0,0 +1,17 @@
1
+ {% from "partials/macros.html.j2" import draft_banner, badge %}
2
+ <section id="executive-summary">
3
+ <h2>Executive summary</h2>
4
+ {{ draft_banner(redaction) }}
5
+ {% if engagement.executive_summary %}
6
+ {{ engagement.executive_summary | markdown }}
7
+ {% endif %}
8
+ <table class="stats">
9
+ <thead><tr><th scope="col">Severity</th><th scope="col">Findings</th></tr></thead>
10
+ <tbody>
11
+ {% for label, count in stats.counts.items() %}
12
+ <tr><th scope="row">{{ label }}</th><td>{{ count }}</td></tr>
13
+ {% endfor %}
14
+ </tbody>
15
+ </table>
16
+ <p>Overall risk: {{ badge(stats.overall_risk) }}</p>
17
+ </section>
@@ -0,0 +1,56 @@
1
+ {% from "partials/macros.html.j2" import badge %}
2
+ <article class="finding" id="{{ finding.anchor }}">
3
+ <h3>{{ finding.id }}: {{ finding.title }}</h3>
4
+ <dl class="finding-meta">
5
+ <dt>Severity</dt><dd>{{ badge(finding.severity) }}</dd>
6
+ {% if finding.score is not none %}
7
+ <dt>CVSS 3.1 score</dt><dd>{{ finding.score_text }} (Impact {{ finding.impact_score }}, Exploitability {{ finding.exploitability_score }})</dd>
8
+ <dt>Vector</dt><dd><code>{{ finding.vector }}</code></dd>
9
+ {% else %}
10
+ <dt>CVSS 3.1 score</dt><dd>N/A (informational)</dd>
11
+ {% endif %}
12
+ <dt>Status</dt><dd>{{ finding.status_label }}</dd>
13
+ {% if finding.cwe %}
14
+ <dt>CWE</dt><dd>{% for number, url in finding.cwe %}<a href="{{ url }}">CWE-{{ number }}</a>{% if not loop.last %}, {% endif %}{% endfor %}</dd>
15
+ {% endif %}
16
+ </dl>
17
+ <h4>Affected assets</h4>
18
+ <ul>
19
+ {% for asset in finding.affected_assets %}
20
+ <li>{{ asset }}</li>
21
+ {% endfor %}
22
+ </ul>
23
+ <h4>Description</h4>
24
+ {{ finding.description | markdown }}
25
+ <h4>Impact</h4>
26
+ {{ finding.impact | markdown }}
27
+ <h4>Steps to reproduce</h4>
28
+ <ol>
29
+ {% for step in finding.steps_to_reproduce %}
30
+ <li>{{ step | markdown_inline }}</li>
31
+ {% endfor %}
32
+ </ol>
33
+ {% if finding.evidence %}
34
+ <h4>Evidence</h4>
35
+ {% for item in finding.evidence %}
36
+ <figure class="evidence">
37
+ <figcaption>Evidence {{ item.number }}: {{ item.caption }}</figcaption>
38
+ {% if item.type == "image" %}
39
+ <img src="{{ image_src(item.image_path, item.mime, item.asset_name) }}" alt="{{ item.caption }}">
40
+ {% else %}
41
+ {{ item.content | highlight(item.language) }}
42
+ {% endif %}
43
+ </figure>
44
+ {% endfor %}
45
+ {% endif %}
46
+ <h4>Remediation</h4>
47
+ {{ finding.remediation | markdown }}
48
+ {% if finding.references %}
49
+ <h4>References</h4>
50
+ <ul>
51
+ {% for url in finding.references %}
52
+ <li><a href="{{ url }}">{{ url }}</a></li>
53
+ {% endfor %}
54
+ </ul>
55
+ {% endif %}
56
+ </article>
@@ -0,0 +1,7 @@
1
+ {% macro draft_banner(redaction) -%}
2
+ {% if redaction.unredacted %}<p class="draft-banner">{{ redaction.banner }}</p>
3
+ {% endif %}
4
+ {%- endmacro %}
5
+ {% macro badge(severity) -%}
6
+ <span class="badge badge-{{ severity.label | lower }}">{{ severity.label }}</span>
7
+ {%- endmacro %}
@@ -0,0 +1,27 @@
1
+ {% from "partials/macros.html.j2" import draft_banner %}
2
+ <section id="scope-and-methodology">
3
+ <h2>Scope and methodology</h2>
4
+ {{ draft_banner(redaction) }}
5
+ <h3>In scope</h3>
6
+ <table>
7
+ <thead><tr><th scope="col">Asset</th><th scope="col">Type</th><th scope="col">Notes</th></tr></thead>
8
+ <tbody>
9
+ {% for asset in engagement.scope.in_scope %}
10
+ <tr><td>{{ asset.asset }}</td><td>{{ asset.type }}</td><td>{{ asset.notes or "" }}</td></tr>
11
+ {% endfor %}
12
+ </tbody>
13
+ </table>
14
+ {% if engagement.scope.out_of_scope %}
15
+ <h3>Out of scope</h3>
16
+ <table>
17
+ <thead><tr><th scope="col">Asset</th><th scope="col">Type</th><th scope="col">Notes</th></tr></thead>
18
+ <tbody>
19
+ {% for asset in engagement.scope.out_of_scope %}
20
+ <tr><td>{{ asset.asset }}</td><td>{{ asset.type }}</td><td>{{ asset.notes or "" }}</td></tr>
21
+ {% endfor %}
22
+ </tbody>
23
+ </table>
24
+ {% endif %}
25
+ <h3>Methodology</h3>
26
+ {{ engagement.methodology | markdown }}
27
+ </section>
@@ -0,0 +1,13 @@
1
+ {% from "partials/macros.html.j2" import draft_banner, badge %}
2
+ <section id="findings-summary">
3
+ <h2>Findings summary</h2>
4
+ {{ draft_banner(redaction) }}
5
+ <table>
6
+ <thead><tr><th scope="col">ID</th><th scope="col">Title</th><th scope="col">Severity</th><th scope="col">Score</th><th scope="col">Status</th></tr></thead>
7
+ <tbody>
8
+ {% for finding in findings %}
9
+ <tr><td><a href="#{{ finding.anchor }}">{{ finding.id }}</a></td><td>{{ finding.title }}</td><td>{{ badge(finding.severity) }}</td><td>{{ finding.score_text }}</td><td>{{ finding.status_label }}</td></tr>
10
+ {% endfor %}
11
+ </tbody>
12
+ </table>
13
+ </section>
@@ -0,0 +1,19 @@
1
+ {% from "partials/macros.html.j2" import draft_banner %}
2
+ <section id="table-of-contents">
3
+ <h2>Table of contents</h2>
4
+ {{ draft_banner(redaction) }}
5
+ <ol class="toc">
6
+ <li><a href="#executive-summary">Executive summary</a></li>
7
+ <li><a href="#scope-and-methodology">Scope and methodology</a></li>
8
+ <li><a href="#findings-summary">Findings summary</a></li>
9
+ <li><a href="#detailed-findings">Detailed findings</a>
10
+ <ol>
11
+ {% for finding in findings %}
12
+ <li><a href="#{{ finding.anchor }}">{{ finding.id }}: {{ finding.title }}</a></li>
13
+ {% endfor %}
14
+ </ol>
15
+ </li>
16
+ <li><a href="#appendix-a">Appendix A: CVSS 3.1 severity scale</a></li>
17
+ <li><a href="#appendix-b">Appendix B: Redaction</a></li>
18
+ </ol>
19
+ </section>