codetrust 1.5.0__py3-none-any.whl

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.
@@ -0,0 +1,265 @@
1
+ Metadata-Version: 2.4
2
+ Name: codetrust
3
+ Version: 1.5.0
4
+ Summary: AI code verification platform — MCP server + cloud API that catches hallucinated packages, broken configs, and code anti-patterns
5
+ Project-URL: Homepage, https://github.com/S-Borna/codetrust
6
+ Project-URL: Repository, https://github.com/S-Borna/codetrust
7
+ Project-URL: Documentation, https://github.com/S-Borna/codetrust#readme
8
+ Project-URL: Bug Tracker, https://github.com/S-Borna/codetrust/issues
9
+ Author-email: Said Borna <codetrust@users.noreply.github.com>
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: claude-code,code-quality,devops,hallucination,mcp,verification
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Software Development :: Quality Assurance
18
+ Requires-Python: >=3.12
19
+ Requires-Dist: alembic>=1.13.0
20
+ Requires-Dist: asyncpg>=0.29.0
21
+ Requires-Dist: fastapi>=0.115.0
22
+ Requires-Dist: httpx>=0.27.0
23
+ Requires-Dist: mcp[cli]>=1.0.0
24
+ Requires-Dist: psycopg2-binary>=2.9.0
25
+ Requires-Dist: pydantic-settings>=2.0.0
26
+ Requires-Dist: pydantic>=2.0.0
27
+ Requires-Dist: pyjwt>=2.8.0
28
+ Requires-Dist: redis[hiredis]>=5.0.0
29
+ Requires-Dist: sqlalchemy[asyncio]>=2.0.0
30
+ Requires-Dist: stripe>=7.0.0
31
+ Requires-Dist: structlog>=24.0.0
32
+ Requires-Dist: tree-sitter-go>=0.23.0
33
+ Requires-Dist: tree-sitter-javascript>=0.23.0
34
+ Requires-Dist: tree-sitter-python>=0.23.0
35
+ Requires-Dist: tree-sitter-rust>=0.23.0
36
+ Requires-Dist: tree-sitter-typescript>=0.23.0
37
+ Requires-Dist: tree-sitter>=0.23.0
38
+ Requires-Dist: uvicorn[standard]>=0.30.0
39
+ Provides-Extra: dev
40
+ Requires-Dist: aiosqlite>=0.20.0; extra == 'dev'
41
+ Requires-Dist: fakeredis[json]>=2.20.0; extra == 'dev'
42
+ Requires-Dist: httpx[cli]>=0.27.0; extra == 'dev'
43
+ Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
44
+ Requires-Dist: pytest-httpx>=0.30.0; extra == 'dev'
45
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
46
+ Requires-Dist: ruff>=0.5.0; extra == 'dev'
47
+ Description-Content-Type: text/markdown
48
+
49
+ # CodeTrust
50
+
51
+ AI code verification platform — MCP server + cloud API that catches hallucinated packages, broken configs, and code anti-patterns before they hit production.
52
+
53
+ ## What It Does
54
+
55
+ | Layer | Capability | How |
56
+ |-------|-----------|-----|
57
+ | **Static Analysis** | Detect anti-patterns, secrets, eval/exec, SQL injection, etc. | Regex engine, 35+ rules |
58
+ | **Package Verification** | Verify imports exist in real registries | PyPI, npm, Docker Hub |
59
+ | **Docker Verification** | Verify base images and tags exist | Docker Hub API |
60
+ | **Enterprise Checks** | Validate repo structure | README, LICENSE, tests, etc. |
61
+ | **Deep Scan** | All layers combined in one pass | Orchestrated scan |
62
+
63
+ ## Quick Start
64
+
65
+ ### Install
66
+
67
+ ```bash
68
+ # Clone and install
69
+ git clone https://github.com/yourorg/codetrust.git
70
+ cd codetrust
71
+ pip install -e ".[dev]"
72
+
73
+ # Or use the setup script
74
+ chmod +x setup.sh && ./setup.sh --all
75
+ ```
76
+
77
+ ### Run MCP Server (for Claude Code)
78
+
79
+ ```bash
80
+ python -m src.server
81
+ ```
82
+
83
+ ### Run HTTP API
84
+
85
+ ```bash
86
+ # Local (no Redis required — degrades gracefully)
87
+ uvicorn src.api:app --host 0.0.0.0 --port 8000
88
+
89
+ # With Redis (recommended for caching)
90
+ docker compose up -d
91
+ ```
92
+
93
+ ## MCP Configuration for Claude Code
94
+
95
+ Add to your Claude Code MCP settings (`~/.claude/claude_desktop_config.json`):
96
+
97
+ ```json
98
+ {
99
+ "mcpServers": {
100
+ "codetrust": {
101
+ "command": "python",
102
+ "args": ["-m", "src.server"],
103
+ "cwd": "/path/to/codetrust"
104
+ }
105
+ }
106
+ }
107
+ ```
108
+
109
+ ## MCP Tools
110
+
111
+ | Tool | Description |
112
+ |------|-------------|
113
+ | `codetrust_static_scan` | Scan code for anti-patterns and security issues |
114
+ | `codetrust_pre_action` | Validate plan before writing code |
115
+ | `codetrust_post_action` | Validate completed work against enterprise standards |
116
+ | `codetrust_list_rules` | List all rules and their severities |
117
+ | `codetrust_verify_imports` | Verify package imports exist in registries |
118
+ | `codetrust_verify_dockerfile` | Verify Docker base images and tags exist |
119
+ | `codetrust_deep_scan` | Run all validation layers in a single pass |
120
+
121
+ ## API Endpoints
122
+
123
+ All endpoints require `X-API-Key` header when `CODETRUST_API_KEY` is set. In local dev (no key set), auth is skipped.
124
+
125
+ ### `GET /v1/status`
126
+
127
+ Health check. Returns version and cache status.
128
+
129
+ ```bash
130
+ curl http://localhost:8000/v1/status
131
+ # {"status":"ok","version":"1.0.0","cache_connected":true}
132
+ ```
133
+
134
+ ### `POST /v1/scan/static`
135
+
136
+ Static anti-pattern analysis.
137
+
138
+ ```bash
139
+ curl -X POST http://localhost:8000/v1/scan/static \
140
+ -H "Content-Type: application/json" \
141
+ -d '{"code": "import os\neval(input())", "filename": "app.py"}'
142
+ ```
143
+
144
+ ### `POST /v1/verify/imports`
145
+
146
+ Verify package imports exist in registries.
147
+
148
+ ```bash
149
+ curl -X POST http://localhost:8000/v1/verify/imports \
150
+ -H "Content-Type: application/json" \
151
+ -d '{"language": "python", "imports": ["fastapi", "nonexistent_xyz"]}'
152
+ ```
153
+
154
+ ### `POST /v1/verify/dockerfile`
155
+
156
+ Verify Docker images and tags.
157
+
158
+ ```bash
159
+ curl -X POST http://localhost:8000/v1/verify/dockerfile \
160
+ -H "Content-Type: application/json" \
161
+ -d '{"images": [{"image": "python", "tag": "3.12-slim"}]}'
162
+ ```
163
+
164
+ ### `POST /v1/scan/deep`
165
+
166
+ Full deep scan combining all layers.
167
+
168
+ ```bash
169
+ curl -X POST http://localhost:8000/v1/scan/deep \
170
+ -H "Content-Type: application/json" \
171
+ -d '{
172
+ "code": "import fastapi\nimport nonexistent_xyz",
173
+ "filename": "app.py",
174
+ "language": "python",
175
+ "verify_imports": true,
176
+ "verify_docker": false
177
+ }'
178
+ ```
179
+
180
+ ## Configuration
181
+
182
+ All settings via environment variables prefixed with `CODETRUST_`:
183
+
184
+ | Variable | Default | Description |
185
+ |----------|---------|-------------|
186
+ | `CODETRUST_HOST` | `0.0.0.0` | API bind host |
187
+ | `CODETRUST_PORT` | `8000` | API bind port |
188
+ | `CODETRUST_DEBUG` | `false` | Enable debug/reload mode |
189
+ | `CODETRUST_API_KEY` | `""` | API key (empty = no auth) |
190
+ | `CODETRUST_REDIS_URL` | `redis://localhost:6379` | Redis connection URL |
191
+ | `CODETRUST_HTTP_TIMEOUT` | `10.0` | HTTP client timeout (seconds) |
192
+ | `CODETRUST_CACHE_TTL_PACKAGE_EXISTS` | `86400` | Cache TTL for package existence |
193
+ | `CODETRUST_CACHE_TTL_DOCKER_TAG` | `86400` | Cache TTL for Docker tags |
194
+
195
+ See [.env.example](.env.example) for all available options.
196
+
197
+ ## Docker
198
+
199
+ ```bash
200
+ # Build
201
+ docker build -t codetrust .
202
+
203
+ # Run API server
204
+ docker run -p 8000:8000 codetrust
205
+
206
+ # Run MCP server
207
+ docker run codetrust python -m src.server
208
+
209
+ # Full stack with Redis
210
+ docker compose up -d
211
+ ```
212
+
213
+ ## Deployment (Railway)
214
+
215
+ 1. Connect your GitHub repo to [Railway](https://railway.app)
216
+ 2. Add a Redis service
217
+ 3. Set environment variables: `CODETRUST_API_KEY`, `CODETRUST_REDIS_URL`
218
+ 4. Deploy — Railway uses the included `railway.toml`
219
+
220
+ ## Development
221
+
222
+ ```bash
223
+ # Install dev dependencies
224
+ pip install -e ".[dev]"
225
+
226
+ # Run tests
227
+ pytest tests/ -v
228
+
229
+ # Lint
230
+ ruff check src/ tests/
231
+
232
+ # Run with pre-commit hooks
233
+ ./setup.sh --hooks
234
+ ```
235
+
236
+ ## Architecture
237
+
238
+ ```
239
+ ┌─────────────────────────────────────┐
240
+ │ Claude Code / Client │
241
+ └──────────┬──────────────────────────┘
242
+ │ MCP Protocol
243
+ ┌──────────▼──────────────────────────┐
244
+ │ MCP Server (server.py) │
245
+ │ 7 tools: scan, verify, deep_scan │
246
+ └──────────┬──────────────────────────┘
247
+
248
+ ┌──────────▼──────────────────────────┐
249
+ │ FastAPI (api.py) │
250
+ │ 5 endpoints, X-API-Key auth │
251
+ └──────────┬──────────────────────────┘
252
+
253
+ ┌──────────▼──────────────────────────┐
254
+ │ Services Layer │
255
+ │ StaticAnalyzer │ Registry │ Docker │
256
+ └──────────┬──────────────────────────┘
257
+
258
+ ┌──────────▼──────────────────────────┐
259
+ │ Redis Cache (graceful degrade) │
260
+ └─────────────────────────────────────┘
261
+ ```
262
+
263
+ ## License
264
+
265
+ MIT
@@ -0,0 +1,39 @@
1
+ src/__init__.py,sha256=hOoezw2EDW92bI4Egr94pazUsCBVaqWKH9o14KsRjmg,51
2
+ src/api.py,sha256=rLJCSGqo9Mh7FGz_4odsgs72C7_o2MYftGA_xyyaz9M,37449
3
+ src/cli.py,sha256=ICPg-Nqq3EA4MYebLUc-n52LYtAD7myMqINov1VVZUQ,15635
4
+ src/config.py,sha256=jwxmAJk3roejIwfVZT4pbcITO9VIz3Ar5167WC00l2I,3265
5
+ src/server.py,sha256=OIiIJCf43C53ytqljYRmHoBB4yBB0kiB3WHku5EXr4Q,23985
6
+ src/formatters/__init__.py,sha256=MJ3WkijQqmqW5-u8eBMlrau0Av3ZpM5MSjn0rAbOfM0,52
7
+ src/formatters/sarif.py,sha256=TCuf5u_6paGiZoVGVMbi5G4coNKbvjE1YVa3LEcUDEI,4924
8
+ src/models/__init__.py,sha256=ASuYj68yAkYHjARrzmkEXYbZ0EXr1-LUYYRkWM82prc,58
9
+ src/models/database.py,sha256=I1k4d0YO34_rv8DFM5kicE2eYz-oUInbnDt1K7ZkOgE,4793
10
+ src/models/enums.py,sha256=Qni9PinACvX7W07DOUXw7M2Q0NcoAOUkqvfhhgLdWXA,1481
11
+ src/models/requests.py,sha256=P1TOlOb6BDEm9buipsrfpJHfUntH7JW04SacwuTiIWo,6476
12
+ src/models/responses.py,sha256=12Zy2E5IGPI_Ef5b1YmvTVj9hoUFrw6XYESKXM77U1g,6272
13
+ src/rules/__init__.py,sha256=22_zuPoT89YX4soRkzMzFj0a8lD4e8YRahPaBQRIO8U,58
14
+ src/rules/anti_patterns.py,sha256=hgsEgTWN0As1lLew3CGFH4dYQ1ir_9OWx0TZmWs-zRM,3775
15
+ src/rules/enterprise.py,sha256=0quEeQ8GvXLFAR_bOHcUPk3Tkd-7N_n--McF2myHwCI,721
16
+ src/services/__init__.py,sha256=v_MeSazS_GlaJQ0wxtokQLtIivikisxdHCo6oWKkzfk,31
17
+ src/services/ast_analyzer.py,sha256=Uyi1cUP2Gl3omPB_8XStWkut1xnjBu5Ha1yEIwuu_f0,20397
18
+ src/services/auth.py,sha256=QJwKLyJcKjiMYfza6Uc-pU014nDu2q4InvxXGjXkovU,4291
19
+ src/services/billing.py,sha256=2kR5Q2yPuiQmTjXGFosRFO3Xqyic2qECD9s9Kud-2IM,5265
20
+ src/services/cache.py,sha256=3dK1WulqK-xAtdNqHjAKii80kw2EiXn-So9Zfv4W3pQ,3464
21
+ src/services/database.py,sha256=dAqyIunTZ4C_WNrb2Q5gQMqobVkwyRXVkPxboOlOcWQ,11957
22
+ src/services/docker_verify.py,sha256=p4IHBD12irsAMy_yL0JBtQwlVk8m3A8hzu-BYGx6qcg,7723
23
+ src/services/rate_limiter.py,sha256=yYbbp_eEb8LE6HZjOZu4xy-jPR3QRS-h2B7qIMvGua0,1921
24
+ src/services/registry.py,sha256=dQg5tWIY041AStyrWhS9FzCI-x59aN6g_Wy797LAa2I,26302
25
+ src/services/sandbox.py,sha256=j-qWoGuUe2t2QFVltPbJFzqNNfQxn0Uqj1GQNstyhis,8879
26
+ src/services/static_analyzer.py,sha256=_yk9hQpilICar7Kb2PTXzbf1qEk4GFd71AMSwrS35VM,12272
27
+ src/templates/CLAUDE.md,sha256=UdtKaKR8zFY03ujQmEGcc07Gd4Evws1WHmKwLq3MIAc,1650
28
+ src/templates/__init__.py,sha256=d4bYhY9vUHes1lGXwIq0x-SWFD7kvzMqpfqzLmURR_A,69
29
+ src/templates/codetrust-scan.yml,sha256=Wc1LmkKULrn-ZCq8ALpjjRgrv6tVTdQvLBQv_g3uhK8,864
30
+ src/templates/cursorrules,sha256=TAn--nnO-Qw72-ayO-_jpRcaymqJpCtonmaa3XcMZ4s,329
31
+ src/templates/pre-commit,sha256=NvBbxMhv2GHyl3CNgmD-OES0vwvbPrfscByx0tEA3ps,2141
32
+ src/utils/__init__.py,sha256=lZOrjvEX5t8bpUCtXBbvTTPb4j4kNd3XQi-pgabZ5yU,57
33
+ src/utils/parsers.py,sha256=vUjiMKgULEDE-VbPgSwbRYounp4bBjk25-Xour6kFbA,16986
34
+ src/utils/similarity.py,sha256=U7b5r3NKqn9x3tg1GCK0beM6hLjjUMDam0OHYLO-jxU,13908
35
+ codetrust-1.5.0.dist-info/METADATA,sha256=_Gu2xDFWLCfni0SWSpG1Y0E5uBkevlkAI245CtR5Xmw,8490
36
+ codetrust-1.5.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
37
+ codetrust-1.5.0.dist-info/entry_points.txt,sha256=S_2VGPq51l4hOxTgmsJzjLugXJiF07Wm0JfNcGe4qZk,106
38
+ codetrust-1.5.0.dist-info/licenses/LICENSE,sha256=HG04cnVUHVbydCK4eBBRh-4CldmqIZ1k7bRKLUMUPX8,1066
39
+ codetrust-1.5.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.28.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,4 @@
1
+ [console_scripts]
2
+ codetrust = src.cli:main
3
+ codetrust-api = src.api:run
4
+ codetrust-mcp = src.server:mcp.run
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 CodeTrust
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.
src/__init__.py ADDED
@@ -0,0 +1 @@
1
+ """CodeTrust — AI code verification platform."""