brox 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 (39) hide show
  1. brox-0.1.0/.github/workflows/brock.yml +71 -0
  2. brox-0.1.0/.github/workflows/publish.yml +33 -0
  3. brox-0.1.0/.github/workflows/test.yml +63 -0
  4. brox-0.1.0/.gitignore +57 -0
  5. brox-0.1.0/License +13 -0
  6. brox-0.1.0/PKG-INFO +321 -0
  7. brox-0.1.0/README.md +288 -0
  8. brox-0.1.0/assets/logo.png +0 -0
  9. brox-0.1.0/brox/__init__.py +3 -0
  10. brox-0.1.0/brox/cli.py +189 -0
  11. brox-0.1.0/brox/diff/__init__.py +0 -0
  12. brox-0.1.0/brox/diff/diff.py +199 -0
  13. brox-0.1.0/brox/diff/risk.py +129 -0
  14. brox-0.1.0/brox/emit.py +121 -0
  15. brox-0.1.0/brox/examples/policy.yaml +41 -0
  16. brox-0.1.0/brox/model.py +360 -0
  17. brox-0.1.0/brox/policy/__init__.py +0 -0
  18. brox-0.1.0/brox/policy/engine.py +121 -0
  19. brox-0.1.0/brox/policy/schema.py +31 -0
  20. brox-0.1.0/brox/scan/__init__.py +0 -0
  21. brox-0.1.0/brox/scan/detectors/__init__.py +0 -0
  22. brox-0.1.0/brox/scan/detectors/agent_frameworks.py +110 -0
  23. brox-0.1.0/brox/scan/detectors/agent_tools.py +244 -0
  24. brox-0.1.0/brox/scan/detectors/cloud_storage.py +207 -0
  25. brox-0.1.0/brox/scan/detectors/egress.py +125 -0
  26. brox-0.1.0/brox/scan/detectors/mcp.py +332 -0
  27. brox-0.1.0/brox/scan/detectors/prompts.py +237 -0
  28. brox-0.1.0/brox/scan/detectors/providers.py +145 -0
  29. brox-0.1.0/brox/scan/normalize.py +71 -0
  30. brox-0.1.0/brox/scan/scanner.py +85 -0
  31. brox-0.1.0/policy.yaml +20 -0
  32. brox-0.1.0/pyproject.toml +71 -0
  33. brox-0.1.0/pytest.ini +15 -0
  34. brox-0.1.0/tests/__init__.py +0 -0
  35. brox-0.1.0/tests/test_diff.py +137 -0
  36. brox-0.1.0/tests/test_model.py +132 -0
  37. brox-0.1.0/tests/test_policy.py +181 -0
  38. brox-0.1.0/tests/test_scope_widening.py +125 -0
  39. brox-0.1.0/uv.lock +647 -0
