aiblueprint-cli 1.4.12 → 1.4.13
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-code-config/scripts/.claude/commands/fix-on-my-computer.md +87 -0
- package/claude-code-config/scripts/command-validator/CLAUDE.md +112 -0
- package/claude-code-config/scripts/command-validator/src/__tests__/validator.test.ts +62 -111
- package/claude-code-config/scripts/command-validator/src/cli.ts +5 -3
- package/claude-code-config/scripts/command-validator/src/lib/security-rules.ts +3 -4
- package/claude-code-config/scripts/command-validator/src/lib/types.ts +1 -0
- package/claude-code-config/scripts/command-validator/src/lib/validator.ts +47 -317
- package/claude-code-config/scripts/statusline/CLAUDE.md +29 -7
- package/claude-code-config/scripts/statusline/README.md +89 -1
- package/claude-code-config/scripts/statusline/defaults.json +75 -0
- package/claude-code-config/scripts/statusline/src/index.ts +101 -24
- package/claude-code-config/scripts/statusline/src/lib/config-types.ts +100 -0
- package/claude-code-config/scripts/statusline/src/lib/config.ts +21 -0
- package/claude-code-config/scripts/statusline/src/lib/context.ts +32 -11
- package/claude-code-config/scripts/statusline/src/lib/formatters.ts +360 -22
- package/claude-code-config/scripts/statusline/src/lib/git.ts +100 -0
- package/claude-code-config/scripts/statusline/src/lib/render-pure.ts +177 -0
- package/claude-code-config/scripts/statusline/src/lib/types.ts +11 -0
- package/claude-code-config/scripts/statusline/statusline.config.json +93 -0
- package/claude-code-config/skills/claude-memory/SKILL.md +689 -0
- package/claude-code-config/skills/claude-memory/references/comprehensive-example.md +175 -0
- package/claude-code-config/skills/claude-memory/references/project-patterns.md +334 -0
- package/claude-code-config/skills/claude-memory/references/prompting-techniques.md +411 -0
- package/claude-code-config/skills/claude-memory/references/section-templates.md +347 -0
- package/claude-code-config/skills/create-slash-commands/SKILL.md +1110 -0
- package/claude-code-config/skills/create-slash-commands/references/arguments.md +273 -0
- package/claude-code-config/skills/create-slash-commands/references/patterns.md +947 -0
- package/claude-code-config/skills/create-slash-commands/references/prompt-examples.md +656 -0
- package/claude-code-config/skills/create-slash-commands/references/tool-restrictions.md +389 -0
- package/claude-code-config/skills/create-subagents/SKILL.md +425 -0
- package/claude-code-config/skills/create-subagents/references/context-management.md +567 -0
- package/claude-code-config/skills/create-subagents/references/debugging-agents.md +714 -0
- package/claude-code-config/skills/create-subagents/references/error-handling-and-recovery.md +502 -0
- package/claude-code-config/skills/create-subagents/references/evaluation-and-testing.md +374 -0
- package/claude-code-config/skills/create-subagents/references/orchestration-patterns.md +591 -0
- package/claude-code-config/skills/create-subagents/references/subagents.md +599 -0
- package/claude-code-config/skills/create-subagents/references/writing-subagent-prompts.md +513 -0
- package/package.json +1 -1
- package/claude-code-config/commands/apex.md +0 -109
- package/claude-code-config/commands/tasks/run-task.md +0 -220
- package/claude-code-config/commands/utils/watch-ci.md +0 -47
- package/claude-code-config/scripts/command-validator/biome.json +0 -29
- package/claude-code-config/scripts/command-validator/bun.lockb +0 -0
- package/claude-code-config/scripts/command-validator/package.json +0 -27
- package/claude-code-config/scripts/command-validator/vitest.config.ts +0 -7
- package/claude-code-config/scripts/hook-post-file.ts +0 -162
- package/claude-code-config/scripts/statusline/biome.json +0 -34
- package/claude-code-config/scripts/statusline/bun.lockb +0 -0
- package/claude-code-config/scripts/statusline/fixtures/test-input.json +0 -25
- package/claude-code-config/scripts/statusline/package.json +0 -19
- package/claude-code-config/scripts/statusline/statusline.config.ts +0 -25
- package/claude-code-config/scripts/statusline/test.ts +0 -20
- package/claude-code-config/scripts/validate-command.js +0 -712
- package/claude-code-config/scripts/validate-command.readme.md +0 -283
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Setup wizard - verify bun, install deps, run tests, fix until ALL pass
|
|
3
|
+
allowed-tools: Bash, Read, Edit, Write, Glob, Grep, TodoWrite
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
<objective>
|
|
7
|
+
Make this scripts repository work PERFECTLY on this machine.
|
|
8
|
+
|
|
9
|
+
You are a relentless setup wizard. Your mission is to verify the environment, install dependencies, run all tests, and fix ANY failing tests until 100% pass. You NEVER give up until every single test is green.
|
|
10
|
+
</objective>
|
|
11
|
+
|
|
12
|
+
<context>
|
|
13
|
+
Current OS: !`uname -s`
|
|
14
|
+
Current directory: !`pwd`
|
|
15
|
+
Bun version: !`bun --version 2>&1 || echo "NOT_INSTALLED"`
|
|
16
|
+
Package.json: @package.json
|
|
17
|
+
</context>
|
|
18
|
+
|
|
19
|
+
<process>
|
|
20
|
+
**Phase 1: Environment Check**
|
|
21
|
+
|
|
22
|
+
1. Verify Bun is installed (`bun --version`)
|
|
23
|
+
- If NOT installed → STOP and tell user: "Install Bun from https://bun.sh"
|
|
24
|
+
2. Verify in correct directory (must have package.json with "test" script)
|
|
25
|
+
3. Check OS: macOS/Linux (full support), Windows (needs WSL)
|
|
26
|
+
|
|
27
|
+
**Phase 2: Install Dependencies**
|
|
28
|
+
|
|
29
|
+
4. Run `bun install`
|
|
30
|
+
- If fails: Delete `bun.lockb` and retry
|
|
31
|
+
- If still fails: Report specific error to user
|
|
32
|
+
|
|
33
|
+
**Phase 3: Run Tests**
|
|
34
|
+
|
|
35
|
+
5. Run `bun run test`
|
|
36
|
+
6. Record output - note which tests pass/fail
|
|
37
|
+
|
|
38
|
+
**Phase 4: Fix Loop (NEVER STOP UNTIL GREEN)**
|
|
39
|
+
|
|
40
|
+
7. While ANY tests fail:
|
|
41
|
+
- Analyze the error message
|
|
42
|
+
- Identify root cause:
|
|
43
|
+
- Missing dependency → `bun install <package>`
|
|
44
|
+
- Wrong import path → Fix the import
|
|
45
|
+
- Cross-platform issue → Use `path.join()`, `os.homedir()`
|
|
46
|
+
- Missing credentials → Check `~/.claude/.credentials.json`
|
|
47
|
+
- File not found → Verify path exists
|
|
48
|
+
- Type error → Fix TypeScript
|
|
49
|
+
- Apply minimal fix
|
|
50
|
+
- Re-run `bun run test`
|
|
51
|
+
- **REPEAT until 100% green**
|
|
52
|
+
|
|
53
|
+
**Phase 5: Final Verification**
|
|
54
|
+
|
|
55
|
+
8. Run `bun run test` one final time
|
|
56
|
+
9. Run `bun run lint` (fix if needed)
|
|
57
|
+
|
|
58
|
+
**Phase 6: Victory Report**
|
|
59
|
+
|
|
60
|
+
10. Report to user:
|
|
61
|
+
- Total tests passed
|
|
62
|
+
- Fixes applied (list each one)
|
|
63
|
+
- Status: READY TO USE
|
|
64
|
+
</process>
|
|
65
|
+
|
|
66
|
+
<testing>
|
|
67
|
+
Install: !`bun install`
|
|
68
|
+
Tests: !`bun run test`
|
|
69
|
+
Lint: !`bun run lint`
|
|
70
|
+
</testing>
|
|
71
|
+
|
|
72
|
+
<verification>
|
|
73
|
+
Before declaring success:
|
|
74
|
+
- `bun run test` exits with code 0
|
|
75
|
+
- ALL 186+ tests pass
|
|
76
|
+
- No lint errors
|
|
77
|
+
- All package.json scripts work
|
|
78
|
+
</verification>
|
|
79
|
+
|
|
80
|
+
<success_criteria>
|
|
81
|
+
- Bun installed and working
|
|
82
|
+
- All dependencies installed
|
|
83
|
+
- ALL tests passing (0 failures)
|
|
84
|
+
- Lint check passes
|
|
85
|
+
- User can run any command from package.json
|
|
86
|
+
- Repository is READY TO USE
|
|
87
|
+
</success_criteria>
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Command Validator - CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code when working with the command-validator security package.
|
|
4
|
+
|
|
5
|
+
## Project Purpose
|
|
6
|
+
|
|
7
|
+
**Command Validator** is a security validation package for Claude Code's PreToolUse hook. It validates bash commands before execution to prevent dangerous operations like:
|
|
8
|
+
- System destruction (rm -rf /, dd, mkfs)
|
|
9
|
+
- Privilege escalation (sudo, chmod, passwd)
|
|
10
|
+
- Network attacks (nc, nmap, telnet)
|
|
11
|
+
- Malicious patterns (fork bombs, backdoors)
|
|
12
|
+
- Sensitive file access (/etc/passwd, /etc/shadow)
|
|
13
|
+
|
|
14
|
+
The validator is integrated as a hook in Claude Code settings and blocks dangerous commands while allowing safe operations.
|
|
15
|
+
|
|
16
|
+
## CRITICAL: This Project Uses BUN
|
|
17
|
+
|
|
18
|
+
**NEVER use npm or node commands. This project exclusively uses BUN.**
|
|
19
|
+
|
|
20
|
+
## Development Commands
|
|
21
|
+
|
|
22
|
+
**CRITICAL**: Only use these BUN commands:
|
|
23
|
+
|
|
24
|
+
### Testing (Primary Workflow)
|
|
25
|
+
- `bun test` - Run all tests with Vitest
|
|
26
|
+
- `bun test:ui` - Run tests with UI interface
|
|
27
|
+
- `bun run test` - Alternative test command
|
|
28
|
+
|
|
29
|
+
### Code Quality
|
|
30
|
+
- `bun run lint` - Run Biome linter and auto-fix
|
|
31
|
+
- `bun run format` - Format code with Biome
|
|
32
|
+
- `bunx tsc --noEmit` - TypeScript type checking (no build)
|
|
33
|
+
|
|
34
|
+
### Execution
|
|
35
|
+
- `bun src/cli.ts` - Run CLI validator directly
|
|
36
|
+
- `bun install` - Install dependencies
|
|
37
|
+
|
|
38
|
+
## Development Workflow
|
|
39
|
+
|
|
40
|
+
**CRITICAL**: The majority of work on this project follows this simple cycle:
|
|
41
|
+
|
|
42
|
+
### Test-Driven Development Cycle
|
|
43
|
+
1. **Run tests**: `bun test`
|
|
44
|
+
2. **Read errors**: Analyze test failures carefully
|
|
45
|
+
3. **Fix the problem**: Make minimal changes to pass tests
|
|
46
|
+
4. **Re-run tests**: `bun test` until ALL tests pass
|
|
47
|
+
5. **Repeat**: Continue cycle until all tests are green
|
|
48
|
+
|
|
49
|
+
**ALWAYS follow this workflow:**
|
|
50
|
+
```bash
|
|
51
|
+
bun test # See what's broken
|
|
52
|
+
# Fix the code
|
|
53
|
+
bun test # Verify fix works
|
|
54
|
+
# Repeat until green
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Architecture Overview
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
src/
|
|
61
|
+
├── cli.ts # CLI entry point (used by Claude Code hook)
|
|
62
|
+
├── lib/
|
|
63
|
+
│ ├── types.ts # TypeScript interfaces
|
|
64
|
+
│ ├── security-rules.ts # Security rules database
|
|
65
|
+
│ └── validator.ts # Core validation logic
|
|
66
|
+
└── __tests__/
|
|
67
|
+
└── validator.test.ts # Comprehensive test suite (82+ tests)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Key Files
|
|
71
|
+
- **@scripts/command-validator/src/lib/validator.ts** - Core CommandValidator class
|
|
72
|
+
- **@scripts/command-validator/src/lib/security-rules.ts** - Security rules database
|
|
73
|
+
- **@scripts/command-validator/src/__tests__/validator.test.ts** - All test cases
|
|
74
|
+
|
|
75
|
+
## Code Conventions
|
|
76
|
+
|
|
77
|
+
- **TypeScript**: Strict mode enabled
|
|
78
|
+
- **Testing**: Vitest with comprehensive coverage (82+ tests)
|
|
79
|
+
- **Linting**: Biome for formatting and linting
|
|
80
|
+
- **Imports**: ESM module format only
|
|
81
|
+
|
|
82
|
+
## Security Test Categories
|
|
83
|
+
|
|
84
|
+
The test suite validates:
|
|
85
|
+
1. **Safe Commands**: ls, git, npm, cat, cp, mv, mkdir (must allow)
|
|
86
|
+
2. **Dangerous Commands**: rm -rf /, dd, sudo, passwd (must block)
|
|
87
|
+
3. **Special Cases**: rm -rf safety rules, protected paths, command chains
|
|
88
|
+
4. **Malicious Patterns**: Fork bombs, backdoors, log manipulation
|
|
89
|
+
|
|
90
|
+
## IMPORTANT: Workflow Rules
|
|
91
|
+
|
|
92
|
+
- **BEFORE making changes**: Run `bun test` to see current state
|
|
93
|
+
- **AFTER any code change**: Run `bun test` to verify
|
|
94
|
+
- **NEVER assume tests pass**: Always verify with `bun test`
|
|
95
|
+
- **Fix one test at a time**: Make minimal changes, then re-test
|
|
96
|
+
- **Use Bun ONLY**: No npm, node, or yarn commands
|
|
97
|
+
|
|
98
|
+
## Common Modifications
|
|
99
|
+
|
|
100
|
+
Most changes involve:
|
|
101
|
+
1. **Adding new security rules** → Update @scripts/command-validator/src/lib/security-rules.ts
|
|
102
|
+
2. **Modifying validation logic** → Update @scripts/command-validator/src/lib/validator.ts
|
|
103
|
+
3. **Adding test cases** → Update @scripts/command-validator/src/__tests__/validator.test.ts
|
|
104
|
+
4. **Run tests after each change** → `bun test`
|
|
105
|
+
|
|
106
|
+
## Test Execution Priority
|
|
107
|
+
|
|
108
|
+
**ALWAYS use the test-driven approach:**
|
|
109
|
+
- Tests define the requirements
|
|
110
|
+
- Code changes must make tests pass
|
|
111
|
+
- All 82+ tests must be green before committing
|
|
112
|
+
- Use `bun test` continuously during development
|
|
@@ -1,148 +1,99 @@
|
|
|
1
|
-
import { describe, expect, it } from "
|
|
1
|
+
import { describe, expect, it } from "bun:test";
|
|
2
2
|
import { CommandValidator } from "../lib/validator";
|
|
3
3
|
|
|
4
4
|
describe("CommandValidator", () => {
|
|
5
5
|
const validator = new CommandValidator();
|
|
6
6
|
|
|
7
|
-
describe("
|
|
8
|
-
const
|
|
7
|
+
describe("Commands that MUST be ALLOWED (action: allow)", () => {
|
|
8
|
+
const allowedCommands = [
|
|
9
9
|
"ls -la",
|
|
10
10
|
"pwd",
|
|
11
11
|
"git status",
|
|
12
|
-
"git
|
|
13
|
-
"git log",
|
|
12
|
+
"git add -A && git commit -m 'Clé API Google gérée côté client'",
|
|
14
13
|
"npm install",
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"cat
|
|
21
|
-
"
|
|
22
|
-
"echo 'hello world'",
|
|
23
|
-
"cd /tmp",
|
|
24
|
-
"mkdir -p /tmp/test",
|
|
25
|
-
"touch /tmp/file.txt",
|
|
26
|
-
"cp file.txt /tmp/",
|
|
27
|
-
"mv file.txt /tmp/",
|
|
28
|
-
"find . -name '*.js'",
|
|
29
|
-
"source ~/.bashrc",
|
|
30
|
-
"psql -d database",
|
|
31
|
-
"mysql -u user",
|
|
32
|
-
"sqlite3 database.db",
|
|
33
|
-
"mongo",
|
|
34
|
-
"git add . && git commit -m 'message'",
|
|
35
|
-
"npm install && npm run build",
|
|
36
|
-
"source venv/bin/activate && python script.py",
|
|
37
|
-
"docker ps",
|
|
38
|
-
"docker ps -a",
|
|
39
|
-
"docker logs my-container",
|
|
40
|
-
"docker build -t myapp .",
|
|
41
|
-
"docker run -d myapp",
|
|
42
|
-
"docker exec -it myapp bash",
|
|
43
|
-
"npx prisma generate",
|
|
44
|
-
"npx prisma migrate dev",
|
|
45
|
-
"npx prisma db push",
|
|
46
|
-
"npx prisma studio",
|
|
47
|
-
"pnpm prisma generate",
|
|
14
|
+
"rm file.txt",
|
|
15
|
+
"rm -r folder",
|
|
16
|
+
"rm -f file.txt",
|
|
17
|
+
"echo 'éàù accents français'",
|
|
18
|
+
"git commit -m '🚀 emoji test'",
|
|
19
|
+
"cat /etc/passwd",
|
|
20
|
+
"curl http://example.com",
|
|
48
21
|
];
|
|
49
22
|
|
|
50
|
-
for (const command of
|
|
51
|
-
it(`should
|
|
23
|
+
for (const command of allowedCommands) {
|
|
24
|
+
it(`should ALLOW: ${command}`, () => {
|
|
52
25
|
const result = validator.validate(command);
|
|
53
26
|
expect(result.isValid).toBe(true);
|
|
27
|
+
expect(result.action).toBe("allow");
|
|
54
28
|
expect(result.violations).toHaveLength(0);
|
|
55
29
|
});
|
|
56
30
|
}
|
|
57
31
|
});
|
|
58
32
|
|
|
59
|
-
describe("
|
|
60
|
-
const
|
|
33
|
+
describe("Commands that MUST be DENIED (action: deny) - rm -rf ONLY", () => {
|
|
34
|
+
const deniedCommands = [
|
|
61
35
|
"rm -rf /",
|
|
62
|
-
"rm -rf
|
|
63
|
-
"rm -rf
|
|
64
|
-
"rm -rf /
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
|
|
92
|
-
"
|
|
93
|
-
"docker container prune -f",
|
|
94
|
-
"docker volume rm $(docker volume ls -q)",
|
|
95
|
-
"docker network rm $(docker network ls -q)",
|
|
96
|
-
"docker rmi -f $(docker images -q)",
|
|
97
|
-
"docker stop $(docker ps -q)",
|
|
98
|
-
"docker kill $(docker ps -q)",
|
|
99
|
-
"npx prisma migrate reset",
|
|
100
|
-
"npx prisma migrate reset --force",
|
|
101
|
-
"npx prisma db push --force-reset",
|
|
102
|
-
"pnpm prisma migrate reset",
|
|
103
|
-
"bunx prisma migrate reset --force",
|
|
104
|
-
"nc example.com 4444",
|
|
105
|
-
"netcat example.com 4444",
|
|
106
|
-
"nmap -sV 192.168.1.1",
|
|
107
|
-
"sudo ls",
|
|
108
|
-
"su root",
|
|
109
|
-
"dd if=/dev/zero of=/dev/sdb",
|
|
110
|
-
"mkfs /dev/sdb",
|
|
111
|
-
"fdisk /dev/sda",
|
|
112
|
-
"parted /dev/sda",
|
|
113
|
-
"chmod 777 file.txt",
|
|
114
|
-
"chown root file.txt",
|
|
36
|
+
"rm -rf folder",
|
|
37
|
+
"rm -rf .",
|
|
38
|
+
"rm -rf /tmp/test",
|
|
39
|
+
"rm -fr folder",
|
|
40
|
+
"rm -r -f folder",
|
|
41
|
+
"rm -f -r folder",
|
|
42
|
+
"rm -rf /Users/test/.claude/skills",
|
|
43
|
+
"mkdir test && rm -rf test",
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
for (const command of deniedCommands) {
|
|
47
|
+
it(`should DENY: ${command}`, () => {
|
|
48
|
+
const result = validator.validate(command);
|
|
49
|
+
expect(result.isValid).toBe(false);
|
|
50
|
+
expect(result.action).toBe("deny");
|
|
51
|
+
expect(result.severity).toBe("CRITICAL");
|
|
52
|
+
expect(result.violations[0]).toContain("rm -rf is forbidden");
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
describe("Commands that MUST ASK permission (action: ask)", () => {
|
|
58
|
+
const askCommands = [
|
|
59
|
+
{ cmd: "sudo apt install", expected: "sudo" },
|
|
60
|
+
{ cmd: "sudo rm something", expected: "sudo" },
|
|
61
|
+
{ cmd: "chmod 777 file.txt", expected: "chmod" },
|
|
62
|
+
{ cmd: "chown root file.txt", expected: "chown" },
|
|
63
|
+
{ cmd: "dd if=/dev/zero of=test.img", expected: "dd" },
|
|
64
|
+
{ cmd: "kill -9 1234", expected: "kill" },
|
|
65
|
+
{ cmd: "killall node", expected: "killall" },
|
|
66
|
+
{ cmd: "su root", expected: "su" },
|
|
115
67
|
];
|
|
116
68
|
|
|
117
|
-
for (const cmd of
|
|
118
|
-
it(`should
|
|
69
|
+
for (const { cmd, expected } of askCommands) {
|
|
70
|
+
it(`should ASK for: ${cmd}`, () => {
|
|
119
71
|
const result = validator.validate(cmd);
|
|
120
72
|
expect(result.isValid).toBe(false);
|
|
121
|
-
expect(result.
|
|
122
|
-
expect(result.severity).
|
|
73
|
+
expect(result.action).toBe("ask");
|
|
74
|
+
expect(result.severity).toBe("HIGH");
|
|
75
|
+
expect(result.violations[0]).toContain(expected);
|
|
123
76
|
});
|
|
124
77
|
}
|
|
125
78
|
});
|
|
126
79
|
|
|
127
80
|
describe("Edge cases", () => {
|
|
128
|
-
it("should
|
|
81
|
+
it("should DENY empty commands", () => {
|
|
129
82
|
const result = validator.validate("");
|
|
130
83
|
expect(result.isValid).toBe(false);
|
|
84
|
+
expect(result.action).toBe("deny");
|
|
131
85
|
});
|
|
132
86
|
|
|
133
|
-
it("should
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
expect(result.
|
|
137
|
-
expect(result.violations).toContain(
|
|
138
|
-
"Command too long (potential buffer overflow)",
|
|
139
|
-
);
|
|
87
|
+
it("should ALLOW commands with accented characters", () => {
|
|
88
|
+
const result = validator.validate("git commit -m 'éàùç accents'");
|
|
89
|
+
expect(result.isValid).toBe(true);
|
|
90
|
+
expect(result.action).toBe("allow");
|
|
140
91
|
});
|
|
141
92
|
|
|
142
|
-
it("should
|
|
143
|
-
const result = validator.validate("echo
|
|
144
|
-
expect(result.isValid).toBe(
|
|
145
|
-
expect(result.
|
|
93
|
+
it("should ALLOW commands with emojis", () => {
|
|
94
|
+
const result = validator.validate("echo '🚀🎉'");
|
|
95
|
+
expect(result.isValid).toBe(true);
|
|
96
|
+
expect(result.action).toBe("allow");
|
|
146
97
|
});
|
|
147
98
|
});
|
|
148
99
|
});
|
|
@@ -94,13 +94,15 @@ async function main() {
|
|
|
94
94
|
process.exit(0);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
const
|
|
97
|
+
const message = result.action === "deny"
|
|
98
|
+
? `Command blocked!\n\nCommand: ${command}\nReason: ${result.violations.join(", ")}\nSeverity: ${result.severity}`
|
|
99
|
+
: `⚠️ Potentially dangerous command\n\nCommand: ${command}\nReason: ${result.violations.join(", ")}\nSeverity: ${result.severity}\n\nDo you want to proceed?`;
|
|
98
100
|
|
|
99
101
|
const hookOutput: HookOutput = {
|
|
100
102
|
hookSpecificOutput: {
|
|
101
103
|
hookEventName: "PreToolUse",
|
|
102
|
-
permissionDecision: "ask",
|
|
103
|
-
permissionDecisionReason:
|
|
104
|
+
permissionDecision: result.action === "deny" ? "deny" : "ask",
|
|
105
|
+
permissionDecisionReason: message,
|
|
104
106
|
},
|
|
105
107
|
};
|
|
106
108
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { homedir } from "os";
|
|
1
|
+
import { homedir } from "node:os";
|
|
2
|
+
import { join } from "node:path";
|
|
2
3
|
import type { SecurityRules } from "./types";
|
|
3
4
|
|
|
4
|
-
const HOME = homedir();
|
|
5
|
-
|
|
6
5
|
export const SECURITY_RULES: SecurityRules = {
|
|
7
6
|
CRITICAL_COMMANDS: [
|
|
8
7
|
"del",
|
|
@@ -129,7 +128,7 @@ export const SECURITY_RULES: SecurityRules = {
|
|
|
129
128
|
],
|
|
130
129
|
|
|
131
130
|
SAFE_RM_PATHS: [
|
|
132
|
-
|
|
131
|
+
join(homedir(), "Developer/"),
|
|
133
132
|
"/tmp/",
|
|
134
133
|
"/var/tmp/",
|
|
135
134
|
`${process.cwd()}/`,
|