{"id":47782404,"url":"https://github.com/adzerk/auto-security-patch","last_synced_at":"2026-04-03T13:44:50.533Z","repository":{"id":346178588,"uuid":"1188824489","full_name":"adzerk/auto-security-patch","owner":"adzerk","description":"AI-powered security vulnerability remediation pipeline — GitHub Actions workflow that resolves code security findings via a 7-stage Claude agent pipeline.","archived":false,"fork":false,"pushed_at":"2026-03-22T19:16:27.000Z","size":148,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-23T07:41:51.300Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adzerk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-22T16:27:13.000Z","updated_at":"2026-03-22T19:16:31.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/adzerk/auto-security-patch","commit_stats":null,"previous_names":["adzerk/auto-security-patch"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/adzerk/auto-security-patch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adzerk%2Fauto-security-patch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adzerk%2Fauto-security-patch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adzerk%2Fauto-security-patch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adzerk%2Fauto-security-patch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adzerk","download_url":"https://codeload.github.com/adzerk/auto-security-patch/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adzerk%2Fauto-security-patch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31354399,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-03T08:03:20.796Z","status":"ssl_error","status_checked_at":"2026-04-03T08:00:37.834Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-03T13:44:49.225Z","updated_at":"2026-04-03T13:44:50.525Z","avatar_url":"https://github.com/adzerk.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# auto-security-patch\n\nAn AI-powered pipeline that takes a raw security vulnerability report — in any format — and automatically produces a GitHub pull request with a fix, or an issue with a suppression/investigation recommendation. All output requires human review before merging.\n\n## How it works\n\nA vulnerability blob (Bandit JSON, SARIF, plain text, or anything else) is passed to a 7-stage Claude agent pipeline. Each stage has a narrowly scoped set of tools and produces structured output for the next stage. The orchestrator handles all git/GitHub operations — agents never write files or call APIs directly.\n\n```mermaid\nflowchart TD\n    Input([VULNERABILITY_DATA\\nany format]) --\u003e S0\n\n    S0[\"Stage 0 — Normalizer\\nExtracts canonical Finding\\nfile · line · CWE · severity\"]\n    S1[\"Stage 1 — Researcher\\nFetches CWE page, OWASP docs,\\nreal-world CVEs\"]\n    S2[\"Stage 2 — Assessor\\nReads actual code, checks auth\\nmiddleware, call paths\"]\n    S2b[\"Stage 2b — Assessment Verifier\\nReads every cited file:line ref\\nand checks code matches claims\"]\n\n    S0 --\u003e S1 --\u003e S2 --\u003e S2b\n\n    S2b --\u003e|\"SUPPRESS (informational)\"| S6\n    S2b --\u003e|NEEDS_INVESTIGATION| S6\n    S2b --\u003e|CONTRADICTED → override| S6\n    S2b --\u003e|PATCH| S3\n    S2b --\u003e|\"SUPPRESS (code change)\"| S3\n\n    subgraph fix [\"Code change loop (max 2 attempts)\"]\n        S3[\"Stage 3 — Explorer\\nDiscovers related files,\\nexisting safe patterns\"] --\u003e S4\n        S4[\"Stage 4 — Fix Writer\\nWrites fix or suppression markers\\nvia write_file tool\"] --\u003e S5\n        S5[\"Stage 5 — Validator\\nRuns py_compile + flake8\\nChecks struct integrity\"]\n        S5 --\u003e|FAIL| S4\n    end\n\n    S3 -.-\u003e fix\n    fix --\u003e S6\n\n    S6[\"Stage 6 — PR Author\\nLLM writes body text\\nOrchestrator calls GitHub API\"]\n\n    S6 --\u003e|PATCH| PR([Pull Request])\n    S6 --\u003e|\"SUPPRESS + code change\"| PR2([Pull Request:\\nsuppression markers])\n    S6 --\u003e|\"SUPPRESS (informational)\"| Issue1([Issue: suppress])\n    S6 --\u003e|NEEDS_INVESTIGATION| Issue2([Issue: investigate])\n    S6 --\u003e|Pipeline failed| Issue3([Issue: failure report])\n```\n\n## Security model\n\nThe pipeline is designed for minimal blast radius:\n\n- **Tool restrictions**: each stage's Claude API call only receives the tool schemas it needs — the model cannot call a tool outside its allowlist (enforced at the API level)\n- **Sandboxed filesystem access**: all file reads/writes operate on a temp-dir clone of the target repo; path traversal is rejected by resolving against the sandbox root\n- **No shell=True anywhere**: subprocess calls use list args throughout\n- **SSRF protection**: `web_fetch` validates URLs against RFC 1918/link-local/loopback ranges before connecting\n- **Token redaction**: GitHub tokens are stripped from error messages before logging\n- **Human oversight always**: output is PRs and issues — nothing is auto-merged\n\n## Usage\n\n### GitHub Actions (recommended)\n\nTrigger manually from the **Actions** tab, or call from another workflow:\n\n```yaml\n# In another workflow:\njobs:\n  patch:\n    uses: adzerk/auto-security-patch/.github/workflows/security-patch.yml@main\n    with:\n      vulnerability_data: ${{ toJson(steps.scan.outputs.finding) }}\n      target_repo: adzerk/my-service\n      dry_run: false\n    secrets:\n      ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}\n      REPO_WRITE_TOKEN: ${{ secrets.REPO_WRITE_TOKEN }}\n```\n\n**Required secrets:**\n\n| Secret | Scopes needed |\n|--------|--------------|\n| `ANTHROPIC_API_KEY` | Claude API |\n| `REPO_WRITE_TOKEN` | `contents:write`, `pull-requests:write`, `issues:write` on the target repo |\n\n### Local dry run\n\n```bash\npyenv local 3.14.2\npoetry env use $(pyenv which python)\npoetry install --with dev\n\nexport ANTHROPIC_API_KEY=...\nexport GITHUB_TOKEN=...          # needs write access to target repo\nexport TARGET_REPO=org/repo\nexport DRY_RUN=true\nexport VULNERABILITY_DATA='{\"test_id\":\"B608\",\"filename\":\"app.py\",\"line_number\":42,...}'\n\npoetry run python -m pipeline.run_pipeline\n# Outputs to pipeline-output/ — no PRs or issues created\n```\n\n## Input format\n\n`VULNERABILITY_DATA` accepts any format. The normalizer (Stage 0) uses Claude to extract the key fields. Supported out of the box:\n\n- **Bandit JSON** — single finding object from `bandit -f json`\n- **SARIF** — GitHub Advanced Security, Semgrep, CodeQL output\n- **Plain text** — any human-readable vulnerability description\n\nThe pipeline fails fast with a clear error if it cannot extract `file_path` and `line_number` with high confidence.\n\n## Output\n\n| Verdict | GitHub output |\n|---------|--------------|\n| `PATCH` | Pull request with diff, research summary, exploitability reasoning, reviewer checklist |\n| `SUPPRESS` (code change) | Pull request adding suppression markers (e.g. `# noqa`, `# nosec`) with justification |\n| `SUPPRESS` (informational) | Issue with suppression reasoning — no code change needed (dead code, test-only) |\n| `NEEDS_INVESTIGATION` | Issue with specific open questions for a human reviewer |\n| Pipeline failure | Issue with available context and failure details |\n\nAll output is logged to a `pipeline-logs` artifact on the Actions run regardless of outcome.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadzerk%2Fauto-security-patch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadzerk%2Fauto-security-patch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadzerk%2Fauto-security-patch/lists"}