FastAPI + Kali tools UI for authorized scans of levkin.ca / LAN targets. Gitignore local data/.env; add pytest + gitleaks CI.
61 lines
1.9 KiB
Python
61 lines
1.9 KiB
Python
from app.export import render_bulk_json, render_bulk_markdown
|
|
|
|
|
|
def _sample_payload() -> dict:
|
|
return {
|
|
"bulk": {
|
|
"id": "bulk-1",
|
|
"profile": "standard",
|
|
"status": "complete",
|
|
"created_at": "2026-05-27T15:00:00+00:00",
|
|
"completed_at": "2026-05-27T16:00:00+00:00",
|
|
"total": 1,
|
|
"complete": 1,
|
|
"failed": 0,
|
|
"running": 0,
|
|
"queued": 0,
|
|
},
|
|
"scans": [
|
|
{
|
|
"scan": {
|
|
"id": "scan-1",
|
|
"target": "auth.example.com",
|
|
"profile": "standard",
|
|
"status": "complete",
|
|
"llm_unavailable": False,
|
|
},
|
|
"phases": [
|
|
{
|
|
"name": "port_scan",
|
|
"status": "complete",
|
|
"tool": "nmap",
|
|
"raw_output": "80/tcp open",
|
|
}
|
|
],
|
|
"findings": [
|
|
{
|
|
"severity": "low",
|
|
"title": "Uncommon HTTP Headers",
|
|
"description": "Custom headers present.",
|
|
"evidence": "x-custom: 1",
|
|
"recommendation": "Review headers.",
|
|
}
|
|
],
|
|
}
|
|
],
|
|
}
|
|
|
|
|
|
def test_render_bulk_markdown_includes_target_and_finding():
|
|
text = render_bulk_markdown(_sample_payload(), for_cursor=True)
|
|
assert "auth.example.com" in text
|
|
assert "Uncommon HTTP Headers" in text
|
|
assert "paste into Cursor" in text
|
|
|
|
|
|
def test_render_bulk_json_truncates_long_output():
|
|
payload = _sample_payload()
|
|
payload["scans"][0]["phases"][0]["raw_output"] = "x" * 5000
|
|
out = render_bulk_json(payload)
|
|
assert len(out["scans"][0]["phases"][0]["raw_output"]) < 5000
|