chore: remove generated migration docs
This commit is contained in:
+10
-10
@@ -95,9 +95,9 @@ async def run_cli(args: Any) -> None: # noqa: PLR0915
|
||||
"resume_instruction": getattr(args, "user_explicit_instruction", None) or "",
|
||||
}
|
||||
|
||||
scan_store = ReportState(args.run_name)
|
||||
scan_store.set_scan_config(scan_config)
|
||||
scan_store.hydrate_from_run_dir()
|
||||
report_state = ReportState(args.run_name)
|
||||
report_state.set_scan_config(scan_config)
|
||||
report_state.hydrate_from_run_dir()
|
||||
|
||||
def display_vulnerability(report: dict[str, Any]) -> None:
|
||||
report_id = report.get("id", "unknown")
|
||||
@@ -115,13 +115,13 @@ async def run_cli(args: Any) -> None: # noqa: PLR0915
|
||||
console.print(vuln_panel)
|
||||
console.print()
|
||||
|
||||
scan_store.vulnerability_found_callback = display_vulnerability
|
||||
report_state.vulnerability_found_callback = display_vulnerability
|
||||
|
||||
def cleanup_on_exit() -> None:
|
||||
scan_store.cleanup()
|
||||
report_state.cleanup()
|
||||
|
||||
def signal_handler(_signum: int, _frame: Any) -> None:
|
||||
scan_store.cleanup()
|
||||
report_state.cleanup()
|
||||
sys.exit(1)
|
||||
|
||||
atexit.register(cleanup_on_exit)
|
||||
@@ -130,14 +130,14 @@ async def run_cli(args: Any) -> None: # noqa: PLR0915
|
||||
if hasattr(signal, "SIGHUP"):
|
||||
signal.signal(signal.SIGHUP, signal_handler)
|
||||
|
||||
set_global_report_state(scan_store)
|
||||
set_global_report_state(report_state)
|
||||
|
||||
def create_live_status() -> Panel:
|
||||
status_text = Text()
|
||||
status_text.append("Penetration test in progress", style="bold #22c55e")
|
||||
status_text.append("\n\n")
|
||||
|
||||
stats_text = build_live_stats_text(scan_store)
|
||||
stats_text = build_live_stats_text(report_state)
|
||||
if stats_text:
|
||||
status_text.append(stats_text)
|
||||
|
||||
@@ -196,7 +196,7 @@ async def run_cli(args: Any) -> None: # noqa: PLR0915
|
||||
console.print(f"[bold red]Error during penetration test:[/] {e}")
|
||||
raise
|
||||
|
||||
if scan_store.final_scan_result:
|
||||
if report_state.final_scan_result:
|
||||
console.print()
|
||||
|
||||
final_report_text = Text()
|
||||
@@ -206,7 +206,7 @@ async def run_cli(args: Any) -> None: # noqa: PLR0915
|
||||
Text.assemble(
|
||||
final_report_text,
|
||||
"\n\n",
|
||||
scan_store.final_scan_result,
|
||||
report_state.final_scan_result,
|
||||
),
|
||||
title="[bold white]STRIX",
|
||||
title_align="left",
|
||||
|
||||
@@ -558,11 +558,11 @@ def _load_resume_state(args: argparse.Namespace, parser: argparse.ArgumentParser
|
||||
|
||||
def display_completion_message(args: argparse.Namespace, results_path: Path) -> None:
|
||||
console = Console()
|
||||
scan_store = get_global_report_state()
|
||||
report_state = get_global_report_state()
|
||||
|
||||
scan_completed = False
|
||||
if scan_store and scan_store.scan_results:
|
||||
scan_completed = scan_store.scan_results.get("scan_completed", False)
|
||||
if report_state and report_state.scan_results:
|
||||
scan_completed = report_state.scan_results.get("scan_completed", False)
|
||||
|
||||
completion_text = Text()
|
||||
if scan_completed:
|
||||
@@ -581,7 +581,7 @@ def display_completion_message(args: argparse.Namespace, results_path: Path) ->
|
||||
target_text.append("\n ")
|
||||
target_text.append(target_info["original"], style="white")
|
||||
|
||||
stats_text = build_final_stats_text(scan_store)
|
||||
stats_text = build_final_stats_text(report_state)
|
||||
|
||||
panel_parts: list[Text | str] = [completion_text, "\n\n", target_text]
|
||||
|
||||
@@ -765,16 +765,16 @@ def main() -> None:
|
||||
posthog.error("unhandled_exception", str(e))
|
||||
raise
|
||||
finally:
|
||||
scan_store = get_global_report_state()
|
||||
if scan_store:
|
||||
posthog.end(scan_store, exit_reason=exit_reason)
|
||||
report_state = get_global_report_state()
|
||||
if report_state:
|
||||
posthog.end(report_state, exit_reason=exit_reason)
|
||||
|
||||
results_path = Path("strix_runs") / args.run_name
|
||||
display_completion_message(args, results_path)
|
||||
|
||||
if args.non_interactive:
|
||||
scan_store = get_global_report_state()
|
||||
if scan_store and scan_store.vulnerability_reports:
|
||||
report_state = get_global_report_state()
|
||||
if report_state and report_state.vulnerability_reports:
|
||||
sys.exit(2)
|
||||
|
||||
|
||||
|
||||
+11
-11
@@ -707,12 +707,12 @@ class StrixTUIApp(App): # type: ignore[misc]
|
||||
self.args = args
|
||||
self.scan_config = self._build_scan_config(args)
|
||||
|
||||
self.scan_store = ReportState(self.scan_config["run_name"])
|
||||
self.scan_store.set_scan_config(self.scan_config)
|
||||
self.scan_store.hydrate_from_run_dir()
|
||||
set_global_report_state(self.scan_store)
|
||||
self.report_state = ReportState(self.scan_config["run_name"])
|
||||
self.report_state.set_scan_config(self.scan_config)
|
||||
self.report_state.hydrate_from_run_dir()
|
||||
set_global_report_state(self.report_state)
|
||||
self.live_view = TuiLiveView()
|
||||
self.live_view.hydrate_from_run_dir(self.scan_store.get_run_dir())
|
||||
self.live_view.hydrate_from_run_dir(self.report_state.get_run_dir())
|
||||
self._agent_graph_sync_future: Any | None = None
|
||||
|
||||
# Pre-create the coordinator here so the TUI can route stop/chat
|
||||
@@ -766,10 +766,10 @@ class StrixTUIApp(App): # type: ignore[misc]
|
||||
|
||||
def _setup_cleanup_handlers(self) -> None:
|
||||
def cleanup_on_exit() -> None:
|
||||
self.scan_store.cleanup()
|
||||
self.report_state.cleanup()
|
||||
|
||||
def signal_handler(_signum: int, _frame: Any) -> None:
|
||||
self.scan_store.cleanup()
|
||||
self.report_state.cleanup()
|
||||
sys.exit(0)
|
||||
|
||||
atexit.register(cleanup_on_exit)
|
||||
@@ -1229,7 +1229,7 @@ class StrixTUIApp(App): # type: ignore[misc]
|
||||
|
||||
stats_content = Text()
|
||||
|
||||
stats_text = build_tui_stats_text(self.scan_store)
|
||||
stats_text = build_tui_stats_text(self.report_state)
|
||||
if stats_text:
|
||||
stats_content.append(stats_text)
|
||||
|
||||
@@ -1248,7 +1248,7 @@ class StrixTUIApp(App): # type: ignore[misc]
|
||||
if not self._is_widget_safe(vuln_panel):
|
||||
return
|
||||
|
||||
vulnerabilities = self.scan_store.vulnerability_reports
|
||||
vulnerabilities = self.report_state.vulnerability_reports
|
||||
|
||||
if not vulnerabilities:
|
||||
self._safe_widget_operation(vuln_panel.add_class, "hidden")
|
||||
@@ -1348,7 +1348,7 @@ class StrixTUIApp(App): # type: ignore[misc]
|
||||
|
||||
def _agent_vulnerability_count(self, agent_id: str) -> int:
|
||||
return sum(
|
||||
1 for vuln in self.scan_store.vulnerability_reports if vuln.get("agent_id") == agent_id
|
||||
1 for vuln in self.report_state.vulnerability_reports if vuln.get("agent_id") == agent_id
|
||||
)
|
||||
|
||||
def _gather_agent_events(self, agent_id: str) -> list[dict[str, Any]]:
|
||||
@@ -1734,7 +1734,7 @@ class StrixTUIApp(App): # type: ignore[misc]
|
||||
|
||||
self._scan_thread.join(timeout=1.0)
|
||||
|
||||
self.scan_store.cleanup()
|
||||
self.report_state.cleanup()
|
||||
|
||||
self.exit()
|
||||
|
||||
|
||||
+13
-13
@@ -196,13 +196,13 @@ def format_vulnerability_report(report: dict[str, Any]) -> Text: # noqa: PLR091
|
||||
return text
|
||||
|
||||
|
||||
def _build_vulnerability_stats(stats_text: Text, scan_store: Any) -> None:
|
||||
def _build_vulnerability_stats(stats_text: Text, report_state: Any) -> None:
|
||||
"""Build vulnerability section of stats text."""
|
||||
vuln_count = len(scan_store.vulnerability_reports)
|
||||
vuln_count = len(report_state.vulnerability_reports)
|
||||
|
||||
if vuln_count > 0:
|
||||
severity_counts = {"critical": 0, "high": 0, "medium": 0, "low": 0, "info": 0}
|
||||
for report in scan_store.vulnerability_reports:
|
||||
for report in report_state.vulnerability_reports:
|
||||
severity = report.get("severity", "").lower()
|
||||
if severity in severity_counts:
|
||||
severity_counts[severity] += 1
|
||||
@@ -235,20 +235,20 @@ def _build_vulnerability_stats(stats_text: Text, scan_store: Any) -> None:
|
||||
stats_text.append("\n")
|
||||
|
||||
|
||||
def build_final_stats_text(scan_store: Any) -> Text:
|
||||
def build_final_stats_text(report_state: Any) -> Text:
|
||||
"""Build final stats from Strix-owned scan artifacts."""
|
||||
stats_text = Text()
|
||||
if not scan_store:
|
||||
if not report_state:
|
||||
return stats_text
|
||||
|
||||
_build_vulnerability_stats(stats_text, scan_store)
|
||||
_build_vulnerability_stats(stats_text, report_state)
|
||||
|
||||
return stats_text
|
||||
|
||||
|
||||
def build_live_stats_text(scan_store: Any) -> Text:
|
||||
def build_live_stats_text(report_state: Any) -> Text:
|
||||
stats_text = Text()
|
||||
if not scan_store:
|
||||
if not report_state:
|
||||
return stats_text
|
||||
|
||||
model = load_settings().llm.model or "unknown"
|
||||
@@ -256,13 +256,13 @@ def build_live_stats_text(scan_store: Any) -> Text:
|
||||
stats_text.append(str(model), style="white")
|
||||
stats_text.append("\n")
|
||||
|
||||
vuln_count = len(scan_store.vulnerability_reports)
|
||||
vuln_count = len(report_state.vulnerability_reports)
|
||||
stats_text.append("Vulnerabilities ", style="dim")
|
||||
stats_text.append(f"{vuln_count}", style="white")
|
||||
stats_text.append("\n")
|
||||
if vuln_count > 0:
|
||||
severity_counts = {"critical": 0, "high": 0, "medium": 0, "low": 0, "info": 0}
|
||||
for report in scan_store.vulnerability_reports:
|
||||
for report in report_state.vulnerability_reports:
|
||||
severity = report.get("severity", "").lower()
|
||||
if severity in severity_counts:
|
||||
severity_counts[severity] += 1
|
||||
@@ -287,15 +287,15 @@ def build_live_stats_text(scan_store: Any) -> Text:
|
||||
return stats_text
|
||||
|
||||
|
||||
def build_tui_stats_text(scan_store: Any) -> Text:
|
||||
def build_tui_stats_text(report_state: Any) -> Text:
|
||||
stats_text = Text()
|
||||
if not scan_store:
|
||||
if not report_state:
|
||||
return stats_text
|
||||
|
||||
model = load_settings().llm.model or "unknown"
|
||||
stats_text.append(str(model), style="white")
|
||||
|
||||
caido_url = getattr(scan_store, "caido_url", None)
|
||||
caido_url = getattr(report_state, "caido_url", None)
|
||||
if caido_url:
|
||||
stats_text.append("\n")
|
||||
stats_text.append("Caido: ", style="bold white")
|
||||
|
||||
@@ -114,9 +114,9 @@ def finding(severity: str) -> None:
|
||||
)
|
||||
|
||||
|
||||
def end(scan_store: "ReportState", exit_reason: str = "completed") -> None:
|
||||
def end(report_state: "ReportState", exit_reason: str = "completed") -> None:
|
||||
vulnerabilities_counts = {"critical": 0, "high": 0, "medium": 0, "low": 0, "info": 0}
|
||||
for v in scan_store.vulnerability_reports:
|
||||
for v in report_state.vulnerability_reports:
|
||||
sev = v.get("severity", "info").lower()
|
||||
if sev in vulnerabilities_counts:
|
||||
vulnerabilities_counts[sev] += 1
|
||||
@@ -125,8 +125,8 @@ def end(scan_store: "ReportState", exit_reason: str = "completed") -> None:
|
||||
try:
|
||||
from datetime import datetime
|
||||
|
||||
start = datetime.fromisoformat(scan_store.start_time.replace("Z", "+00:00"))
|
||||
end_iso = scan_store.end_time or datetime.now(start.tzinfo).isoformat()
|
||||
start = datetime.fromisoformat(report_state.start_time.replace("Z", "+00:00"))
|
||||
end_iso = report_state.end_time or datetime.now(start.tzinfo).isoformat()
|
||||
duration = (datetime.fromisoformat(end_iso.replace("Z", "+00:00")) - start).total_seconds()
|
||||
except (ValueError, TypeError, AttributeError):
|
||||
pass
|
||||
@@ -137,7 +137,7 @@ def end(scan_store: "ReportState", exit_reason: str = "completed") -> None:
|
||||
**_base_props(),
|
||||
"exit_reason": exit_reason,
|
||||
"duration_seconds": round(duration),
|
||||
"vulnerabilities_total": len(scan_store.vulnerability_reports),
|
||||
"vulnerabilities_total": len(report_state.vulnerability_reports),
|
||||
**{f"vulnerabilities_{k}": v for k, v in vulnerabilities_counts.items()},
|
||||
},
|
||||
)
|
||||
|
||||
@@ -46,22 +46,22 @@ def _do_finish(
|
||||
try:
|
||||
from strix.report.state import get_global_report_state
|
||||
|
||||
scan_store = get_global_report_state()
|
||||
if scan_store is None:
|
||||
logger.warning("No global scan store; scan results not persisted")
|
||||
report_state = get_global_report_state()
|
||||
if report_state is None:
|
||||
logger.warning("No global report state; scan results not persisted")
|
||||
return {
|
||||
"success": True,
|
||||
"scan_completed": True,
|
||||
"message": "Scan completed (not persisted)",
|
||||
"warning": "Results could not be persisted - scan store unavailable",
|
||||
"warning": "Results could not be persisted - report state unavailable",
|
||||
}
|
||||
scan_store.update_scan_final_fields(
|
||||
report_state.update_scan_final_fields(
|
||||
executive_summary=executive_summary.strip(),
|
||||
methodology=methodology.strip(),
|
||||
technical_analysis=technical_analysis.strip(),
|
||||
recommendations=recommendations.strip(),
|
||||
)
|
||||
vuln_count = len(scan_store.vulnerability_reports)
|
||||
vuln_count = len(report_state.vulnerability_reports)
|
||||
except (ImportError, AttributeError) as e:
|
||||
logger.exception("finish_scan persistence failed")
|
||||
return {"success": False, "message": f"Failed to complete scan: {e!s}"}
|
||||
|
||||
@@ -216,18 +216,18 @@ async def _do_create( # noqa: PLR0912
|
||||
try:
|
||||
from strix.report.state import get_global_report_state
|
||||
|
||||
scan_store = get_global_report_state()
|
||||
if scan_store is None:
|
||||
logger.warning("No global scan store; vulnerability report not persisted")
|
||||
report_state = get_global_report_state()
|
||||
if report_state is None:
|
||||
logger.warning("No global report state; vulnerability report not persisted")
|
||||
return {
|
||||
"success": True,
|
||||
"message": f"Vulnerability report '{title}' created (not persisted)",
|
||||
"warning": "Report could not be persisted - scan store unavailable",
|
||||
"warning": "Report could not be persisted - report state unavailable",
|
||||
}
|
||||
|
||||
from strix.report.dedupe import check_duplicate
|
||||
|
||||
existing = scan_store.get_existing_vulnerabilities()
|
||||
existing = report_state.get_existing_vulnerabilities()
|
||||
candidate = {
|
||||
"title": title,
|
||||
"description": description,
|
||||
@@ -258,7 +258,7 @@ async def _do_create( # noqa: PLR0912
|
||||
"reason": dedupe.get("reason", ""),
|
||||
}
|
||||
|
||||
report_id = scan_store.add_vulnerability_report(
|
||||
report_id = report_state.add_vulnerability_report(
|
||||
title=title,
|
||||
description=description,
|
||||
severity=severity,
|
||||
|
||||
Reference in New Issue
Block a user