secfoo 0.3.0__tar.gz → 0.3.1__tar.gz
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.
- {secfoo-0.3.0 → secfoo-0.3.1}/.gitignore +5 -0
- secfoo-0.3.1/PKG-INFO +160 -0
- secfoo-0.3.1/README.md +116 -0
- secfoo-0.3.1/src/secfoo/__about__.py +1 -0
- secfoo-0.3.1/src/secfoo/agents/__init__.py +4 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/agents/antigravity.py +1 -1
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/agents/api.py +119 -10
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/agents/base.py +81 -12
- secfoo-0.3.1/src/secfoo/agents/claude.py +159 -0
- secfoo-0.3.1/src/secfoo/agents/codex.py +95 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/agents/copilot.py +36 -4
- secfoo-0.3.1/src/secfoo/agents/devin.py +95 -0
- secfoo-0.3.1/src/secfoo/agents/droid.py +97 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/agents/registry.py +4 -2
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/cli.py +390 -41
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/cloud.py +3 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/config.example.toml +21 -3
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/cost.py +13 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/mcp.py +17 -0
- secfoo-0.3.1/src/secfoo/memory.py +194 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/report/architecture.py +32 -0
- secfoo-0.3.1/src/secfoo/report/code_region.py +65 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/report/sast.py +70 -34
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/report/sca.py +84 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/report/secret_scanning.py +98 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/runner.py +304 -51
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/settings.py +30 -1
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/skills/renderer.py +69 -0
- secfoo-0.3.1/src/secfoo/stack.py +270 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/storage/models.py +74 -3
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/storage/repository.py +354 -26
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/storage/schema.sql +89 -5
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/app.py +13 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/architecture_dashboard.py +23 -2
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/dashboard_common.py +1 -0
- secfoo-0.3.1/src/secfoo/web/finding_filters.py +77 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/routes/activities.py +186 -15
- secfoo-0.3.1/src/secfoo/web/routes/agents.py +16 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/routes/assessments.py +101 -2
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/routes/overview.py +20 -6
- secfoo-0.3.1/src/secfoo/web/routes/runs.py +81 -0
- secfoo-0.3.1/src/secfoo/web/run_status.py +231 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/sast_dashboard.py +5 -1
- secfoo-0.3.1/src/secfoo/web/static/css/dashboard.css +414 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/static/design-system/base.css +2 -2
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/static/design-system/components/alerts.css +9 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/static/design-system/components/badges.css +18 -4
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/static/design-system/components/buttons.css +1 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/static/design-system/components/cards.css +1 -1
- secfoo-0.3.1/src/secfoo/web/static/design-system/components/dark.css +56 -0
- secfoo-0.3.1/src/secfoo/web/static/design-system/components/dashboard.css +369 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/static/design-system/components/donut.css +4 -3
- secfoo-0.3.1/src/secfoo/web/static/design-system/components/run-ui.css +279 -0
- secfoo-0.3.1/src/secfoo/web/static/design-system/components/sidebar.css +168 -0
- secfoo-0.3.1/src/secfoo/web/static/design-system/components/stat-card.css +86 -0
- secfoo-0.3.1/src/secfoo/web/static/design-system/components/tables.css +70 -0
- secfoo-0.3.1/src/secfoo/web/static/design-system/components/workflow.css +305 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/static/design-system/design-system.css +4 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/static/design-system/tokens.css +16 -7
- secfoo-0.3.1/src/secfoo/web/static/js/interactive.js +188 -0
- secfoo-0.3.1/src/secfoo/web/static/js/live-run.js +84 -0
- secfoo-0.3.1/src/secfoo/web/static/js/palette.js +131 -0
- secfoo-0.3.1/src/secfoo/web/static/js/run-form.js +23 -0
- secfoo-0.3.1/src/secfoo/web/static/js/theme.js +36 -0
- secfoo-0.3.1/src/secfoo/web/templates/_icons.html +29 -0
- secfoo-0.3.1/src/secfoo/web/templates/_macros.html +59 -0
- secfoo-0.3.1/src/secfoo/web/templates/_page.html +20 -0
- secfoo-0.3.1/src/secfoo/web/templates/activities/architecture_dashboard.html +252 -0
- secfoo-0.3.1/src/secfoo/web/templates/activities/architecture_standards.html +30 -0
- secfoo-0.3.1/src/secfoo/web/templates/activities/detail.html +260 -0
- secfoo-0.3.1/src/secfoo/web/templates/activities/sast_dashboard.html +156 -0
- secfoo-0.3.1/src/secfoo/web/templates/activities/sast_finding_detail.html +100 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/templates/activities/sast_findings_list.html +29 -12
- secfoo-0.3.1/src/secfoo/web/templates/activities/sca_dashboard.html +148 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/templates/activities/sca_vulnerabilities_list.html +10 -7
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/templates/activities/sca_vulnerability_detail.html +14 -14
- secfoo-0.3.1/src/secfoo/web/templates/activities/secret_scanning_dashboard.html +125 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/templates/activities/secret_scanning_finding_detail.html +7 -7
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/templates/activities/secret_scanning_findings_list.html +10 -7
- secfoo-0.3.1/src/secfoo/web/templates/activities/threat_modeling_accepted.html +35 -0
- secfoo-0.3.1/src/secfoo/web/templates/activities/threat_modeling_assumptions.html +30 -0
- secfoo-0.3.1/src/secfoo/web/templates/activities/threat_modeling_dashboard.html +357 -0
- secfoo-0.3.1/src/secfoo/web/templates/activities/threat_modeling_post_build.html +32 -0
- secfoo-0.3.1/src/secfoo/web/templates/agents.html +36 -0
- secfoo-0.3.1/src/secfoo/web/templates/assessments/detail.html +129 -0
- secfoo-0.3.1/src/secfoo/web/templates/assessments/list.html +96 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/templates/assessments/new.html +12 -9
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/templates/assessments/run.html +29 -9
- secfoo-0.3.1/src/secfoo/web/templates/base.html +104 -0
- secfoo-0.3.1/src/secfoo/web/templates/overview.html +300 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/templates/project.html +6 -6
- secfoo-0.3.1/src/secfoo/web/templates/responsible_ai.html +56 -0
- secfoo-0.3.1/src/secfoo/web/templates/run_detail.html +106 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/templates/third_party.html +23 -13
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/templating.py +62 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/threat_modeling_dashboard.py +32 -4
- secfoo-0.3.0/PKG-INFO +0 -233
- secfoo-0.3.0/README.md +0 -189
- secfoo-0.3.0/src/secfoo/__about__.py +0 -1
- secfoo-0.3.0/src/secfoo/agents/__init__.py +0 -5
- secfoo-0.3.0/src/secfoo/agents/claude.py +0 -79
- secfoo-0.3.0/src/secfoo/agents/codex.py +0 -54
- secfoo-0.3.0/src/secfoo/agents/secfoo.py +0 -89
- secfoo-0.3.0/src/secfoo/web/routes/runs.py +0 -47
- secfoo-0.3.0/src/secfoo/web/static/design-system/components/sidebar.css +0 -112
- secfoo-0.3.0/src/secfoo/web/static/design-system/components/stat-card.css +0 -51
- secfoo-0.3.0/src/secfoo/web/static/design-system/components/tables.css +0 -38
- secfoo-0.3.0/src/secfoo/web/static/js/interactive.js +0 -50
- secfoo-0.3.0/src/secfoo/web/templates/_macros.html +0 -15
- secfoo-0.3.0/src/secfoo/web/templates/activities/architecture_dashboard.html +0 -183
- secfoo-0.3.0/src/secfoo/web/templates/activities/detail.html +0 -189
- secfoo-0.3.0/src/secfoo/web/templates/activities/sast_dashboard.html +0 -114
- secfoo-0.3.0/src/secfoo/web/templates/activities/sast_finding_detail.html +0 -66
- secfoo-0.3.0/src/secfoo/web/templates/activities/sca_dashboard.html +0 -115
- secfoo-0.3.0/src/secfoo/web/templates/activities/secret_scanning_dashboard.html +0 -94
- secfoo-0.3.0/src/secfoo/web/templates/activities/threat_modeling_dashboard.html +0 -227
- secfoo-0.3.0/src/secfoo/web/templates/assessments/detail.html +0 -97
- secfoo-0.3.0/src/secfoo/web/templates/assessments/list.html +0 -68
- secfoo-0.3.0/src/secfoo/web/templates/base.html +0 -59
- secfoo-0.3.0/src/secfoo/web/templates/overview.html +0 -147
- secfoo-0.3.0/src/secfoo/web/templates/responsible_ai.html +0 -47
- secfoo-0.3.0/src/secfoo/web/templates/run_detail.html +0 -67
- {secfoo-0.3.0 → secfoo-0.3.1}/LICENSE +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/pyproject.toml +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/__init__.py +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/agents/cursor.py +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/agents/gemini.py +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/aibom.py +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/attachments.py +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/config.py +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/cvss.py +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/docext.py +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/osv.py +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/report/__init__.py +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/report/markdown.py +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/report/severity.py +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/skills/__init__.py +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/skills/definitions/deployment-readiness.md +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/skills/definitions/prompt-review.md +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/skills/definitions/responsible-ai-compliance.md +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/skills/definitions/sast.md +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/skills/definitions/sca-reachability.md +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/skills/definitions/secret-scanning.md +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/skills/definitions/security-architecture-review.md +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/skills/definitions/third-party-risk-assessment.md +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/skills/definitions/threat-modeling.md +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/skills/loader.py +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/storage/__init__.py +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/storage/schema_indexes.sql +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/targets/__init__.py +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/targets/github.py +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/targets/resolver.py +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/__init__.py +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/routes/__init__.py +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/routes/projects.py +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/routes/responsible_ai.py +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/routes/third_party.py +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/sca_dashboard.py +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/secret_scanning_dashboard.py +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/static/design-system/README.md +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/static/design-system/components/code.css +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/static/design-system/components/conformance-bar.css +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/static/design-system/components/forms.css +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/static/design-system/components/logo.css +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/static/design-system/components/modal.css +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/static/design-system/components/navigation.css +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/static/design-system/components/segmented-control.css +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/static/design-system/components/severity-bar.css +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/static/design-system/components/stacked-bar.css +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/static/design-system/components/tabs.css +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/static/design-system/components/themes.css +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/static/design-system/demo.html +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/static/js/mermaid-init.js +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/third_party_dashboard.py +0 -0
- {secfoo-0.3.0 → secfoo-0.3.1}/src/secfoo/web/top_findings.py +0 -0
|
@@ -8,6 +8,11 @@ build/
|
|
|
8
8
|
dist/
|
|
9
9
|
.DS_Store
|
|
10
10
|
|
|
11
|
+
# Local-only secrets (API keys for manual testing) -- never commit these.
|
|
12
|
+
.env
|
|
13
|
+
.env.*
|
|
14
|
+
*.secret
|
|
15
|
+
|
|
11
16
|
# Unrelated third-party repo cloned into this directory for testing --
|
|
12
17
|
# never belongs in this repo (already caused one real incident: it leaked
|
|
13
18
|
# into a published PyPI sdist before this line existed).
|
secfoo-0.3.1/PKG-INFO
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: secfoo
|
|
3
|
+
Version: 0.3.1
|
|
4
|
+
Summary: Context-based security architectural assessment orchestrator: pick skills, targets, and an agent CLI to run them.
|
|
5
|
+
Author-email: RakFort <info@rakfort.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Keywords: compliance,llm-agent,owasp,security,stride,threat-modeling
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
14
|
+
Classifier: Topic :: Security
|
|
15
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Requires-Dist: click<9,>=8.3.3
|
|
18
|
+
Requires-Dist: fastapi>=0.110
|
|
19
|
+
Requires-Dist: jinja2>=3.1
|
|
20
|
+
Requires-Dist: langgraph>=0.2
|
|
21
|
+
Requires-Dist: litellm>=1.40
|
|
22
|
+
Requires-Dist: markdown-it-py>=3.0
|
|
23
|
+
Requires-Dist: pypdf>=4.0
|
|
24
|
+
Requires-Dist: python-docx>=1.1
|
|
25
|
+
Requires-Dist: python-multipart>=0.0.9
|
|
26
|
+
Requires-Dist: python-pptx>=0.6.23
|
|
27
|
+
Requires-Dist: rich>=13.0
|
|
28
|
+
Requires-Dist: tomli>=2.0; python_version < '3.11'
|
|
29
|
+
Requires-Dist: typer>=0.15
|
|
30
|
+
Requires-Dist: uvicorn[standard]>=0.29
|
|
31
|
+
Provides-Extra: api
|
|
32
|
+
Requires-Dist: langgraph>=0.2; extra == 'api'
|
|
33
|
+
Requires-Dist: litellm>=1.40; extra == 'api'
|
|
34
|
+
Provides-Extra: build
|
|
35
|
+
Requires-Dist: pyinstaller>=6.0; extra == 'build'
|
|
36
|
+
Provides-Extra: dev
|
|
37
|
+
Requires-Dist: bandit>=1.8; extra == 'dev'
|
|
38
|
+
Requires-Dist: httpx>=0.27; extra == 'dev'
|
|
39
|
+
Requires-Dist: langgraph>=0.2; extra == 'dev'
|
|
40
|
+
Requires-Dist: pip-audit>=2.7; extra == 'dev'
|
|
41
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
42
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
43
|
+
Description-Content-Type: text/markdown
|
|
44
|
+
|
|
45
|
+
# secfoo
|
|
46
|
+
|
|
47
|
+
<p align="center">
|
|
48
|
+
<strong>Turn any AI coding agent into a disciplined security reviewer.</strong><br>
|
|
49
|
+
Same standards, same report, every run.
|
|
50
|
+
</p>
|
|
51
|
+
|
|
52
|
+
<p align="center">
|
|
53
|
+
<a href="https://pypi.org/project/secfoo/"><img src="https://img.shields.io/pypi/v/secfoo" alt="PyPI"></a>
|
|
54
|
+
<a href="https://pypi.org/project/secfoo/"><img src="https://img.shields.io/pypi/dm/secfoo" alt="PyPI downloads"></a>
|
|
55
|
+
<a href="https://github.com/secfoo-com/secfoo/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/secfoo-com/secfoo/ci.yml" alt="CI"></a>
|
|
56
|
+
<a href="https://github.com/secfoo-com/secfoo/blob/main/LICENSE"><img src="https://img.shields.io/github/license/secfoo-com/secfoo" alt="MIT license"></a>
|
|
57
|
+
</p>
|
|
58
|
+
|
|
59
|
+
<p align="center">
|
|
60
|
+
<img src="docs/assets/dashboard.png" alt="secfoo local dashboard: program posture across applications, findings, and security activities" width="900">
|
|
61
|
+
</p>
|
|
62
|
+
|
|
63
|
+
<p align="center">
|
|
64
|
+
<a href="https://secfoo.com">Website</a> ·
|
|
65
|
+
<a href="https://secfoo.com/docs/index.html#install">Getting started</a> ·
|
|
66
|
+
<a href="https://secfoo.com/docs/cli.html">CLI</a> ·
|
|
67
|
+
<a href="https://secfoo.com/docs/index.html">Docs</a>
|
|
68
|
+
</p>
|
|
69
|
+
|
|
70
|
+
Point Claude Code, Cursor, Antigravity, Gemini CLI, or Codex at a target.
|
|
71
|
+
Pick architecture review, threat modeling, SAST, and the rest of the catalog.
|
|
72
|
+
Browse every result in a local dashboard — `secfoo serve`, on your machine.
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
pip install secfoo
|
|
76
|
+
secfoo run --skill sast --target https://github.com/org/repo --agent claude
|
|
77
|
+
secfoo serve
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
You need an agent CLI already installed and authenticated
|
|
81
|
+
(`--agent claude|agent|agy|gemini|codex`), or an API key with the built-in
|
|
82
|
+
`api` agent — see [Install](#install).
|
|
83
|
+
|
|
84
|
+
## A 30-second look at the dashboard
|
|
85
|
+
|
|
86
|
+
<p align="center">
|
|
87
|
+
<img src="docs/assets/demo.gif" alt="30-second tour of the secfoo dashboard: posture, threat modeling, STRIDE coverage, architecture verdict, and SAST" width="900">
|
|
88
|
+
</p>
|
|
89
|
+
|
|
90
|
+
<p align="center"><a href="docs/assets/demo.mp4">Watch as MP4</a></p>
|
|
91
|
+
|
|
92
|
+
<p align="center">
|
|
93
|
+
<img src="docs/assets/threat-modeling.png" alt="Threat modeling program dashboard with coverage and STRIDE" width="48%">
|
|
94
|
+
<img src="docs/assets/architecture.png" alt="Security architecture design verdict and data-flow diagram" width="48%">
|
|
95
|
+
</p>
|
|
96
|
+
|
|
97
|
+
Screenshots are from a real local `secfoo serve` against public vulnerable-app targets.
|
|
98
|
+
|
|
99
|
+
## What you get
|
|
100
|
+
|
|
101
|
+
- **A skill is a brief, not a parser.** secfoo hands your coding agent a
|
|
102
|
+
structured prompt and a target, then collects a report in a fixed shape.
|
|
103
|
+
- **One dashboard for the program.** Coverage, dispositions, STRIDE,
|
|
104
|
+
design verdicts, and findings across every project you have scanned.
|
|
105
|
+
- **Local first.** Runs and `secfoo serve` stay on your machine. Optional
|
|
106
|
+
`secfoo cloud login` syncs to an org portal that is not in this repo.
|
|
107
|
+
- **Concurrent by default.** Several `--skill` flags run at the same time.
|
|
108
|
+
- **CI-ready.** `--fail-on high`, `--max-cost 2.00`, `--json`, and distinct
|
|
109
|
+
exit codes for "the scan broke" vs "policy failed". Details in
|
|
110
|
+
[docs/REFERENCE.md](docs/REFERENCE.md#ci-gates-and-machine-readable-output).
|
|
111
|
+
|
|
112
|
+
## Activity catalog
|
|
113
|
+
|
|
114
|
+
| Activity | Skill ID |
|
|
115
|
+
|---|---|
|
|
116
|
+
| Security Architecture Review | `security-architecture-review` |
|
|
117
|
+
| Threat Modeling | `threat-modeling` |
|
|
118
|
+
| SAST — Static Code Analysis | `sast` |
|
|
119
|
+
| SCA — Reachability & Upgrade Triage | `sca-reachability` |
|
|
120
|
+
| Secret Scanning | `secret-scanning` |
|
|
121
|
+
| Prompt Review | `prompt-review` |
|
|
122
|
+
| Deployment Readiness | `deployment-readiness` |
|
|
123
|
+
| Responsible AI Compliance | `responsible-ai-compliance` |
|
|
124
|
+
|
|
125
|
+
Run one, or several together. What each report actually contains is in
|
|
126
|
+
[docs/REFERENCE.md](docs/REFERENCE.md).
|
|
127
|
+
|
|
128
|
+
## Install
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
pip install secfoo # PyPI, Python 3.10+
|
|
132
|
+
npm install -g @rakfortltd/secfoo # npm, no Python needed
|
|
133
|
+
docker run --rm ghcr.io/rakfortltd/secfoo --help
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
No agent CLI? Use an API key:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
pip install "secfoo[api]"
|
|
140
|
+
export OPENAI_API_KEY=... # or ANTHROPIC_API_KEY / GEMINI_API_KEY
|
|
141
|
+
secfoo run --skill sast --agent api --target https://github.com/org/repo
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Universal install scripts, standalone binaries, CI flags, spend tracking,
|
|
145
|
+
and configuration live in [docs/REFERENCE.md](docs/REFERENCE.md#install).
|
|
146
|
+
Developing this repo: `pip install -e ".[dev]"`.
|
|
147
|
+
|
|
148
|
+
## Learn more
|
|
149
|
+
|
|
150
|
+
- [docs/REFERENCE.md](docs/REFERENCE.md) — catalog, dashboards, assessments, config, distribution
|
|
151
|
+
- [Getting started](https://secfoo.com/docs/index.html#quickstart)
|
|
152
|
+
- [CLI reference](https://secfoo.com/docs/cli.html)
|
|
153
|
+
- [Running an assessment](https://secfoo.com/docs/guide-running-an-assessment.html)
|
|
154
|
+
- [Editions](https://secfoo.com/editions.html)
|
|
155
|
+
|
|
156
|
+
## Contributing
|
|
157
|
+
|
|
158
|
+
PRs welcome — see [CONTRIBUTING.md](CONTRIBUTING.md) and
|
|
159
|
+
[CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md). Security issues go through
|
|
160
|
+
[SECURITY.md](SECURITY.md), not a public issue.
|
secfoo-0.3.1/README.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# secfoo
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<strong>Turn any AI coding agent into a disciplined security reviewer.</strong><br>
|
|
5
|
+
Same standards, same report, every run.
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
<p align="center">
|
|
9
|
+
<a href="https://pypi.org/project/secfoo/"><img src="https://img.shields.io/pypi/v/secfoo" alt="PyPI"></a>
|
|
10
|
+
<a href="https://pypi.org/project/secfoo/"><img src="https://img.shields.io/pypi/dm/secfoo" alt="PyPI downloads"></a>
|
|
11
|
+
<a href="https://github.com/secfoo-com/secfoo/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/secfoo-com/secfoo/ci.yml" alt="CI"></a>
|
|
12
|
+
<a href="https://github.com/secfoo-com/secfoo/blob/main/LICENSE"><img src="https://img.shields.io/github/license/secfoo-com/secfoo" alt="MIT license"></a>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<p align="center">
|
|
16
|
+
<img src="docs/assets/dashboard.png" alt="secfoo local dashboard: program posture across applications, findings, and security activities" width="900">
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
<p align="center">
|
|
20
|
+
<a href="https://secfoo.com">Website</a> ·
|
|
21
|
+
<a href="https://secfoo.com/docs/index.html#install">Getting started</a> ·
|
|
22
|
+
<a href="https://secfoo.com/docs/cli.html">CLI</a> ·
|
|
23
|
+
<a href="https://secfoo.com/docs/index.html">Docs</a>
|
|
24
|
+
</p>
|
|
25
|
+
|
|
26
|
+
Point Claude Code, Cursor, Antigravity, Gemini CLI, or Codex at a target.
|
|
27
|
+
Pick architecture review, threat modeling, SAST, and the rest of the catalog.
|
|
28
|
+
Browse every result in a local dashboard — `secfoo serve`, on your machine.
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install secfoo
|
|
32
|
+
secfoo run --skill sast --target https://github.com/org/repo --agent claude
|
|
33
|
+
secfoo serve
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
You need an agent CLI already installed and authenticated
|
|
37
|
+
(`--agent claude|agent|agy|gemini|codex`), or an API key with the built-in
|
|
38
|
+
`api` agent — see [Install](#install).
|
|
39
|
+
|
|
40
|
+
## A 30-second look at the dashboard
|
|
41
|
+
|
|
42
|
+
<p align="center">
|
|
43
|
+
<img src="docs/assets/demo.gif" alt="30-second tour of the secfoo dashboard: posture, threat modeling, STRIDE coverage, architecture verdict, and SAST" width="900">
|
|
44
|
+
</p>
|
|
45
|
+
|
|
46
|
+
<p align="center"><a href="docs/assets/demo.mp4">Watch as MP4</a></p>
|
|
47
|
+
|
|
48
|
+
<p align="center">
|
|
49
|
+
<img src="docs/assets/threat-modeling.png" alt="Threat modeling program dashboard with coverage and STRIDE" width="48%">
|
|
50
|
+
<img src="docs/assets/architecture.png" alt="Security architecture design verdict and data-flow diagram" width="48%">
|
|
51
|
+
</p>
|
|
52
|
+
|
|
53
|
+
Screenshots are from a real local `secfoo serve` against public vulnerable-app targets.
|
|
54
|
+
|
|
55
|
+
## What you get
|
|
56
|
+
|
|
57
|
+
- **A skill is a brief, not a parser.** secfoo hands your coding agent a
|
|
58
|
+
structured prompt and a target, then collects a report in a fixed shape.
|
|
59
|
+
- **One dashboard for the program.** Coverage, dispositions, STRIDE,
|
|
60
|
+
design verdicts, and findings across every project you have scanned.
|
|
61
|
+
- **Local first.** Runs and `secfoo serve` stay on your machine. Optional
|
|
62
|
+
`secfoo cloud login` syncs to an org portal that is not in this repo.
|
|
63
|
+
- **Concurrent by default.** Several `--skill` flags run at the same time.
|
|
64
|
+
- **CI-ready.** `--fail-on high`, `--max-cost 2.00`, `--json`, and distinct
|
|
65
|
+
exit codes for "the scan broke" vs "policy failed". Details in
|
|
66
|
+
[docs/REFERENCE.md](docs/REFERENCE.md#ci-gates-and-machine-readable-output).
|
|
67
|
+
|
|
68
|
+
## Activity catalog
|
|
69
|
+
|
|
70
|
+
| Activity | Skill ID |
|
|
71
|
+
|---|---|
|
|
72
|
+
| Security Architecture Review | `security-architecture-review` |
|
|
73
|
+
| Threat Modeling | `threat-modeling` |
|
|
74
|
+
| SAST — Static Code Analysis | `sast` |
|
|
75
|
+
| SCA — Reachability & Upgrade Triage | `sca-reachability` |
|
|
76
|
+
| Secret Scanning | `secret-scanning` |
|
|
77
|
+
| Prompt Review | `prompt-review` |
|
|
78
|
+
| Deployment Readiness | `deployment-readiness` |
|
|
79
|
+
| Responsible AI Compliance | `responsible-ai-compliance` |
|
|
80
|
+
|
|
81
|
+
Run one, or several together. What each report actually contains is in
|
|
82
|
+
[docs/REFERENCE.md](docs/REFERENCE.md).
|
|
83
|
+
|
|
84
|
+
## Install
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
pip install secfoo # PyPI, Python 3.10+
|
|
88
|
+
npm install -g @rakfortltd/secfoo # npm, no Python needed
|
|
89
|
+
docker run --rm ghcr.io/rakfortltd/secfoo --help
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
No agent CLI? Use an API key:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
pip install "secfoo[api]"
|
|
96
|
+
export OPENAI_API_KEY=... # or ANTHROPIC_API_KEY / GEMINI_API_KEY
|
|
97
|
+
secfoo run --skill sast --agent api --target https://github.com/org/repo
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Universal install scripts, standalone binaries, CI flags, spend tracking,
|
|
101
|
+
and configuration live in [docs/REFERENCE.md](docs/REFERENCE.md#install).
|
|
102
|
+
Developing this repo: `pip install -e ".[dev]"`.
|
|
103
|
+
|
|
104
|
+
## Learn more
|
|
105
|
+
|
|
106
|
+
- [docs/REFERENCE.md](docs/REFERENCE.md) — catalog, dashboards, assessments, config, distribution
|
|
107
|
+
- [Getting started](https://secfoo.com/docs/index.html#quickstart)
|
|
108
|
+
- [CLI reference](https://secfoo.com/docs/cli.html)
|
|
109
|
+
- [Running an assessment](https://secfoo.com/docs/guide-running-an-assessment.html)
|
|
110
|
+
- [Editions](https://secfoo.com/editions.html)
|
|
111
|
+
|
|
112
|
+
## Contributing
|
|
113
|
+
|
|
114
|
+
PRs welcome — see [CONTRIBUTING.md](CONTRIBUTING.md) and
|
|
115
|
+
[CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md). Security issues go through
|
|
116
|
+
[SECURITY.md](SECURITY.md), not a public issue.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.3.1"
|
|
@@ -42,6 +42,6 @@ class AntigravityAdapter(AgentAdapter):
|
|
|
42
42
|
effective_timeout = getattr(self, "_effective_timeout", self.default_timeout_seconds)
|
|
43
43
|
return [self.binary, "--print", prompt, "--print-timeout", f"{effective_timeout}s"]
|
|
44
44
|
|
|
45
|
-
def run(self, prompt: str, *, workdir: Path, timeout: int | None = None) -> AgentResult:
|
|
45
|
+
def run(self, prompt: str, *, workdir: Path, timeout: int | None = None, prev_commit: str | None = None) -> AgentResult: # Memory Bank: prev_commit is only used by the api agent.
|
|
46
46
|
self._effective_timeout = timeout or self.default_timeout_seconds
|
|
47
47
|
return super().run(prompt, workdir=workdir, timeout=timeout)
|
|
@@ -18,6 +18,7 @@ from __future__ import annotations
|
|
|
18
18
|
|
|
19
19
|
import fnmatch
|
|
20
20
|
import os
|
|
21
|
+
import subprocess # nosec B404 -- fixed git argv, no shell
|
|
21
22
|
import time
|
|
22
23
|
from pathlib import Path
|
|
23
24
|
from typing import TypedDict
|
|
@@ -50,6 +51,10 @@ class _State(TypedDict):
|
|
|
50
51
|
workdir: str
|
|
51
52
|
model: str
|
|
52
53
|
timeout: int
|
|
54
|
+
prev_commit: str | None # Memory Bank: SHA of the last scanned commit; None = full scan.
|
|
55
|
+
# Memory Bank: paths an incremental scan covered (files sent + files
|
|
56
|
+
# deleted); None = full scan. The runner only closes findings in these.
|
|
57
|
+
scan_scope: list[str] | None
|
|
53
58
|
messages: list[dict]
|
|
54
59
|
report: str
|
|
55
60
|
attempts: int
|
|
@@ -63,21 +68,80 @@ def _matches(name: str, patterns: list[str]) -> bool:
|
|
|
63
68
|
return any(fnmatch.fnmatch(name, p) for p in patterns)
|
|
64
69
|
|
|
65
70
|
|
|
66
|
-
def
|
|
67
|
-
|
|
71
|
+
def _git(workdir: Path, *args: str, timeout: int = 30) -> subprocess.CompletedProcess[str]:
|
|
72
|
+
return subprocess.run( # nosec B603 B607 -- fixed git argv, no shell
|
|
73
|
+
["git", "-C", str(workdir), *args], capture_output=True, text=True, timeout=timeout, check=False
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def _ensure_commit_available(workdir: Path, commit: str) -> bool:
|
|
78
|
+
"""GitHub targets are depth-1 clones, so the previous scan's commit is
|
|
79
|
+
usually missing. Fetch only that commit (all a diff against it needs)
|
|
80
|
+
rather than unshallowing the whole history on every rescan."""
|
|
81
|
+
if _git(workdir, "cat-file", "-e", f"{commit}^{{commit}}").returncode == 0:
|
|
82
|
+
return True
|
|
83
|
+
_git(workdir, "fetch", "--depth=1", "origin", commit, timeout=60)
|
|
84
|
+
return _git(workdir, "cat-file", "-e", f"{commit}^{{commit}}").returncode == 0
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def _git_changed_files(workdir: Path, prev_commit: str) -> tuple[list[str], list[str]] | None:
|
|
88
|
+
"""Return (changed_paths, deleted_paths), relative to `workdir`, for
|
|
89
|
+
everything that differs between prev_commit and the files on disk now:
|
|
90
|
+
commits since prev_commit, uncommitted edits, and untracked files.
|
|
91
|
+
|
|
92
|
+
Renames come back as a delete of the old path plus a new path
|
|
93
|
+
(--no-renames), so findings recorded against the old path are covered.
|
|
94
|
+
|
|
95
|
+
None means the diff couldn't be computed (git missing, commit not
|
|
96
|
+
reachable); the caller then falls back to a full scan.
|
|
97
|
+
"""
|
|
98
|
+
try:
|
|
99
|
+
if not _ensure_commit_available(workdir, prev_commit):
|
|
100
|
+
return None
|
|
101
|
+
# `git diff <commit>` (no `..HEAD`) compares against the working
|
|
102
|
+
# tree, so staged and unstaged edits are included, not just commits.
|
|
103
|
+
diff = _git(workdir, "diff", "--name-status", "--no-renames", "--relative", "-z", prev_commit)
|
|
104
|
+
untracked = _git(workdir, "ls-files", "--others", "--exclude-standard", "-z")
|
|
105
|
+
except (OSError, subprocess.SubprocessError):
|
|
106
|
+
return None
|
|
107
|
+
if diff.returncode != 0 or untracked.returncode != 0:
|
|
108
|
+
return None
|
|
109
|
+
changed: set[str] = set()
|
|
110
|
+
deleted: set[str] = set()
|
|
111
|
+
tokens = diff.stdout.split("\0")
|
|
112
|
+
for status, path in zip(tokens[0::2], tokens[1::2]):
|
|
113
|
+
if path:
|
|
114
|
+
(deleted if status.startswith("D") else changed).add(path)
|
|
115
|
+
changed.update(path for path in untracked.stdout.split("\0") if path)
|
|
116
|
+
return sorted(changed), sorted(deleted)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def _read_files(workdir: Path, *, changed_only: list[str] | None = None) -> tuple[str, list[str]]:
|
|
120
|
+
"""collect_files, plus the relative paths that actually made it into the
|
|
121
|
+
text (after exclusions, size limits and binary detection)."""
|
|
122
|
+
allowed = set(changed_only) if changed_only is not None else None
|
|
68
123
|
chunks: list[str] = []
|
|
124
|
+
included: list[str] = []
|
|
69
125
|
total = 0
|
|
70
126
|
for root, dirs, files in os.walk(workdir):
|
|
71
127
|
dirs[:] = sorted(d for d in dirs if not _matches(d, DIR_PATTERNS))
|
|
72
128
|
for name in sorted(files):
|
|
73
129
|
path = Path(root) / name
|
|
130
|
+
rel = path.relative_to(workdir).as_posix()
|
|
131
|
+
if allowed is not None and rel not in allowed:
|
|
132
|
+
continue # incremental scan: unchanged file
|
|
133
|
+
# Never follow symlinks: a target repo could point one at a file
|
|
134
|
+
# outside itself (~/.ssh/id_rsa) and have it sent to the model,
|
|
135
|
+
# and a dangling one would crash the whole scan on stat().
|
|
136
|
+
if path.is_symlink():
|
|
137
|
+
continue
|
|
74
138
|
if _matches(name, FILE_PATTERNS) or path.stat().st_size > MAX_FILE_BYTES:
|
|
75
139
|
continue
|
|
76
140
|
try:
|
|
77
141
|
text = path.read_text(encoding="utf-8")
|
|
78
142
|
except (UnicodeDecodeError, OSError):
|
|
79
143
|
continue # binary file (image, font, ...)
|
|
80
|
-
chunk = f"\n===== FILE: {
|
|
144
|
+
chunk = f"\n===== FILE: {rel} =====\n{text}\n"
|
|
81
145
|
total += len(chunk)
|
|
82
146
|
if total > MAX_TOTAL_CHARS:
|
|
83
147
|
raise ValueError(
|
|
@@ -85,7 +149,14 @@ def collect_files(workdir: Path) -> str:
|
|
|
85
149
|
"Use --exclude to narrow it, or use a CLI agent."
|
|
86
150
|
)
|
|
87
151
|
chunks.append(chunk)
|
|
88
|
-
|
|
152
|
+
included.append(rel)
|
|
153
|
+
return "".join(chunks), included
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def collect_files(workdir: Path, *, changed_only: list[str] | None = None) -> str:
|
|
157
|
+
"""Return readable text files under `workdir` as one labelled string.
|
|
158
|
+
If `changed_only` is given, only those paths are included (incremental scan)."""
|
|
159
|
+
return _read_files(workdir, changed_only=changed_only)[0]
|
|
89
160
|
|
|
90
161
|
|
|
91
162
|
def build_graph(litellm, StateGraph, START, END):
|
|
@@ -93,12 +164,41 @@ def build_graph(litellm, StateGraph, START, END):
|
|
|
93
164
|
run the real graph against a fake LiteLLM."""
|
|
94
165
|
|
|
95
166
|
def collect(state: _State) -> dict:
|
|
96
|
-
|
|
167
|
+
workdir = Path(state["workdir"])
|
|
168
|
+
prev_commit = state["prev_commit"]
|
|
169
|
+
scan_scope: list[str] | None = None
|
|
170
|
+
scope_note = ""
|
|
171
|
+
code = ""
|
|
172
|
+
if prev_commit:
|
|
173
|
+
diff = _git_changed_files(workdir, prev_commit)
|
|
174
|
+
if diff is not None:
|
|
175
|
+
changed, deleted = diff
|
|
176
|
+
code, included = _read_files(workdir, changed_only=changed)
|
|
177
|
+
# Go incremental only if at least one changed file is actually
|
|
178
|
+
# scannable. A commit touching only images, lock files or
|
|
179
|
+
# excluded directories would otherwise send the model no
|
|
180
|
+
# source at all -- and an empty report would read as "every
|
|
181
|
+
# open finding is fixed".
|
|
182
|
+
if included:
|
|
183
|
+
scan_scope = sorted(set(included) | set(deleted))
|
|
184
|
+
scope_note = (
|
|
185
|
+
f"Note: this is an incremental scan. Only files changed since "
|
|
186
|
+
f"commit {prev_commit[:8]} are included below.\n\n"
|
|
187
|
+
)
|
|
188
|
+
if deleted:
|
|
189
|
+
scope_note += (
|
|
190
|
+
"## Deleted files\nThe following files were deleted since the last scan "
|
|
191
|
+
"and are no longer present:\n" + "\n".join(f"- {f}" for f in deleted) + "\n\n"
|
|
192
|
+
)
|
|
193
|
+
if scan_scope is None:
|
|
194
|
+
# First scan, nothing scannable changed, or git couldn't diff: full scan.
|
|
195
|
+
code = collect_files(workdir)
|
|
97
196
|
content = (
|
|
98
|
-
f"{state['prompt']}\n\n
|
|
197
|
+
f"{state['prompt']}\n\n{scope_note}"
|
|
198
|
+
f"## Source files\nYou cannot open files. "
|
|
99
199
|
f"The complete target source is included below.\n{code}"
|
|
100
200
|
)
|
|
101
|
-
return {"messages": [{"role": "user", "content": content}]}
|
|
201
|
+
return {"messages": [{"role": "user", "content": content}], "scan_scope": scan_scope}
|
|
102
202
|
|
|
103
203
|
def assess(state: _State) -> dict:
|
|
104
204
|
response = litellm.completion(
|
|
@@ -149,11 +249,14 @@ class ApiAdapter(AgentAdapter):
|
|
|
149
249
|
def build_command(self, prompt: str, *, workdir: Path) -> list[str]:
|
|
150
250
|
return [] # required by the base class; there is no program to launch
|
|
151
251
|
|
|
152
|
-
def run(self, prompt: str, *, workdir: Path, timeout: int | None = None) -> AgentResult:
|
|
252
|
+
def run(self, prompt: str, *, workdir: Path, timeout: int | None = None, prev_commit: str | None = None) -> AgentResult: # Memory Bank: prev_commit triggers incremental diff scan.
|
|
153
253
|
started = time.monotonic()
|
|
154
254
|
_strip_key_whitespace()
|
|
155
255
|
if not self.is_available():
|
|
156
|
-
|
|
256
|
+
# Not "binary_not_found": this adapter has no CLI to find on PATH
|
|
257
|
+
# in the first place -- the thing actually missing is a key.
|
|
258
|
+
# Reusing the CLI-adapters' status here was SECFOO-35.
|
|
259
|
+
return self._result("not_configured", started, stderr=f"No API key set. Set one of: {', '.join(KEY_VARS)}")
|
|
157
260
|
try:
|
|
158
261
|
import litellm
|
|
159
262
|
from langgraph.graph import END, START, StateGraph
|
|
@@ -167,6 +270,8 @@ class ApiAdapter(AgentAdapter):
|
|
|
167
270
|
"workdir": str(workdir),
|
|
168
271
|
"model": os.environ.get("SECFOO_API_MODEL", DEFAULT_MODEL),
|
|
169
272
|
"timeout": timeout or self.default_timeout_seconds,
|
|
273
|
+
"prev_commit": prev_commit, # Memory Bank: None = full scan, SHA = incremental diff.
|
|
274
|
+
"scan_scope": None,
|
|
170
275
|
"messages": [],
|
|
171
276
|
"report": "",
|
|
172
277
|
"attempts": 0,
|
|
@@ -183,7 +288,9 @@ class ApiAdapter(AgentAdapter):
|
|
|
183
288
|
cost_usd=None if final["unpriced"] else final["cost_usd"],
|
|
184
289
|
)
|
|
185
290
|
report = final["report"]
|
|
186
|
-
return self._result(
|
|
291
|
+
return self._result(
|
|
292
|
+
"success", started, stdout=report, report=report, usage=usage, scan_scope=final.get("scan_scope")
|
|
293
|
+
)
|
|
187
294
|
|
|
188
295
|
def _result(
|
|
189
296
|
self,
|
|
@@ -194,6 +301,7 @@ class ApiAdapter(AgentAdapter):
|
|
|
194
301
|
stderr: str = "",
|
|
195
302
|
report: str = "",
|
|
196
303
|
usage: Usage | None = None,
|
|
304
|
+
scan_scope: list[str] | None = None,
|
|
197
305
|
) -> AgentResult:
|
|
198
306
|
usage = usage or Usage()
|
|
199
307
|
return AgentResult(
|
|
@@ -208,6 +316,7 @@ class ApiAdapter(AgentAdapter):
|
|
|
208
316
|
input_tokens=usage.input_tokens,
|
|
209
317
|
output_tokens=usage.output_tokens,
|
|
210
318
|
cost_usd=usage.cost_usd,
|
|
319
|
+
scan_scope=scan_scope,
|
|
211
320
|
)
|
|
212
321
|
|
|
213
322
|
|
|
@@ -18,7 +18,7 @@ from dataclasses import dataclass
|
|
|
18
18
|
from pathlib import Path
|
|
19
19
|
from typing import ClassVar, Literal
|
|
20
20
|
|
|
21
|
-
Status = Literal["success", "failed", "timeout", "binary_not_found"]
|
|
21
|
+
Status = Literal["success", "failed", "timeout", "binary_not_found", "not_configured"]
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
def _kill_process_tree(pid: int, *, posix: bool = os.name == "posix") -> None:
|
|
@@ -70,6 +70,10 @@ class AgentResult:
|
|
|
70
70
|
input_tokens: int | None = None
|
|
71
71
|
output_tokens: int | None = None
|
|
72
72
|
cost_usd: float | None = None
|
|
73
|
+
# Memory Bank: for an incremental scan, the paths it covered (files sent
|
|
74
|
+
# to the model plus files deleted since the last scan). None means a
|
|
75
|
+
# full scan. The runner only closes findings located in these paths.
|
|
76
|
+
scan_scope: list[str] | None = None
|
|
73
77
|
|
|
74
78
|
|
|
75
79
|
@dataclass(frozen=True)
|
|
@@ -83,6 +87,13 @@ class AgentAdapter(ABC):
|
|
|
83
87
|
name: ClassVar[str]
|
|
84
88
|
binary: ClassVar[str]
|
|
85
89
|
default_timeout_seconds: ClassVar[int] = 1800
|
|
90
|
+
# Send the prompt on stdin instead of argv. npm-installed CLIs are
|
|
91
|
+
# `.cmd`/`.bat` shims on Windows, so argv goes through cmd.exe, which
|
|
92
|
+
# truncates it at the first newline and caps the whole command line at
|
|
93
|
+
# ~8K chars -- a multi-line skill prompt silently loses everything past
|
|
94
|
+
# line one. Only enable this for CLIs whose non-interactive mode
|
|
95
|
+
# documents reading the prompt from stdin.
|
|
96
|
+
prompt_via_stdin: ClassVar[bool] = False
|
|
86
97
|
|
|
87
98
|
def is_available(self) -> bool:
|
|
88
99
|
return shutil.which(self.binary) is not None
|
|
@@ -99,7 +110,36 @@ class AgentAdapter(ABC):
|
|
|
99
110
|
"""Pull token counts / cost out of raw stdout. Default: unknown."""
|
|
100
111
|
return Usage()
|
|
101
112
|
|
|
102
|
-
def
|
|
113
|
+
def detect_failure(self, stdout: str, stderr: str) -> str | None:
|
|
114
|
+
"""Return a reason when a zero-exit run still didn't do the job (e.g.
|
|
115
|
+
every tool call was refused, so the agent never saw the target and
|
|
116
|
+
its "no findings" report would read as a clean bill of health).
|
|
117
|
+
Default: trust the exit code."""
|
|
118
|
+
return None
|
|
119
|
+
def extract_usage_from_stderr(self, stderr: str) -> Usage:
|
|
120
|
+
"""Pull token counts / cost out of raw stderr. Default: unknown.
|
|
121
|
+
|
|
122
|
+
For CLIs that print usage alongside their progress output on stderr
|
|
123
|
+
rather than in stdout (e.g. Codex). Only consulted when
|
|
124
|
+
`extract_usage()` found nothing, so adapters that already read usage
|
|
125
|
+
from stdout are unaffected.
|
|
126
|
+
"""
|
|
127
|
+
return Usage()
|
|
128
|
+
|
|
129
|
+
def describe_failure(self, stdout: str, stderr: str) -> str | None:
|
|
130
|
+
"""Return the reason for a non-zero exit when the CLI reports it
|
|
131
|
+
somewhere other than stderr (e.g. Claude Code puts it in its stdout
|
|
132
|
+
JSON and leaves stderr empty), so the run isn't recorded as failed
|
|
133
|
+
with no explanation. Default: stderr already says why."""
|
|
134
|
+
return None
|
|
135
|
+
|
|
136
|
+
def _collect_usage(self, stdout: str, stderr: str) -> Usage:
|
|
137
|
+
usage = self.extract_usage(stdout)
|
|
138
|
+
if usage == Usage():
|
|
139
|
+
usage = self.extract_usage_from_stderr(stderr)
|
|
140
|
+
return usage
|
|
141
|
+
|
|
142
|
+
def run(self, prompt: str, *, workdir: Path, timeout: int | None = None, prev_commit: str | None = None) -> AgentResult: # Memory Bank: prev_commit passed through; CLI adapters ignore it.
|
|
103
143
|
if not self.is_available():
|
|
104
144
|
return AgentResult(
|
|
105
145
|
agent=self.name,
|
|
@@ -113,6 +153,10 @@ class AgentAdapter(ABC):
|
|
|
113
153
|
)
|
|
114
154
|
|
|
115
155
|
cmd = self.build_command(prompt, workdir=workdir)
|
|
156
|
+
# Popen, unlike shutil.which, ignores PATHEXT on Windows, so a bare
|
|
157
|
+
# "copilot"/"codex" never finds the npm `.cmd` shim and raises
|
|
158
|
+
# FileNotFoundError. Launch exactly what is_available() found.
|
|
159
|
+
cmd[0] = shutil.which(cmd[0]) or cmd[0]
|
|
116
160
|
effective_timeout = timeout or self.default_timeout_seconds
|
|
117
161
|
started = time.monotonic()
|
|
118
162
|
|
|
@@ -120,20 +164,45 @@ class AgentAdapter(ABC):
|
|
|
120
164
|
# can kill the whole process tree via _kill_process_tree() -- see
|
|
121
165
|
# its docstring for why subprocess.run's own timeout handling isn't
|
|
122
166
|
# enough on its own.
|
|
123
|
-
proc = subprocess.Popen(
|
|
124
|
-
cmd,
|
|
125
|
-
cwd=workdir,
|
|
126
|
-
stdin=subprocess.DEVNULL,
|
|
127
|
-
stdout=subprocess.PIPE,
|
|
128
|
-
stderr=subprocess.PIPE,
|
|
129
|
-
text=True,
|
|
130
|
-
start_new_session=True,
|
|
131
|
-
)
|
|
132
167
|
try:
|
|
133
|
-
|
|
168
|
+
proc = subprocess.Popen(
|
|
169
|
+
cmd,
|
|
170
|
+
cwd=workdir,
|
|
171
|
+
# DEVNULL (or a pipe closed right after the prompt) means an
|
|
172
|
+
# interactive auth/trust prompt hits EOF instead of hanging.
|
|
173
|
+
stdin=subprocess.PIPE if self.prompt_via_stdin else subprocess.DEVNULL,
|
|
174
|
+
stdout=subprocess.PIPE,
|
|
175
|
+
stderr=subprocess.PIPE,
|
|
176
|
+
text=True,
|
|
177
|
+
# Agent CLIs emit UTF-8; the Windows locale default (cp1252)
|
|
178
|
+
# would raise UnicodeDecodeError on e.g. Copilot's stats line.
|
|
179
|
+
encoding="utf-8",
|
|
180
|
+
errors="replace",
|
|
181
|
+
start_new_session=True,
|
|
182
|
+
)
|
|
183
|
+
except OSError as exc:
|
|
184
|
+
return AgentResult(
|
|
185
|
+
agent=self.name,
|
|
186
|
+
exit_code=None,
|
|
187
|
+
stdout="",
|
|
188
|
+
stderr=f"failed to launch {cmd[0]!r}: {exc}",
|
|
189
|
+
duration_seconds=time.monotonic() - started,
|
|
190
|
+
timed_out=False,
|
|
191
|
+
status="failed",
|
|
192
|
+
raw_report="",
|
|
193
|
+
)
|
|
194
|
+
stdin_input = prompt if self.prompt_via_stdin else None
|
|
195
|
+
try:
|
|
196
|
+
stdout, stderr = proc.communicate(input=stdin_input, timeout=effective_timeout)
|
|
134
197
|
duration = time.monotonic() - started
|
|
135
198
|
status: Status = "success" if proc.returncode == 0 else "failed"
|
|
199
|
+
if status == "success" and (reason := self.detect_failure(stdout, stderr)):
|
|
200
|
+
status = "failed"
|
|
201
|
+
stderr = f"secfoo: {reason}\n{stderr}"
|
|
202
|
+
elif status == "failed" and (reason := self.describe_failure(stdout, stderr)):
|
|
203
|
+
stderr = f"secfoo: {reason}\n{stderr}"
|
|
136
204
|
usage = self.extract_usage(stdout)
|
|
205
|
+
usage = self._collect_usage(stdout, stderr)
|
|
137
206
|
return AgentResult(
|
|
138
207
|
agent=self.name,
|
|
139
208
|
exit_code=proc.returncode,
|