openfix-cli 0.4.0__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.
Files changed (60) hide show
  1. openfix_cli-0.4.0/.gitignore +16 -0
  2. openfix_cli-0.4.0/LICENSE +21 -0
  3. openfix_cli-0.4.0/PKG-INFO +322 -0
  4. openfix_cli-0.4.0/README.md +276 -0
  5. openfix_cli-0.4.0/examples/vulnerable-app/.semgrep.yml +103 -0
  6. openfix_cli-0.4.0/examples/vulnerable-app/README.md +23 -0
  7. openfix_cli-0.4.0/examples/vulnerable-app/data/readme.txt +1 -0
  8. openfix_cli-0.4.0/examples/vulnerable-app/demo/path-traversal.script.yaml +46 -0
  9. openfix_cli-0.4.0/examples/vulnerable-app/demo/snyk-and-semgrep.script.yaml +91 -0
  10. openfix_cli-0.4.0/examples/vulnerable-app/findings/semgrep.sarif +1 -0
  11. openfix_cli-0.4.0/examples/vulnerable-app/findings/snyk-code.sarif +4183 -0
  12. openfix_cli-0.4.0/examples/vulnerable-app/openfix.yaml +33 -0
  13. openfix_cli-0.4.0/examples/vulnerable-app/package.json +18 -0
  14. openfix_cli-0.4.0/examples/vulnerable-app/src/auth/tokens.js +4 -0
  15. openfix_cli-0.4.0/examples/vulnerable-app/src/calc.js +9 -0
  16. openfix_cli-0.4.0/examples/vulnerable-app/src/comments.js +8 -0
  17. openfix_cli-0.4.0/examples/vulnerable-app/src/config-merge.js +13 -0
  18. openfix_cli-0.4.0/examples/vulnerable-app/src/db/query.js +9 -0
  19. openfix_cli-0.4.0/examples/vulnerable-app/src/exec.js +16 -0
  20. openfix_cli-0.4.0/examples/vulnerable-app/src/fetch.js +22 -0
  21. openfix_cli-0.4.0/examples/vulnerable-app/src/files.js +14 -0
  22. openfix_cli-0.4.0/examples/vulnerable-app/src/listdir.js +15 -0
  23. openfix_cli-0.4.0/examples/vulnerable-app/src/redirect.js +9 -0
  24. openfix_cli-0.4.0/examples/vulnerable-app/src/sandbox.js +10 -0
  25. openfix_cli-0.4.0/examples/vulnerable-app/src/server.js +122 -0
  26. openfix_cli-0.4.0/examples/vulnerable-app/src/util/weak-cipher.js +14 -0
  27. openfix_cli-0.4.0/examples/vulnerable-app/test/files.test.js +8 -0
  28. openfix_cli-0.4.0/pyproject.toml +95 -0
  29. openfix_cli-0.4.0/src/openfix/__init__.py +3 -0
  30. openfix_cli-0.4.0/src/openfix/agent/__init__.py +4 -0
  31. openfix_cli-0.4.0/src/openfix/agent/loop.py +105 -0
  32. openfix_cli-0.4.0/src/openfix/agent/prompts.py +76 -0
  33. openfix_cli-0.4.0/src/openfix/agent/tools.py +346 -0
  34. openfix_cli-0.4.0/src/openfix/cli.py +211 -0
  35. openfix_cli-0.4.0/src/openfix/console.py +68 -0
  36. openfix_cli-0.4.0/src/openfix/deps.py +112 -0
  37. openfix_cli-0.4.0/src/openfix/engine.py +477 -0
  38. openfix_cli-0.4.0/src/openfix/findings.py +140 -0
  39. openfix_cli-0.4.0/src/openfix/github.py +119 -0
  40. openfix_cli-0.4.0/src/openfix/gitutil.py +93 -0
  41. openfix_cli-0.4.0/src/openfix/ingest.py +512 -0
  42. openfix_cli-0.4.0/src/openfix/policy.py +310 -0
  43. openfix_cli-0.4.0/src/openfix/pricing.py +40 -0
  44. openfix_cli-0.4.0/src/openfix/providers/__init__.py +104 -0
  45. openfix_cli-0.4.0/src/openfix/providers/anthropic.py +114 -0
  46. openfix_cli-0.4.0/src/openfix/providers/base.py +86 -0
  47. openfix_cli-0.4.0/src/openfix/providers/gemini.py +82 -0
  48. openfix_cli-0.4.0/src/openfix/providers/openai_compat.py +134 -0
  49. openfix_cli-0.4.0/src/openfix/providers/scripted.py +75 -0
  50. openfix_cli-0.4.0/src/openfix/receipt.py +143 -0
  51. openfix_cli-0.4.0/src/openfix/redact.py +47 -0
  52. openfix_cli-0.4.0/src/openfix/report.py +92 -0
  53. openfix_cli-0.4.0/src/openfix/sandbox.py +230 -0
  54. openfix_cli-0.4.0/src/openfix/sarif_out.py +74 -0
  55. openfix_cli-0.4.0/src/openfix/scanners.py +187 -0
  56. openfix_cli-0.4.0/src/openfix/verify.py +251 -0
  57. openfix_cli-0.4.0/tests/test_end_to_end.py +255 -0
  58. openfix_cli-0.4.0/tests/test_ingest.py +253 -0
  59. openfix_cli-0.4.0/tests/test_providers.py +164 -0
  60. openfix_cli-0.4.0/tests/test_units.py +217 -0
