veto-leash 2.0.4 → 2.1.1
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.
- package/README.md +228 -127
- package/go/leash-darwin-amd64 +0 -0
- package/go/leash-darwin-arm64 +0 -0
- package/go/leash-linux-amd64 +0 -0
- package/go/leash-linux-arm64 +0 -0
- package/go/leash-windows-amd64.exe +0 -0
- package/package.json +1 -1
- package/bin/leash +0 -0
package/README.md
CHANGED
|
@@ -1,213 +1,314 @@
|
|
|
1
1
|
<p align="center">
|
|
2
2
|
<h1 align="center">veto-leash</h1>
|
|
3
|
-
<p align="center"><strong>
|
|
3
|
+
<p align="center"><strong>Permission layer for AI coding agents</strong></p>
|
|
4
4
|
<p align="center">
|
|
5
|
-
<a href="https://www.npmjs.com/package/veto-leash"><img src="https://img.shields.io/npm/v/veto-leash?style=flat-square&color=
|
|
6
|
-
<a href="https://github.com/VulnZap/veto-leash/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/veto-leash?style=flat-square&color=
|
|
7
|
-
<a href="https://www.npmjs.com/package/veto-leash"><img src="https://img.shields.io/npm/dm/veto-leash?style=flat-square&color=
|
|
5
|
+
<a href="https://www.npmjs.com/package/veto-leash"><img src="https://img.shields.io/npm/v/veto-leash?style=flat-square&color=f5a524" alt="npm version"></a>
|
|
6
|
+
<a href="https://github.com/VulnZap/veto-leash/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/veto-leash?style=flat-square&color=000" alt="License"></a>
|
|
7
|
+
<a href="https://www.npmjs.com/package/veto-leash"><img src="https://img.shields.io/npm/dm/veto-leash?style=flat-square&color=000" alt="Downloads"></a>
|
|
8
8
|
</p>
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
<br>
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
# One file. That's it.
|
|
15
|
-
echo "no lodash
|
|
16
|
-
no any types" > .leash
|
|
13
|
+
## Overview
|
|
17
14
|
|
|
18
|
-
leash
|
|
19
|
-
```
|
|
15
|
+
AI coding agents have unrestricted access to your codebase. veto-leash adds a permission layer with natural language policies enforced through AST-level validation.
|
|
20
16
|
|
|
21
|
-
|
|
17
|
+
```bash
|
|
18
|
+
npm install -g veto-leash
|
|
19
|
+
leash
|
|
20
|
+
```
|
|
22
21
|
|
|
23
|
-
|
|
22
|
+
Create policies in plain English. Block dangerous operations. Zero false positives.
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
- **4.5MB binary** - Instant startup, no Node.js required at runtime
|
|
27
|
-
- **Cross-platform** - Native binaries for macOS, Linux, Windows (arm64 + amd64)
|
|
28
|
-
- **Hybrid engine** - Go for speed, TypeScript for LLM compilation + AST validation
|
|
24
|
+
<br>
|
|
29
25
|
|
|
30
26
|
## The Problem
|
|
31
27
|
|
|
32
|
-
AI coding
|
|
28
|
+
Modern AI coding assistants can execute arbitrary commands and modify any file. While powerful, this creates risk:
|
|
29
|
+
|
|
30
|
+
- Installing unwanted dependencies (lodash when you prefer native)
|
|
31
|
+
- Using loose types (any instead of proper TypeScript)
|
|
32
|
+
- Executing dangerous commands (force push to main)
|
|
33
|
+
- Modifying protected files (.env, credentials)
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
Traditional regex-based blocking creates false positives. Comments mentioning "lodash" shouldn't trigger blocks.
|
|
36
|
+
|
|
37
|
+
<br>
|
|
35
38
|
|
|
36
39
|
## The Solution
|
|
37
40
|
|
|
38
|
-
veto-leash uses
|
|
41
|
+
veto-leash uses Abstract Syntax Tree parsing for surgical precision:
|
|
42
|
+
|
|
43
|
+
| Code | Regex Blocker | veto-leash |
|
|
44
|
+
| ------------------------ | ------------- | --------------------- |
|
|
45
|
+
| `// import lodash` | BLOCKED | ALLOWED (comment) |
|
|
46
|
+
| `"use any type"` | BLOCKED | ALLOWED (string) |
|
|
47
|
+
| `const anyValue = 5` | BLOCKED | ALLOWED (variable) |
|
|
48
|
+
| `import _ from 'lodash'` | BLOCKED | BLOCKED (actual code) |
|
|
39
49
|
|
|
40
|
-
|
|
41
|
-
| ------------------------ | ------------ | -------------------------- |
|
|
42
|
-
| `// import lodash` | BLOCKED | ALLOWED (comment) |
|
|
43
|
-
| `"use any type"` | BLOCKED | ALLOWED (string) |
|
|
44
|
-
| `const anyValue = 5` | BLOCKED | ALLOWED (variable name) |
|
|
45
|
-
| `import _ from 'lodash'` | BLOCKED | BLOCKED (correct) |
|
|
50
|
+
The difference is precision. AST parsing understands code structure, eliminating false positives entirely.
|
|
46
51
|
|
|
47
|
-
|
|
52
|
+
<br>
|
|
48
53
|
|
|
49
54
|
## Quick Start
|
|
50
55
|
|
|
56
|
+
### Installation
|
|
57
|
+
|
|
51
58
|
```bash
|
|
52
|
-
# Install globally
|
|
53
59
|
npm install -g veto-leash
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Create Policies
|
|
54
63
|
|
|
55
|
-
|
|
56
|
-
|
|
64
|
+
One policy per line in `.leash`:
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
no lodash
|
|
57
68
|
no any types
|
|
58
|
-
prefer pnpm
|
|
69
|
+
prefer pnpm over npm
|
|
70
|
+
protect .env files
|
|
71
|
+
```
|
|
59
72
|
|
|
60
|
-
|
|
73
|
+
### Launch Dashboard
|
|
74
|
+
|
|
75
|
+
```bash
|
|
61
76
|
leash
|
|
62
77
|
```
|
|
63
78
|
|
|
64
|
-
|
|
65
|
-
- Add and manage policies
|
|
66
|
-
- Install hooks for detected agents
|
|
67
|
-
- Monitor enforcement in real-time
|
|
68
|
-
- View audit logs
|
|
79
|
+
Interactive TUI for policy management, agent configuration, and monitoring.
|
|
69
80
|
|
|
70
|
-
|
|
81
|
+
### CLI Usage
|
|
71
82
|
|
|
72
83
|
```bash
|
|
73
84
|
leash init # Auto-detect agents, install hooks
|
|
74
|
-
leash add "no axios" # Add
|
|
85
|
+
leash add "no axios" # Add policy
|
|
75
86
|
leash sync # Apply to all agents
|
|
87
|
+
leash status # Show configuration
|
|
76
88
|
```
|
|
77
89
|
|
|
78
|
-
|
|
90
|
+
<br>
|
|
79
91
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
no any types - enforces strict TypeScript
|
|
84
|
-
no console.log
|
|
85
|
-
prefer pnpm over npm
|
|
86
|
-
protect .env files
|
|
87
|
-
```
|
|
92
|
+
## Features
|
|
93
|
+
|
|
94
|
+
### Native Performance
|
|
88
95
|
|
|
89
|
-
|
|
96
|
+
- **6.8MB binary** - Go-based TUI, instant startup
|
|
97
|
+
- **Cross-platform** - macOS, Linux, Windows (ARM64 + AMD64)
|
|
98
|
+
- **Auto-update** - Built-in version checking and updates
|
|
90
99
|
|
|
91
|
-
|
|
100
|
+
### Smart Validation
|
|
92
101
|
|
|
93
|
-
|
|
102
|
+
- **50+ built-in patterns** - Common policies work instantly
|
|
103
|
+
- **AST parsing** - Tree-sitter for zero false positives
|
|
104
|
+
- **LLM compilation** - Custom policies use Gemini API
|
|
105
|
+
- **243 test suite** - Comprehensive validation coverage
|
|
94
106
|
|
|
95
|
-
|
|
107
|
+
### Agent Integration
|
|
108
|
+
|
|
109
|
+
Native support for major AI coding tools:
|
|
110
|
+
|
|
111
|
+
| Agent | Integration Method | Status |
|
|
112
|
+
| --------------- | --------------------------- | ------ |
|
|
113
|
+
| **Claude Code** | PreToolUse hooks | Full |
|
|
114
|
+
| **OpenCode** | AGENTS.md injection | Full |
|
|
115
|
+
| **Cursor** | rules/ directory | Full |
|
|
116
|
+
| **Windsurf** | Cascade rules | Full |
|
|
117
|
+
| **Aider** | .aider.conf.yml | Full |
|
|
118
|
+
|
|
119
|
+
<br>
|
|
120
|
+
|
|
121
|
+
## Built-in Policies
|
|
122
|
+
|
|
123
|
+
Instant validation without LLM calls:
|
|
124
|
+
|
|
125
|
+
| Policy | Blocks |
|
|
96
126
|
| --------------------- | ------------------------------------------ |
|
|
97
127
|
| `no lodash` | ES imports, require(), dynamic import() |
|
|
98
128
|
| `no any types` | Type annotations, generics, as expressions |
|
|
99
129
|
| `no console.log` | console.log(), console['log']() |
|
|
100
130
|
| `no eval` | eval(), new Function() |
|
|
101
131
|
| `no class components` | React.Component, PureComponent |
|
|
102
|
-
| `no
|
|
132
|
+
| `no innerHTML` | innerHTML, dangerouslySetInnerHTML |
|
|
103
133
|
| `no debugger` | debugger statements |
|
|
104
134
|
| `no var` | var declarations |
|
|
105
|
-
| `prefer pnpm` | npm/yarn commands
|
|
106
|
-
| `protect .env` |
|
|
135
|
+
| `prefer pnpm` | npm/yarn package manager commands |
|
|
136
|
+
| `protect .env` | Modifications to environment files |
|
|
107
137
|
|
|
108
|
-
50
|
|
138
|
+
Over 50 patterns available. See source for complete list.
|
|
109
139
|
|
|
110
|
-
|
|
140
|
+
<br>
|
|
111
141
|
|
|
112
|
-
|
|
113
|
-
| --------------- | ------------------------------------ | ---------- |
|
|
114
|
-
| **Claude Code** | PreToolUse hooks with AST validation | Full |
|
|
115
|
-
| **OpenCode** | AGENTS.md injection | Full |
|
|
116
|
-
| **Cursor** | rules/ directory integration | Full |
|
|
117
|
-
| **Windsurf** | Cascade rules integration | Full |
|
|
118
|
-
| **Aider** | .aider.conf.yml configuration | Full |
|
|
119
|
-
|
|
120
|
-
## Commands
|
|
142
|
+
## Architecture
|
|
121
143
|
|
|
122
144
|
```
|
|
123
|
-
|
|
124
|
-
leash
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
145
|
+
┌──────────────────────────────────────────────┐
|
|
146
|
+
│ leash (Native Binary) │
|
|
147
|
+
├──────────────────────────────────────────────┤
|
|
148
|
+
│ Interactive TUI │ CLI Commands │
|
|
149
|
+
│ • Policy editor │ • add, list, sync │
|
|
150
|
+
│ • Agent manager │ • install, status │
|
|
151
|
+
│ • Live updates │ • Pattern matching │
|
|
152
|
+
├─────────────────────┴──────────────────────┤
|
|
153
|
+
│ TypeScript Engine (as needed) │
|
|
154
|
+
│ • LLM policy compilation (Gemini API) │
|
|
155
|
+
│ • AST validation (Tree-sitter) │
|
|
156
|
+
│ • Audit logging and reporting │
|
|
157
|
+
└──────────────────────────────────────────────┘
|
|
133
158
|
```
|
|
134
159
|
|
|
135
|
-
|
|
160
|
+
Built-in policies execute in Go (instant). Custom policies compile via TypeScript engine with LLM.
|
|
136
161
|
|
|
137
|
-
|
|
162
|
+
<br>
|
|
163
|
+
|
|
164
|
+
## How It Works
|
|
165
|
+
|
|
166
|
+
**Step 1: Policy Compilation**
|
|
138
167
|
|
|
139
168
|
```
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
│ TypeScript Engine (when needed) │
|
|
149
|
-
│ - LLM policy compilation (custom rules) │
|
|
150
|
-
│ - AST validation (Tree-sitter) │
|
|
151
|
-
│ - 243 tests │
|
|
152
|
-
└─────────────────────────────────────────────────────────┘
|
|
169
|
+
Input: "no lodash"
|
|
170
|
+
↓
|
|
171
|
+
Check built-in patterns → Match found
|
|
172
|
+
↓
|
|
173
|
+
Generate:
|
|
174
|
+
- Regex pre-filter: /lodash/
|
|
175
|
+
- AST query: (import_statement source: "lodash")
|
|
176
|
+
- Suggested alternative: "Use native ES6+"
|
|
153
177
|
```
|
|
154
178
|
|
|
155
|
-
**
|
|
179
|
+
**Step 2: Runtime Enforcement**
|
|
156
180
|
|
|
157
|
-
|
|
181
|
+
```
|
|
182
|
+
Agent attempts: import _ from 'lodash'
|
|
183
|
+
↓
|
|
184
|
+
Regex pre-filter → Contains "lodash"
|
|
185
|
+
↓
|
|
186
|
+
Parse file with Tree-sitter (5ms)
|
|
187
|
+
↓
|
|
188
|
+
Query AST → Import statement found
|
|
189
|
+
↓
|
|
190
|
+
BLOCK with context and suggestion
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
<br>
|
|
194
|
+
|
|
195
|
+
## Configuration
|
|
196
|
+
|
|
197
|
+
### .leash Format
|
|
158
198
|
|
|
159
199
|
```
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
└─────────────────────────────────────────┘
|
|
166
|
-
↓
|
|
167
|
-
┌─────────────────────────────────────────┐
|
|
168
|
-
│ 2. Runtime: Write/Edit intercepted │
|
|
169
|
-
│ → Regex pre-filter: "lodash"? │
|
|
170
|
-
│ → AST parse (5ms, cached) │
|
|
171
|
-
│ → BLOCKED with line/column │
|
|
172
|
-
└─────────────────────────────────────────┘
|
|
200
|
+
# Lines starting with # are comments
|
|
201
|
+
no lodash
|
|
202
|
+
no any types - enforces strict TypeScript
|
|
203
|
+
protect .env
|
|
204
|
+
prefer pnpm over npm
|
|
173
205
|
```
|
|
174
206
|
|
|
175
|
-
|
|
207
|
+
Policies support optional reasoning after `-`.
|
|
208
|
+
|
|
209
|
+
### Environment Variables
|
|
176
210
|
|
|
177
|
-
| Variable |
|
|
178
|
-
| ---------------- |
|
|
179
|
-
| `GEMINI_API_KEY` |
|
|
211
|
+
| Variable | Purpose | Required |
|
|
212
|
+
| ---------------- | ------------------------------- | -------- |
|
|
213
|
+
| `GEMINI_API_KEY` | LLM compilation for custom rules | Optional |
|
|
180
214
|
|
|
181
|
-
|
|
215
|
+
Free API key: https://aistudio.google.com/apikey
|
|
182
216
|
|
|
183
|
-
|
|
217
|
+
Built-in policies work without API key.
|
|
184
218
|
|
|
185
|
-
|
|
186
|
-
2. **Invisible until needed** - Auto-detection, background enforcement
|
|
187
|
-
3. **Native performance** - Go binary, instant startup
|
|
188
|
-
4. **Natural language** - `no lodash` not `{ "rule": "no-import", "pattern": "^lodash" }`
|
|
219
|
+
<br>
|
|
189
220
|
|
|
190
|
-
##
|
|
221
|
+
## CLI Reference
|
|
191
222
|
|
|
192
223
|
```
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
224
|
+
USAGE
|
|
225
|
+
leash Interactive dashboard
|
|
226
|
+
leash init Setup wizard
|
|
227
|
+
leash add "policy" Add enforcement rule
|
|
228
|
+
leash list Show active policies
|
|
229
|
+
leash sync [agent] Apply to agents
|
|
230
|
+
leash install <agent> Install agent hooks
|
|
231
|
+
leash uninstall <agent> Remove hooks
|
|
232
|
+
leash status Show configuration
|
|
233
|
+
leash explain "policy" Preview rule behavior
|
|
234
|
+
leash audit [--tail] View enforcement log
|
|
235
|
+
leash update Update to latest version
|
|
236
|
+
|
|
237
|
+
AGENTS
|
|
238
|
+
cc, claude-code Claude Code
|
|
239
|
+
oc, opencode OpenCode
|
|
240
|
+
cursor Cursor
|
|
241
|
+
windsurf Windsurf
|
|
242
|
+
aider Aider
|
|
201
243
|
```
|
|
202
244
|
|
|
245
|
+
<br>
|
|
246
|
+
|
|
247
|
+
## Development
|
|
248
|
+
|
|
249
|
+
### Build from Source
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
git clone https://github.com/VulnZap/veto-leash
|
|
253
|
+
cd veto-leash
|
|
254
|
+
pnpm install
|
|
255
|
+
pnpm build
|
|
256
|
+
cd go && make build-all
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### Run Tests
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
pnpm test # TypeScript test suite
|
|
263
|
+
pnpm typecheck # Type validation
|
|
264
|
+
go test ./... # Go tests
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Test Suite
|
|
268
|
+
|
|
269
|
+
- 243 tests passing
|
|
270
|
+
- 77 AST validation tests
|
|
271
|
+
- 93 content matching tests
|
|
272
|
+
- 41 command interception tests
|
|
273
|
+
- 17 pattern matcher tests
|
|
274
|
+
- 16 builtin rule tests
|
|
275
|
+
- 12 parser tests
|
|
276
|
+
- 9 session tests
|
|
277
|
+
|
|
278
|
+
<br>
|
|
279
|
+
|
|
280
|
+
## Design Principles
|
|
281
|
+
|
|
282
|
+
1. **Precision over approximation** - AST parsing eliminates false positives
|
|
283
|
+
2. **Speed over flexibility** - Native binary, instant feedback
|
|
284
|
+
3. **Clarity over cleverness** - Natural language policies
|
|
285
|
+
4. **Safety over convenience** - Explicit validation required
|
|
286
|
+
|
|
287
|
+
<br>
|
|
288
|
+
|
|
289
|
+
## Comparison
|
|
290
|
+
|
|
291
|
+
| Feature | veto-leash | git hooks | IDE linters |
|
|
292
|
+
| ---------------- | ------------ | --------- | ----------- |
|
|
293
|
+
| AST validation | Yes | No | Limited |
|
|
294
|
+
| Natural language | Yes | No | No |
|
|
295
|
+
| Agent-aware | Yes | No | No |
|
|
296
|
+
| False positives | Zero | High | Medium |
|
|
297
|
+
| Runtime | 5ms | N/A | Seconds |
|
|
298
|
+
| Setup | One command | Manual | Per-project |
|
|
299
|
+
|
|
300
|
+
<br>
|
|
301
|
+
|
|
203
302
|
## License
|
|
204
303
|
|
|
205
304
|
Apache-2.0
|
|
206
305
|
|
|
306
|
+
See [LICENSE](LICENSE) for details.
|
|
307
|
+
|
|
308
|
+
<br>
|
|
309
|
+
|
|
207
310
|
---
|
|
208
311
|
|
|
209
312
|
<p align="center">
|
|
210
313
|
Built by <a href="https://plaw.io">Plaw, Inc.</a> for the <a href="https://veto.run">Veto</a> product line.
|
|
211
|
-
<br><br>
|
|
212
|
-
<strong>Ship faster. Sleep better.</strong>
|
|
213
314
|
</p>
|
package/go/leash-darwin-amd64
CHANGED
|
Binary file
|
package/go/leash-darwin-arm64
CHANGED
|
Binary file
|
package/go/leash-linux-amd64
CHANGED
|
Binary file
|
package/go/leash-linux-arm64
CHANGED
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
package/bin/leash
DELETED
|
Binary file
|