secfoo 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.

Potentially problematic release.


This version of secfoo might be problematic. Click here for more details.

Files changed (58) hide show
  1. secfoo/__about__.py +1 -0
  2. secfoo/__init__.py +3 -0
  3. secfoo/agents/__init__.py +4 -0
  4. secfoo/agents/antigravity.py +47 -0
  5. secfoo/agents/base.py +113 -0
  6. secfoo/agents/claude.py +36 -0
  7. secfoo/agents/cursor.py +26 -0
  8. secfoo/agents/gemini.py +38 -0
  9. secfoo/agents/registry.py +22 -0
  10. secfoo/cli.py +243 -0
  11. secfoo/config.py +21 -0
  12. secfoo/report/__init__.py +3 -0
  13. secfoo/report/markdown.py +43 -0
  14. secfoo/runner.py +197 -0
  15. secfoo/skills/__init__.py +11 -0
  16. secfoo/skills/definitions/deployment-readiness.md +42 -0
  17. secfoo/skills/definitions/prompt-review.md +44 -0
  18. secfoo/skills/definitions/responsible-ai-compliance.md +41 -0
  19. secfoo/skills/definitions/threat-assessment.md +41 -0
  20. secfoo/skills/loader.py +77 -0
  21. secfoo/skills/renderer.py +149 -0
  22. secfoo/storage/__init__.py +4 -0
  23. secfoo/storage/models.py +33 -0
  24. secfoo/storage/repository.py +154 -0
  25. secfoo/storage/schema.sql +30 -0
  26. secfoo/targets/__init__.py +19 -0
  27. secfoo/targets/github.py +35 -0
  28. secfoo/targets/resolver.py +50 -0
  29. secfoo/web/__init__.py +0 -0
  30. secfoo/web/app.py +19 -0
  31. secfoo/web/routes/__init__.py +0 -0
  32. secfoo/web/routes/overview.py +20 -0
  33. secfoo/web/routes/projects.py +22 -0
  34. secfoo/web/routes/runs.py +41 -0
  35. secfoo/web/static/design-system/README.md +108 -0
  36. secfoo/web/static/design-system/base.css +91 -0
  37. secfoo/web/static/design-system/components/alerts.css +49 -0
  38. secfoo/web/static/design-system/components/badges.css +48 -0
  39. secfoo/web/static/design-system/components/buttons.css +120 -0
  40. secfoo/web/static/design-system/components/cards.css +72 -0
  41. secfoo/web/static/design-system/components/forms.css +108 -0
  42. secfoo/web/static/design-system/components/modal.css +63 -0
  43. secfoo/web/static/design-system/components/navigation.css +79 -0
  44. secfoo/web/static/design-system/components/tables.css +38 -0
  45. secfoo/web/static/design-system/components/tabs.css +40 -0
  46. secfoo/web/static/design-system/demo.html +222 -0
  47. secfoo/web/static/design-system/design-system.css +18 -0
  48. secfoo/web/static/design-system/tokens.css +146 -0
  49. secfoo/web/templates/base.html +31 -0
  50. secfoo/web/templates/overview.html +48 -0
  51. secfoo/web/templates/project.html +25 -0
  52. secfoo/web/templates/run_detail.html +50 -0
  53. secfoo/web/templating.py +38 -0
  54. secfoo-0.1.0.dist-info/METADATA +73 -0
  55. secfoo-0.1.0.dist-info/RECORD +58 -0
  56. secfoo-0.1.0.dist-info/WHEEL +4 -0
  57. secfoo-0.1.0.dist-info/entry_points.txt +2 -0
  58. secfoo-0.1.0.dist-info/licenses/LICENSE +202 -0
