breachgraph 0.1.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 (61) hide show
  1. breachgraph-0.1.0/.gitignore +15 -0
  2. breachgraph-0.1.0/CHANGELOG.md +78 -0
  3. breachgraph-0.1.0/LICENSE +202 -0
  4. breachgraph-0.1.0/PKG-INFO +290 -0
  5. breachgraph-0.1.0/README.md +240 -0
  6. breachgraph-0.1.0/examples/vulnerable-app/README.md +23 -0
  7. breachgraph-0.1.0/examples/vulnerable-platform/README.md +44 -0
  8. breachgraph-0.1.0/pyproject.toml +103 -0
  9. breachgraph-0.1.0/src/breachgraph/__init__.py +10 -0
  10. breachgraph-0.1.0/src/breachgraph/ai/__init__.py +322 -0
  11. breachgraph-0.1.0/src/breachgraph/ai/context.py +395 -0
  12. breachgraph-0.1.0/src/breachgraph/ai/prompts.py +69 -0
  13. breachgraph-0.1.0/src/breachgraph/cicd/__init__.py +298 -0
  14. breachgraph-0.1.0/src/breachgraph/cicd/workflows.py +188 -0
  15. breachgraph-0.1.0/src/breachgraph/cli.py +537 -0
  16. breachgraph-0.1.0/src/breachgraph/config.py +234 -0
  17. breachgraph-0.1.0/src/breachgraph/enrich/__init__.py +117 -0
  18. breachgraph-0.1.0/src/breachgraph/graph/__init__.py +87 -0
  19. breachgraph-0.1.0/src/breachgraph/graph/correlate.py +292 -0
  20. breachgraph-0.1.0/src/breachgraph/graph/model.py +149 -0
  21. breachgraph-0.1.0/src/breachgraph/graph/paths.py +181 -0
  22. breachgraph-0.1.0/src/breachgraph/graph/sources/actions.py +286 -0
  23. breachgraph-0.1.0/src/breachgraph/graph/sources/azure.py +804 -0
  24. breachgraph-0.1.0/src/breachgraph/graph/sources/common.py +40 -0
  25. breachgraph-0.1.0/src/breachgraph/graph/sources/gcp.py +718 -0
  26. breachgraph-0.1.0/src/breachgraph/graph/sources/hcl.py +122 -0
  27. breachgraph-0.1.0/src/breachgraph/graph/sources/images.py +90 -0
  28. breachgraph-0.1.0/src/breachgraph/graph/sources/kubernetes.py +537 -0
  29. breachgraph-0.1.0/src/breachgraph/graph/sources/routes.py +373 -0
  30. breachgraph-0.1.0/src/breachgraph/graph/sources/terraform.py +834 -0
  31. breachgraph-0.1.0/src/breachgraph/graph/sources/tfload.py +122 -0
  32. breachgraph-0.1.0/src/breachgraph/graph/summary.py +83 -0
  33. breachgraph-0.1.0/src/breachgraph/integrations/__init__.py +0 -0
  34. breachgraph-0.1.0/src/breachgraph/integrations/github.py +200 -0
  35. breachgraph-0.1.0/src/breachgraph/models.py +295 -0
  36. breachgraph-0.1.0/src/breachgraph/normalize/__init__.py +291 -0
  37. breachgraph-0.1.0/src/breachgraph/normalize/taxonomy.py +117 -0
  38. breachgraph-0.1.0/src/breachgraph/paths.py +81 -0
  39. breachgraph-0.1.0/src/breachgraph/pipeline.py +198 -0
  40. breachgraph-0.1.0/src/breachgraph/policy.py +167 -0
  41. breachgraph-0.1.0/src/breachgraph/py.typed +0 -0
  42. breachgraph-0.1.0/src/breachgraph/reachability/__init__.py +157 -0
  43. breachgraph-0.1.0/src/breachgraph/reachability/imports.py +157 -0
  44. breachgraph-0.1.0/src/breachgraph/reporters/__init__.py +38 -0
  45. breachgraph-0.1.0/src/breachgraph/reporters/html.py +33 -0
  46. breachgraph-0.1.0/src/breachgraph/reporters/junit.py +37 -0
  47. breachgraph-0.1.0/src/breachgraph/reporters/markdown.py +239 -0
  48. breachgraph-0.1.0/src/breachgraph/reporters/sarif.py +147 -0
  49. breachgraph-0.1.0/src/breachgraph/reporters/templates/report.html.j2 +236 -0
  50. breachgraph-0.1.0/src/breachgraph/scanners/__init__.py +29 -0
  51. breachgraph-0.1.0/src/breachgraph/scanners/_util.py +51 -0
  52. breachgraph-0.1.0/src/breachgraph/scanners/base.py +179 -0
  53. breachgraph-0.1.0/src/breachgraph/scanners/checkov.py +81 -0
  54. breachgraph-0.1.0/src/breachgraph/scanners/cicd.py +46 -0
  55. breachgraph-0.1.0/src/breachgraph/scanners/gitleaks.py +112 -0
  56. breachgraph-0.1.0/src/breachgraph/scanners/sarif_import.py +99 -0
  57. breachgraph-0.1.0/src/breachgraph/scanners/semgrep.py +89 -0
  58. breachgraph-0.1.0/src/breachgraph/scanners/trivy.py +242 -0
  59. breachgraph-0.1.0/src/breachgraph/scanners/zap.py +94 -0
  60. breachgraph-0.1.0/src/breachgraph/scanners/zizmor.py +116 -0
  61. breachgraph-0.1.0/src/breachgraph/scoring.py +110 -0
