fix: self-host fonts (no Google Fonts request) and crates at 0.4.3 #430

Merged
sharang merged 4 commits from fix/self-host-fonts into main 2026-09-30 20:48:02 +00:00
2 changed files with 30 additions and 8 deletions
Showing only changes of commit 4f5a841ffd - Show all commits

No files matched your search

@@ -124,9 +124,6 @@ pub(super) fn build_html_report(ctx: &ReportContext) -> String {
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Penetration Test Report — {target_name}</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Libre+Baskerville:ital,wght@0,400;0,700;1,400&family=Source+Sans+3:ital,wght@0,300;0,400;0,600;0,700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
{styles_html}
</head>
<body>
@@ -412,6 +409,29 @@ mod tests {
assert!(html.contains("https://example.com"));
}
#[test]
fn report_loads_nothing_from_a_third_party() {
let ctx = make_report_context(
vec![make_finding(Severity::High, "SQL Injection", true)],
vec![make_attack_node("sqlmap")],
);
let html = build_html_report(&ctx);
for needle in [
"googleapis",
"gstatic",
"preconnect",
"<link",
"@import",
"url(http",
"src=\"http",
] {
assert!(!html.contains(needle), "report contains {needle:?}");
}
// The fonts come from the reader's system, with generic fallbacks.
assert!(html.contains("--font-sans:"));
assert!(html.contains("sans-serif;"));
}
#[test]
fn report_contains_requester_info() {
let ctx = make_report_context(vec![], vec![]);
@@ -27,9 +27,11 @@ pub(super) fn styles() -> String {
--sev-medium: #a16207;
--sev-low: #1d4ed8;
--sev-info: #4b5563;
--font-serif: 'Libre Baskerville', 'Georgia', serif;
--font-sans: 'Source Sans 3', 'Helvetica Neue', sans-serif;
--font-mono: 'JetBrains Mono', 'Consolas', monospace;
/* System fonts only: the report is a standalone file and fetches
nothing from a font CDN. The named faces apply where installed. */
--font-serif: 'Libre Baskerville', Georgia, 'Times New Roman', serif;
--font-sans: 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
--font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
}
body {
@@ -642,7 +644,7 @@ table.tools-table td:first-child {
border: 1px solid #fecaca;
border-left: 3px solid #dc2626;
padding: 8px 10px;
font-family: 'JetBrains Mono', monospace;
font-family: var(--font-mono);
font-size: 8pt;
line-height: 1.5;
white-space: pre-wrap;
@@ -655,7 +657,7 @@ table.tools-table td:first-child {
border: 1px solid #bbf7d0;
border-left: 3px solid #16a34a;
padding: 8px 10px;
font-family: 'JetBrains Mono', monospace;
font-family: var(--font-mono);
font-size: 8pt;
line-height: 1.5;
white-space: pre-wrap;