autoforge-ai 0.1.0
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/.claude/commands/check-code.md +32 -0
- package/.claude/commands/checkpoint.md +40 -0
- package/.claude/commands/create-spec.md +613 -0
- package/.claude/commands/expand-project.md +234 -0
- package/.claude/commands/gsd-to-autoforge-spec.md +10 -0
- package/.claude/commands/review-pr.md +75 -0
- package/.claude/templates/app_spec.template.txt +331 -0
- package/.claude/templates/coding_prompt.template.md +265 -0
- package/.claude/templates/initializer_prompt.template.md +354 -0
- package/.claude/templates/testing_prompt.template.md +146 -0
- package/.env.example +64 -0
- package/LICENSE.md +676 -0
- package/README.md +423 -0
- package/agent.py +444 -0
- package/api/__init__.py +10 -0
- package/api/database.py +536 -0
- package/api/dependency_resolver.py +449 -0
- package/api/migration.py +156 -0
- package/auth.py +83 -0
- package/autoforge_paths.py +315 -0
- package/autonomous_agent_demo.py +293 -0
- package/bin/autoforge.js +3 -0
- package/client.py +607 -0
- package/env_constants.py +27 -0
- package/examples/OPTIMIZE_CONFIG.md +230 -0
- package/examples/README.md +531 -0
- package/examples/org_config.yaml +172 -0
- package/examples/project_allowed_commands.yaml +139 -0
- package/lib/cli.js +791 -0
- package/mcp_server/__init__.py +1 -0
- package/mcp_server/feature_mcp.py +988 -0
- package/package.json +53 -0
- package/parallel_orchestrator.py +1800 -0
- package/progress.py +247 -0
- package/prompts.py +427 -0
- package/pyproject.toml +17 -0
- package/rate_limit_utils.py +132 -0
- package/registry.py +614 -0
- package/requirements-prod.txt +14 -0
- package/security.py +959 -0
- package/server/__init__.py +17 -0
- package/server/main.py +261 -0
- package/server/routers/__init__.py +32 -0
- package/server/routers/agent.py +177 -0
- package/server/routers/assistant_chat.py +327 -0
- package/server/routers/devserver.py +309 -0
- package/server/routers/expand_project.py +239 -0
- package/server/routers/features.py +746 -0
- package/server/routers/filesystem.py +514 -0
- package/server/routers/projects.py +524 -0
- package/server/routers/schedules.py +356 -0
- package/server/routers/settings.py +127 -0
- package/server/routers/spec_creation.py +357 -0
- package/server/routers/terminal.py +453 -0
- package/server/schemas.py +593 -0
- package/server/services/__init__.py +36 -0
- package/server/services/assistant_chat_session.py +496 -0
- package/server/services/assistant_database.py +304 -0
- package/server/services/chat_constants.py +57 -0
- package/server/services/dev_server_manager.py +557 -0
- package/server/services/expand_chat_session.py +399 -0
- package/server/services/process_manager.py +657 -0
- package/server/services/project_config.py +475 -0
- package/server/services/scheduler_service.py +683 -0
- package/server/services/spec_chat_session.py +502 -0
- package/server/services/terminal_manager.py +756 -0
- package/server/utils/__init__.py +1 -0
- package/server/utils/process_utils.py +134 -0
- package/server/utils/project_helpers.py +32 -0
- package/server/utils/validation.py +54 -0
- package/server/websocket.py +903 -0
- package/start.py +456 -0
- package/ui/dist/assets/index-8W_wmZzz.js +168 -0
- package/ui/dist/assets/index-B47Ubhox.css +1 -0
- package/ui/dist/assets/vendor-flow-CVNK-_lx.js +7 -0
- package/ui/dist/assets/vendor-query-BUABzP5o.js +1 -0
- package/ui/dist/assets/vendor-radix-DTNNCg2d.js +45 -0
- package/ui/dist/assets/vendor-react-qkC6yhPU.js +1 -0
- package/ui/dist/assets/vendor-utils-COeKbHgx.js +2 -0
- package/ui/dist/assets/vendor-xterm-DP_gxef0.js +16 -0
- package/ui/dist/index.html +23 -0
- package/ui/dist/ollama.png +0 -0
- package/ui/dist/vite.svg +6 -0
- package/ui/package.json +57 -0
|
@@ -0,0 +1,531 @@
|
|
|
1
|
+
# AutoForge Security Configuration Examples
|
|
2
|
+
|
|
3
|
+
This directory contains example configuration files for controlling which bash commands the autonomous coding agent can execute.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Quick Start](#quick-start)
|
|
8
|
+
- [Project-Level Configuration](#project-level-configuration)
|
|
9
|
+
- [Organization-Level Configuration](#organization-level-configuration)
|
|
10
|
+
- [Command Hierarchy](#command-hierarchy)
|
|
11
|
+
- [Pattern Matching](#pattern-matching)
|
|
12
|
+
- [Common Use Cases](#common-use-cases)
|
|
13
|
+
- [Security Best Practices](#security-best-practices)
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
### For a Single Project (Most Common)
|
|
20
|
+
|
|
21
|
+
When you create a new project with AutoForge, it automatically creates:
|
|
22
|
+
|
|
23
|
+
```text
|
|
24
|
+
my-project/
|
|
25
|
+
.autoforge/
|
|
26
|
+
allowed_commands.yaml ← Automatically created from template
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Edit this file** to add project-specific commands (Swift tools, Rust compiler, etc.).
|
|
30
|
+
|
|
31
|
+
### For All Projects (Organization-Wide)
|
|
32
|
+
|
|
33
|
+
If you want commands available across **all projects**, manually create:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Copy the example to your home directory
|
|
37
|
+
cp examples/org_config.yaml ~/.autoforge/config.yaml
|
|
38
|
+
|
|
39
|
+
# Edit it to add org-wide commands
|
|
40
|
+
nano ~/.autoforge/config.yaml
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Project-Level Configuration
|
|
46
|
+
|
|
47
|
+
**File:** `{project_dir}/.autoforge/allowed_commands.yaml`
|
|
48
|
+
|
|
49
|
+
**Purpose:** Define commands needed for THIS specific project.
|
|
50
|
+
|
|
51
|
+
**Example** (iOS project):
|
|
52
|
+
|
|
53
|
+
```yaml
|
|
54
|
+
version: 1
|
|
55
|
+
commands:
|
|
56
|
+
- name: swift
|
|
57
|
+
description: Swift compiler
|
|
58
|
+
|
|
59
|
+
- name: xcodebuild
|
|
60
|
+
description: Xcode build system
|
|
61
|
+
|
|
62
|
+
- name: swift*
|
|
63
|
+
description: All Swift tools (swiftc, swiftlint, swiftformat)
|
|
64
|
+
|
|
65
|
+
- name: ./scripts/build.sh
|
|
66
|
+
description: Project build script
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**When to use:**
|
|
70
|
+
- ✅ Project uses a specific language toolchain (Swift, Rust, Go)
|
|
71
|
+
- ✅ Project has custom build scripts
|
|
72
|
+
- ✅ Temporary tools needed during development
|
|
73
|
+
|
|
74
|
+
**Limits:**
|
|
75
|
+
- Maximum 100 commands per project
|
|
76
|
+
- Cannot override org-level blocked commands
|
|
77
|
+
- Cannot allow hardcoded blocklist commands (sudo, dd, etc.)
|
|
78
|
+
|
|
79
|
+
**See:** `examples/project_allowed_commands.yaml` for full example with Rust, Python, iOS, etc.
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## Organization-Level Configuration
|
|
84
|
+
|
|
85
|
+
**File:** `~/.autoforge/config.yaml`
|
|
86
|
+
|
|
87
|
+
**Purpose:** Define commands and policies for ALL projects.
|
|
88
|
+
|
|
89
|
+
**Example** (startup team):
|
|
90
|
+
|
|
91
|
+
```yaml
|
|
92
|
+
version: 1
|
|
93
|
+
|
|
94
|
+
# Available to all projects
|
|
95
|
+
allowed_commands:
|
|
96
|
+
- name: jq
|
|
97
|
+
description: JSON processor
|
|
98
|
+
|
|
99
|
+
- name: python3
|
|
100
|
+
description: Python interpreter
|
|
101
|
+
|
|
102
|
+
# Blocked across all projects (cannot be overridden)
|
|
103
|
+
blocked_commands:
|
|
104
|
+
- aws
|
|
105
|
+
- kubectl
|
|
106
|
+
- terraform
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**When to use:**
|
|
110
|
+
- ✅ Multiple projects need the same tools (jq, python3, etc.)
|
|
111
|
+
- ✅ Enforce organization-wide security policies
|
|
112
|
+
- ✅ Block dangerous commands across all projects
|
|
113
|
+
|
|
114
|
+
**See:** `examples/org_config.yaml` for full example with enterprise/startup configurations.
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Command Hierarchy
|
|
119
|
+
|
|
120
|
+
When the agent tries to run a command, the system checks in this order:
|
|
121
|
+
|
|
122
|
+
```text
|
|
123
|
+
┌─────────────────────────────────────────────────────┐
|
|
124
|
+
│ 1. HARDCODED BLOCKLIST (highest priority) │
|
|
125
|
+
│ sudo, dd, shutdown, reboot, chown, etc. │
|
|
126
|
+
│ ❌ NEVER allowed, even with user approval │
|
|
127
|
+
└─────────────────────────────────────────────────────┘
|
|
128
|
+
↓
|
|
129
|
+
┌─────────────────────────────────────────────────────┐
|
|
130
|
+
│ 2. ORG BLOCKLIST (~/.autoforge/config.yaml) │
|
|
131
|
+
│ Commands you block organization-wide │
|
|
132
|
+
│ ❌ Projects CANNOT override these │
|
|
133
|
+
└─────────────────────────────────────────────────────┘
|
|
134
|
+
↓
|
|
135
|
+
┌─────────────────────────────────────────────────────┐
|
|
136
|
+
│ 3. ORG ALLOWLIST (~/.autoforge/config.yaml) │
|
|
137
|
+
│ Commands available to all projects │
|
|
138
|
+
│ ✅ Automatically available │
|
|
139
|
+
└─────────────────────────────────────────────────────┘
|
|
140
|
+
↓
|
|
141
|
+
┌─────────────────────────────────────────────────────┐
|
|
142
|
+
│ 4. GLOBAL ALLOWLIST (security.py) │
|
|
143
|
+
│ Default commands: npm, git, curl, ls, cat, etc. │
|
|
144
|
+
│ ✅ Always available │
|
|
145
|
+
└─────────────────────────────────────────────────────┘
|
|
146
|
+
↓
|
|
147
|
+
┌─────────────────────────────────────────────────────┐
|
|
148
|
+
│ 5. PROJECT ALLOWLIST (.autoforge/allowed_commands) │
|
|
149
|
+
│ Project-specific commands │
|
|
150
|
+
│ ✅ Available only to this project │
|
|
151
|
+
└─────────────────────────────────────────────────────┘
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
**Key Rules:**
|
|
155
|
+
- If a command is BLOCKED at any level above, it cannot be allowed below
|
|
156
|
+
- If a command is ALLOWED at any level, it's available (unless blocked above)
|
|
157
|
+
- Blocklist always wins over allowlist
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## Pattern Matching
|
|
162
|
+
|
|
163
|
+
You can use patterns to match multiple commands:
|
|
164
|
+
|
|
165
|
+
### Exact Match
|
|
166
|
+
```yaml
|
|
167
|
+
- name: swift
|
|
168
|
+
description: Swift compiler only
|
|
169
|
+
```
|
|
170
|
+
Matches: `swift`
|
|
171
|
+
Does NOT match: `swiftc`, `swiftlint`
|
|
172
|
+
|
|
173
|
+
### Prefix Wildcard
|
|
174
|
+
```yaml
|
|
175
|
+
- name: swift*
|
|
176
|
+
description: All Swift tools
|
|
177
|
+
```
|
|
178
|
+
Matches: `swift`, `swiftc`, `swiftlint`, `swiftformat`
|
|
179
|
+
Does NOT match: `npm`, `rustc`
|
|
180
|
+
|
|
181
|
+
### Local Scripts
|
|
182
|
+
```yaml
|
|
183
|
+
- name: ./scripts/build.sh
|
|
184
|
+
description: Build script
|
|
185
|
+
```
|
|
186
|
+
Matches:
|
|
187
|
+
- `./scripts/build.sh`
|
|
188
|
+
- `scripts/build.sh`
|
|
189
|
+
- `/full/path/to/scripts/build.sh`
|
|
190
|
+
- Running `build.sh` from any directory (matched by filename)
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## Common Use Cases
|
|
195
|
+
|
|
196
|
+
### iOS Development
|
|
197
|
+
|
|
198
|
+
**Project config** (`.autoforge/allowed_commands.yaml`):
|
|
199
|
+
```yaml
|
|
200
|
+
version: 1
|
|
201
|
+
commands:
|
|
202
|
+
- name: swift*
|
|
203
|
+
description: All Swift tools
|
|
204
|
+
- name: xcodebuild
|
|
205
|
+
description: Xcode build system
|
|
206
|
+
- name: xcrun
|
|
207
|
+
description: Xcode tools runner
|
|
208
|
+
- name: simctl
|
|
209
|
+
description: iOS Simulator control
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Rust CLI Project
|
|
213
|
+
|
|
214
|
+
**Project config**:
|
|
215
|
+
```yaml
|
|
216
|
+
version: 1
|
|
217
|
+
commands:
|
|
218
|
+
- name: cargo
|
|
219
|
+
description: Rust package manager
|
|
220
|
+
- name: rustc
|
|
221
|
+
description: Rust compiler
|
|
222
|
+
- name: rustfmt
|
|
223
|
+
description: Rust formatter
|
|
224
|
+
- name: clippy
|
|
225
|
+
description: Rust linter
|
|
226
|
+
- name: ./target/debug/my-cli
|
|
227
|
+
description: Debug build
|
|
228
|
+
- name: ./target/release/my-cli
|
|
229
|
+
description: Release build
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### API Testing Project
|
|
233
|
+
|
|
234
|
+
**Project config**:
|
|
235
|
+
```yaml
|
|
236
|
+
version: 1
|
|
237
|
+
commands:
|
|
238
|
+
- name: jq
|
|
239
|
+
description: JSON processor
|
|
240
|
+
- name: httpie
|
|
241
|
+
description: HTTP client
|
|
242
|
+
- name: ./scripts/test-api.sh
|
|
243
|
+
description: API test runner
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Enterprise Organization (Restrictive)
|
|
247
|
+
|
|
248
|
+
**Org config** (`~/.autoforge/config.yaml`):
|
|
249
|
+
```yaml
|
|
250
|
+
version: 1
|
|
251
|
+
|
|
252
|
+
allowed_commands:
|
|
253
|
+
- name: jq
|
|
254
|
+
description: JSON processor
|
|
255
|
+
|
|
256
|
+
blocked_commands:
|
|
257
|
+
- aws # No cloud access
|
|
258
|
+
- gcloud
|
|
259
|
+
- az
|
|
260
|
+
- kubectl # No k8s access
|
|
261
|
+
- terraform # No infrastructure changes
|
|
262
|
+
- psql # No production DB access
|
|
263
|
+
- mysql
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### Startup Team (Permissive)
|
|
267
|
+
|
|
268
|
+
**Org config** (`~/.autoforge/config.yaml`):
|
|
269
|
+
```yaml
|
|
270
|
+
version: 1
|
|
271
|
+
|
|
272
|
+
allowed_commands:
|
|
273
|
+
- name: python3
|
|
274
|
+
description: Python interpreter
|
|
275
|
+
- name: jq
|
|
276
|
+
description: JSON processor
|
|
277
|
+
- name: pytest
|
|
278
|
+
description: Python tests
|
|
279
|
+
|
|
280
|
+
blocked_commands: [] # Rely on hardcoded blocklist only
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
---
|
|
284
|
+
|
|
285
|
+
## Security Best Practices
|
|
286
|
+
|
|
287
|
+
### ✅ DO
|
|
288
|
+
|
|
289
|
+
1. **Start restrictive, add as needed**
|
|
290
|
+
- Begin with default commands only
|
|
291
|
+
- Add project-specific tools when required
|
|
292
|
+
- Review the agent's blocked command errors to understand what's needed
|
|
293
|
+
|
|
294
|
+
2. **Use org-level config for shared tools**
|
|
295
|
+
- If 3+ projects need `jq`, add it to org config
|
|
296
|
+
- Reduces duplication across project configs
|
|
297
|
+
|
|
298
|
+
3. **Block dangerous commands at org level**
|
|
299
|
+
- Prevent accidental production deployments (`kubectl`, `terraform`)
|
|
300
|
+
- Block cloud CLIs if appropriate (`aws`, `gcloud`, `az`)
|
|
301
|
+
|
|
302
|
+
4. **Use descriptive command names**
|
|
303
|
+
- Good: `description: "Swift compiler for iOS builds"`
|
|
304
|
+
- Bad: `description: "Compiler"`
|
|
305
|
+
|
|
306
|
+
5. **Prefer patterns for tool families**
|
|
307
|
+
- `swift*` instead of listing `swift`, `swiftc`, `swiftlint` separately
|
|
308
|
+
- Automatically includes future tools (e.g., new Swift utilities)
|
|
309
|
+
|
|
310
|
+
### ❌ DON'T
|
|
311
|
+
|
|
312
|
+
1. **Don't add commands "just in case"**
|
|
313
|
+
- Only add when the agent actually needs them
|
|
314
|
+
- Empty config is fine - defaults are usually enough
|
|
315
|
+
|
|
316
|
+
2. **Don't try to allow blocklisted commands**
|
|
317
|
+
- Commands like `sudo`, `dd`, `shutdown` can NEVER be allowed
|
|
318
|
+
- The system will reject these in validation
|
|
319
|
+
|
|
320
|
+
3. **Don't use org config for project-specific tools**
|
|
321
|
+
- Bad: Adding `xcodebuild` to org config when only one project uses it
|
|
322
|
+
- Good: Add `xcodebuild` to that project's config
|
|
323
|
+
|
|
324
|
+
4. **Don't exceed the 100 command limit per project**
|
|
325
|
+
- If you need more, you're probably listing subcommands unnecessarily
|
|
326
|
+
- Use wildcards instead: `flutter*` covers all flutter commands, not just the base
|
|
327
|
+
|
|
328
|
+
5. **Don't ignore validation errors**
|
|
329
|
+
- If your YAML is rejected, fix the structure
|
|
330
|
+
- Common issues: missing `version`, malformed lists, over 100 commands
|
|
331
|
+
|
|
332
|
+
---
|
|
333
|
+
|
|
334
|
+
## Default Allowed Commands
|
|
335
|
+
|
|
336
|
+
These commands are **always available** to all projects:
|
|
337
|
+
|
|
338
|
+
**File Operations:**
|
|
339
|
+
- `ls`, `cat`, `head`, `tail`, `wc`, `grep`, `cp`, `mkdir`, `mv`, `rm`, `touch`
|
|
340
|
+
|
|
341
|
+
**Shell:**
|
|
342
|
+
- `pwd`, `echo`, `sh`, `bash`, `sleep`
|
|
343
|
+
|
|
344
|
+
**Version Control:**
|
|
345
|
+
- `git`
|
|
346
|
+
|
|
347
|
+
**Process Management:**
|
|
348
|
+
- `ps`, `lsof`, `kill`, `pkill` (dev processes only: node, npm, vite)
|
|
349
|
+
|
|
350
|
+
**Network:**
|
|
351
|
+
- `curl`
|
|
352
|
+
|
|
353
|
+
**Node.js:**
|
|
354
|
+
- `npm`, `npx`, `pnpm`, `node`
|
|
355
|
+
|
|
356
|
+
**Docker:**
|
|
357
|
+
- `docker`
|
|
358
|
+
|
|
359
|
+
**Special:**
|
|
360
|
+
- `chmod` (only `+x` mode for making scripts executable)
|
|
361
|
+
|
|
362
|
+
---
|
|
363
|
+
|
|
364
|
+
## Hardcoded Blocklist
|
|
365
|
+
|
|
366
|
+
These commands are **NEVER allowed**, even with user approval:
|
|
367
|
+
|
|
368
|
+
**Disk Operations:**
|
|
369
|
+
- `dd`, `mkfs`, `fdisk`, `parted`
|
|
370
|
+
|
|
371
|
+
**System Control:**
|
|
372
|
+
- `shutdown`, `reboot`, `poweroff`, `halt`, `init`
|
|
373
|
+
|
|
374
|
+
**Privilege Escalation:**
|
|
375
|
+
- `sudo`, `su`, `doas`
|
|
376
|
+
|
|
377
|
+
**System Services:**
|
|
378
|
+
- `systemctl`, `service`, `launchctl`
|
|
379
|
+
|
|
380
|
+
**Network Security:**
|
|
381
|
+
- `iptables`, `ufw`
|
|
382
|
+
|
|
383
|
+
**Ownership Changes:**
|
|
384
|
+
- `chown`, `chgrp`
|
|
385
|
+
|
|
386
|
+
**Dangerous Commands** (Phase 3 will add approval):
|
|
387
|
+
- `aws`, `gcloud`, `az`, `kubectl`, `docker-compose`
|
|
388
|
+
|
|
389
|
+
---
|
|
390
|
+
|
|
391
|
+
## Troubleshooting
|
|
392
|
+
|
|
393
|
+
### Error: "Command 'X' is not allowed"
|
|
394
|
+
|
|
395
|
+
**Solution:** Add the command to your project config:
|
|
396
|
+
```yaml
|
|
397
|
+
# In .autoforge/allowed_commands.yaml
|
|
398
|
+
commands:
|
|
399
|
+
- name: X
|
|
400
|
+
description: What this command does
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
### Error: "Command 'X' is blocked at organization level"
|
|
404
|
+
|
|
405
|
+
**Cause:** The command is in the org blocklist or hardcoded blocklist.
|
|
406
|
+
|
|
407
|
+
**Solution:**
|
|
408
|
+
- If in org blocklist: Edit `~/.autoforge/config.yaml` to remove it
|
|
409
|
+
- If in hardcoded blocklist: Cannot be allowed (by design)
|
|
410
|
+
|
|
411
|
+
### Error: "Could not parse YAML config"
|
|
412
|
+
|
|
413
|
+
**Cause:** YAML syntax error.
|
|
414
|
+
|
|
415
|
+
**Solution:** Check for:
|
|
416
|
+
- Missing colons after keys
|
|
417
|
+
- Incorrect indentation (use 2 spaces, not tabs)
|
|
418
|
+
- Missing quotes around special characters
|
|
419
|
+
|
|
420
|
+
### Config not taking effect
|
|
421
|
+
|
|
422
|
+
**Solution:**
|
|
423
|
+
1. Restart the agent (changes are loaded on startup)
|
|
424
|
+
2. Verify file location:
|
|
425
|
+
- Project: `{project}/.autoforge/allowed_commands.yaml`
|
|
426
|
+
- Org: `~/.autoforge/config.yaml` (must be manually created)
|
|
427
|
+
3. Check YAML is valid (run through a YAML validator)
|
|
428
|
+
|
|
429
|
+
---
|
|
430
|
+
|
|
431
|
+
## Testing
|
|
432
|
+
|
|
433
|
+
### Running the Tests
|
|
434
|
+
|
|
435
|
+
AutoForge has comprehensive tests for the security system:
|
|
436
|
+
|
|
437
|
+
**Unit Tests** (136 tests - fast):
|
|
438
|
+
```bash
|
|
439
|
+
source venv/bin/activate
|
|
440
|
+
python test_security.py
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
Tests:
|
|
444
|
+
- Pattern matching (exact, wildcards, scripts)
|
|
445
|
+
- YAML loading and validation
|
|
446
|
+
- Blocklist enforcement
|
|
447
|
+
- Project and org config hierarchy
|
|
448
|
+
- All existing security validations
|
|
449
|
+
|
|
450
|
+
**Integration Tests** (9 tests - uses real security hooks):
|
|
451
|
+
```bash
|
|
452
|
+
source venv/bin/activate
|
|
453
|
+
python test_security_integration.py
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
Tests:
|
|
457
|
+
- Blocked commands are rejected (sudo, shutdown, etc.)
|
|
458
|
+
- Default commands work (ls, git, npm, etc.)
|
|
459
|
+
- Non-allowed commands are blocked (wget, python, etc.)
|
|
460
|
+
- Project config allows commands (swift, xcodebuild, etc.)
|
|
461
|
+
- Pattern matching works (swift* matches swiftlint)
|
|
462
|
+
- Org blocklist cannot be overridden
|
|
463
|
+
- Org allowlist is inherited by projects
|
|
464
|
+
- Invalid YAML is safely ignored
|
|
465
|
+
- 50 command limit is enforced
|
|
466
|
+
|
|
467
|
+
### Manual Testing
|
|
468
|
+
|
|
469
|
+
To manually test the security system:
|
|
470
|
+
|
|
471
|
+
**1. Create a test project:**
|
|
472
|
+
```bash
|
|
473
|
+
python start.py
|
|
474
|
+
# Choose "Create new project"
|
|
475
|
+
# Name it "security-test"
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
**2. Edit the project config:**
|
|
479
|
+
```bash
|
|
480
|
+
# Navigate to the project directory
|
|
481
|
+
cd path/to/security-test
|
|
482
|
+
|
|
483
|
+
# Edit the config
|
|
484
|
+
nano .autoforge/allowed_commands.yaml
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
**3. Add a test command (e.g., Swift):**
|
|
488
|
+
```yaml
|
|
489
|
+
version: 1
|
|
490
|
+
commands:
|
|
491
|
+
- name: swift
|
|
492
|
+
description: Swift compiler
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
**4. Run the agent and observe:**
|
|
496
|
+
- Try a blocked command: `"Run sudo apt install nginx"` → Should be blocked
|
|
497
|
+
- Try an allowed command: `"Run ls -la"` → Should work
|
|
498
|
+
- Try your config command: `"Run swift --version"` → Should work
|
|
499
|
+
- Try a non-allowed command: `"Run wget https://example.com"` → Should be blocked
|
|
500
|
+
|
|
501
|
+
**5. Check the agent output:**
|
|
502
|
+
|
|
503
|
+
The agent will show security hook messages like:
|
|
504
|
+
```text
|
|
505
|
+
Command 'sudo' is blocked at organization level and cannot be approved.
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
Or:
|
|
509
|
+
```text
|
|
510
|
+
Command 'wget' is not allowed.
|
|
511
|
+
To allow this command:
|
|
512
|
+
1. Add to .autoforge/allowed_commands.yaml for this project, OR
|
|
513
|
+
2. Request mid-session approval (the agent can ask)
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
---
|
|
517
|
+
|
|
518
|
+
## Files Reference
|
|
519
|
+
|
|
520
|
+
- **`examples/project_allowed_commands.yaml`** - Full project config template
|
|
521
|
+
- **`examples/org_config.yaml`** - Full org config template
|
|
522
|
+
- **`security.py`** - Implementation and hardcoded blocklist
|
|
523
|
+
- **`test_security.py`** - Unit tests (136 tests)
|
|
524
|
+
- **`test_security_integration.py`** - Integration tests (9 tests)
|
|
525
|
+
- **`CLAUDE.md`** - Full system documentation
|
|
526
|
+
|
|
527
|
+
---
|
|
528
|
+
|
|
529
|
+
## Questions?
|
|
530
|
+
|
|
531
|
+
See the main documentation in `CLAUDE.md` for architecture details and implementation specifics.
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# Organization-Level AutoForge Configuration
|
|
2
|
+
# ============================================
|
|
3
|
+
# Location: ~/.autoforge/config.yaml
|
|
4
|
+
#
|
|
5
|
+
# IMPORTANT: This file is OPTIONAL and must be manually created by you.
|
|
6
|
+
# It does NOT exist by default.
|
|
7
|
+
#
|
|
8
|
+
# Org-level config applies to ALL projects and provides:
|
|
9
|
+
# 1. Organization-wide allowed commands (available to all projects)
|
|
10
|
+
# 2. Organization-wide blocked commands (cannot be overridden by projects)
|
|
11
|
+
# 3. Global settings (approval timeout, etc.)
|
|
12
|
+
#
|
|
13
|
+
# Use this to:
|
|
14
|
+
# - Add commands that ALL your projects need (jq, python3, etc.)
|
|
15
|
+
# - Block dangerous commands across ALL projects (aws, kubectl, etc.)
|
|
16
|
+
# - Enforce organization-wide security policies
|
|
17
|
+
|
|
18
|
+
version: 1
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# ==========================================
|
|
22
|
+
# Organization-Wide Allowed Commands
|
|
23
|
+
# ==========================================
|
|
24
|
+
# These commands become available to ALL projects automatically.
|
|
25
|
+
# Projects don't need to add them to their own .autoforge/allowed_commands.yaml
|
|
26
|
+
#
|
|
27
|
+
# By default, this is empty. Uncomment and add commands as needed.
|
|
28
|
+
|
|
29
|
+
allowed_commands: []
|
|
30
|
+
|
|
31
|
+
# Common development utilities
|
|
32
|
+
# - name: jq
|
|
33
|
+
# description: JSON processor for API responses
|
|
34
|
+
|
|
35
|
+
# - name: python3
|
|
36
|
+
# description: Python 3 interpreter
|
|
37
|
+
|
|
38
|
+
# - name: pip3
|
|
39
|
+
# description: Python package installer
|
|
40
|
+
|
|
41
|
+
# - name: pytest
|
|
42
|
+
# description: Python testing framework
|
|
43
|
+
|
|
44
|
+
# - name: black
|
|
45
|
+
# description: Python code formatter
|
|
46
|
+
|
|
47
|
+
# Database CLIs (if safe in your environment)
|
|
48
|
+
# - name: psql
|
|
49
|
+
# description: PostgreSQL client
|
|
50
|
+
|
|
51
|
+
# - name: mysql
|
|
52
|
+
# description: MySQL client
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
# ==========================================
|
|
56
|
+
# Organization-Wide Blocked Commands
|
|
57
|
+
# ==========================================
|
|
58
|
+
# Commands listed here are BLOCKED across ALL projects.
|
|
59
|
+
# Projects CANNOT override these blocks - this is the final word.
|
|
60
|
+
#
|
|
61
|
+
# Use this to enforce security policies, such as:
|
|
62
|
+
# - Preventing accidental production deployments
|
|
63
|
+
# - Blocking cloud CLI tools to avoid infrastructure changes
|
|
64
|
+
# - Preventing access to production databases
|
|
65
|
+
#
|
|
66
|
+
# By default, this is empty. Uncomment commands you want to block.
|
|
67
|
+
|
|
68
|
+
blocked_commands: []
|
|
69
|
+
|
|
70
|
+
# Block cloud CLIs to prevent accidental production changes
|
|
71
|
+
# - aws
|
|
72
|
+
# - gcloud
|
|
73
|
+
# - az
|
|
74
|
+
|
|
75
|
+
# Block container orchestration to prevent production deployments
|
|
76
|
+
# - kubectl
|
|
77
|
+
# - docker-compose
|
|
78
|
+
|
|
79
|
+
# Block infrastructure-as-code tools
|
|
80
|
+
# - terraform
|
|
81
|
+
# - pulumi
|
|
82
|
+
|
|
83
|
+
# Block database CLIs to prevent production data access
|
|
84
|
+
# - psql
|
|
85
|
+
# - mysql
|
|
86
|
+
# - mongosh
|
|
87
|
+
|
|
88
|
+
# Block other potentially dangerous tools
|
|
89
|
+
# - ansible
|
|
90
|
+
# - chef
|
|
91
|
+
# - puppet
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
# ==========================================
|
|
95
|
+
# Global Settings (Phase 3 feature)
|
|
96
|
+
# ==========================================
|
|
97
|
+
# These settings control approval behavior when agents request
|
|
98
|
+
# commands that aren't in the allowlist.
|
|
99
|
+
|
|
100
|
+
# How long to wait for user approval before denying a command request
|
|
101
|
+
approval_timeout_minutes: 5
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
# ==========================================
|
|
105
|
+
# Command Hierarchy (for reference)
|
|
106
|
+
# ==========================================
|
|
107
|
+
# When the agent tries to run a bash command, the system checks in this order:
|
|
108
|
+
#
|
|
109
|
+
# 1. Hardcoded Blocklist (in security.py) - HIGHEST PRIORITY
|
|
110
|
+
# Commands like: sudo, dd, shutdown, reboot, etc.
|
|
111
|
+
# These can NEVER be allowed, even with user approval.
|
|
112
|
+
#
|
|
113
|
+
# 2. Org Blocked Commands (this file)
|
|
114
|
+
# Commands you specify in "blocked_commands:" above.
|
|
115
|
+
# Projects cannot override these.
|
|
116
|
+
#
|
|
117
|
+
# 3. Org Allowed Commands (this file)
|
|
118
|
+
# Commands you specify in "allowed_commands:" above.
|
|
119
|
+
# Available to all projects automatically.
|
|
120
|
+
#
|
|
121
|
+
# 4. Global Allowed Commands (in security.py)
|
|
122
|
+
# Default commands: npm, git, curl, ls, cat, etc.
|
|
123
|
+
# Always available to all projects.
|
|
124
|
+
#
|
|
125
|
+
# 5. Project Allowed Commands (.autoforge/allowed_commands.yaml)
|
|
126
|
+
# Project-specific commands defined in each project.
|
|
127
|
+
# LOWEST PRIORITY (can't override blocks above).
|
|
128
|
+
#
|
|
129
|
+
# If a command is in BOTH allowed and blocked lists, BLOCKED wins.
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
# ==========================================
|
|
133
|
+
# Example Configurations by Organization Type
|
|
134
|
+
# ==========================================
|
|
135
|
+
|
|
136
|
+
# Startup / Small Team (permissive):
|
|
137
|
+
# allowed_commands:
|
|
138
|
+
# - name: python3
|
|
139
|
+
# - name: jq
|
|
140
|
+
# blocked_commands: [] # Empty - rely on hardcoded blocklist only
|
|
141
|
+
|
|
142
|
+
# Enterprise / Regulated (restrictive):
|
|
143
|
+
# allowed_commands: [] # Empty - projects must explicitly request each tool
|
|
144
|
+
# blocked_commands:
|
|
145
|
+
# - aws
|
|
146
|
+
# - gcloud
|
|
147
|
+
# - az
|
|
148
|
+
# - kubectl
|
|
149
|
+
# - terraform
|
|
150
|
+
# - psql
|
|
151
|
+
# - mysql
|
|
152
|
+
# - mongosh
|
|
153
|
+
|
|
154
|
+
# Development Team (balanced):
|
|
155
|
+
# allowed_commands:
|
|
156
|
+
# - name: jq
|
|
157
|
+
# - name: python3
|
|
158
|
+
# - name: pytest
|
|
159
|
+
# blocked_commands:
|
|
160
|
+
# - aws # Block production access
|
|
161
|
+
# - kubectl # Block deployments
|
|
162
|
+
# - terraform
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
# ==========================================
|
|
166
|
+
# To Create This File
|
|
167
|
+
# ==========================================
|
|
168
|
+
# 1. Copy this example to: ~/.autoforge/config.yaml
|
|
169
|
+
# 2. Uncomment and customize the sections you need
|
|
170
|
+
# 3. Leave empty lists if you don't need org-level controls
|
|
171
|
+
#
|
|
172
|
+
# To learn more, see: examples/README.md
|