auditwright 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.
- auditwright/__init__.py +7 -0
- auditwright/__main__.py +5 -0
- auditwright/_util.py +55 -0
- auditwright/_version.py +1 -0
- auditwright/attack.py +224 -0
- auditwright/cli.py +521 -0
- auditwright/config.py +104 -0
- auditwright/cvss.py +49 -0
- auditwright/deps.py +532 -0
- auditwright/engine.py +108 -0
- auditwright/inventory.py +92 -0
- auditwright/model.py +181 -0
- auditwright/net.py +91 -0
- auditwright/netscan.py +532 -0
- auditwright/pentest.py +405 -0
- auditwright/py.typed +0 -0
- auditwright/report/__init__.py +1 -0
- auditwright/report/formats.py +220 -0
- auditwright/report/html.py +541 -0
- auditwright/rules/__init__.py +1 -0
- auditwright/rules/base.py +136 -0
- auditwright/rules/crypto.py +101 -0
- auditwright/rules/iac.py +572 -0
- auditwright/rules/patterns.py +266 -0
- auditwright/rules/python_ast.py +843 -0
- auditwright/rules/unicode.py +129 -0
- auditwright/secrets.py +216 -0
- auditwright/testgen.py +483 -0
- auditwright/testrun.py +257 -0
- auditwright/walk.py +255 -0
- auditwright-0.1.0.dist-info/METADATA +280 -0
- auditwright-0.1.0.dist-info/RECORD +36 -0
- auditwright-0.1.0.dist-info/WHEEL +4 -0
- auditwright-0.1.0.dist-info/entry_points.txt +2 -0
- auditwright-0.1.0.dist-info/licenses/LICENSE +202 -0
- auditwright-0.1.0.dist-info/licenses/NOTICE +5 -0
|
@@ -0,0 +1,541 @@
|
|
|
1
|
+
"""Self-contained HTML report: a security-operations style dashboard.
|
|
2
|
+
|
|
3
|
+
* No JavaScript and no external requests. Interactivity (theme switch, severity
|
|
4
|
+
filters, expandable findings) is pure CSS.
|
|
5
|
+
* A strict Content-Security-Policy allows only the inline stylesheet, by hash.
|
|
6
|
+
No inline style attributes are used, so nothing needs 'unsafe-inline';
|
|
7
|
+
charts are SVG with presentation attributes.
|
|
8
|
+
* Every value that came from a scanned project is HTML-escaped.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import base64
|
|
14
|
+
import hashlib
|
|
15
|
+
import math
|
|
16
|
+
from collections import Counter
|
|
17
|
+
from html import escape
|
|
18
|
+
|
|
19
|
+
from ..model import CATEGORIES, RANK, SEVERITIES, Finding, Report, score
|
|
20
|
+
|
|
21
|
+
OWASP_TOP10 = [
|
|
22
|
+
("A01", "Broken Access Control"), ("A02", "Cryptographic Failures"), ("A03", "Injection"),
|
|
23
|
+
("A04", "Insecure Design"), ("A05", "Security Misconfiguration"), ("A06", "Vulnerable Components"),
|
|
24
|
+
("A07", "Authentication Failures"), ("A08", "Integrity Failures"), ("A09", "Logging Failures"),
|
|
25
|
+
("A10", "Server-Side Request Forgery"),
|
|
26
|
+
] # fmt: skip
|
|
27
|
+
OWASP_LLM = [
|
|
28
|
+
("LLM01", "Prompt Injection"), ("LLM02", "Sensitive Info Disclosure"), ("LLM03", "Supply Chain"),
|
|
29
|
+
("LLM04", "Data and Model Poisoning"), ("LLM05", "Improper Output Handling"), ("LLM06", "Excessive Agency"),
|
|
30
|
+
("LLM07", "System Prompt Leakage"), ("LLM08", "Vector Weaknesses"), ("LLM09", "Misinformation"),
|
|
31
|
+
("LLM10", "Unbounded Consumption"),
|
|
32
|
+
] # fmt: skip
|
|
33
|
+
SURFACES = [
|
|
34
|
+
("code", "Code"), ("secrets", "Secrets"), ("deps", "Dependencies"), ("supply-chain", "Supply chain"),
|
|
35
|
+
("config", "Config and IaC"), ("ai", "AI and LLM"), ("unicode", "Hidden text"), ("crypto", "Cryptography"),
|
|
36
|
+
("pentest", "Live target"),
|
|
37
|
+
("network", "Network"),
|
|
38
|
+
] # fmt: skip
|
|
39
|
+
THREAT = {
|
|
40
|
+
"critical": ("CRITICAL", "Exploitable weaknesses present. Act now."),
|
|
41
|
+
"high": ("HIGH", "Serious weaknesses need prompt fixes."),
|
|
42
|
+
"medium": ("ELEVATED", "Moderate risk. Schedule fixes."),
|
|
43
|
+
"low": ("GUARDED", "Minor issues only."),
|
|
44
|
+
"info": ("CLEAR", "No actionable weaknesses found."),
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
CSS = """
|
|
48
|
+
:root{--bg:#070b12;--bg2:#0b111c;--panel:#0f1724;--panel2:#131d2d;--line:#1f2b3d;--fg:#dbe6f3;--muted:#7f8ea3;
|
|
49
|
+
--cyan:#22d3ee;--violet:#a78bfa;--green:#34d399;--critical:#ff3d71;--high:#ff6b6b;--medium:#fbbf24;--low:#60a5fa;--info:#94a3b8;
|
|
50
|
+
--glow:0 0 0 1px rgba(34,211,238,.12),0 10px 30px -12px rgba(34,211,238,.25)}
|
|
51
|
+
#theme:checked~.app{--bg:#f4f7fb;--bg2:#eaf0f7;--panel:#ffffff;--panel2:#f6f9fc;--line:#dbe3ee;--fg:#0f1b2b;--muted:#5b6b80;
|
|
52
|
+
--cyan:#0891b2;--violet:#6d28d9;--green:#059669;--critical:#be123c;--high:#dc2626;--medium:#b45309;--low:#2563eb;--info:#64748b;
|
|
53
|
+
--glow:0 1px 2px rgba(15,27,43,.06),0 8px 24px -14px rgba(15,27,43,.25)}
|
|
54
|
+
*{box-sizing:border-box}html,body{margin:0}body{background:#070b12}
|
|
55
|
+
#theme,.flt{position:absolute;opacity:0;pointer-events:none}
|
|
56
|
+
.app{min-height:100vh;overflow-x:hidden;background:var(--bg);color:var(--fg);font:14px/1.55 Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif;
|
|
57
|
+
background-image:linear-gradient(rgba(34,211,238,.035) 1px,transparent 1px),linear-gradient(90deg,rgba(34,211,238,.035) 1px,transparent 1px);background-size:32px 32px}
|
|
58
|
+
.wrap{max-width:1240px;margin:0 auto;padding:22px 22px 70px}
|
|
59
|
+
.mono,code,pre{font-family:"JetBrains Mono",ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
|
|
60
|
+
.top{display:flex;flex-wrap:wrap;align-items:center;gap:10px 14px;justify-content:space-between;border-bottom:1px solid var(--line);padding-bottom:14px}
|
|
61
|
+
.brand{display:flex;align-items:center;gap:10px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;font-size:13px}
|
|
62
|
+
.brand svg{flex:none}.brand b{color:var(--cyan)}.meta{color:var(--muted);font-size:12px;text-align:right}
|
|
63
|
+
.toggle{cursor:pointer;border:1px solid var(--line);border-radius:999px;padding:4px 12px;font-size:12px;color:var(--muted);user-select:none;background:var(--panel)}
|
|
64
|
+
.toggle:hover{color:var(--fg);border-color:var(--cyan)}
|
|
65
|
+
nav{display:flex;flex-wrap:wrap;gap:6px;margin:14px 0 4px}nav a{color:var(--muted);text-decoration:none;font-size:12px;letter-spacing:.04em;
|
|
66
|
+
text-transform:uppercase;border:1px solid var(--line);border-radius:8px;padding:4px 10px;background:var(--panel)}nav a:hover{color:var(--cyan);border-color:var(--cyan)}
|
|
67
|
+
h2{font-size:13px;letter-spacing:.14em;text-transform:uppercase;color:var(--muted);margin:30px 0 12px;display:flex;align-items:center;gap:10px}
|
|
68
|
+
h2::before{content:"";width:8px;height:8px;border-radius:2px;background:var(--cyan);box-shadow:0 0 12px var(--cyan)}
|
|
69
|
+
h3{margin:0 0 10px;font-size:14px}.panel{background:linear-gradient(180deg,var(--panel),var(--panel2));border:1px solid var(--line);border-radius:14px;padding:16px 18px;box-shadow:var(--glow)}
|
|
70
|
+
.grid{display:grid;gap:14px}.grid>*,.heat>*{min-width:0}.hero{grid-template-columns:300px 1fr}.g2{grid-template-columns:repeat(auto-fit,minmax(min(340px,100%),1fr))}
|
|
71
|
+
.g5{grid-template-columns:repeat(5,minmax(0,1fr))}.g3{grid-template-columns:repeat(auto-fit,minmax(min(190px,100%),1fr))}
|
|
72
|
+
@media (max-width:860px){.hero{grid-template-columns:minmax(0,1fr)}.g5{grid-template-columns:repeat(2,minmax(0,1fr))}}
|
|
73
|
+
.gauge{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center}
|
|
74
|
+
.gauge .ring-bg{stroke:var(--line)}.gauge .ring{stroke-linecap:round}
|
|
75
|
+
.gA .ring,.gB .ring{stroke:var(--green)}.gC .ring{stroke:var(--medium)}.gD .ring,.gF .ring{stroke:var(--critical)}
|
|
76
|
+
.gauge .grade{font-size:40px;font-weight:800;fill:var(--fg)}.gauge .sub{font-size:9px;fill:var(--muted);letter-spacing:.08em}
|
|
77
|
+
.threat{border-radius:12px;padding:12px 14px;margin-bottom:12px;border:1px solid var(--line);display:flex;align-items:center;gap:12px}
|
|
78
|
+
.threat .lvl{font-weight:800;letter-spacing:.16em;font-size:13px;padding:3px 10px;border-radius:6px}
|
|
79
|
+
.t-critical .lvl{background:var(--critical);color:#fff;box-shadow:0 0 18px var(--critical);animation:pulse 2s infinite}.t-high .lvl{background:var(--high);color:#fff}
|
|
80
|
+
.t-medium .lvl{background:var(--medium);color:#111}.t-low .lvl{background:var(--low);color:#fff}.t-info .lvl{background:var(--green);color:#062}
|
|
81
|
+
@keyframes pulse{50%{box-shadow:0 0 4px var(--critical)}}
|
|
82
|
+
.kpi{border-radius:12px;padding:12px 14px;background:var(--panel);border:1px solid var(--line);position:relative;overflow:hidden}
|
|
83
|
+
.kpi::after{content:"";position:absolute;inset:auto 0 0 0;height:3px}.kpi .n{font-size:30px;font-weight:800;line-height:1.1}.kpi .l{color:var(--muted);font-size:11px;letter-spacing:.12em;text-transform:uppercase}
|
|
84
|
+
.k-critical .n{color:var(--critical)}.k-critical::after{background:var(--critical);box-shadow:0 0 14px var(--critical)}.k-high .n{color:var(--high)}.k-high::after{background:var(--high)}
|
|
85
|
+
.k-medium .n{color:var(--medium)}.k-medium::after{background:var(--medium)}.k-low .n{color:var(--low)}.k-low::after{background:var(--low)}.k-info .n{color:var(--info)}.k-info::after{background:var(--info)}
|
|
86
|
+
.sevbar{margin-top:12px}.sevbar rect.critical,.bars rect.critical{fill:var(--critical)}.sevbar rect.high,.bars rect.high{fill:var(--high)}
|
|
87
|
+
.sevbar rect.medium,.bars rect.medium{fill:var(--medium)}.sevbar rect.low,.bars rect.low{fill:var(--low)}.sevbar rect.info,.bars rect.info{fill:var(--info)}
|
|
88
|
+
.sevbar rect.track,.bars rect.track{fill:var(--line)}.bars rect.ok{fill:var(--green)}.bars rect.bad{fill:var(--critical)}.bars rect.cy{fill:var(--cyan)}
|
|
89
|
+
.surface{display:flex;align-items:center;gap:10px;padding:10px 12px;border:1px solid var(--line);border-radius:10px;background:var(--panel)}
|
|
90
|
+
.led{width:10px;height:10px;border-radius:50%;flex:none}.led.critical{background:var(--critical);box-shadow:0 0 10px var(--critical)}.led.high{background:var(--high);box-shadow:0 0 8px var(--high)}
|
|
91
|
+
.led.medium{background:var(--medium)}.led.low{background:var(--low)}.led.ok{background:var(--green);box-shadow:0 0 8px var(--green)}.led.off{background:var(--line)}
|
|
92
|
+
.surface .c{margin-left:auto;font-weight:700}.surface .s{color:var(--muted);font-size:12px}
|
|
93
|
+
.heat{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:8px}.cell{border-radius:10px;padding:9px 10px;border:1px solid var(--line);min-height:70px}
|
|
94
|
+
.cell .id{font-size:11px;letter-spacing:.1em;color:var(--muted)}.cell .nm{font-size:11.5px;font-weight:600;line-height:1.25;margin:2px 0 4px;overflow-wrap:break-word;hyphens:auto}.cell .ct{font-weight:800;font-size:18px}
|
|
95
|
+
.h0{background:var(--panel)}.h0 .ct{color:var(--muted)}.h1{background:rgba(96,165,250,.12);border-color:rgba(96,165,250,.35)}.h2{background:rgba(251,191,36,.14);border-color:rgba(251,191,36,.4)}
|
|
96
|
+
.h3{background:rgba(255,107,107,.16);border-color:rgba(255,107,107,.45)}.h4{background:rgba(255,61,113,.24);border-color:var(--critical);box-shadow:0 0 16px -4px var(--critical)}
|
|
97
|
+
@media (max-width:860px){.heat{grid-template-columns:repeat(2,minmax(0,1fr))}}
|
|
98
|
+
.fix li{margin:0 0 8px;list-style:none;display:flex;gap:10px;align-items:flex-start}.fix ol{padding:0;margin:0}
|
|
99
|
+
.sev{display:inline-block;flex:none;white-space:nowrap;min-width:74px;text-align:center;padding:1px 8px;border-radius:6px;font-size:11px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}
|
|
100
|
+
.sev.critical{background:var(--critical);color:#fff}.sev.high{background:var(--high);color:#fff}.sev.medium{background:var(--medium);color:#111}.sev.low{background:var(--low);color:#fff}.sev.info{background:var(--info);color:#fff}
|
|
101
|
+
.loc{color:var(--muted);font-size:12px;word-break:break-all}.chip{display:inline-block;border:1px solid var(--line);border-radius:6px;padding:0 7px;font-size:11px;color:var(--muted);margin:2px 4px 0 0}
|
|
102
|
+
.filters{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:12px}.filters label{cursor:pointer;border:1px solid var(--line);border-radius:8px;padding:5px 12px;font-size:12px;background:var(--panel);color:var(--muted);user-select:none}
|
|
103
|
+
#fa:checked~.filters .la,#fc:checked~.filters .lc,#fh:checked~.filters .lh,#fm:checked~.filters .lm,#fl:checked~.filters .ll{color:var(--fg);border-color:var(--cyan);box-shadow:0 0 0 1px var(--cyan) inset}
|
|
104
|
+
#fc:checked~.list .f:not(.critical){display:none}#fh:checked~.list .f:not(.critical):not(.high){display:none}
|
|
105
|
+
#fm:checked~.list .f.low,#fm:checked~.list .f.info{display:none}#fl:checked~.list .f.info{display:none}
|
|
106
|
+
#fc:checked~.list .cat:not(.has-critical),#fh:checked~.list .cat:not(.has-high){display:none}
|
|
107
|
+
.cat{margin-bottom:14px}.cat>h3{display:flex;gap:8px;align-items:center}.cat>h3 span{color:var(--muted);font-weight:500}
|
|
108
|
+
details.f{border:1px solid var(--line);border-left:4px solid var(--info);border-radius:10px;margin:0 0 8px;background:var(--panel);overflow:hidden}
|
|
109
|
+
details.f.critical{border-left-color:var(--critical)}details.f.high{border-left-color:var(--high)}details.f.medium{border-left-color:var(--medium)}details.f.low{border-left-color:var(--low)}
|
|
110
|
+
details.f>summary{cursor:pointer;list-style:none;display:flex;gap:12px;align-items:baseline;padding:10px 12px}details.f>summary::-webkit-details-marker{display:none}
|
|
111
|
+
details.f>summary:hover{background:var(--panel2)}details.f[open]>summary{border-bottom:1px solid var(--line)}
|
|
112
|
+
.fb{padding:10px 14px 12px}.term{background:#05080e;color:#c9fbe9;border:1px solid var(--line);border-radius:8px;padding:0;margin:8px 0;overflow:hidden}
|
|
113
|
+
.term .bar{display:flex;gap:6px;padding:6px 10px;background:#0b1220;border-bottom:1px solid #1a2333}.term .bar i{width:9px;height:9px;border-radius:50%;background:#334155}
|
|
114
|
+
.term .bar span{margin-left:8px;color:#7f8ea3;font-size:11px}.term pre{margin:0;padding:10px 12px;white-space:pre-wrap;word-break:break-word;font-size:12.5px}
|
|
115
|
+
.term .ln{color:#4b5b72;user-select:none;margin-right:12px}.fixbox{border:1px dashed var(--green);border-radius:8px;padding:8px 10px;margin-top:8px}
|
|
116
|
+
.fixbox b{color:var(--green);letter-spacing:.08em;font-size:11px;text-transform:uppercase;margin-right:6px}
|
|
117
|
+
table{width:100%;border-collapse:collapse}th,td{text-align:left;padding:7px 8px;border-bottom:1px solid var(--line);vertical-align:top}
|
|
118
|
+
th{font-size:11px;text-transform:uppercase;letter-spacing:.1em;color:var(--muted);font-weight:600}.ok{color:var(--green)}.bad{color:var(--critical)}.muted{color:var(--muted)}
|
|
119
|
+
.big{font-size:26px;font-weight:800}footer{margin-top:44px;color:var(--muted);font-size:12px;border-top:1px solid var(--line);padding-top:14px}
|
|
120
|
+
.gauge svg{width:min(190px,60vw);height:auto}.meta .mono{word-break:break-all}
|
|
121
|
+
details.f>summary>span{min-width:0;overflow-wrap:anywhere}
|
|
122
|
+
@media (max-width:600px){.wrap{padding:14px 12px 50px}.top{flex-direction:column;align-items:flex-start}.meta{text-align:left}
|
|
123
|
+
.toggle{align-self:flex-start}nav a{padding:3px 8px;font-size:11px}h2{margin-top:22px}.panel{padding:12px 13px;border-radius:12px}
|
|
124
|
+
.kpi .n{font-size:24px}.g5{grid-template-columns:repeat(3,minmax(0,1fr))}.heat{grid-template-columns:repeat(2,minmax(0,1fr))}
|
|
125
|
+
details.f>summary{flex-wrap:wrap;gap:6px 10px}.sev{min-width:0}.threat{flex-direction:column;align-items:flex-start}.threat>span{min-width:0;overflow-wrap:anywhere}.fix li>span{min-width:0;overflow-wrap:anywhere}
|
|
126
|
+
table{display:block;overflow-x:auto;white-space:nowrap}td .loc,td.loc{white-space:normal}.big{font-size:22px}.term pre{font-size:11.5px}}
|
|
127
|
+
.attack{border:1px solid rgba(255,61,113,.45);background:rgba(255,61,113,.07);border-radius:8px;padding:8px 10px;margin-top:8px}
|
|
128
|
+
.attack b{color:var(--critical);letter-spacing:.08em;font-size:11px;text-transform:uppercase;margin-right:6px}
|
|
129
|
+
.chains{display:grid;gap:14px}.chain{border:1px solid var(--line);border-left:4px solid var(--critical);border-radius:12px;padding:14px 16px;
|
|
130
|
+
background:linear-gradient(90deg,rgba(255,61,113,.10),transparent 40%),var(--panel)}.chain.high{border-left-color:var(--high)}
|
|
131
|
+
.chain h3{display:flex;gap:10px;align-items:center;flex-wrap:wrap}.chain p{margin:6px 0 10px;color:var(--muted)}
|
|
132
|
+
.path{display:flex;flex-wrap:wrap;align-items:stretch;gap:8px}.step{flex:1 1 200px;min-width:0;border:1px solid var(--line);border-radius:10px;padding:8px 10px;background:var(--bg2)}
|
|
133
|
+
.step .k{font-size:10px;letter-spacing:.14em;color:var(--muted);text-transform:uppercase}.step .t{font-weight:700;margin:2px 0}.step .loc{overflow-wrap:anywhere}
|
|
134
|
+
.arrow{align-self:center;color:var(--critical);font-weight:800;font-size:18px}
|
|
135
|
+
@media (max-width:600px){.arrow{transform:rotate(90deg);width:100%;text-align:center}}
|
|
136
|
+
@media print{.toggle,nav,.filters{display:none}details.f{break-inside:avoid}details.f>.fb{display:block}.app{background:#fff}}
|
|
137
|
+
"""
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def _e(v: object) -> str:
|
|
141
|
+
return escape(str(v), quote=True)
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def _sev(s: str) -> str:
|
|
145
|
+
return f'<span class="sev {_e(s)}">{_e(s)}</span>'
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def _hbar(parts: list[tuple[str, float]], total: float, height: int = 12) -> str:
|
|
149
|
+
"""Horizontal stacked bar as SVG (no inline styles, so the strict CSP holds)."""
|
|
150
|
+
x = 0.0
|
|
151
|
+
rects = [f'<rect class="track" x="0" y="0" width="1000" height="{height}" rx="{height // 2}"/>']
|
|
152
|
+
for cls, value in parts:
|
|
153
|
+
if value <= 0 or total <= 0:
|
|
154
|
+
continue
|
|
155
|
+
w = max(4.0, value / total * 1000)
|
|
156
|
+
rects.append(f'<rect class="{_e(cls)}" x="{x:.1f}" y="0" width="{w:.1f}" height="{height}"/>')
|
|
157
|
+
x += w
|
|
158
|
+
return f'<svg class="bars" viewBox="0 0 1000 {height}" preserveAspectRatio="none" width="100%" height="{height}" role="img">{"".join(rects)}</svg>'
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def _gauge(value: int, grade: str) -> str:
|
|
162
|
+
c = 2 * math.pi * 52
|
|
163
|
+
filled = c * value / 100
|
|
164
|
+
return (
|
|
165
|
+
f'<svg class="g{_e(grade)}" viewBox="0 0 120 120" width="190" height="190" role="img" aria-label="risk score {value} of 100">'
|
|
166
|
+
f'<circle class="ring-bg" cx="60" cy="60" r="52" fill="none" stroke-width="10"/>'
|
|
167
|
+
f'<circle class="ring" cx="60" cy="60" r="52" fill="none" stroke-width="10" transform="rotate(-90 60 60)" stroke-dasharray="{filled:.1f} {c:.1f}"/>'
|
|
168
|
+
f'<text class="grade" x="60" y="62" text-anchor="middle">{_e(grade)}</text>'
|
|
169
|
+
f'<text class="sub" x="60" y="80" text-anchor="middle">{value} / 100</text></svg>'
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def _heat(count: int, worst: str | None) -> str:
|
|
174
|
+
if not count:
|
|
175
|
+
return "h0"
|
|
176
|
+
return {"critical": "h4", "high": "h3", "medium": "h2"}.get(worst or "", "h1")
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
def _snippet(f: Finding) -> str:
|
|
180
|
+
where = f"{f.file}:{f.line}" if f.line else (f.file or "evidence")
|
|
181
|
+
ln = f'<span class="ln">{f.line}</span>' if f.line else ""
|
|
182
|
+
return (
|
|
183
|
+
f'<div class="term"><div class="bar"><i></i><i></i><i></i><span class="mono">{_e(where)}</span></div>'
|
|
184
|
+
f"<pre>{ln}{_e(f.snippet)}</pre></div>"
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def _label(f: Finding) -> str:
|
|
189
|
+
"""Summary line: the title, plus the package and advisory for dependency findings."""
|
|
190
|
+
x = f.extra if isinstance(f.extra, dict) else {}
|
|
191
|
+
if x.get("package"):
|
|
192
|
+
adv = x.get("cve") or x.get("advisory") or ""
|
|
193
|
+
return f'<b>{_e(x["package"])}</b> <span class="mono">{_e(x.get("version", ""))}</span> <span class="muted">{_e(adv)}</span>'
|
|
194
|
+
return f"<b>{_e(f.title)}</b>"
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def render(report: Report, title: str = "Security Assessment") -> str: # noqa: C901 - one linear page
|
|
198
|
+
counts = report.counts()
|
|
199
|
+
sc = score(report)
|
|
200
|
+
worst = next((s for s in reversed(SEVERITIES) if counts[s] and s != "info"), "info")
|
|
201
|
+
css_hash = base64.b64encode(hashlib.sha256(CSS.encode()).digest()).decode()
|
|
202
|
+
by_cat = report.by_category()
|
|
203
|
+
out: list[str] = []
|
|
204
|
+
a = out.append
|
|
205
|
+
|
|
206
|
+
a('<!doctype html><html lang="en"><head><meta charset="utf-8">')
|
|
207
|
+
a(
|
|
208
|
+
f"<meta http-equiv=\"Content-Security-Policy\" content=\"default-src 'none'; style-src 'sha256-{css_hash}'; img-src data:; base-uri 'none'; form-action 'none'\">"
|
|
209
|
+
)
|
|
210
|
+
a(
|
|
211
|
+
'<meta name="viewport" content="width=device-width,initial-scale=1"><meta name="referrer" content="no-referrer"><meta name="color-scheme" content="dark light">'
|
|
212
|
+
)
|
|
213
|
+
a(f"<title>{_e(title)} | {_e(report.target)}</title><style>{CSS}</style></head><body>")
|
|
214
|
+
a('<input type="checkbox" id="theme"><div class="app"><div class="wrap">')
|
|
215
|
+
|
|
216
|
+
# header
|
|
217
|
+
a('<div class="top"><div class="brand"><svg width="30" height="30" viewBox="0 0 32 32" aria-hidden="true">'
|
|
218
|
+
'<path d="M16 2 4 7v8c0 7.5 5.1 13.4 12 15 6.9-1.6 12-7.5 12-15V7z" fill="none" stroke="currentColor" stroke-width="2"/>'
|
|
219
|
+
'<path d="m10 16 4 4 8-9" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"/></svg>'
|
|
220
|
+
f'<span><b>Auditwright</b> · {_e(title)}</span></div>'
|
|
221
|
+
f'<div class="meta"><div class="mono">{_e(report.target)}</div><div>{_e(report.finished or report.started)} · v{_e(report.tool_version)}</div></div>'
|
|
222
|
+
'<label class="toggle" for="theme">Light / dark</label></div>') # fmt: skip
|
|
223
|
+
a('<nav><a href="#overview">Overview</a><a href="#paths">Attack paths</a><a href="#surface">Attack surface</a><a href="#standards">Standards</a><a href="#findings">Findings</a>'
|
|
224
|
+
'<a href="#deps">Dependencies</a><a href="#crypto">Crypto</a><a href="#tests">Tests</a><a href="#web">Live target</a><a href="#network">Network</a><a href="#project">Project</a></nav>') # fmt: skip
|
|
225
|
+
|
|
226
|
+
# overview
|
|
227
|
+
lvl, desc = THREAT[worst]
|
|
228
|
+
a('<h2 id="overview">Threat overview</h2><div class="grid hero">')
|
|
229
|
+
a(f'<div class="panel gauge">{_gauge(sc["score"], sc["grade"])}<div class="muted">Risk grade</div></div><div>')
|
|
230
|
+
a(f'<div class="threat panel t-{_e(worst)}"><span class="lvl">{lvl}</span><span>{_e(desc)} '
|
|
231
|
+
f'<span class="muted">{len(report.findings)} findings across {len(by_cat)} areas · {report.suppressed} suppressed · {report.baseline_matched} in baseline</span></span></div>') # fmt: skip
|
|
232
|
+
a(
|
|
233
|
+
'<div class="grid g5">'
|
|
234
|
+
+ "".join(
|
|
235
|
+
f'<div class="kpi k-{s}"><div class="n">{counts[s]}</div><div class="l">{s}</div></div>'
|
|
236
|
+
for s in reversed(SEVERITIES)
|
|
237
|
+
)
|
|
238
|
+
+ "</div>"
|
|
239
|
+
)
|
|
240
|
+
a('<div class="sevbar">' + _hbar([(s, counts[s]) for s in reversed(SEVERITIES)], sum(counts.values())) + "</div>")
|
|
241
|
+
top = [f for f in report.sorted_findings() if RANK[f.severity] >= RANK["high"]][:6]
|
|
242
|
+
a('<div class="panel fix"><h3>Fix first</h3>')
|
|
243
|
+
if top:
|
|
244
|
+
a(
|
|
245
|
+
"<ol>"
|
|
246
|
+
+ "".join(
|
|
247
|
+
f'<li>{_sev(f.severity)}<span>{_label(f)}<div class="loc mono">{_e(f.file)}{":" + str(f.line) if f.line else ""}</div></span></li>'
|
|
248
|
+
for f in top
|
|
249
|
+
)
|
|
250
|
+
+ "</ol>"
|
|
251
|
+
)
|
|
252
|
+
else:
|
|
253
|
+
a('<p class="ok">No high or critical findings.</p>')
|
|
254
|
+
a("</div></div></div>")
|
|
255
|
+
if report.errors:
|
|
256
|
+
a(
|
|
257
|
+
'<div class="panel"><h3 class="bad">Incomplete checks</h3><ul>'
|
|
258
|
+
+ "".join(f"<li>{_e(e)}</li>" for e in report.errors)
|
|
259
|
+
+ "</ul></div>"
|
|
260
|
+
)
|
|
261
|
+
|
|
262
|
+
# attack paths
|
|
263
|
+
chains = [f for f in report.findings if f.category == "chain"]
|
|
264
|
+
if chains:
|
|
265
|
+
a(f'<h2 id="paths">Attack paths ({len(chains)})</h2><div class="chains">')
|
|
266
|
+
for ch in chains:
|
|
267
|
+
a(f'<div class="chain {_e(ch.severity)}"><h3>{_sev(ch.severity)}{_e(ch.title)}</h3>')
|
|
268
|
+
a(f'<p>{_e(ch.message.split(" Path: ")[0])}</p><div class="path">')
|
|
269
|
+
steps = ch.extra.get("steps", []) if isinstance(ch.extra, dict) else []
|
|
270
|
+
for i, st in enumerate(steps):
|
|
271
|
+
if i:
|
|
272
|
+
a('<span class="arrow" aria-hidden="true">→</span>')
|
|
273
|
+
loc = f"{st.get('file', '')}:{st.get('line')}" if st.get("line") else st.get("file", "")
|
|
274
|
+
a(f'<div class="step"><div class="k">{("Entry point" if i == 0 else "Impact" if i == len(steps) - 1 else "Escalation")}</div><div class="t">{_e(st.get("title", ""))}</div>'
|
|
275
|
+
f'<div class="loc mono">{_e(loc)}</div></div>') # fmt: skip
|
|
276
|
+
a("</div></div>")
|
|
277
|
+
a("</div>")
|
|
278
|
+
|
|
279
|
+
# attack surface
|
|
280
|
+
a('<h2 id="surface">Attack surface</h2><div class="grid g3">')
|
|
281
|
+
ran = set(report.analyzers)
|
|
282
|
+
for key, label in SURFACES:
|
|
283
|
+
items = by_cat.get(key, [])
|
|
284
|
+
analyzer = {"supply-chain": "deps", "ai": "code"}.get(key, key)
|
|
285
|
+
if items:
|
|
286
|
+
w = max(items, key=lambda f: RANK[f.severity]).severity
|
|
287
|
+
led = w if w in ("critical", "high", "medium", "low") else "low"
|
|
288
|
+
status = f"worst: {w}"
|
|
289
|
+
elif analyzer in ran or (key == "supply-chain" and "config" in ran):
|
|
290
|
+
led, status = "ok", "no findings"
|
|
291
|
+
else:
|
|
292
|
+
led, status = "off", "not scanned"
|
|
293
|
+
a(
|
|
294
|
+
f'<div class="surface"><span class="led {led}"></span><div><div>{_e(label)}</div><div class="s">{_e(status)}</div></div><span class="c">{len(items)}</span></div>'
|
|
295
|
+
)
|
|
296
|
+
a("</div>")
|
|
297
|
+
|
|
298
|
+
# standards heatmaps
|
|
299
|
+
a('<h2 id="standards">Standards coverage</h2><div class="grid g2">')
|
|
300
|
+
for heading, catalog in (
|
|
301
|
+
("OWASP Top 10 (2021)", OWASP_TOP10),
|
|
302
|
+
("OWASP Top 10 for LLM Applications (2025)", OWASP_LLM),
|
|
303
|
+
):
|
|
304
|
+
a(f'<div class="panel"><h3>{_e(heading)}</h3><div class="heat">')
|
|
305
|
+
for code, name in catalog:
|
|
306
|
+
hits = [f for f in report.findings if f.owasp.startswith(code + ":")]
|
|
307
|
+
w = max((f.severity for f in hits), key=lambda s: RANK[s], default=None)
|
|
308
|
+
a(
|
|
309
|
+
f'<div class="cell {_heat(len(hits), w)}"><div class="id mono">{code}</div><div class="nm">{_e(name)}</div><div class="ct">{len(hits)}</div></div>'
|
|
310
|
+
)
|
|
311
|
+
a("</div></div>")
|
|
312
|
+
a("</div>")
|
|
313
|
+
cwe = Counter(f.cwe for f in report.findings if f.cwe).most_common(10)
|
|
314
|
+
if cwe:
|
|
315
|
+
mx = cwe[0][1]
|
|
316
|
+
a('<div class="panel"><h3>Top weaknesses (CWE)</h3><table><tbody>')
|
|
317
|
+
for k, v in cwe:
|
|
318
|
+
a(f'<tr><td class="mono">{_e(k)}</td><td>{_hbar([("cy", v)], mx, 8)}</td><td>{v}</td></tr>')
|
|
319
|
+
a("</tbody></table></div>")
|
|
320
|
+
|
|
321
|
+
# findings
|
|
322
|
+
a(f'<h2 id="findings">Findings ({len(report.findings)})</h2>')
|
|
323
|
+
if not report.findings:
|
|
324
|
+
a('<div class="panel ok">No findings. Nothing to fix.</div>')
|
|
325
|
+
else:
|
|
326
|
+
a('<input class="flt" type="radio" name="flt" id="fa" checked><input class="flt" type="radio" name="flt" id="fc">'
|
|
327
|
+
'<input class="flt" type="radio" name="flt" id="fh"><input class="flt" type="radio" name="flt" id="fm"><input class="flt" type="radio" name="flt" id="fl">'
|
|
328
|
+
f'<div class="filters"><label class="la" for="fa">All {len(report.findings)}</label><label class="lc" for="fc">Critical {counts["critical"]}</label>'
|
|
329
|
+
f'<label class="lh" for="fh">High and above {counts["critical"] + counts["high"]}</label><label class="lm" for="fm">Medium and above</label>'
|
|
330
|
+
'<label class="ll" for="fl">Hide info</label></div><div class="list">') # fmt: skip
|
|
331
|
+
for cat, items in by_cat.items():
|
|
332
|
+
sevs = {f.severity for f in items}
|
|
333
|
+
flags = " ".join(f"has-{s}" for s in sevs) + (" has-high" if "critical" in sevs else "")
|
|
334
|
+
a(f'<div class="cat {flags}"><h3>{_e(CATEGORIES.get(cat, cat))} <span>{len(items)}</span></h3>')
|
|
335
|
+
for f in items[:2000]:
|
|
336
|
+
loc = f"{f.file}:{f.line}" if f.line else f.file
|
|
337
|
+
a(
|
|
338
|
+
f'<details class="f {_e(f.severity)}"><summary>{_sev(f.severity)}<span>{_label(f)} <span class="loc mono">{_e(loc)}</span></span></summary><div class="fb">'
|
|
339
|
+
)
|
|
340
|
+
a(f"<div>{_e(f.message)}</div>")
|
|
341
|
+
if f.snippet:
|
|
342
|
+
a(_snippet(f))
|
|
343
|
+
a(
|
|
344
|
+
"<div>"
|
|
345
|
+
+ "".join(
|
|
346
|
+
f'<span class="chip mono">{_e(t)}</span>'
|
|
347
|
+
for t in (f.rule_id, f.cwe, f.owasp, f"confidence {f.confidence}")
|
|
348
|
+
if t
|
|
349
|
+
)
|
|
350
|
+
+ "</div>"
|
|
351
|
+
)
|
|
352
|
+
attack = f.extra.get("attack") if isinstance(f.extra, dict) else None
|
|
353
|
+
if attack:
|
|
354
|
+
a(f'<div class="attack"><b>How an attacker uses this</b>{_e(attack)}</div>')
|
|
355
|
+
if f.fix:
|
|
356
|
+
a(f'<div class="fixbox"><b>Fix</b>{_e(f.fix)}</div>')
|
|
357
|
+
url = f.extra.get("url") if isinstance(f.extra, dict) else None
|
|
358
|
+
if url and str(url).startswith("https://"):
|
|
359
|
+
a(f'<div class="loc mono">advisory: {_e(url)}</div>')
|
|
360
|
+
a("</div></details>")
|
|
361
|
+
if len(items) > 2000:
|
|
362
|
+
a(f'<p class="muted">{len(items) - 2000} more in the JSON report.</p>')
|
|
363
|
+
a("</div>")
|
|
364
|
+
a("</div>")
|
|
365
|
+
|
|
366
|
+
# dependencies
|
|
367
|
+
a(f'<h2 id="deps">Dependencies ({len(report.dependencies)})</h2>')
|
|
368
|
+
if report.dependencies:
|
|
369
|
+
vulnerable = [d for d in report.dependencies if d.get("vulns")]
|
|
370
|
+
eco = Counter(d["ecosystem"] for d in report.dependencies)
|
|
371
|
+
a('<div class="grid g2"><div class="panel"><h3>Inventory</h3>')
|
|
372
|
+
a(
|
|
373
|
+
f'<div class="big">{len(report.dependencies)}</div><div class="muted">packages resolved from lockfiles and manifests</div>'
|
|
374
|
+
)
|
|
375
|
+
a(
|
|
376
|
+
_hbar(
|
|
377
|
+
[("bad", len(vulnerable)), ("ok", len(report.dependencies) - len(vulnerable))],
|
|
378
|
+
len(report.dependencies),
|
|
379
|
+
10,
|
|
380
|
+
)
|
|
381
|
+
)
|
|
382
|
+
a(
|
|
383
|
+
f'<p><span class="bad">{len(vulnerable)} vulnerable</span> · '
|
|
384
|
+
+ " ".join(f'<span class="chip">{_e(k)} {v}</span>' for k, v in eco.most_common())
|
|
385
|
+
+ "</p></div>"
|
|
386
|
+
)
|
|
387
|
+
sev_dep = Counter(v["severity"] for d in vulnerable for v in d["vulns"])
|
|
388
|
+
a(
|
|
389
|
+
'<div class="panel"><h3>Advisories by severity</h3>'
|
|
390
|
+
+ _hbar([(s, sev_dep[s]) for s in reversed(SEVERITIES)], sum(sev_dep.values()) or 1, 10)
|
|
391
|
+
)
|
|
392
|
+
a("<p>" + " ".join(f"{_sev(s)} {sev_dep[s]}" for s in reversed(SEVERITIES) if sev_dep[s]) + "</p></div></div>")
|
|
393
|
+
if vulnerable:
|
|
394
|
+
a(
|
|
395
|
+
'<div class="panel"><table><thead><tr><th>Package</th><th>Version</th><th>Advisories</th><th>Fixed in</th></tr></thead><tbody>'
|
|
396
|
+
)
|
|
397
|
+
for d in sorted(vulnerable, key=lambda d: -max(RANK[v["severity"]] for v in d["vulns"]))[:500]:
|
|
398
|
+
adv = " ".join(f'{_sev(v["severity"])} <span class="mono">{_e(v["id"])}</span>' for v in d["vulns"][:6])
|
|
399
|
+
fixed = ", ".join(sorted({x for v in d["vulns"] for x in v.get("fixed", [])}))
|
|
400
|
+
a(
|
|
401
|
+
f'<tr><td><b>{_e(d["name"])}</b><div class="loc">{_e(d["ecosystem"])} · {_e(d["file"])}</div></td><td class="mono">{_e(d["version"])}</td><td>{adv}</td><td class="mono">{_e(fixed or "none yet")}</td></tr>'
|
|
402
|
+
)
|
|
403
|
+
a("</tbody></table></div>")
|
|
404
|
+
else:
|
|
405
|
+
a('<div class="panel muted">No lockfiles or pinned manifests found.</div>')
|
|
406
|
+
|
|
407
|
+
# crypto
|
|
408
|
+
a('<h2 id="crypto">Cryptography and post-quantum readiness</h2>')
|
|
409
|
+
inv = report.crypto_inventory
|
|
410
|
+
if inv:
|
|
411
|
+
vuln = sum(1 for c in inv if c["quantum_vulnerable"])
|
|
412
|
+
pq = sum(1 for c in inv if c["family"].startswith("Post-quantum"))
|
|
413
|
+
a('<div class="grid g2"><div class="panel"><h3>Quantum exposure</h3>')
|
|
414
|
+
a(
|
|
415
|
+
f'<div class="big">{vuln}</div><div class="muted">files using public-key algorithms that a quantum computer breaks (Shor)</div>'
|
|
416
|
+
)
|
|
417
|
+
a(_hbar([("bad", vuln), ("ok", pq), ("cy", len(inv) - vuln - pq)], len(inv), 10))
|
|
418
|
+
a(
|
|
419
|
+
f'<p class="muted">{pq} post-quantum, {len(inv) - vuln - pq} symmetric. Migrate key exchange to ML-KEM (FIPS 203), signatures to ML-DSA / SLH-DSA (FIPS 204/205).</p></div>'
|
|
420
|
+
)
|
|
421
|
+
a('<div class="panel"><table><thead><tr><th>Family</th><th>Quantum-safe</th><th>Where</th></tr></thead><tbody>')
|
|
422
|
+
for c in inv[:200]:
|
|
423
|
+
safe = '<span class="bad">no</span>' if c["quantum_vulnerable"] else '<span class="ok">yes</span>'
|
|
424
|
+
a(
|
|
425
|
+
f'<tr><td>{_e(c["family"])}<div class="loc">{_e(c["use"])}</div></td><td>{safe}</td><td class="loc mono">{_e(c["file"])}:{_e(",".join(map(str, c["lines"][:5])))}</td></tr>'
|
|
426
|
+
)
|
|
427
|
+
a("</tbody></table></div></div>")
|
|
428
|
+
else:
|
|
429
|
+
a('<div class="panel muted">No cryptographic primitives detected in source.</div>')
|
|
430
|
+
|
|
431
|
+
# tests
|
|
432
|
+
a('<h2 id="tests">Tests</h2>')
|
|
433
|
+
if report.test_runs:
|
|
434
|
+
a('<div class="grid g2">')
|
|
435
|
+
for run in report.test_runs:
|
|
436
|
+
c = run.counts()
|
|
437
|
+
total = sum(c.values()) or 1
|
|
438
|
+
ok = run.exit_code == 0 and not c["failed"] and not c["error"]
|
|
439
|
+
cov = f" · coverage {run.coverage:.1f}%" if run.coverage is not None else ""
|
|
440
|
+
a(
|
|
441
|
+
f'<div class="panel"><h3>{_e(run.framework)} <span class="{"ok" if ok else "bad"}">{"PASS" if ok else "FAIL"}</span></h3>'
|
|
442
|
+
)
|
|
443
|
+
a(_hbar([("ok", c["passed"]), ("bad", c["failed"] + c["error"]), ("info", c["skipped"])], total, 10))
|
|
444
|
+
a(
|
|
445
|
+
f"<p>{c['passed']} passed · {c['failed']} failed · {c['error']} errors · {c['skipped']} skipped · {run.duration:.1f}s{cov}</p>"
|
|
446
|
+
)
|
|
447
|
+
if run.error:
|
|
448
|
+
a(f'<p class="bad">{_e(run.error)}</p>')
|
|
449
|
+
for t in [t for t in run.cases if t.status in ("failed", "error")][:25]:
|
|
450
|
+
a(
|
|
451
|
+
f'<details class="f high"><summary>{_sev("failed")}<span class="mono">{_e(t.classname)}::{_e(t.name)}</span></summary><div class="fb"><div class="term"><pre>{_e(t.message[:800])}</pre></div></div></details>'
|
|
452
|
+
)
|
|
453
|
+
a(f'<div class="loc mono">$ {_e(" ".join(run.command))}</div></div>')
|
|
454
|
+
a("</div>")
|
|
455
|
+
else:
|
|
456
|
+
a(
|
|
457
|
+
'<div class="panel muted">Tests were not run. Use <code>auditwright test</code> or <code>auditwright full --run-tests</code>.</div>'
|
|
458
|
+
)
|
|
459
|
+
|
|
460
|
+
# live target
|
|
461
|
+
a('<h2 id="web">Live target</h2>')
|
|
462
|
+
if report.pentest:
|
|
463
|
+
a(
|
|
464
|
+
'<div class="panel"><table><tbody>'
|
|
465
|
+
+ "".join(f'<tr><th>{_e(k)}</th><td class="mono">{_e(v)}</td></tr>' for k, v in report.pentest.items())
|
|
466
|
+
+ "</tbody></table></div>"
|
|
467
|
+
)
|
|
468
|
+
else:
|
|
469
|
+
a(
|
|
470
|
+
'<div class="panel muted">No live target tested. Use <code>auditwright pentest https://your-site --i-am-authorized</code>.</div>'
|
|
471
|
+
)
|
|
472
|
+
|
|
473
|
+
# network
|
|
474
|
+
net = report.network
|
|
475
|
+
if net:
|
|
476
|
+
host_ids = {h["host"] for h in net.get("hosts", [])}
|
|
477
|
+
a(f'<h2 id="network">Network ({_e(net.get("live_hosts", 0))} live hosts)</h2>')
|
|
478
|
+
kpis = (("scanned_hosts", "hosts scanned"), ("live_hosts", "live hosts"), ("open_ports", "open ports"),
|
|
479
|
+
("ports_checked", "ports per host"), ("duration_s", "seconds")) # fmt: skip
|
|
480
|
+
a(
|
|
481
|
+
'<div class="grid g5">'
|
|
482
|
+
+ "".join(
|
|
483
|
+
f'<div class="kpi k-info"><div class="n">{_e(net.get(k, 0))}</div><div class="l">{lbl}</div></div>'
|
|
484
|
+
for k, lbl in kpis
|
|
485
|
+
)
|
|
486
|
+
+ "</div>"
|
|
487
|
+
)
|
|
488
|
+
by_host: dict[str, list[Finding]] = {}
|
|
489
|
+
for f in report.findings:
|
|
490
|
+
hid = f.file.split("://")[-1].split(":")[0].rstrip("/")
|
|
491
|
+
if hid in host_ids:
|
|
492
|
+
by_host.setdefault(hid, []).append(f)
|
|
493
|
+
a('<div class="grid g2">')
|
|
494
|
+
for h in net.get("hosts", []):
|
|
495
|
+
hf = by_host.get(h["host"], [])
|
|
496
|
+
worst = max((f.severity for f in hf), key=lambda s: RANK[s], default=None)
|
|
497
|
+
led = worst if worst in ("critical", "high", "medium", "low") else "ok"
|
|
498
|
+
a(
|
|
499
|
+
f'<div class="panel"><h3><span class="led {led}"></span> <span class="mono">{_e(h["host"])}</span> <span class="muted">{len(h["services"])} open</span></h3><table><tbody>'
|
|
500
|
+
)
|
|
501
|
+
for svc in h["services"]:
|
|
502
|
+
a(
|
|
503
|
+
f'<tr><td class="mono">{_e(svc["port"])}</td><td>{_e(svc["service"])}</td><td class="loc">{_e(svc.get("banner", ""))}</td></tr>'
|
|
504
|
+
)
|
|
505
|
+
a("</tbody></table>")
|
|
506
|
+
for f in sorted(hf, key=lambda x: -RANK[x.severity])[:8]:
|
|
507
|
+
a(f'<div>{_sev(f.severity)} {_e(f.title)} <span class="loc mono">{_e(f.file)}</span></div>')
|
|
508
|
+
a("</div>")
|
|
509
|
+
a("</div>")
|
|
510
|
+
|
|
511
|
+
# project
|
|
512
|
+
pinv = report.inventory
|
|
513
|
+
a('<h2 id="project">Project profile</h2><div class="grid g2"><div class="panel"><h3>Languages</h3><table><tbody>')
|
|
514
|
+
langs = list((pinv.get("languages") or {}).items())[:12]
|
|
515
|
+
mx = max((v["lines"] for _, v in langs), default=1) or 1
|
|
516
|
+
for lang, v in langs:
|
|
517
|
+
a(
|
|
518
|
+
f'<tr><td>{_e(lang)}</td><td>{_hbar([("cy", v["lines"])], mx, 8)}</td><td class="mono">{v["lines"]:,}</td></tr>'
|
|
519
|
+
)
|
|
520
|
+
a('</tbody></table></div><div class="panel"><h3>Stack and controls</h3><table><tbody>')
|
|
521
|
+
for label, key in (("Frameworks", "frameworks"), ("AI SDKs", "ai_sdks"), ("Tests", "test_frameworks"), ("CI", "ci"),
|
|
522
|
+
("Containers", "containers"), ("Infrastructure", "iac")): # fmt: skip
|
|
523
|
+
a(f"<tr><th>{label}</th><td>{_e(', '.join(pinv.get(key) or []) or '-')}</td></tr>")
|
|
524
|
+
for k, v in (pinv.get("controls") or {}).items():
|
|
525
|
+
if isinstance(v, list):
|
|
526
|
+
a(f'<tr><th>{_e(k.replace("_", " "))}</th><td class="mono">{_e(", ".join(v) or "none")}</td></tr>')
|
|
527
|
+
else:
|
|
528
|
+
state = '<span class="ok">present</span>' if v else '<span class="bad">missing</span>'
|
|
529
|
+
a(f"<tr><th>{_e(k.replace('_', ' '))}</th><td>{state}</td></tr>")
|
|
530
|
+
a(
|
|
531
|
+
f'<tr><th>Files scanned</th><td class="mono">{_e(pinv.get("files_scanned", 0))}</td></tr></tbody></table></div></div>'
|
|
532
|
+
)
|
|
533
|
+
|
|
534
|
+
for note in report.notes:
|
|
535
|
+
a(f'<div class="panel muted">{_e(note)}</div>')
|
|
536
|
+
a('<footer>Static analysis reads source, configuration, lockfiles and optionally git history without running project code. '
|
|
537
|
+
'Python is analysed on its syntax tree with taint tracking; other languages with line rules. Advisories come from OSV.dev. '
|
|
538
|
+
'Automated analysis finds many but not all weaknesses and can report false positives: a clean report is not proof of security. '
|
|
539
|
+
f'Generated by Auditwright {_e(report.tool_version)}.</footer>') # fmt: skip
|
|
540
|
+
a("</div></div></body></html>")
|
|
541
|
+
return "".join(out)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Analyzers and rule definitions."""
|