@@ -0,0 +1,16 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ .venv/
5
+ venv/
6
+ dist/
7
+ build/
8
+ .pytest_cache/
9
+ .mypy_cache/
10
+ .ruff_cache/
11
+ node_modules/
12
+ .env
13
+ .openfix/
14
+ .openfix-scan/
15
+ *.log
16
+ .DS_Store
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Markus Weldon
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,322 @@
1
+ Metadata-Version: 2.5
2
+ Name: openfix-cli
3
+ Version: 0.4.0
4
+ Summary: Model-agnostic security remediation agent. Every fix ships with proof.
5
+ Project-URL: Homepage, https://github.com/markusweldon/openfix
6
+ Project-URL: Documentation, https://github.com/markusweldon/openfix#documentation
7
+ Project-URL: Issues, https://github.com/markusweldon/openfix/issues
8
+ Project-URL: Changelog, https://github.com/markusweldon/openfix/releases
9
+ Author: Markus Weldon
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: agent,appsec,autofix,devsecops,llm,remediation,sarif,security
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Environment :: Console
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Information Technology
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Topic :: Security
25
+ Classifier: Topic :: Software Development :: Quality Assurance
26
+ Requires-Python: >=3.10
27
+ Requires-Dist: httpx>=0.27
28
+ Requires-Dist: pydantic>=2.7
29
+ Requires-Dist: pyyaml>=6.0
30
+ Provides-Extra: all
31
+ Requires-Dist: anthropic>=0.69; extra == 'all'
32
+ Requires-Dist: google-genai>=1.0; extra == 'all'
33
+ Requires-Dist: openai>=1.50; extra == 'all'
34
+ Provides-Extra: anthropic
35
+ Requires-Dist: anthropic>=0.69; extra == 'anthropic'
36
+ Provides-Extra: dev
37
+ Requires-Dist: mypy>=1.11; extra == 'dev'
38
+ Requires-Dist: pytest>=8; extra == 'dev'
39
+ Requires-Dist: ruff>=0.6; extra == 'dev'
40
+ Requires-Dist: types-pyyaml; extra == 'dev'
41
+ Provides-Extra: gemini
42
+ Requires-Dist: google-genai>=1.0; extra == 'gemini'
43
+ Provides-Extra: openai
44
+ Requires-Dist: openai>=1.50; extra == 'openai'
45
+ Description-Content-Type: text/markdown
46
+
47
+ <div align="center">
48
+
49
+ <img alt="OpenFix" src="https://raw.githubusercontent.com/markusweldon/openfix/main/docs/assets/logo-dark.svg" width="480">
50
+
51
+ **Turn scanner findings into verified fixes, with any model, under your policy.**
52
+
53
+ [![CI](https://github.com/markusweldon/openfix/actions/workflows/ci.yml/badge.svg)](https://github.com/markusweldon/openfix/actions/workflows/ci.yml) [![Python](https://img.shields.io/badge/python-3.10%2B-3776ab)](https://github.com/markusweldon/openfix/blob/main/pyproject.toml) [![License: MIT](https://img.shields.io/badge/license-MIT-green)](https://github.com/markusweldon/openfix/blob/main/LICENSE) [![Status: alpha](https://img.shields.io/badge/status-alpha-orange)](https://github.com/markusweldon/openfix/blob/main/ROADMAP.md)
54
+
55
+ [Quick start](#quick-start) · [How it works](#how-it-works) · [Policy](#policy-as-code) · [Models](#bring-any-model) · [GitHub Action](#github-action) · [Docs](#documentation)
56
+
57
+ </div>
58
+
59
+ ---
60
+
61
+ OpenFix reads the reports your scanners already produce: Semgrep, CodeQL, Snyk, Trivy, OSV-Scanner, Gitleaks, Dependabot, or anything that writes SARIF. A policy file decides which findings may be fixed. The model you choose writes a minimal patch in a throwaway checkout, and OpenFix then **checks the patch without trusting the model**. A fix only counts when the scanner, your tests and a new regression test all agree.
62
+
63
+ Every fix comes with a **receipt**: a signed, re-checkable record of what changed, why it was allowed, which model wrote it and what proved it works.
64
+
65
+ <br>
66
+
67
+ <img alt="OpenFix pipeline. Ingest: any scanner report is normalized. Policy: openfix.yaml decides autofix, propose or skip. Agent: any model edits a disposable worktree using policy-checked tools only. Verify: rescan, tests, regression test and optional review, independent of the agent. Ship: receipt.json, patch.diff, SARIF fixes and a draft PR." src="https://raw.githubusercontent.com/markusweldon/openfix/main/docs/assets/architecture-dark.svg" width="100%">
68
+
69
+ **Models propose. Code verifies.** The model writes the patch. Your scanner, your tests and a new regression test prove it, or it doesn't ship.
70
+
71
+ <br>
72
+
73
+ <img alt="OpenFix implementation. Scanners in: Snyk, Semgrep, GitHub CodeQL and Dependabot, Trivy, or any SARIF, plus openfix.yaml. OpenFix core: ingest.py, policy.py and engine.py hand each finding to a disposable git worktree (gitutil.py), where agent/loop.py talks to Claude, Gemini, OpenAI, Grok or Ollama through providers/ using tool calls only. verify.py then runs rescan, tests, regression test and review, using sandbox.py (Docker, no network) and scanners.py. Results out: receipt.json, patch.diff, openfix.sarif, summary.md and a GitHub draft pull request. Runs as a CLI or GitHub Action on Python 3.10+." src="https://raw.githubusercontent.com/markusweldon/openfix/main/docs/assets/implementation-dark.svg" width="100%">
74
+
75
+ <br>
76
+
77
+ <img alt="Terminal demo. Snyk Code found a command injection in /ping and Semgrep found a path traversal in readUserFile. One openfix fix command takes both reports. For each finding it shows rescan, tests and regression test passed, then verified, with a link to the draft pull request it opened. The demo then shows that pull request on GitHub, with the finding, the change and a table of passed checks. It ends on: 2 scanners in, 2 verified fixes out." src="https://raw.githubusercontent.com/markusweldon/openfix/main/docs/assets/demo-dark.gif" width="100%">
78
+
79
+ Demo example from <code>examples/vulnerable-app</code> with <a href="https://github.com/markusweldon/openfix/blob/main/docs/demo/record.py"><code>docs/demo/record.py</code></a>. The model's tool calls are replayed so anyone can rerun it without an API key; Snyk Code, Semgrep, the tests and GitHub are real. The pull request in the demo is live: <a href="https://github.com/markusweldon/openfix-demo/pull/2">markusweldon/openfix-demo#2</a>. Waiting is sped up.
80
+
81
+ <br>
82
+
83
+ ## Why OpenFix
84
+
85
+ <table>
86
+ <tr>
87
+ <td width="50%" valign="top">
88
+
89
+ ### 🔌 Any model
90
+ Claude, OpenAI, Gemini, Grok, OpenRouter, Groq, DeepSeek, Mistral, Together, Fireworks, any OpenAI-compatible gateway, or a local model through Ollama, vLLM or LM Studio. Change it with one flag: `--model provider:model`.
91
+
92
+ </td>
93
+ <td width="50%" valign="top">
94
+
95
+ ### ✅ Proof, not prose
96
+ Verification is a separate step. It never asks the model whether the fix worked. Findings that a fresh scan can't reproduce are dropped **before** any model is called, so stale results cost nothing.
97
+
98
+ </td>
99
+ </tr>
100
+ <tr>
101
+ <td valign="top">
102
+
103
+ ### 📜 Policy as code
104
+ One YAML file decides what is auto-fixed, what only gets a proposed patch, and what is never sent to a model. It also sets change-size limits, protected paths, budgets, and which code may only be seen by local models.
105
+
106
+ </td>
107
+ <td valign="top">
108
+
109
+ ### 🧱 A small blast radius
110
+ The agent has no shell, no network and no git. It can read, search and edit files, run your tests and re-run the scanner, and every write is checked against the policy. Tests run in a Docker container with networking off.
111
+
112
+ </td>
113
+ </tr>
114
+ <tr>
115
+ <td valign="top">
116
+
117
+ ### ⚙️ Deterministic when it can be
118
+ A vulnerable direct dependency is bumped to the lowest fixed version with no model involved. That is cheaper, faster and reproducible.
119
+
120
+ </td>
121
+ <td valign="top">
122
+
123
+ ### 🧾 Fits your pipeline
124
+ CLI and GitHub Action. SARIF in and SARIF out (with `fixes[]`). in-toto receipts with optional Sigstore signing. Draft PRs for humans to review. It never merges anything.
125
+
126
+ </td>
127
+ </tr>
128
+ </table>
129
+
130
+ ## Quick start
131
+
132
+ ```bash
133
+ pip install "openfix-cli[all]" # or: uv tool install "openfix-cli[all]"
134
+ export ANTHROPIC_API_KEY=... # or OPENAI_API_KEY, GEMINI_API_KEY, XAI_API_KEY, ... (openfix providers)
135
+
136
+ semgrep scan --sarif -o semgrep.sarif # any scanner that writes SARIF or a supported JSON format
137
+ openfix plan semgrep.sarif # what the policy will do with each finding; no model calls
138
+ openfix fix semgrep.sarif # fix, verify, and write receipts to .openfix/runs/<timestamp>/
139
+ ```
140
+
141
+ Use a different model to write fixes than the one that reviews them, and open draft PRs for the fixes that pass:
142
+
143
+ ```bash
144
+ openfix fix semgrep.sarif --model openai:gpt-5 --reviewer anthropic:claude-opus-5-5 --open-prs
145
+ ```
146
+
147
+ <details>
148
+ <summary><b>Try it without an API key</b></summary>
149
+
150
+ <br>
151
+
152
+ The repository includes a deliberately vulnerable Node app, real Semgrep rules, and a recorded model session:
153
+
154
+ ```bash
155
+ git clone https://github.com/markusweldon/openfix && cd openfix
156
+ pip install -e . semgrep
157
+ cd examples/vulnerable-app
158
+ openfix fix findings/semgrep.sarif --only path-traversal-path-join-var \
159
+ --model scripted:demo/path-traversal.script.yaml --sandbox local
160
+ ```
161
+
162
+ ```text
163
+ → [high] path-traversal-path-join-var src/files.js:11 [autofix via rule 'code findings']
164
+ verified: all required checks passed (rescan, tests, regression_test)
165
+ ```
166
+
167
+ CI runs this same flow on every push.
168
+
169
+ </details>
170
+
171
+ ## How it works
172
+
173
+ | # | Stage | What happens |
174
+ |:-:|---|---|
175
+ | 1 | **Ingest** | Reports are detected and normalized into one finding model. Secret values are redacted and finding ids are sanitized, because reports are untrusted input. |
176
+ | 2 | **Policy** | The first matching rule in `openfix.yaml` decides `autofix`, `propose` or `skip`, and guards and budgets are applied. |
177
+ | 3 | **Reproduce** | A fresh scan of the original code must still report the finding. If it doesn't, the finding is dropped. |
178
+ | 4 | **Fix** | The model works in a disposable git worktree through a small set of policy-checked tools. Your checkout is never touched. |
179
+ | 5 | **Verify** | The checks below run independently of the agent. |
180
+ | 6 | **Ship** | OpenFix writes `patch.diff`, `receipt.json` and SARIF `fixes[]`. A verified `autofix` can become a draft PR. |
181
+
182
+ ### The checks
183
+
184
+ <img alt="How OpenFix proves a fix. Each check runs on the original code and then on the patched code. Rescan: your scanner reports the finding before, and it is gone with nothing new after, so the fix removed the real finding. Tests: a baseline is recorded before, and the suite does no worse after. Regression test, the key check: the test the model wrote must fail on the original code and pass with the fix, so it really exercises the bug. Review, optional: a second model approves the diff. If every required check passes the fix is verified and can become a draft PR; if any fails you get the patch and evidence only. The model is never asked whether it worked." src="https://raw.githubusercontent.com/markusweldon/openfix/main/docs/assets/proof-dark.svg" width="100%">
185
+
186
+ | Check | What it proves |
187
+ |---|---|
188
+ | **Rescan** | The scanner reports the finding on the original code, **and** doesn't report it (or anything new) on the patched code. |
189
+ | **Tests** | Your test suite does no worse on the patched code than on the original. |
190
+ | **Regression test** | The test the agent added **fails on the original code and passes with the fix**, so it actually exercises the vulnerability. |
191
+ | **Review** *(optional)* | A second model, ideally from another provider, reads the exact diff, looking for bypasses and behavior changes. |
192
+
193
+ ### The receipt
194
+
195
+ Each receipt is an [in-toto](https://in-toto.io) statement whose subject is the SHA-256 of `patch.diff`. It records the finding, the policy decision, the model and token cost, and the evidence for every check. Sign it with `--sign` (Sigstore cosign), and re-check it at any time:
196
+
197
+ ```bash
198
+ openfix receipt verify .openfix/runs/<timestamp>/<finding-id> --repo .
199
+ ```
200
+
201
+ <img alt="An OpenFix receipt. receipt.json is an in-toto Statement v1 holding: the subject, sha256 of patch.diff; the finding; the policy decision and the policy's hash; the base commit; the author model, turns and cost; and the checks with their commands, exit codes and output. An optional receipt.sigstore.json signature comes from --sign. openfix receipt verify re-checks that it is a valid statement, that patch.diff matches the digest, that the base commit exists, and that the patch still applies." src="https://raw.githubusercontent.com/markusweldon/openfix/main/docs/assets/receipt-dark.svg" width="100%">
202
+
203
+ ## Policy as code
204
+
205
+ ```yaml
206
+ # openfix.yaml (the first matching rule wins)
207
+ rules:
208
+ - match: { category: [secrets] }
209
+ action: skip # rotate credentials; don't just delete them from code
210
+ - match: { path: ["**/auth/**", "**/payment*/**"] }
211
+ action: propose # patch + receipt for a human, no PR
212
+ - match: { category: [sast, sca], min_severity: medium }
213
+ action: autofix # draft PR when every required check passes
214
+ guards:
215
+ max_files_changed: 4
216
+ max_lines_changed: 200
217
+ protected_paths: [".github/workflows/**", "**/.env*"]
218
+ models:
219
+ author: anthropic:claude-opus-5-5
220
+ reviewer: openai:gpt-5
221
+ local_only_paths: ["services/payments/**"] # this code is only ever sent to local models
222
+ budgets: { max_turns: 40, max_usd_per_fix: 3.0, max_usd_per_run: 25.0 }
223
+ verify:
224
+ require: [rescan, tests, regression_test]
225
+ ```
226
+
227
+ Run `openfix init` to write a starter file. Full reference: [docs/policy.md](https://github.com/markusweldon/openfix/blob/main/docs/policy.md).
228
+
229
+ ## Bring any model
230
+
231
+ | Provider | Example `--model` | Credential |
232
+ |---|---|---|
233
+ | Anthropic | `anthropic:claude-opus-5-5` | `ANTHROPIC_API_KEY` |
234
+ | OpenAI | `openai:gpt-5` | `OPENAI_API_KEY` |
235
+ | Google Gemini | `gemini:gemini-2.5-pro` | `GEMINI_API_KEY` |
236
+ | xAI Grok | `xai:grok-4` | `XAI_API_KEY` |
237
+ | OpenRouter, Groq, DeepSeek, Mistral, Together, Fireworks | `openrouter:<model>`, `groq:<model>`, … | `<PROVIDER>_API_KEY` |
238
+ | Any OpenAI-compatible gateway | `compat:<model>` | `OPENFIX_COMPAT_BASE_URL` |
239
+ | Local: Ollama, vLLM, LM Studio | `ollama:qwen2.5-coder:32b` | none |
240
+
241
+ Run `openfix providers` to see which credentials are set. Details: [docs/providers.md](https://github.com/markusweldon/openfix/blob/main/docs/providers.md).
242
+
243
+ ## GitHub Action
244
+
245
+ ### Run it on a schedule
246
+
247
+ Put OpenFix on a schedule and it works as a remediation factory: your scanners' findings go in, and verified draft PRs come out. Nothing ships without proof, and a person still merges every fix. The workflow below runs every Monday at 06:00 UTC, and you can also start it by hand from the Actions tab. `max` caps how many findings one run attempts, and `max_usd_per_run` in [`openfix.yaml`](https://github.com/markusweldon/openfix/blob/main/docs/policy.md) caps what a run can spend on the model.
248
+
249
+ <img alt="OpenFix on a schedule. 1 Schedule: cron every Monday, or run it by hand. 2 Scan: Snyk, Semgrep, CodeQL or Trivy write SARIF. 3 Fix and verify: policy decides, the model patches, code proves it, within max and max_usd_per_run. 4 Draft PRs: one per verified fix, with an evidence table and the receipt digest, never auto-merged. 5 You merge: your CI runs and a person reviews and decides. The next run updates the same PR branch instead of opening a duplicate. Every run uploads receipts, summary.md and openfix.sarif as a workflow artifact." src="https://raw.githubusercontent.com/markusweldon/openfix/main/docs/assets/schedule-dark.svg" width="100%">
250
+
251
+ ```yaml
252
+ name: OpenFix
253
+ on:
254
+ workflow_dispatch:
255
+ schedule: [{ cron: "0 6 * * 1" }]
256
+ permissions:
257
+ contents: write
258
+ pull-requests: write
259
+ jobs:
260
+ fix:
261
+ runs-on: ubuntu-latest
262
+ steps:
263
+ - uses: actions/checkout@v4
264
+ - run: pip install semgrep && semgrep scan --config p/default --sarif -o semgrep.sarif || true
265
+ - uses: markusweldon/openfix@v0.4.0
266
+ with:
267
+ reports: semgrep.sarif
268
+ model: anthropic:claude-opus-5-5
269
+ reviewer: openai:gpt-5
270
+ env:
271
+ ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
272
+ OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
273
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
274
+ ```
275
+
276
+ Each verified autofix becomes a draft PR with an evidence table and the receipt digest. Receipts, `summary.md` and `openfix.sarif` are uploaded as a workflow artifact. Your CI still runs on the PR, and a person still merges it.
277
+
278
+ ## Supported inputs
279
+
280
+ | Format | Sources |
281
+ |---|---|
282
+ | SARIF 2.1.0 | Semgrep, CodeQL, Snyk Code, Trivy, Checkov, Bandit, Gitleaks, … |
283
+ | Native JSON | Semgrep, Snyk Open Source, Trivy (vulnerabilities, misconfigurations, secrets), OSV-Scanner, Gitleaks |
284
+ | GitHub APIs | Code-scanning alerts, Dependabot alerts |
285
+ | OpenFix | [Findings JSON](https://github.com/markusweldon/openfix/blob/main/docs/findings-format.md), for your own tools |
286
+
287
+ Formats are detected automatically. Pass several reports at once and duplicate findings are merged.
288
+
289
+ ## Commands
290
+
291
+ | Command | |
292
+ |---|---|
293
+ | `openfix findings REPORT...` | Normalize and list findings (`--json` for OpenFix findings JSON) |
294
+ | `openfix plan REPORT...` | Show the policy decision for each finding |
295
+ | `openfix fix REPORT...` | Fix, verify and write receipts: `--model`, `--reviewer`, `--only`, `--max`, `--require`, `--sandbox`, `--open-prs`, `--sign` |
296
+ | `openfix receipt verify DIR` | Re-check a receipt's digests and that its patch still applies |
297
+ | `openfix providers` | Supported providers and credential status |
298
+ | `openfix init` | Write a starter `openfix.yaml` |
299
+
300
+ `--repo` can point at a subdirectory of a monorepo. Findings, tests and scans are resolved relative to it, and patches are written relative to the repository root.
301
+
302
+ ## Documentation
303
+
304
+ - [Policy reference](https://github.com/markusweldon/openfix/blob/main/docs/policy.md)
305
+ - [Providers and models](https://github.com/markusweldon/openfix/blob/main/docs/providers.md)
306
+ - [Verification and receipts](https://github.com/markusweldon/openfix/blob/main/docs/receipts.md)
307
+ - [Security model](https://github.com/markusweldon/openfix/blob/main/docs/security-model.md): what OpenFix protects against, and what it doesn't
308
+ - [Findings format](https://github.com/markusweldon/openfix/blob/main/docs/findings-format.md)
309
+ - [Brand and diagrams](https://github.com/markusweldon/openfix/blob/main/docs/brand/README.md): logo, colours, type, and the script that draws the images
310
+ - [Roadmap](https://github.com/markusweldon/openfix/blob/main/ROADMAP.md)
311
+
312
+ ## Status
313
+
314
+ OpenFix 0.3 is **alpha**. The core pipeline (ingest, policy, agent, verification, receipts and PRs) is implemented and tested end to end against real scanners and test suites. Next on the [roadmap](https://github.com/markusweldon/openfix/blob/main/ROADMAP.md): a public fix-rate benchmark across models, an MCP server, and GitLab support.
315
+
316
+ Issues and pull requests are welcome; start with [CONTRIBUTING.md](https://github.com/markusweldon/openfix/blob/main/CONTRIBUTING.md). To report a vulnerability in OpenFix itself, see [SECURITY.md](https://github.com/markusweldon/openfix/blob/main/SECURITY.md).
317
+
318
+ ## License
319
+
320
+ [MIT](https://github.com/markusweldon/openfix/blob/main/LICENSE)
321
+
322
+ <sub>Brand icons in the diagrams come from [Simple Icons](https://simpleicons.org) (CC0) and the [Semgrep repository](https://github.com/semgrep/semgrep). All trademarks belong to their owners, and their use here doesn't imply endorsement.</sub>
@@ -0,0 +1,276 @@
1
+ <div align="center">
2
+
3
+ <img alt="OpenFix" src="docs/assets/logo-dark.svg" width="480">
4
+
5
+ **Turn scanner findings into verified fixes, with any model, under your policy.**
6
+
7
+ [![CI](https://github.com/markusweldon/openfix/actions/workflows/ci.yml/badge.svg)](https://github.com/markusweldon/openfix/actions/workflows/ci.yml) [![Python](https://img.shields.io/badge/python-3.10%2B-3776ab)](pyproject.toml) [![License: MIT](https://img.shields.io/badge/license-MIT-green)](LICENSE) [![Status: alpha](https://img.shields.io/badge/status-alpha-orange)](ROADMAP.md)
8
+
9
+ [Quick start](#quick-start) · [How it works](#how-it-works) · [Policy](#policy-as-code) · [Models](#bring-any-model) · [GitHub Action](#github-action) · [Docs](#documentation)
10
+
11
+ </div>
12
+
13
+ ---
14
+
15
+ OpenFix reads the reports your scanners already produce: Semgrep, CodeQL, Snyk, Trivy, OSV-Scanner, Gitleaks, Dependabot, or anything that writes SARIF. A policy file decides which findings may be fixed. The model you choose writes a minimal patch in a throwaway checkout, and OpenFix then **checks the patch without trusting the model**. A fix only counts when the scanner, your tests and a new regression test all agree.
16
+
17
+ Every fix comes with a **receipt**: a signed, re-checkable record of what changed, why it was allowed, which model wrote it and what proved it works.
18
+
19
+ <br>
20
+
21
+ <img alt="OpenFix pipeline. Ingest: any scanner report is normalized. Policy: openfix.yaml decides autofix, propose or skip. Agent: any model edits a disposable worktree using policy-checked tools only. Verify: rescan, tests, regression test and optional review, independent of the agent. Ship: receipt.json, patch.diff, SARIF fixes and a draft PR." src="docs/assets/architecture-dark.svg" width="100%">
22
+
23
+ **Models propose. Code verifies.** The model writes the patch. Your scanner, your tests and a new regression test prove it, or it doesn't ship.
24
+
25
+ <br>
26
+
27
+ <img alt="OpenFix implementation. Scanners in: Snyk, Semgrep, GitHub CodeQL and Dependabot, Trivy, or any SARIF, plus openfix.yaml. OpenFix core: ingest.py, policy.py and engine.py hand each finding to a disposable git worktree (gitutil.py), where agent/loop.py talks to Claude, Gemini, OpenAI, Grok or Ollama through providers/ using tool calls only. verify.py then runs rescan, tests, regression test and review, using sandbox.py (Docker, no network) and scanners.py. Results out: receipt.json, patch.diff, openfix.sarif, summary.md and a GitHub draft pull request. Runs as a CLI or GitHub Action on Python 3.10+." src="docs/assets/implementation-dark.svg" width="100%">
28
+
29
+ <br>
30
+
31
+ <img alt="Terminal demo. Snyk Code found a command injection in /ping and Semgrep found a path traversal in readUserFile. One openfix fix command takes both reports. For each finding it shows rescan, tests and regression test passed, then verified, with a link to the draft pull request it opened. The demo then shows that pull request on GitHub, with the finding, the change and a table of passed checks. It ends on: 2 scanners in, 2 verified fixes out." src="docs/assets/demo-dark.gif" width="100%">
32
+
33
+ Demo example from <code>examples/vulnerable-app</code> with <a href="docs/demo/record.py"><code>docs/demo/record.py</code></a>. The model's tool calls are replayed so anyone can rerun it without an API key; Snyk Code, Semgrep, the tests and GitHub are real. The pull request in the demo is live: <a href="https://github.com/markusweldon/openfix-demo/pull/2">markusweldon/openfix-demo#2</a>. Waiting is sped up.
34
+
35
+ <br>
36
+
37
+ ## Why OpenFix
38
+
39
+ <table>
40
+ <tr>
41
+ <td width="50%" valign="top">
42
+
43
+ ### 🔌 Any model
44
+ Claude, OpenAI, Gemini, Grok, OpenRouter, Groq, DeepSeek, Mistral, Together, Fireworks, any OpenAI-compatible gateway, or a local model through Ollama, vLLM or LM Studio. Change it with one flag: `--model provider:model`.
45
+
46
+ </td>
47
+ <td width="50%" valign="top">
48
+
49
+ ### ✅ Proof, not prose
50
+ Verification is a separate step. It never asks the model whether the fix worked. Findings that a fresh scan can't reproduce are dropped **before** any model is called, so stale results cost nothing.
51
+
52
+ </td>
53
+ </tr>
54
+ <tr>
55
+ <td valign="top">
56
+
57
+ ### 📜 Policy as code
58
+ One YAML file decides what is auto-fixed, what only gets a proposed patch, and what is never sent to a model. It also sets change-size limits, protected paths, budgets, and which code may only be seen by local models.
59
+
60
+ </td>
61
+ <td valign="top">
62
+
63
+ ### 🧱 A small blast radius
64
+ The agent has no shell, no network and no git. It can read, search and edit files, run your tests and re-run the scanner, and every write is checked against the policy. Tests run in a Docker container with networking off.
65
+
66
+ </td>
67
+ </tr>
68
+ <tr>
69
+ <td valign="top">
70
+
71
+ ### ⚙️ Deterministic when it can be
72
+ A vulnerable direct dependency is bumped to the lowest fixed version with no model involved. That is cheaper, faster and reproducible.
73
+
74
+ </td>
75
+ <td valign="top">
76
+
77
+ ### 🧾 Fits your pipeline
78
+ CLI and GitHub Action. SARIF in and SARIF out (with `fixes[]`). in-toto receipts with optional Sigstore signing. Draft PRs for humans to review. It never merges anything.
79
+
80
+ </td>
81
+ </tr>
82
+ </table>
83
+
84
+ ## Quick start
85
+
86
+ ```bash
87
+ pip install "openfix-cli[all]" # or: uv tool install "openfix-cli[all]"
88
+ export ANTHROPIC_API_KEY=... # or OPENAI_API_KEY, GEMINI_API_KEY, XAI_API_KEY, ... (openfix providers)
89
+
90
+ semgrep scan --sarif -o semgrep.sarif # any scanner that writes SARIF or a supported JSON format
91
+ openfix plan semgrep.sarif # what the policy will do with each finding; no model calls
92
+ openfix fix semgrep.sarif # fix, verify, and write receipts to .openfix/runs/<timestamp>/
93
+ ```
94
+
95
+ Use a different model to write fixes than the one that reviews them, and open draft PRs for the fixes that pass:
96
+
97
+ ```bash
98
+ openfix fix semgrep.sarif --model openai:gpt-5 --reviewer anthropic:claude-opus-5-5 --open-prs
99
+ ```
100
+
101
+ <details>
102
+ <summary><b>Try it without an API key</b></summary>
103
+
104
+ <br>
105
+
106
+ The repository includes a deliberately vulnerable Node app, real Semgrep rules, and a recorded model session:
107
+
108
+ ```bash
109
+ git clone https://github.com/markusweldon/openfix && cd openfix
110
+ pip install -e . semgrep
111
+ cd examples/vulnerable-app
112
+ openfix fix findings/semgrep.sarif --only path-traversal-path-join-var \
113
+ --model scripted:demo/path-traversal.script.yaml --sandbox local
114
+ ```
115
+
116
+ ```text
117
+ → [high] path-traversal-path-join-var src/files.js:11 [autofix via rule 'code findings']
118
+ verified: all required checks passed (rescan, tests, regression_test)
119
+ ```
120
+
121
+ CI runs this same flow on every push.
122
+
123
+ </details>
124
+
125
+ ## How it works
126
+
127
+ | # | Stage | What happens |
128
+ |:-:|---|---|
129
+ | 1 | **Ingest** | Reports are detected and normalized into one finding model. Secret values are redacted and finding ids are sanitized, because reports are untrusted input. |
130
+ | 2 | **Policy** | The first matching rule in `openfix.yaml` decides `autofix`, `propose` or `skip`, and guards and budgets are applied. |
131
+ | 3 | **Reproduce** | A fresh scan of the original code must still report the finding. If it doesn't, the finding is dropped. |
132
+ | 4 | **Fix** | The model works in a disposable git worktree through a small set of policy-checked tools. Your checkout is never touched. |
133
+ | 5 | **Verify** | The checks below run independently of the agent. |
134
+ | 6 | **Ship** | OpenFix writes `patch.diff`, `receipt.json` and SARIF `fixes[]`. A verified `autofix` can become a draft PR. |
135
+
136
+ ### The checks
137
+
138
+ <img alt="How OpenFix proves a fix. Each check runs on the original code and then on the patched code. Rescan: your scanner reports the finding before, and it is gone with nothing new after, so the fix removed the real finding. Tests: a baseline is recorded before, and the suite does no worse after. Regression test, the key check: the test the model wrote must fail on the original code and pass with the fix, so it really exercises the bug. Review, optional: a second model approves the diff. If every required check passes the fix is verified and can become a draft PR; if any fails you get the patch and evidence only. The model is never asked whether it worked." src="docs/assets/proof-dark.svg" width="100%">
139
+
140
+ | Check | What it proves |
141
+ |---|---|
142
+ | **Rescan** | The scanner reports the finding on the original code, **and** doesn't report it (or anything new) on the patched code. |
143
+ | **Tests** | Your test suite does no worse on the patched code than on the original. |
144
+ | **Regression test** | The test the agent added **fails on the original code and passes with the fix**, so it actually exercises the vulnerability. |
145
+ | **Review** *(optional)* | A second model, ideally from another provider, reads the exact diff, looking for bypasses and behavior changes. |
146
+
147
+ ### The receipt
148
+
149
+ Each receipt is an [in-toto](https://in-toto.io) statement whose subject is the SHA-256 of `patch.diff`. It records the finding, the policy decision, the model and token cost, and the evidence for every check. Sign it with `--sign` (Sigstore cosign), and re-check it at any time:
150
+
151
+ ```bash
152
+ openfix receipt verify .openfix/runs/<timestamp>/<finding-id> --repo .
153
+ ```
154
+
155
+ <img alt="An OpenFix receipt. receipt.json is an in-toto Statement v1 holding: the subject, sha256 of patch.diff; the finding; the policy decision and the policy's hash; the base commit; the author model, turns and cost; and the checks with their commands, exit codes and output. An optional receipt.sigstore.json signature comes from --sign. openfix receipt verify re-checks that it is a valid statement, that patch.diff matches the digest, that the base commit exists, and that the patch still applies." src="docs/assets/receipt-dark.svg" width="100%">
156
+
157
+ ## Policy as code
158
+
159
+ ```yaml
160
+ # openfix.yaml (the first matching rule wins)
161
+ rules:
162
+ - match: { category: [secrets] }
163
+ action: skip # rotate credentials; don't just delete them from code
164
+ - match: { path: ["**/auth/**", "**/payment*/**"] }
165
+ action: propose # patch + receipt for a human, no PR
166
+ - match: { category: [sast, sca], min_severity: medium }
167
+ action: autofix # draft PR when every required check passes
168
+ guards:
169
+ max_files_changed: 4
170
+ max_lines_changed: 200
171
+ protected_paths: [".github/workflows/**", "**/.env*"]
172
+ models:
173
+ author: anthropic:claude-opus-5-5
174
+ reviewer: openai:gpt-5
175
+ local_only_paths: ["services/payments/**"] # this code is only ever sent to local models
176
+ budgets: { max_turns: 40, max_usd_per_fix: 3.0, max_usd_per_run: 25.0 }
177
+ verify:
178
+ require: [rescan, tests, regression_test]
179
+ ```
180
+
181
+ Run `openfix init` to write a starter file. Full reference: [docs/policy.md](docs/policy.md).
182
+
183
+ ## Bring any model
184
+
185
+ | Provider | Example `--model` | Credential |
186
+ |---|---|---|
187
+ | Anthropic | `anthropic:claude-opus-5-5` | `ANTHROPIC_API_KEY` |
188
+ | OpenAI | `openai:gpt-5` | `OPENAI_API_KEY` |
189
+ | Google Gemini | `gemini:gemini-2.5-pro` | `GEMINI_API_KEY` |
190
+ | xAI Grok | `xai:grok-4` | `XAI_API_KEY` |
191
+ | OpenRouter, Groq, DeepSeek, Mistral, Together, Fireworks | `openrouter:<model>`, `groq:<model>`, … | `<PROVIDER>_API_KEY` |
192
+ | Any OpenAI-compatible gateway | `compat:<model>` | `OPENFIX_COMPAT_BASE_URL` |
193
+ | Local: Ollama, vLLM, LM Studio | `ollama:qwen2.5-coder:32b` | none |
194
+
195
+ Run `openfix providers` to see which credentials are set. Details: [docs/providers.md](docs/providers.md).
196
+
197
+ ## GitHub Action
198
+
199
+ ### Run it on a schedule
200
+
201
+ Put OpenFix on a schedule and it works as a remediation factory: your scanners' findings go in, and verified draft PRs come out. Nothing ships without proof, and a person still merges every fix. The workflow below runs every Monday at 06:00 UTC, and you can also start it by hand from the Actions tab. `max` caps how many findings one run attempts, and `max_usd_per_run` in [`openfix.yaml`](docs/policy.md) caps what a run can spend on the model.
202
+
203
+ <img alt="OpenFix on a schedule. 1 Schedule: cron every Monday, or run it by hand. 2 Scan: Snyk, Semgrep, CodeQL or Trivy write SARIF. 3 Fix and verify: policy decides, the model patches, code proves it, within max and max_usd_per_run. 4 Draft PRs: one per verified fix, with an evidence table and the receipt digest, never auto-merged. 5 You merge: your CI runs and a person reviews and decides. The next run updates the same PR branch instead of opening a duplicate. Every run uploads receipts, summary.md and openfix.sarif as a workflow artifact." src="docs/assets/schedule-dark.svg" width="100%">
204
+
205
+ ```yaml
206
+ name: OpenFix
207
+ on:
208
+ workflow_dispatch:
209
+ schedule: [{ cron: "0 6 * * 1" }]
210
+ permissions:
211
+ contents: write
212
+ pull-requests: write
213
+ jobs:
214
+ fix:
215
+ runs-on: ubuntu-latest
216
+ steps:
217
+ - uses: actions/checkout@v4
218
+ - run: pip install semgrep && semgrep scan --config p/default --sarif -o semgrep.sarif || true
219
+ - uses: markusweldon/openfix@v0.4.0
220
+ with:
221
+ reports: semgrep.sarif
222
+ model: anthropic:claude-opus-5-5
223
+ reviewer: openai:gpt-5
224
+ env:
225
+ ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
226
+ OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
227
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
228
+ ```
229
+
230
+ Each verified autofix becomes a draft PR with an evidence table and the receipt digest. Receipts, `summary.md` and `openfix.sarif` are uploaded as a workflow artifact. Your CI still runs on the PR, and a person still merges it.
231
+
232
+ ## Supported inputs
233
+
234
+ | Format | Sources |
235
+ |---|---|
236
+ | SARIF 2.1.0 | Semgrep, CodeQL, Snyk Code, Trivy, Checkov, Bandit, Gitleaks, … |
237
+ | Native JSON | Semgrep, Snyk Open Source, Trivy (vulnerabilities, misconfigurations, secrets), OSV-Scanner, Gitleaks |
238
+ | GitHub APIs | Code-scanning alerts, Dependabot alerts |
239
+ | OpenFix | [Findings JSON](docs/findings-format.md), for your own tools |
240
+
241
+ Formats are detected automatically. Pass several reports at once and duplicate findings are merged.
242
+
243
+ ## Commands
244
+
245
+ | Command | |
246
+ |---|---|
247
+ | `openfix findings REPORT...` | Normalize and list findings (`--json` for OpenFix findings JSON) |
248
+ | `openfix plan REPORT...` | Show the policy decision for each finding |
249
+ | `openfix fix REPORT...` | Fix, verify and write receipts: `--model`, `--reviewer`, `--only`, `--max`, `--require`, `--sandbox`, `--open-prs`, `--sign` |
250
+ | `openfix receipt verify DIR` | Re-check a receipt's digests and that its patch still applies |
251
+ | `openfix providers` | Supported providers and credential status |
252
+ | `openfix init` | Write a starter `openfix.yaml` |
253
+
254
+ `--repo` can point at a subdirectory of a monorepo. Findings, tests and scans are resolved relative to it, and patches are written relative to the repository root.
255
+
256
+ ## Documentation
257
+
258
+ - [Policy reference](docs/policy.md)
259
+ - [Providers and models](docs/providers.md)
260
+ - [Verification and receipts](docs/receipts.md)
261
+ - [Security model](docs/security-model.md): what OpenFix protects against, and what it doesn't
262
+ - [Findings format](docs/findings-format.md)
263
+ - [Brand and diagrams](docs/brand/README.md): logo, colours, type, and the script that draws the images
264
+ - [Roadmap](ROADMAP.md)
265
+
266
+ ## Status
267
+
268
+ OpenFix 0.3 is **alpha**. The core pipeline (ingest, policy, agent, verification, receipts and PRs) is implemented and tested end to end against real scanners and test suites. Next on the [roadmap](ROADMAP.md): a public fix-rate benchmark across models, an MCP server, and GitLab support.
269
+
270
+ Issues and pull requests are welcome; start with [CONTRIBUTING.md](CONTRIBUTING.md). To report a vulnerability in OpenFix itself, see [SECURITY.md](SECURITY.md).
271
+
272
+ ## License
273
+
274
+ [MIT](LICENSE)
275
+
276
+ <sub>Brand icons in the diagrams come from [Simple Icons](https://simpleicons.org) (CC0) and the [Semgrep repository](https://github.com/semgrep/semgrep). All trademarks belong to their owners, and their use here doesn't imply endorsement.</sub>