@@ -0,0 +1,15 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.pyc
4
+ .pytest_cache/
5
+ .mypy_cache/
6
+ .ruff_cache/
7
+ .coverage
8
+ coverage.xml
9
+ htmlcov/
10
+ dist/
11
+ build/
12
+ *.egg-info/
13
+ breachgraph-report/
14
+ .env
15
+ .tmp/
@@ -0,0 +1,78 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and versions follow
5
+ [Semantic Versioning](https://semver.org/).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.1.0] - 2026-10-27
10
+
11
+ ### Added
12
+
13
+ - `breachgraph scan` orchestrating Semgrep (SAST), Gitleaks (secrets), Trivy (SCA, IaC, images,
14
+ licenses, CycloneDX SBOM), Checkov (IaC) and OWASP ZAP (DAST) in parallel.
15
+ - `--import` for existing reports from any supported tool or any SARIF 2.1.0 producer.
16
+ - Normalized finding model with CWE and OWASP Top 10 (2021) mapping and content-based fingerprints.
17
+ - Two-stage deduplication (same-tool rule overlap and cross-tool clustering, at most one finding
18
+ per tool in each cluster).
19
+ - CISA KEV and FIRST EPSS enrichment with on-disk caching and offline fallback.
20
+ - Risk score (0–10) and P1–P4 priority with an explanation for every score.
21
+ - Policy as code (`.breachgraph.yml`): thresholds, path excludes and deprioritization, suppressions
22
+ with mandatory reason and expiry, severity overrides.
23
+ - Baselines (`--write-baseline`) so only new findings fail the gate.
24
+ - Reports: SARIF (GitHub code scanning), JSON, HTML, Markdown, JUnit.
25
+ - GitHub integration: sticky PR comment, job summary, automatic issues for P1 findings.
26
+ - Composite GitHub Action, GitLab CI template, Docker image with pinned and checksum-verified scanners.
27
+ - `breachgraph report`, `breachgraph doctor`, `breachgraph init`.
28
+
29
+ - **CI/CD and supply chain.** Built-in checks for the attacks that actually hit CI: script
30
+ injection of outsider-controlled text (`issue.title`, `comment.body`, branch names) into `run:`
31
+ and `github-script`; pwn requests (`pull_request_target`/`workflow_run` jobs that check out and
32
+ run pull request code, critical when the job holds secrets or a write token); and dependency
33
+ confusion via pip `--extra-index-url` / uv `unsafe-best-match`. Maintainer-only `if:` gates lower
34
+ severity. zizmor runs too (bundled in the image) for broader Actions hygiene; its findings merge
35
+ with the built-in ones.
36
+ - **CI jobs in the attack graph.** Jobs that outsiders can start are entry points; their OIDC
37
+ cloud identities (checked against AWS trust `sub` conditions and Azure federated subjects),
38
+ secrets and write-capable `GITHUB_TOKEN` are linked behind code execution. A role that trusts
39
+ GitHub OIDC without naming a repository is flagged as reachable from the internet. The demo now
40
+ includes an `issue_comment` injection that reaches the customer-data bucket through a deploy
41
+ role scoped "safely" to `main`.
42
+
43
+ - **Azure and GCP in the attack graph** (Terraform). Azure: role assignments evaluated as
44
+ Actions/NotActions/DataActions over their scope, custom roles, Key Vault RBAC and access
45
+ policies, privilege escalation via `roleAssignments/write`, managed identities on VMs, App
46
+ Service, Functions, Container Apps and AKS, NSG/public-IP exposure, public blob containers and
47
+ database firewalls, AKS workload identity. GCP: IAM members/bindings/policies from organization
48
+ to resource level, predefined and custom roles, service-account impersonation chains,
49
+ `setIamPolicy` escalation, GCE/Cloud Run/Cloud Functions/GKE identities, firewall exposure,
50
+ public invokers, buckets, datasets and Cloud SQL, GKE Workload Identity. SSRF to the Azure or
51
+ GCP metadata endpoint is low confidence, because it needs a request header.
52
+
53
+ - **Attack-path analysis**: a code-to-cloud graph (Kubernetes, Terraform/AWS, HTTP routes in
54
+ Python/JS/TS/Java/Go) that finds chains from the internet to crown-jewel assets. Every
55
+ control step requires a real weakness, so network exposure alone never reaches credentials.
56
+ - Real AWS IAM evaluation (scoping, managed policies, explicit-Deny-wins, privilege escalation),
57
+ EKS IRSA and node roles, Kubernetes RBAC and container-escape detection, exposure analysis.
58
+ - Choke-point analysis: the cheapest fixes that break the most paths.
59
+ - Attack paths render in the HTML report (flow diagram), the PR comment and the console; the gate
60
+ can fail on new attack paths (`attack_graph.fail_on_new_path`).
61
+ - `breachgraph graph` command to build the graph standalone.
62
+ - `examples/vulnerable-platform` demo with a real internet-to-S3 path.
63
+ - **AI-assisted triage (bring your own key)**: optional, off by default. With your own
64
+ `ANTHROPIC_API_KEY`, each top finding gets a real / likely-false-positive / needs-review verdict,
65
+ reasoning with line numbers, and a concrete fix with corrected code. The model sees what a
66
+ reviewer would open: the whole enclosing function and the HTTP route that runs it, the attack
67
+ path the finding is a step on, and for dependency CVEs the lines that call the package. Advisory
68
+ only (never changes the gate), defensive only, secrets redacted before sending, a spend cap
69
+ enforced before each request, and every failure (no key, refusal, API error) is a warning, never
70
+ a failed scan. Enable with `--ai`; see docs/ai-triage.md.
71
+ - **Reachability analysis**: for each dependency CVE, checks whether first-party code actually
72
+ imports the package (Python/JS/TS/Java/Go via tree-sitter) and whether the importing module is
73
+ reachable from an HTTP entry point. Unused (transitive-only) CVEs are deprioritized and don't
74
+ gate by default; reachable ones are flagged. Also decides which dependency CVEs can be weapons
75
+ in the attack graph.
76
+
77
+ [Unreleased]: https://github.com/amoghnellutla/breachgraph/compare/v0.1.0...HEAD
78
+ [0.1.0]: https://github.com/amoghnellutla/breachgraph/releases/tag/v0.1.0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,290 @@
1
+ Metadata-Version: 2.5
2
+ Name: breachgraph
3
+ Version: 0.1.0
4
+ Summary: Attack-path-aware security gate for CI: runs Semgrep, Gitleaks, Trivy, Checkov, zizmor and ZAP, links findings to code, Kubernetes, cloud IAM (AWS, Azure, GCP) and GitHub Actions, and fails the build on real internet-to-crown-jewel paths.
5
+ Project-URL: Homepage, https://github.com/amoghnellutla/breachgraph
6
+ Project-URL: Documentation, https://github.com/amoghnellutla/breachgraph/tree/main/docs
7
+ Project-URL: Issues, https://github.com/amoghnellutla/breachgraph/issues
8
+ Author: breachgraph contributors
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: appsec,attack-path,checkov,cloud-security,devsecops,github-actions,gitleaks,iac,sarif,sast,sca,security,semgrep,supply-chain,trivy,zizmor
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Information Technology
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Security
22
+ Classifier: Topic :: Software Development :: Quality Assurance
23
+ Classifier: Typing :: Typed
24
+ Requires-Python: >=3.11
25
+ Requires-Dist: httpx>=0.27
26
+ Requires-Dist: jinja2>=3.1
27
+ Requires-Dist: pydantic>=2.6
28
+ Requires-Dist: python-hcl2>=8.1
29
+ Requires-Dist: pyyaml>=6.0
30
+ Requires-Dist: rich>=13.7
31
+ Requires-Dist: tree-sitter-go>=0.25
32
+ Requires-Dist: tree-sitter-java>=0.23
33
+ Requires-Dist: tree-sitter-javascript>=0.25
34
+ Requires-Dist: tree-sitter-python>=0.25
35
+ Requires-Dist: tree-sitter-typescript>=0.23
36
+ Requires-Dist: tree-sitter>=0.26
37
+ Requires-Dist: typer>=0.12
38
+ Provides-Extra: ai
39
+ Requires-Dist: anthropic>=1.13; extra == 'ai'
40
+ Provides-Extra: dev
41
+ Requires-Dist: anthropic>=1.13; extra == 'dev'
42
+ Requires-Dist: jsonschema>=4.21; extra == 'dev'
43
+ Requires-Dist: mypy>=1.10; extra == 'dev'
44
+ Requires-Dist: pytest-cov>=5.0; extra == 'dev'
45
+ Requires-Dist: pytest>=8.0; extra == 'dev'
46
+ Requires-Dist: respx>=0.21; extra == 'dev'
47
+ Requires-Dist: ruff>=0.6; extra == 'dev'
48
+ Requires-Dist: types-pyyaml; extra == 'dev'
49
+ Description-Content-Type: text/markdown
50
+
51
+ <div align="center">
52
+
53
+ # 🛡️ breachgraph
54
+
55
+ **Find the attack paths that matter — from code to cloud.**
56
+
57
+ breachgraph runs the open-source scanners you already trust (Semgrep, Gitleaks, Trivy, Checkov, zizmor,
58
+ ZAP), then does what they can't: it builds one **code-to-cloud graph** and finds the real
59
+ **attack paths** — the chains where an internet-facing route, a vulnerability, a container and an
60
+ over-broad IAM role line up so an outsider can reach your crown-jewel data. It ranks findings by
61
+ whether they actually lie on such a path, so you fix the ten things that can hurt you, not the
62
+ three hundred that can't.
63
+
64
+ [![ci](https://github.com/amoghnellutla/breachgraph/actions/workflows/ci.yml/badge.svg)](https://github.com/amoghnellutla/breachgraph/actions/workflows/ci.yml)
65
+ [![self-scan](https://github.com/amoghnellutla/breachgraph/actions/workflows/self-scan.yml/badge.svg)](https://github.com/amoghnellutla/breachgraph/actions/workflows/self-scan.yml)
66
+ [![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)
67
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-blue.svg)](pyproject.toml)
68
+
69
+ </div>
70
+
71
+ ---
72
+
73
+ ## Why this is different
74
+
75
+ Most tools hand you a list. A big security team already has Snyk, CodeQL and a cloud scanner —
76
+ what they lack is the *connection between layers*. A medium-severity SSRF is boring on its own.
77
+ SSRF on an internet-facing route, in a pod with host networking, whose node role can read the
78
+ customer-data bucket, is a breach. No single scanner sees that chain, because each one looks at
79
+ only one layer.
80
+
81
+ breachgraph joins the layers — **code → container → Kubernetes → cloud IAM → data** — into one
82
+ graph and asks the question that matters: *what can an attacker actually reach, and how?*
83
+
84
+ **It is not a gimmick:** every step that represents gaining control requires a real weakness.
85
+ Being reachable on the network is not the same as being owned. With zero code vulnerabilities,
86
+ breachgraph reports **no path** to your data even if the pod is public and its role is over-broad
87
+ — you can [see that guarantee as a test](tests/test_graph_paths.py). Fix the one cheapest link
88
+ (the "choke point") and the whole path disappears.
89
+
90
+ <p align="center"><img src="docs/img/attack-paths.png" alt="breachgraph attack paths" width="860"></p>
91
+
92
+ ## What you get
93
+
94
+ | | |
95
+ |---|---|
96
+ | 🎯 **Attack-path analysis** | Joins code, containers, Kubernetes and Terraform (AWS, Azure, GCP) into one graph and finds every chain from the internet to a crown-jewel asset. Each independent entry point surfaces separately; each path names the cheapest fix |
97
+ | ☁️ **Real cloud reasoning** | Evaluates AWS IAM policies (scoping, managed policies, explicit-Deny-wins, **privilege-escalation** primitives), Azure role assignments (Actions/NotActions/DataActions by scope, Key Vault access policies), GCP IAM bindings (predefined and custom roles, service-account impersonation), EKS IRSA, AKS and GKE workload identity, node identities, public exposure (LBs, security groups, public buckets/DBs, unauth Lambda URLs), Kubernetes RBAC and container escape |
98
+ | 🔍 **Coverage** | SAST (Semgrep) · secrets (Gitleaks) · dependency CVEs, IaC, container images, licenses (Trivy) · IaC (Checkov) · GitHub Actions (zizmor, plus built-in pwn-request, script-injection and dependency-confusion checks) · DAST (ZAP) · plus **any SARIF** tool (CodeQL, Bandit, gosec…) via `--import` |
99
+ | 🔗 **CI/CD attack paths** | A script injection in an `issue_comment` workflow is not just a finding: breachgraph follows the job's OIDC deploy role, secrets and write token to what they reach, and checks trust policies against the token the job really gets. See [docs/cicd.md](docs/cicd.md) |
100
+ | 🧹 **Deduplication** | Cross-tool clustering (e.g. Trivy `AVD-DS-0002` ≡ Checkov `CKV_DOCKER_3`) and same-tool rule overlap — at most one finding per tool in each cluster |
101
+ | 📊 **Risk-based priority** | CVSS/severity adjusted by **CISA KEV** (actively exploited → always P1), **FIRST EPSS**, confidence, multi-tool agreement and reachability to crown jewels. Every score explains itself |
102
+ | 🚦 **Gate that teams keep on** | Content-based fingerprints + **baselines**, so only *new* findings and *new* attack paths fail the build. **Suppressions require a reason and an expiry date** |
103
+ | 💬 **Feedback where developers are** | Sticky PR comment with the attack-path diagram · inline code-scanning annotations (SARIF) · job summary · auto-managed GitHub issues |
104
+ | 📦 **Reports** | SARIF 2.1.0 · JSON · self-contained HTML (interactive attack-path flows) · Markdown · JUnit · CycloneDX SBOM |
105
+ | 🤖 **Optional AI triage** | Bring your own Anthropic key: a real / likely-false-positive / needs-review verdict and a concrete fix per top finding, judged from the enclosing function, its HTTP route, its attack path, and how a vulnerable package is actually called. Advisory only, secrets redacted, spend cap. See [docs/ai-triage.md](docs/ai-triage.md) |
106
+ | 🔒 **Trustworthy itself** | Scanner binaries pinned and SHA-256 verified · actions pinned to commit SHAs · signed images with SBOM + provenance · secrets always redacted · untrusted scanner output escaped |
107
+
108
+ <p align="center"><img src="docs/img/html-report.png" alt="breachgraph findings report" width="820"></p>
109
+
110
+ ## Quick start
111
+
112
+ ### GitHub Actions
113
+
114
+ ```yaml
115
+ # .github/workflows/breachgraph.yml
116
+ name: breachgraph
117
+ on: [pull_request, push]
118
+ permissions:
119
+ contents: read
120
+ security-events: write # code scanning upload
121
+ pull-requests: write # PR comment
122
+ jobs:
123
+ breachgraph:
124
+ runs-on: ubuntu-latest
125
+ steps:
126
+ - uses: actions/checkout@v7
127
+ - uses: amoghnellutla/breachgraph@v0
128
+ ```
129
+
130
+ More recipes (baselines, DAST, container images, issue tracking) are in [docs/github-action.md](docs/github-action.md).
131
+
132
+ ### Docker (any CI, or your laptop)
133
+
134
+ ```bash
135
+ docker run --rm -v "$PWD:/src" ghcr.io/amoghnellutla/breachgraph scan .
136
+ open breachgraph-report/breachgraph.html
137
+ ```
138
+
139
+ ### pip
140
+
141
+ ```bash
142
+ pip install breachgraph
143
+ breachgraph doctor # shows which scanners are on PATH
144
+ breachgraph scan .
145
+ ```
146
+
147
+ The pip package only orchestrates. It runs whichever scanners are installed and skips the rest.
148
+ The Docker image bundles all of them at pinned versions.
149
+
150
+ ### GitLab CI
151
+
152
+ ```yaml
153
+ include:
154
+ - remote: https://raw.githubusercontent.com/amoghnellutla/breachgraph/v0/templates/gitlab-ci.yml
155
+ ```
156
+
157
+ ## Try it on the demo app
158
+
159
+ [`examples/vulnerable-app`](examples/vulnerable-app) is an intentionally vulnerable Flask app
160
+ with Terraform, Kubernetes and Dockerfile misconfigurations, fake secrets and Log4Shell:
161
+
162
+ ```bash
163
+ docker run --rm -v "$PWD:/src" ghcr.io/amoghnellutla/breachgraph scan examples/vulnerable-app
164
+ ```
165
+
166
+ ```
167
+ ok gitleaks 2 findings 0.7s
168
+ ok checkov 50 findings 8.2s
169
+ ok semgrep 26 findings 9.2s
170
+ ok trivy 149 findings 25.5s
171
+ | Prio | Risk | Finding | Location | Tools | Status |
172
+ | P1 | 10.0 | CVE-2021-44228 in log4j-core 2.14.1: Remote code exec KEV | pom.xml:11 | trivy | BLOCKS new |
173
+ | P1 | 10.0 | Hardcoded secret: Identified a Private Key | settings.py:6| gitleaks,semgrep | BLOCKS new |
174
+ ...
175
+ Gate failed: 104 finding(s) at or above the threshold (priority >= P2, any KEV, any secret)
176
+ ```
177
+
178
+ ## Adopting it on an existing codebase
179
+
180
+ ```bash
181
+ # 1. Accept what exists today
182
+ breachgraph scan --write-baseline .breachgraph-baseline.json && git add .breachgraph-baseline.json
183
+
184
+ # 2. Turn the gate on. From now on only NEW findings fail PRs.
185
+ # 3. Burn down the baseline over time; accepted risks go into .breachgraph.yml with an expiry:
186
+ ```
187
+
188
+ ```yaml
189
+ # .breachgraph.yml
190
+ fail_on:
191
+ priority: P2 # new P1/P2 findings fail the build
192
+ kev: true # so does anything actively exploited
193
+ secrets: true # and any hardcoded secret
194
+ suppressions:
195
+ - vuln: CVE-2023-12345
196
+ reason: "Vulnerable code path not reachable; tracked in SEC-142"
197
+ expires: 2026-12-31
198
+ ```
199
+
200
+ Full reference: [docs/configuration.md](docs/configuration.md).
201
+
202
+ ## Attack paths
203
+
204
+ [`examples/vulnerable-platform`](examples/vulnerable-platform) is a small microservice (Flask API
205
+ on EKS with IRSA, plus Terraform) with a real internet-to-S3 path. breachgraph reports:
206
+
207
+ ```
208
+ 🎯 2 attack path(s) to crown-jewel assets
209
+ 1. [high] risk 14.0 BLOCKS
210
+ Internet → Ingress api → Deployment shop/api → GET /thumbnail
211
+ → ServiceAccount shop/api (code_execution) → IAM role api-pod-role
212
+ → S3 bucket shop-customer-data-prod
213
+ 2. [high] risk 12.73 BLOCKS
214
+ Internet → Ingress api → Deployment shop/api → GET /fetch
215
+ → IAM role eks-node-role (ssrf → node metadata) → S3 bucket shop-customer-data-prod
216
+ Fix first:
217
+ • Command injection via os.popen (services/api/app.py:30) — breaks 1 path(s)
218
+ • SSRF via requests.get (services/api/app.py:23) — breaks 1 path(s)
219
+ ```
220
+
221
+ Two independent ways in (command injection gives the pod role; SSRF steals the node role via the
222
+ metadata endpoint) surface separately, because fixing one does not fix the other. Run it yourself:
223
+
224
+ ```bash
225
+ breachgraph scan examples/vulnerable-platform # scanners + attack graph
226
+ breachgraph graph examples/vulnerable-platform # attack graph only
227
+ ```
228
+
229
+ How reachability and IAM are modeled: [docs/attack-graph.md](docs/attack-graph.md).
230
+
231
+ ## How it works
232
+
233
+ ```mermaid
234
+ flowchart LR
235
+ A[Semgrep · Gitleaks · Trivy · Checkov · zizmor · built-in CI/CD · ZAP · SARIF] --> B[Normalize<br/>CWE · OWASP · fingerprint]
236
+ B --> C[Dedupe] --> D[Enrich<br/>KEV · EPSS] --> E[Score P1–P4]
237
+ E --> G2[Attack graph<br/>code→cloud paths]
238
+ CFG[Kubernetes · Terraform · routes] --> G2
239
+ G2 --> F[Baseline ·<br/>suppressions]
240
+ F --> GATE{Gate}
241
+ GATE --> H[SARIF · PR comment · HTML · issues]
242
+ ```
243
+
244
+ Design notes and how to add a scanner: [docs/architecture.md](docs/architecture.md).
245
+
246
+ ## CLI
247
+
248
+ ```
249
+ breachgraph scan [PATH] Scan and gate
250
+ -c, --config FILE .breachgraph.yml (auto-detected)
251
+ -b, --baseline FILE accepted findings (auto-detected .breachgraph-baseline.json)
252
+ --write-baseline FILE accept all current findings
253
+ -f, --format LIST json,sarif,html,md,junit
254
+ --only / --skip LIST choose scanners
255
+ --import TOOL=FILE ingest existing reports (semgrep, gitleaks, trivy, checkov, zap, sarif)
256
+ --fail-on P1..P4|none override the threshold
257
+ --dast-url URL run ZAP against a running app
258
+ --image REF scan a container image
259
+ --github-comment sticky PR comment
260
+ --github-issues P1 open/close issues per finding
261
+ --ai AI triage (bring your own ANTHROPIC_API_KEY): verdicts + fixes, advisory
262
+ --offline skip KEV/EPSS
263
+ --no-fail report only
264
+ breachgraph graph [PATH] build the attack graph only (--findings a prior scan)
265
+ breachgraph report results.json re-render reports, optionally with a new policy
266
+ breachgraph doctor show installed scanners
267
+ breachgraph init write a starter .breachgraph.yml and workflow
268
+ ```
269
+
270
+ Exit codes: `0` pass · `1` gate failed · `2` usage/config error · `3` scanner error (opt-in).
271
+
272
+ ## Roadmap
273
+
274
+ - [x] **Reachability** for dependency CVEs: is the package imported by first-party code, and is that code reachable from an HTTP route (Python/JS/TS/Java/Go)
275
+ - [ ] Function-level reachability: is the vulnerable function itself called
276
+ - [x] **Bring-your-own-key AI triage**: optional; with your own Anthropic key, a verdict and fix per top finding, grounded in the enclosing code, route and attack path. Advisory, defensive-only, with a spend cap. See [docs/ai-triage.md](docs/ai-triage.md)
277
+ - [x] Azure and GCP in the attack graph
278
+ - [x] **CI/CD and supply chain**: GitHub Actions script injection and pwn requests, zizmor audits, dependency confusion, and CI jobs as attack-graph entry points (OIDC roles, secrets, write tokens). See [docs/cicd.md](docs/cicd.md)
279
+ - [ ] Malicious-package detection; GitLab CI
280
+ - [ ] OSV-Scanner and Grype adapters; GitLab merge-request notes; trend history across runs
281
+
282
+ ## Contributing
283
+
284
+ Issues and PRs are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md). To report a vulnerability in
285
+ breachgraph itself, see [SECURITY.md](SECURITY.md).
286
+
287
+ ## License
288
+
289
+ [Apache-2.0](LICENSE). The bundled scanners keep their own licenses: Semgrep CE (LGPL-2.1),
290
+ Gitleaks (MIT), Trivy (Apache-2.0), Checkov (Apache-2.0), zizmor (MIT), ZAP (Apache-2.0).