@@ -0,0 +1,71 @@
1
+ name: brox — Capability Diff
2
+
3
+ on:
4
+ pull_request:
5
+ types: [opened, synchronize, reopened]
6
+
7
+ jobs:
8
+ brox:
9
+ runs-on: ubuntu-latest
10
+ permissions:
11
+ contents: read
12
+ pull-requests: write
13
+
14
+ steps:
15
+ - name: Checkout head
16
+ uses: actions/checkout@v4
17
+ with:
18
+ fetch-depth: 0
19
+
20
+ - name: Set up Python
21
+ uses: actions/setup-python@v5
22
+ with:
23
+ python-version: "3.11"
24
+
25
+ - name: Install brox
26
+ run: |
27
+ pip install brox
28
+
29
+ - name: Scan HEAD
30
+ run: |
31
+ brox scan --repo . --out head.aibom.json
32
+
33
+ - name: Checkout base
34
+ run: |
35
+ git checkout origin/${{ github.base_ref }}
36
+
37
+ - name: Scan BASE
38
+ run: |
39
+ brox scan --repo . --out base.aibom.json
40
+
41
+ - name: Diff + Gate
42
+ run: |
43
+ git checkout ${{ github.sha }}
44
+ brox diff --base base.aibom.json --head head.aibom.json --out capdiff.json --md capdiff.md
45
+ brox gate --diff capdiff.json --policy policy.yaml
46
+
47
+ - name: Post PR comment (optional)
48
+ if: always()
49
+ uses: actions/github-script@v7
50
+ with:
51
+ script: |
52
+ const fs = require('fs');
53
+ const body = fs.readFileSync('capdiff.md', 'utf8');
54
+ const issue_number = context.payload.pull_request.number;
55
+ const { owner, repo } = context.repo;
56
+
57
+ // naive: always comment; you can later upsert by marker
58
+ await github.rest.issues.createComment({
59
+ owner, repo, issue_number, body
60
+ });
61
+
62
+ - name: Upload artifacts
63
+ if: always()
64
+ uses: actions/upload-artifact@v4
65
+ with:
66
+ name: brox
67
+ path: |
68
+ base.aibom.json
69
+ head.aibom.json
70
+ capdiff.json
71
+ capdiff.md
@@ -0,0 +1,33 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ publish:
9
+ runs-on: ubuntu-latest
10
+
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+
14
+ - name: Set up Python
15
+ uses: actions/setup-python@v5
16
+ with:
17
+ python-version: "3.11"
18
+
19
+ - name: Install build dependencies
20
+ run: |
21
+ python -m pip install --upgrade pip
22
+ pip install build twine
23
+
24
+ - name: Build package
25
+ run: |
26
+ python -m build
27
+
28
+ - name: Publish to PyPI
29
+ env:
30
+ TWINE_USERNAME: __token__
31
+ TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
32
+ run: |
33
+ twine upload dist/*
@@ -0,0 +1,63 @@
1
+ name: Tests
2
+
3
+ on:
4
+ push:
5
+ branches: [main, develop]
6
+ pull_request:
7
+ branches: [main, develop]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ${{ matrix.os }}
12
+ strategy:
13
+ matrix:
14
+ os: [ubuntu-latest, macos-latest]
15
+ python-version: ["3.11", "3.12"]
16
+
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+
20
+ - name: Set up Python ${{ matrix.python-version }}
21
+ uses: actions/setup-python@v5
22
+ with:
23
+ python-version: ${{ matrix.python-version }}
24
+
25
+ - name: Install dependencies
26
+ run: |
27
+ python -m pip install --upgrade pip
28
+ pip install -e ".[test]"
29
+
30
+ - name: Run tests
31
+ run: |
32
+ pytest --cov=brox --cov-report=xml
33
+
34
+ - name: Upload coverage to Codecov
35
+ if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
36
+ uses: codecov/codecov-action@v3
37
+ with:
38
+ file: ./coverage.xml
39
+ fail_ci_if_error: false
40
+
41
+ lint:
42
+ runs-on: ubuntu-latest
43
+
44
+ steps:
45
+ - uses: actions/checkout@v4
46
+
47
+ - name: Set up Python
48
+ uses: actions/setup-python@v5
49
+ with:
50
+ python-version: "3.11"
51
+
52
+ - name: Install dependencies
53
+ run: |
54
+ python -m pip install --upgrade pip
55
+ pip install black ruff
56
+
57
+ - name: Check formatting with black
58
+ run: |
59
+ black --check brox/ tests/
60
+
61
+ - name: Lint with ruff
62
+ run: |
63
+ ruff check brox/ tests/
brox-0.1.0/.gitignore ADDED
@@ -0,0 +1,57 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ *.egg-info/
20
+ .installed.cfg
21
+ *.egg
22
+ MANIFEST
23
+
24
+ # Virtual environments
25
+ venv/
26
+ env/
27
+ ENV/
28
+ .venv
29
+
30
+ # Environment variables
31
+ .env
32
+ .env.local
33
+
34
+ # IDEs
35
+ .vscode/
36
+ .idea/
37
+ *.swp
38
+ *.swo
39
+ *~
40
+
41
+ # Testing
42
+ .pytest_cache/
43
+ .coverage
44
+ htmlcov/
45
+ .tox/
46
+
47
+ # brox outputs
48
+ *.aibom.json
49
+ capdiff.json
50
+ capdiff.md
51
+
52
+ # OS
53
+ .DS_Store
54
+ Thumbs.db
55
+
56
+ # Logs
57
+ *.log
brox-0.1.0/License ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2025 oha
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
brox-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,321 @@
1
+ Metadata-Version: 2.4
2
+ Name: brox
3
+ Version: 0.1.0
4
+ Summary: Repo scanner that turns agent/tool/model changes into a PR capability diff and blocks unsafe power upgrades
5
+ Project-URL: Homepage, https://github.com/yourusername/brox
6
+ Project-URL: Repository, https://github.com/yourusername/brox
7
+ Project-URL: Issues, https://github.com/yourusername/brox/issues
8
+ Author: brox Contributors
9
+ License: Apache 2.0
10
+ Keywords: agent-security,ai-bom,capability-diff,mcp,sbom,security,supply-chain
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Topic :: Security
16
+ Classifier: Topic :: Software Development :: Quality Assurance
17
+ Requires-Python: >=3.11
18
+ Requires-Dist: click>=8.1.0
19
+ Requires-Dist: jsonschema>=4.17.0
20
+ Requires-Dist: pathspec>=0.11.0
21
+ Requires-Dist: pyyaml>=6.0
22
+ Provides-Extra: dev
23
+ Requires-Dist: black>=23.0.0; extra == 'dev'
24
+ Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
25
+ Requires-Dist: pytest-mock>=3.12.0; extra == 'dev'
26
+ Requires-Dist: pytest>=7.0.0; extra == 'dev'
27
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
28
+ Provides-Extra: test
29
+ Requires-Dist: pytest-cov>=4.0.0; extra == 'test'
30
+ Requires-Dist: pytest-mock>=3.12.0; extra == 'test'
31
+ Requires-Dist: pytest>=7.0.0; extra == 'test'
32
+ Description-Content-Type: text/markdown
33
+
34
+
35
+ <div align="center">
36
+ <img src="assets/logo.png" alt="brox - AI-BOM Generator and Capability Diff Tool for MCP and Agents" width="200">
37
+ <h1>AI-BOM Generator and Capability Diff Tool for MCP and Agents</h1>
38
+ </div>
39
+
40
+ ![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)
41
+ ![Security Policy](https://img.shields.io/badge/security-policy-brightgreen)
42
+ ![PRs welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)
43
+
44
+ **brox** scans a repo, produces an **AI-BOM**, and generates a **capability diff** (the "power change" in a PR):
45
+ **new MCP tools, widened filesystem scopes, new model egress, system prompt edits, new agent frameworks**, etc.
46
+ Then it **gates merges** with policy-as-code.
47
+
48
+ > Don't just track code changes. Track **Power** changes.
49
+
50
+ ## Quick Start
51
+
52
+ ### Installation
53
+
54
+ ```bash
55
+ pip install brox
56
+ ```
57
+
58
+ Or install from source:
59
+
60
+ ```bash
61
+ git clone https://github.com/yourusername/brox.git
62
+ cd brox
63
+ pip install -e .
64
+ ```
65
+
66
+ ### Usage
67
+
68
+ #### 1. Scan a repository
69
+
70
+ ```bash
71
+ brox scan --repo . --out head.aibom.json
72
+ ```
73
+
74
+ This generates an AI-BOM (Bill of Materials) in CycloneDX format, containing:
75
+ - MCP servers and their capabilities
76
+ - Prompts (file-based and inline)
77
+ - LLM provider endpoints
78
+ - Agent frameworks
79
+ - Network egress domains
80
+
81
+ #### 2. Compare two AI-BOMs
82
+
83
+ ```bash
84
+ brox diff --base base.aibom.json --head head.aibom.json --out capdiff.json --md capdiff.md
85
+ ```
86
+
87
+ This generates:
88
+ - `capdiff.json`: Structured capability diff
89
+ - `capdiff.md`: Human-readable markdown report for PRs
90
+
91
+ #### 3. Gate with policy
92
+
93
+ ```bash
94
+ brox gate --diff capdiff.json --policy policy.yaml
95
+ ```
96
+
97
+ Exit codes:
98
+ - `0`: Pass
99
+ - `2`: Policy blocked (fail CI)
100
+ - `3`: Internal error
101
+
102
+ ## What brox Detects
103
+
104
+ ### MCP Servers
105
+ - Configuration files: `mcp.json`, `mcp.yaml`, `servers.json`
106
+ - Extracted capabilities:
107
+ - `filesystem.read` / `filesystem.write` with scopes
108
+ - `exec.shell` for shell execution
109
+ - `db.read` / `db.write` for database access
110
+ - `network.egress` for network tools
111
+
112
+ ### Prompts
113
+ - **File-based**: `.prompt`, `.jinja`, `.jinja2`, `.md` files in `prompts/`, `agents/`, `system/` directories
114
+ - **Inline**: Multiline strings (≥200 chars) near LLM client calls
115
+ - Risk signals: "ignore previous", "bypass safety", "exfiltrate", "reveal secrets"
116
+
117
+ ### LLM Providers & Egress
118
+ - OpenAI, Anthropic, Azure OpenAI, AWS Bedrock, Cohere
119
+ - Generic HTTP egress to external domains
120
+ - Maps to `network.egress` capabilities
121
+
122
+ ### Agent Frameworks
123
+ - LangChain, LlamaIndex, Autogen, CrewAI, Semantic Kernel, Haystack
124
+
125
+ ## Policy Configuration
126
+
127
+ Create a `policy.yaml` file to define rules:
128
+
129
+ ```yaml
130
+ version: 1
131
+ rules:
132
+ - id: block-shell-exec
133
+ when:
134
+ capability_added: "exec.shell"
135
+ action: block
136
+ message: "Shell execution introduced. Requires security approval."
137
+
138
+ - id: block-broad-fs-write
139
+ when:
140
+ capability_added: "filesystem.write"
141
+ scope_matches_any:
142
+ - "/**"
143
+ - "/etc/**"
144
+ - "~/.ssh/**"
145
+ - "**/*.pem"
146
+ action: block
147
+ message: "Broad filesystem write introduced."
148
+
149
+ - id: warn-system-prompt-change
150
+ when:
151
+ asset_changed_kind: "prompt"
152
+ prompt_type: "system"
153
+ action: warn
154
+ message: "System prompt changed. Review for jailbreak/injection patterns."
155
+ ```
156
+
157
+ ### Policy Actions
158
+
159
+ - **`block`**: Fail CI (exit code 2)
160
+ - **`warn`**: Pass CI but annotate
161
+ - **`require_approval`**: Fail CI unless approval signal present (e.g., PR label)
162
+
163
+ ### Condition Syntax
164
+
165
+ - `capability_added`: Match new capabilities
166
+ - `capability_widened`: Match expanded scopes
167
+ - `asset_added_kind`: Match new assets by kind
168
+ - `asset_changed_kind`: Match changed assets by kind
169
+ - `scope_matches_any`: Glob patterns for scope matching
170
+
171
+ ## GitHub Action Integration
172
+
173
+ Add `.github/workflows/brox.yml`:
174
+
175
+ ```yaml
176
+ name: brox — Capability Diff
177
+
178
+ on:
179
+ pull_request:
180
+ types: [opened, synchronize, reopened]
181
+
182
+ jobs:
183
+ brox:
184
+ runs-on: ubuntu-latest
185
+ permissions:
186
+ contents: read
187
+ pull-requests: write
188
+
189
+ steps:
190
+ - name: Checkout head
191
+ uses: actions/checkout@v4
192
+ with:
193
+ fetch-depth: 0
194
+
195
+ - name: Set up Python
196
+ uses: actions/setup-python@v5
197
+ with:
198
+ python-version: "3.11"
199
+
200
+ - name: Install brox
201
+ run: pip install brox
202
+
203
+ - name: Scan HEAD
204
+ run: brox scan --repo . --out head.aibom.json
205
+
206
+ - name: Checkout base
207
+ run: git checkout origin/${{ github.base_ref }}
208
+
209
+ - name: Scan BASE
210
+ run: brox scan --repo . --out base.aibom.json
211
+
212
+ - name: Diff + Gate
213
+ run: |
214
+ git checkout ${{ github.sha }}
215
+ brox diff --base base.aibom.json --head head.aibom.json --out capdiff.json --md capdiff.md
216
+ brox gate --diff capdiff.json --policy policy.yaml
217
+
218
+ - name: Upload artifacts
219
+ if: always()
220
+ uses: actions/upload-artifact@v4
221
+ with:
222
+ name: brox
223
+ path: |
224
+ base.aibom.json
225
+ head.aibom.json
226
+ capdiff.json
227
+ capdiff.md
228
+ ```
229
+
230
+ ## AI-BOM Format
231
+
232
+ brox generates CycloneDX-compatible AI-BOMs with custom properties:
233
+
234
+ ```json
235
+ {
236
+ "$schema": "https://cyclonedx.org/schema/bom-1.5.schema.json",
237
+ "bomFormat": "CycloneDX",
238
+ "specVersion": "1.5",
239
+ "version": 1,
240
+ "metadata": {
241
+ "timestamp": "2026-02-11T00:00:00Z",
242
+ "tools": [{"vendor": "brox", "name": "brox", "version": "0.1.0"}]
243
+ },
244
+ "components": [
245
+ {
246
+ "type": "service",
247
+ "name": "mcp-server:filesystem-server",
248
+ "bom-ref": "mcp_server:filesystem-server",
249
+ "properties": [
250
+ {"name": "brox.ai.asset.kind", "value": "mcp_server"},
251
+ {"name": "brox.location.file", "value": "mcp.json"}
252
+ ]
253
+ }
254
+ ],
255
+ "services": [
256
+ {
257
+ "name": "brox.ai.capabilities",
258
+ "properties": [
259
+ {
260
+ "name": "brox.capability.record",
261
+ "value": "cap=filesystem.write;scope=./data/**;evidence=mcp.json:12;asset=mcp_server:filesystem-server"
262
+ }
263
+ ]
264
+ }
265
+ ]
266
+ }
267
+ ```
268
+
269
+ ## Risk Scoring
270
+
271
+ brox automatically assesses risk levels:
272
+
273
+ - **Low**: No significant changes
274
+ - **Medium**: New egress domain, agent framework, or system prompt change
275
+ - **High**: Shell execution, sensitive filesystem access, database writes
276
+ - **Critical**: Shell exec + broad filesystem write, or sensitive paths + egress
277
+
278
+ ## Development
279
+
280
+ ### Setup
281
+
282
+ ```bash
283
+ git clone https://github.com/yourusername/brox.git
284
+ cd brox
285
+ pip install -e ".[dev]"
286
+ ```
287
+
288
+ ### Run Tests
289
+
290
+ ```bash
291
+ pytest
292
+ ```
293
+
294
+ ### Code Formatting
295
+
296
+ ```bash
297
+ black brox/
298
+ ruff check brox/
299
+ ```
300
+
301
+ ## License
302
+
303
+ Apache 2.0
304
+
305
+ ## Contributing
306
+
307
+ Contributions welcome! Please open an issue or PR.
308
+
309
+ ## Roadmap
310
+
311
+ - [ ] TypeScript/JavaScript language support
312
+ - [ ] Capability provenance tracking
313
+ - [ ] CODEOWNERS-based approval workflows
314
+ - [ ] AI-BOM registry for org dashboards
315
+ - [ ] Secret/PII flow analysis
316
+ - [ ] Plugin system for custom detectors
317
+
318
+ ---
319
+
320
+ **Capabilities + diff + gate + evidence.**
321
+ Not "security theater," not "SBOM spam," just **power deltas** in PRs.