secfoo/__about__.py ADDED
@@ -0,0 +1 @@
1
+ __version__ = "0.1.0"
secfoo/__init__.py ADDED
@@ -0,0 +1,3 @@
1
+ from secfoo.__about__ import __version__
2
+
3
+ __all__ = ["__version__"]
@@ -0,0 +1,4 @@
1
+ from secfoo.agents.base import AgentAdapter, AgentResult
2
+ from secfoo.agents.registry import ADAPTERS, get_adapter
3
+
4
+ __all__ = ["AgentAdapter", "AgentResult", "ADAPTERS", "get_adapter"]
@@ -0,0 +1,47 @@
1
+ """Google Antigravity CLI adapter.
2
+
3
+ Verified against a real `agy --help` (Aug 2026): `-p`/`--print` runs a
4
+ single prompt non-interactively and prints the response as plain text to
5
+ stdout (no `--output-format`/JSON mode exists, unlike Claude Code and
6
+ Gemini CLI -- so the base class's default `extract_report`, which returns
7
+ stdout as-is, is correct here and deliberately not overridden).
8
+
9
+ `agy --print` has its own internal timeout (`--print-timeout`, default
10
+ `5m0s`) independent of the timeout this package enforces at the subprocess
11
+ level. Without passing it explicitly, `agy` could silently truncate a long
12
+ review well before our own (longer) timeout fires, so `build_command()`
13
+ sets `--print-timeout` to match whatever effective timeout `run()` is using.
14
+
15
+ Deliberately does NOT pass `--dangerously-skip-permissions`: headless mode
16
+ soft-denies any tool call requiring approval rather than hanging, and a
17
+ read-only review should never need that flag.
18
+
19
+ OBSERVED FLAKINESS (Aug 2026, real testing): on at least one machine, `agy
20
+ --print` sometimes exits 0 with completely empty stdout, and on repeated
21
+ calls has failed outright with `Error: Agent execution terminated due to
22
+ error.` on stderr. Both are handled correctly by this adapter (empty output
23
+ renders as "no report content" in the dashboard rather than crashing;
24
+ non-zero exit is captured as status="failed" with the stderr message
25
+ preserved) -- but this suggests the CLI itself is still unstable this early
26
+ in its release. If Antigravity runs are unreliable, prefer another agent.
27
+ """
28
+
29
+ from __future__ import annotations
30
+
31
+ from pathlib import Path
32
+
33
+ from secfoo.agents.base import AgentAdapter, AgentResult
34
+
35
+
36
+ class AntigravityAdapter(AgentAdapter):
37
+ name = "agy"
38
+ binary = "agy"
39
+ default_timeout_seconds = 1800
40
+
41
+ def build_command(self, prompt: str, *, workdir: Path) -> list[str]:
42
+ effective_timeout = getattr(self, "_effective_timeout", self.default_timeout_seconds)
43
+ return [self.binary, "--print", prompt, "--print-timeout", f"{effective_timeout}s"]
44
+
45
+ def run(self, prompt: str, *, workdir: Path, timeout: int | None = None) -> AgentResult:
46
+ self._effective_timeout = timeout or self.default_timeout_seconds
47
+ return super().run(prompt, workdir=workdir, timeout=timeout)
secfoo/agents/base.py ADDED
@@ -0,0 +1,113 @@
1
+ """Common subprocess execution contract for every agent adapter.
2
+
3
+ Concrete adapters only need to implement `build_command()` and, optionally,
4
+ `extract_report()` for CLIs that wrap their answer in a JSON envelope. All
5
+ timeout/kill/binary-detection behavior lives here so it's implemented once
6
+ and correctly.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import os
12
+ import shutil
13
+ import signal
14
+ import subprocess
15
+ import time
16
+ from abc import ABC, abstractmethod
17
+ from dataclasses import dataclass
18
+ from pathlib import Path
19
+ from typing import ClassVar, Literal
20
+
21
+ Status = Literal["success", "failed", "timeout", "binary_not_found"]
22
+
23
+
24
+ @dataclass
25
+ class AgentResult:
26
+ agent: str
27
+ exit_code: int | None
28
+ stdout: str
29
+ stderr: str
30
+ duration_seconds: float
31
+ timed_out: bool
32
+ status: Status
33
+ raw_report: str
34
+
35
+
36
+ class AgentAdapter(ABC):
37
+ name: ClassVar[str]
38
+ binary: ClassVar[str]
39
+ default_timeout_seconds: ClassVar[int] = 1800
40
+
41
+ def is_available(self) -> bool:
42
+ return shutil.which(self.binary) is not None
43
+
44
+ @abstractmethod
45
+ def build_command(self, prompt: str, *, workdir: Path) -> list[str]:
46
+ """Return the argv to invoke this agent non-interactively with `prompt`."""
47
+
48
+ def extract_report(self, stdout: str) -> str:
49
+ """Pull the report text out of raw stdout. Default: stdout is the report."""
50
+ return stdout
51
+
52
+ def run(self, prompt: str, *, workdir: Path, timeout: int | None = None) -> AgentResult:
53
+ if not self.is_available():
54
+ return AgentResult(
55
+ agent=self.name,
56
+ exit_code=None,
57
+ stdout="",
58
+ stderr=f"binary {self.binary!r} not found on PATH",
59
+ duration_seconds=0.0,
60
+ timed_out=False,
61
+ status="binary_not_found",
62
+ raw_report="",
63
+ )
64
+
65
+ cmd = self.build_command(prompt, workdir=workdir)
66
+ effective_timeout = timeout or self.default_timeout_seconds
67
+ started = time.monotonic()
68
+
69
+ # Driven via Popen (rather than subprocess.run) so that on timeout we
70
+ # can killpg() the whole process group. subprocess.run's own timeout
71
+ # handling only kills the direct child, which is not enough to
72
+ # reliably contain Cursor's documented `agent -p` hang bug if it
73
+ # spawns any grandchildren.
74
+ proc = subprocess.Popen(
75
+ cmd,
76
+ cwd=workdir,
77
+ stdin=subprocess.DEVNULL,
78
+ stdout=subprocess.PIPE,
79
+ stderr=subprocess.PIPE,
80
+ text=True,
81
+ start_new_session=True,
82
+ )
83
+ try:
84
+ stdout, stderr = proc.communicate(timeout=effective_timeout)
85
+ duration = time.monotonic() - started
86
+ status: Status = "success" if proc.returncode == 0 else "failed"
87
+ return AgentResult(
88
+ agent=self.name,
89
+ exit_code=proc.returncode,
90
+ stdout=stdout,
91
+ stderr=stderr,
92
+ duration_seconds=duration,
93
+ timed_out=False,
94
+ status=status,
95
+ raw_report=self.extract_report(stdout) if status == "success" else "",
96
+ )
97
+ except subprocess.TimeoutExpired:
98
+ try:
99
+ os.killpg(os.getpgid(proc.pid), signal.SIGKILL)
100
+ except ProcessLookupError:
101
+ pass
102
+ stdout, stderr = proc.communicate()
103
+ duration = time.monotonic() - started
104
+ return AgentResult(
105
+ agent=self.name,
106
+ exit_code=None,
107
+ stdout=stdout,
108
+ stderr=stderr,
109
+ duration_seconds=duration,
110
+ timed_out=True,
111
+ status="timeout",
112
+ raw_report="",
113
+ )
@@ -0,0 +1,36 @@
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ from pathlib import Path
5
+
6
+ from secfoo.agents.base import AgentAdapter
7
+
8
+ # Minimal read-only tool grant: the assessment only needs to read the
9
+ # target and look at git history/diffs, never to edit anything.
10
+ ALLOWED_TOOLS = "Read,Grep,Glob,Bash(git log:*),Bash(git diff:*)"
11
+
12
+
13
+ class ClaudeAdapter(AgentAdapter):
14
+ name = "claude"
15
+ binary = "claude"
16
+ default_timeout_seconds = 1800
17
+
18
+ def build_command(self, prompt: str, *, workdir: Path) -> list[str]:
19
+ return [
20
+ self.binary,
21
+ "-p",
22
+ prompt,
23
+ "--output-format",
24
+ "json",
25
+ "--allowedTools",
26
+ ALLOWED_TOOLS,
27
+ "--permission-mode",
28
+ "default",
29
+ ]
30
+
31
+ def extract_report(self, stdout: str) -> str:
32
+ try:
33
+ payload = json.loads(stdout)
34
+ except json.JSONDecodeError:
35
+ return stdout
36
+ return payload.get("result", stdout)
@@ -0,0 +1,26 @@
1
+ """Cursor CLI adapter.
2
+
3
+ KNOWN ISSUE (as of Aug 2026): the `agent -p` headless/print mode has a
4
+ documented bug where it can hang indefinitely and never return
5
+ (https://forum.cursor.com/t/cursor-agent-p-print-headless-mode-hangs-indefinitely-and-never-returns/150246).
6
+ Do not remove or loosen the hard timeout in AgentAdapter.run() for this
7
+ adapter — it is the only thing standing between this bug and a `secfoo
8
+ run` invocation that never completes. The shorter default timeout below is
9
+ intentional: we'd rather fail fast and let the user retry than tie up a
10
+ batch run.
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ from pathlib import Path
16
+
17
+ from secfoo.agents.base import AgentAdapter
18
+
19
+
20
+ class CursorAdapter(AgentAdapter):
21
+ name = "agent"
22
+ binary = "agent"
23
+ default_timeout_seconds = 900
24
+
25
+ def build_command(self, prompt: str, *, workdir: Path) -> list[str]:
26
+ return [self.binary, "-p", prompt]
@@ -0,0 +1,38 @@
1
+ """Gemini CLI adapter.
2
+
3
+ Flags verified against a real `gemini --help` (Aug 2026): `-p`/`--prompt`
4
+ for headless mode, `-o`/`--output-format json` for structured output.
5
+
6
+ Note: on individual/free-tier accounts, Google has been migrating users to
7
+ Antigravity CLI -- a real invocation on such an account fails fast with
8
+ `IneligibleTierError` rather than hanging, which surfaces correctly here as
9
+ `status="failed"` with the error in `stderr`. If this adapter consistently
10
+ fails with that error, prefer the `antigravity` agent instead.
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ import json
16
+ from pathlib import Path
17
+
18
+ from secfoo.agents.base import AgentAdapter
19
+
20
+
21
+ class GeminiAdapter(AgentAdapter):
22
+ name = "gemini"
23
+ binary = "gemini"
24
+ default_timeout_seconds = 1800
25
+
26
+ def build_command(self, prompt: str, *, workdir: Path) -> list[str]:
27
+ # Deliberately no --yolo: a read-only review never needs
28
+ # auto-approved write access, and we'd rather a blocked tool call
29
+ # show up as a lower-quality report than silently grant it edit
30
+ # rights.
31
+ return [self.binary, "-p", prompt, "--output-format", "json"]
32
+
33
+ def extract_report(self, stdout: str) -> str:
34
+ try:
35
+ payload = json.loads(stdout)
36
+ except json.JSONDecodeError:
37
+ return stdout
38
+ return payload.get("response", payload.get("result", stdout))
@@ -0,0 +1,22 @@
1
+ from __future__ import annotations
2
+
3
+ from secfoo.agents.antigravity import AntigravityAdapter
4
+ from secfoo.agents.base import AgentAdapter
5
+ from secfoo.agents.claude import ClaudeAdapter
6
+ from secfoo.agents.cursor import CursorAdapter
7
+ from secfoo.agents.gemini import GeminiAdapter
8
+
9
+ ADAPTERS: dict[str, type[AgentAdapter]] = {
10
+ ClaudeAdapter.name: ClaudeAdapter,
11
+ CursorAdapter.name: CursorAdapter,
12
+ AntigravityAdapter.name: AntigravityAdapter,
13
+ GeminiAdapter.name: GeminiAdapter,
14
+ }
15
+
16
+
17
+ def get_adapter(agent_id: str) -> AgentAdapter:
18
+ try:
19
+ return ADAPTERS[agent_id]()
20
+ except KeyError:
21
+ available = ", ".join(sorted(ADAPTERS))
22
+ raise ValueError(f"unknown agent id {agent_id!r}. Available: {available}") from None
secfoo/cli.py ADDED
@@ -0,0 +1,243 @@
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ from enum import Enum
5
+ from pathlib import Path
6
+ from typing import Optional
7
+
8
+ import typer
9
+ from rich.console import Console
10
+ from rich.progress import Progress, SpinnerColumn, TextColumn
11
+ from rich.table import Table
12
+
13
+ from secfoo.agents.registry import ADAPTERS, get_adapter
14
+ from secfoo.runner import execute_runs
15
+ from secfoo.storage.repository import RunRepository
16
+ from secfoo.targets.resolver import TargetResolutionError
17
+
18
+ app = typer.Typer(name="secfoo", help="Context-based security architectural assessment.")
19
+ console = Console()
20
+ err_console = Console(stderr=True)
21
+
22
+
23
+ class SkillId(str, Enum):
24
+ THREAT_ASSESSMENT = "threat-assessment"
25
+ PROMPT_REVIEW = "prompt-review"
26
+ RESPONSIBLE_AI = "responsible-ai-compliance"
27
+ DEPLOYMENT_READINESS = "deployment-readiness"
28
+
29
+
30
+ class AgentId(str, Enum):
31
+ CLAUDE = "claude"
32
+ CURSOR = "agent"
33
+ ANTIGRAVITY = "agy"
34
+ GEMINI = "gemini"
35
+
36
+
37
+ class DepthId(str, Enum):
38
+ QUICK = "quick"
39
+ STANDARD = "standard"
40
+
41
+
42
+ _STATUS_STYLE = {
43
+ "success": "green",
44
+ "failed": "red",
45
+ "timeout": "yellow",
46
+ "binary_not_found": "red",
47
+ "running": "cyan",
48
+ }
49
+
50
+
51
+ @app.command()
52
+ def run(
53
+ skill: list[SkillId] = typer.Option(
54
+ ..., "--skill", "-s", help="Security skill to run. Repeatable."
55
+ ),
56
+ target: Optional[str] = typer.Option(
57
+ None, "--target", "-t", help="GitHub URL or local directory. Defaults to the current directory."
58
+ ),
59
+ confluence: list[str] = typer.Option(
60
+ [], "--confluence", "-c", help="Confluence page URL for extra context. Repeatable."
61
+ ),
62
+ agent: AgentId = typer.Option(
63
+ AgentId.CLAUDE, "--agent", "-a", help="Which agent CLI runs the assessment."
64
+ ),
65
+ depth: DepthId = typer.Option(
66
+ DepthId.QUICK,
67
+ "--depth",
68
+ "-d",
69
+ help="quick: fast triage, top findings only (default, good when time is limited). "
70
+ "standard: thorough, full checklist coverage, takes longer.",
71
+ ),
72
+ timeout: Optional[int] = typer.Option(
73
+ None, "--timeout", help="Per-skill timeout in seconds. Overrides the agent's default."
74
+ ),
75
+ ) -> None:
76
+ """Run one or more security skills against a target using the chosen agent.
77
+
78
+ Multiple --skill flags run concurrently, not one after another.
79
+ """
80
+ for url in confluence:
81
+ if not url.strip().lower().startswith(("http://", "https://")):
82
+ console.print(f"[yellow]Warning:[/] {url!r} doesn't look like a URL — passing it through anyway.")
83
+
84
+ task_ids: dict[str, int] = {}
85
+ progress = Progress(SpinnerColumn(finished_text=" "), TextColumn("{task.description}"), console=console)
86
+
87
+ def handle_start(skill_name: str) -> None:
88
+ task_ids[skill_name] = progress.add_task(f"Running [bold]{skill_name}[/] via {agent.value}...", total=None)
89
+
90
+ def handle_complete(skill_name: str, result_status: str) -> None:
91
+ style = _STATUS_STYLE.get(result_status, "white")
92
+ task_id = task_ids.get(skill_name)
93
+ if task_id is not None:
94
+ progress.update(
95
+ task_id,
96
+ description=f"[{style}]{result_status}[/] — {skill_name}",
97
+ total=1,
98
+ completed=1,
99
+ )
100
+ progress.stop_task(task_id)
101
+
102
+ with progress:
103
+ try:
104
+ outcomes = execute_runs(
105
+ skill_ids=[s.value for s in skill],
106
+ target=target,
107
+ confluence_urls=confluence,
108
+ agent_id=agent.value,
109
+ depth=depth.value,
110
+ timeout=timeout,
111
+ on_skill_start=handle_start,
112
+ on_skill_complete=handle_complete,
113
+ )
114
+ except TargetResolutionError as exc:
115
+ err_console.print(f"[red]Error:[/] {exc}")
116
+ raise typer.Exit(code=1) from None
117
+
118
+ table = Table(title="Assessment results")
119
+ table.add_column("Skill")
120
+ table.add_column("Status")
121
+ table.add_column("Duration")
122
+ table.add_column("Run ID")
123
+
124
+ any_failed = False
125
+ for outcome in outcomes:
126
+ style = _STATUS_STYLE.get(outcome.status, "white")
127
+ duration = f"{outcome.duration_seconds:.1f}s" if outcome.duration_seconds else "-"
128
+ table.add_row(outcome.skill_name, f"[{style}]{outcome.status}[/]", duration, outcome.run_uuid)
129
+ if outcome.status != "success":
130
+ any_failed = True
131
+
132
+ console.print(table)
133
+ console.print("Run [bold]secfoo serve[/] to view full reports in your browser.")
134
+ if any_failed:
135
+ raise typer.Exit(code=1)
136
+
137
+
138
+ @app.command(name="list")
139
+ def list_runs(
140
+ project: Optional[str] = typer.Option(None, "--project", "-p", help="Filter by project name/URL substring."),
141
+ limit: int = typer.Option(50, "--limit", help="Maximum runs to show."),
142
+ status: Optional[str] = typer.Option(None, "--status", help="Filter by run status."),
143
+ ) -> None:
144
+ """List past assessment runs."""
145
+ with RunRepository() as repo:
146
+ project_id = None
147
+ if project:
148
+ matches = [
149
+ p for p in repo.list_projects()
150
+ if project.lower() in p.display_name.lower() or project.lower() in p.identifier.lower()
151
+ ]
152
+ if not matches:
153
+ console.print(f"[yellow]No project matches {project!r}.[/]")
154
+ return
155
+ project_id = matches[0].id
156
+
157
+ runs = repo.list_runs(project_id=project_id, limit=limit, status=status)
158
+
159
+ if not runs:
160
+ console.print("No runs found.")
161
+ return
162
+
163
+ table = Table(title="Assessment runs")
164
+ table.add_column("Started")
165
+ table.add_column("Project")
166
+ table.add_column("Skill")
167
+ table.add_column("Agent")
168
+ table.add_column("Status")
169
+ table.add_column("Run ID")
170
+
171
+ for r in runs:
172
+ style = _STATUS_STYLE.get(r.status, "white")
173
+ table.add_row(
174
+ r.started_at.split("T")[0] + " " + r.started_at.split("T")[1][:8],
175
+ r.project_display_name or "",
176
+ r.skill_name,
177
+ r.agent_id,
178
+ f"[{style}]{r.status}[/]",
179
+ r.run_uuid,
180
+ )
181
+ console.print(table)
182
+
183
+
184
+ @app.command()
185
+ def show(
186
+ run_uuid: str,
187
+ json_output: bool = typer.Option(False, "--json", help="Print the run record as JSON instead of the report."),
188
+ ) -> None:
189
+ """Show a single assessment run's report."""
190
+ with RunRepository() as repo:
191
+ record = repo.get_run(run_uuid)
192
+
193
+ if record is None:
194
+ err_console.print(f"[red]No run found with id {run_uuid!r}.[/]")
195
+ raise typer.Exit(code=1)
196
+
197
+ if json_output:
198
+ console.print_json(json.dumps(record.__dict__))
199
+ return
200
+
201
+ console.print(f"[bold]{record.skill_name}[/] via {record.agent_id} — status: {record.status}")
202
+ if record.report_path and Path(record.report_path).exists():
203
+ console.print(Path(record.report_path).read_text())
204
+ else:
205
+ console.print("[yellow]No report content available for this run.[/]")
206
+
207
+
208
+ @app.command()
209
+ def serve(
210
+ host: str = typer.Option("127.0.0.1", "--host"),
211
+ port: int = typer.Option(8787, "--port"),
212
+ ) -> None:
213
+ """Launch the local web dashboard."""
214
+ import uvicorn
215
+
216
+ from secfoo.web.app import create_app
217
+
218
+ console.print(f"Serving dashboard at [bold]http://{host}:{port}[/]")
219
+ uvicorn.run(create_app(), host=host, port=port)
220
+
221
+
222
+ @app.command()
223
+ def agents() -> None:
224
+ """List known agent adapters and whether their CLI is installed."""
225
+ table = Table(title="Agent adapters")
226
+ table.add_column("Agent ID")
227
+ table.add_column("Binary")
228
+ table.add_column("Available")
229
+
230
+ for agent_id in ADAPTERS:
231
+ adapter = get_adapter(agent_id)
232
+ available = adapter.is_available()
233
+ style = "green" if available else "red"
234
+ table.add_row(agent_id, adapter.binary, f"[{style}]{'yes' if available else 'no'}[/]")
235
+ console.print(table)
236
+
237
+
238
+ def main() -> None:
239
+ app()
240
+
241
+
242
+ if __name__ == "__main__":
243
+ main()
secfoo/config.py ADDED
@@ -0,0 +1,21 @@
1
+ """Filesystem layout for the global secfoo store (~/.secfoo by default)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ from pathlib import Path
7
+
8
+ STORE_DIR = Path(os.environ.get("SECFOO_HOME", Path.home() / ".secfoo"))
9
+ DB_PATH = STORE_DIR / "secfoo.db"
10
+ REPORTS_DIR = STORE_DIR / "reports"
11
+ TMP_DIR = STORE_DIR / "tmp"
12
+
13
+
14
+ def ensure_store_dirs() -> None:
15
+ STORE_DIR.mkdir(parents=True, exist_ok=True)
16
+ REPORTS_DIR.mkdir(parents=True, exist_ok=True)
17
+ TMP_DIR.mkdir(parents=True, exist_ok=True)
18
+
19
+
20
+ def run_dir(run_uuid: str) -> Path:
21
+ return REPORTS_DIR / run_uuid
@@ -0,0 +1,3 @@
1
+ from secfoo.report.markdown import render_report_html
2
+
3
+ __all__ = ["render_report_html"]
@@ -0,0 +1,43 @@
1
+ """Renders a stored assessment report (Markdown, following the fixed
2
+ `### [SEVERITY] Title` finding shape from skills/renderer.py) to HTML, with
3
+ severity badges injected using the design system's existing badge classes.
4
+ A report that doesn't match the expected shape still renders fine as plain
5
+ markdown -- badge injection is best-effort, not a requirement.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import re
11
+
12
+ from markdown_it import MarkdownIt
13
+
14
+ _SEVERITY_BADGE_CLASS = {
15
+ "critical": "badge--error",
16
+ "high": "badge--error",
17
+ "medium": "badge--warning",
18
+ "low": "badge--teal",
19
+ "informational": "badge--neutral",
20
+ }
21
+
22
+ _FINDING_HEADING_RE = re.compile(
23
+ r"<h3>\[(?P<severity>[A-Za-z]+)\]\s*(?P<title>.*?)</h3>", re.IGNORECASE
24
+ )
25
+
26
+ _md = MarkdownIt("commonmark")
27
+
28
+
29
+ def _annotate_severity_badges(html: str) -> str:
30
+ def replace(match: re.Match[str]) -> str:
31
+ severity = match.group("severity")
32
+ title = match.group("title")
33
+ badge_class = _SEVERITY_BADGE_CLASS.get(severity.lower(), "badge--neutral")
34
+ return (
35
+ f'<h3><span class="badge {badge_class}">{severity.upper()}</span> {title}</h3>'
36
+ )
37
+
38
+ return _FINDING_HEADING_RE.sub(replace, html)
39
+
40
+
41
+ def render_report_html(markdown_text: str) -> str:
42
+ html = _md.render(markdown_text)
43
+ return _annotate_severity_badges(html)