Skip to content

Commit 440bbaf

Browse files
committed
Harden markdown table rendering for monitor output
1 parent 3b80460 commit 440bbaf

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

domain-security-monitor.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,10 @@ def load_domains(args: argparse.Namespace) -> list[str]:
306306
return dedup
307307

308308

309+
def _md_cell(value: Any) -> str:
310+
return str(value).replace("|", "\\|").replace("\n", " ").strip()
311+
312+
309313
def render_markdown(results: list[dict[str, Any]]) -> str:
310314
lines = [
311315
"# Domain Security Monitor Report",
@@ -339,11 +343,11 @@ def render_markdown(results: list[dict[str, Any]]) -> str:
339343
lines.append("")
340344

341345
lines.append("| Signal | Status | Confidence | Data source |")
342-
lines.append("|---|---|---|---|")
346+
lines.append("| --- | --- | --- | --- |")
343347
for name, sig in signals.items():
344348
sig = sig or {}
345349
lines.append(
346-
f"| `{name}` | {sig.get('status', 'unknown')} | {sig.get('confidence', 'low')} | {sig.get('data_source', 'unknown')} |"
350+
f"| {_md_cell(name)} | {_md_cell(sig.get('status', 'unknown'))} | {_md_cell(sig.get('confidence', 'low'))} | {_md_cell(sig.get('data_source', 'unknown'))} |"
347351
)
348352

349353
lines.append("")

0 commit comments

Comments
 (0)