claude-flow-novice 2.16.0 → 2.16.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/.claude/cfn-extras/skills/GOOGLE_SHEETS_SKILLS_README.md +1 -1
- package/.claude/cfn-extras/skills/google-sheets-api-coordinator/SKILL.md +1 -1
- package/.claude/cfn-extras/skills/google-sheets-formula-builder/SKILL.md +1 -1
- package/.claude/cfn-extras/skills/google-sheets-progress/SKILL.md +1 -1
- package/.claude/commands/CFN_LOOP_FRONTEND.md +1 -1
- package/.claude/commands/cfn-loop-cli.md +124 -46
- package/.claude/commands/cfn-loop-frontend.md +1 -1
- package/.claude/commands/cfn-loop-task.md +2 -2
- package/.claude/commands/deprecated/cfn-loop.md +2 -2
- package/.claude/hooks/cfn-invoke-post-edit.sh +31 -5
- package/.claude/hooks/cfn-post-edit.config.json +9 -2
- package/.claude/root-claude-distribute/CFN-CLAUDE.md +1 -1
- package/.claude/skills/cfn-backlog-management/SKILL.md +1 -1
- package/.claude/skills/cfn-loop-orchestration/NORTH_STAR_INDEX.md +1 -1
- package/claude-assets/agents/cfn-dev-team/analysts/root-cause-analyst.md +2 -2
- package/claude-assets/agents/cfn-dev-team/architecture/base-template-generator.md +1 -1
- package/claude-assets/agents/cfn-dev-team/coordinators/cfn-frontend-coordinator.md +2 -2
- package/claude-assets/agents/cfn-dev-team/coordinators/handoff-coordinator.md +1 -1
- package/claude-assets/agents/cfn-dev-team/dev-ops/devops-engineer.md +1 -1
- package/claude-assets/agents/cfn-dev-team/dev-ops/docker-specialist.md +2 -2
- package/claude-assets/agents/cfn-dev-team/dev-ops/github-commit-agent.md +2 -2
- package/claude-assets/agents/cfn-dev-team/dev-ops/kubernetes-specialist.md +1 -1
- package/claude-assets/agents/cfn-dev-team/developers/api-gateway-specialist.md +1 -1
- package/claude-assets/agents/cfn-dev-team/developers/data/data-engineer.md +1 -1
- package/claude-assets/agents/cfn-dev-team/developers/database/database-architect.md +1 -1
- package/claude-assets/agents/cfn-dev-team/developers/frontend/typescript-specialist.md +1 -1
- package/claude-assets/agents/cfn-dev-team/developers/frontend/ui-designer.md +1 -1
- package/claude-assets/agents/cfn-dev-team/developers/graphql-specialist.md +1 -1
- package/claude-assets/agents/cfn-dev-team/documentation/pseudocode.md +1 -1
- package/claude-assets/agents/cfn-dev-team/product-owners/accessibility-advocate-persona.md +1 -1
- package/claude-assets/agents/cfn-dev-team/product-owners/cto-agent.md +1 -1
- package/claude-assets/agents/cfn-dev-team/product-owners/power-user-persona.md +1 -1
- package/claude-assets/agents/cfn-dev-team/reviewers/quality/security-specialist.md +1 -1
- package/claude-assets/agents/cfn-dev-team/testers/api-testing-specialist.md +1 -1
- package/claude-assets/agents/cfn-dev-team/testers/chaos-engineering-specialist.md +1 -1
- package/claude-assets/agents/cfn-dev-team/testers/contract-tester.md +1 -1
- package/claude-assets/agents/cfn-dev-team/testers/e2e/playwright-tester.md +1 -1
- package/claude-assets/agents/cfn-dev-team/testers/integration-tester.md +1 -1
- package/claude-assets/agents/cfn-dev-team/testers/load-testing-specialist.md +1 -1
- package/claude-assets/agents/cfn-dev-team/testers/mutation-testing-specialist.md +1 -1
- package/claude-assets/agents/cfn-dev-team/testers/unit/tdd-london-unit-swarm.md +1 -1
- package/claude-assets/agents/cfn-dev-team/utility/agent-builder.md +11 -0
- package/claude-assets/agents/cfn-dev-team/utility/analyst.md +1 -1
- package/claude-assets/agents/cfn-dev-team/utility/claude-code-expert.md +1 -1
- package/claude-assets/agents/cfn-dev-team/utility/epic-creator.md +1 -1
- package/claude-assets/agents/cfn-dev-team/utility/memory-leak-specialist.md +1 -1
- package/claude-assets/agents/cfn-dev-team/utility/researcher.md +1 -1
- package/claude-assets/agents/cfn-dev-team/utility/z-ai-specialist.md +1 -1
- package/claude-assets/agents/custom/cfn-docker-expert.md +1 -0
- package/claude-assets/agents/custom/cfn-loops-cli-expert.md +326 -17
- package/claude-assets/agents/custom/cfn-redis-operations.md +529 -529
- package/claude-assets/agents/custom/cfn-system-expert.md +1 -1
- package/claude-assets/agents/custom/trigger-dev-expert.md +369 -0
- package/claude-assets/agents/docker-team/micro-sprint-planner.md +747 -747
- package/claude-assets/agents/project-only-agents/npm-package-specialist.md +1 -1
- package/claude-assets/cfn-extras/skills/GOOGLE_SHEETS_SKILLS_README.md +1 -1
- package/claude-assets/cfn-extras/skills/google-sheets-api-coordinator/SKILL.md +1 -1
- package/claude-assets/cfn-extras/skills/google-sheets-formula-builder/SKILL.md +1 -1
- package/claude-assets/cfn-extras/skills/google-sheets-progress/SKILL.md +1 -1
- package/claude-assets/commands/CFN_LOOP_FRONTEND.md +1 -1
- package/claude-assets/commands/cfn-loop-cli.md +124 -46
- package/claude-assets/commands/cfn-loop-frontend.md +1 -1
- package/claude-assets/commands/cfn-loop-task.md +2 -2
- package/claude-assets/commands/deprecated/cfn-loop.md +2 -2
- package/claude-assets/hooks/GIT-HOOKS-USAGE-EXAMPLES.md +116 -0
- package/claude-assets/hooks/README-GIT-HOOKS.md +443 -0
- package/claude-assets/hooks/cfn-invoke-post-edit.sh +31 -5
- package/claude-assets/hooks/cfn-post-edit.config.json +9 -2
- package/claude-assets/hooks/install-git-hooks.sh +243 -0
- package/claude-assets/hooks/subagent-start.sh +98 -0
- package/claude-assets/hooks/subagent-stop.sh +93 -0
- package/claude-assets/hooks/validators/credential-scanner.sh +172 -0
- package/claude-assets/root-claude-distribute/CFN-CLAUDE.md +1 -1
- package/claude-assets/skills/cfn-backlog-management/SKILL.md +1 -1
- package/claude-assets/skills/cfn-dependency-ingestion/SKILL.md +41 -13
- package/claude-assets/skills/cfn-dependency-ingestion/ingest.sh +237 -0
- package/claude-assets/skills/cfn-dependency-ingestion/manifests/cli-mode-dependencies.txt +73 -0
- package/claude-assets/skills/cfn-dependency-ingestion/manifests/shared-dependencies.txt +57 -0
- package/claude-assets/skills/cfn-dependency-ingestion/manifests/trigger-dev-dependencies.txt +82 -0
- package/claude-assets/skills/cfn-dependency-ingestion/manifests/trigger-mode-dependencies.txt +80 -0
- package/claude-assets/skills/cfn-environment-sanitization/sanitize-environment.sh +14 -4
- package/claude-assets/skills/cfn-loop-orchestration/NORTH_STAR_INDEX.md +1 -1
- package/claude-assets/skills/cfn-provider-routing/SKILL.md +23 -0
- package/claude-assets/skills/docker-build/build.sh +1 -1
- package/dist/agent/skill-mcp-selector.js +2 -1
- package/dist/agent/skill-mcp-selector.js.map +1 -1
- package/dist/agents/agent-loader.js +165 -146
- package/dist/agents/agent-loader.js.map +1 -1
- package/dist/cli/agent-executor.js +470 -26
- package/dist/cli/agent-executor.js.map +1 -1
- package/dist/cli/agent-prompt-builder.js +2 -2
- package/dist/cli/agent-prompt-builder.js.map +1 -1
- package/dist/cli/agent-spawn.js +7 -4
- package/dist/cli/agent-spawn.js.map +1 -1
- package/dist/cli/agent-spawner.js +51 -4
- package/dist/cli/agent-spawner.js.map +1 -1
- package/dist/cli/agent-token-manager.js +2 -1
- package/dist/cli/agent-token-manager.js.map +1 -1
- package/dist/cli/anthropic-client.js +117 -11
- package/dist/cli/anthropic-client.js.map +1 -1
- package/dist/cli/cfn-context.js +2 -1
- package/dist/cli/cfn-context.js.map +1 -1
- package/dist/cli/cfn-metrics.js +2 -1
- package/dist/cli/cfn-metrics.js.map +1 -1
- package/dist/cli/cfn-redis.js +2 -1
- package/dist/cli/cfn-redis.js.map +1 -1
- package/dist/cli/cli-agent-context.js +2 -0
- package/dist/cli/cli-agent-context.js.map +1 -1
- package/dist/cli/config-manager.js +4 -252
- package/dist/cli/config-manager.js.map +1 -1
- package/dist/cli/conversation-fork-cleanup.js +2 -1
- package/dist/cli/conversation-fork-cleanup.js.map +1 -1
- package/dist/cli/conversation-fork.js +2 -1
- package/dist/cli/conversation-fork.js.map +1 -1
- package/dist/cli/coordination/agent-messaging.js +415 -0
- package/dist/cli/coordination/agent-messaging.js.map +1 -0
- package/dist/cli/coordination/wait-for-threshold.js +232 -0
- package/dist/cli/coordination/wait-for-threshold.js.map +1 -0
- package/dist/cli/iteration-history.js +2 -1
- package/dist/cli/iteration-history.js.map +1 -1
- package/dist/cli/process-lifecycle.js +5 -1
- package/dist/cli/process-lifecycle.js.map +1 -1
- package/dist/cli/spawn-agent-cli.js +41 -6
- package/dist/cli/spawn-agent-cli.js.map +1 -1
- package/dist/coordination/redis-waiting-mode.js +4 -0
- package/dist/coordination/redis-waiting-mode.js.map +1 -1
- package/dist/lib/artifact-registry.js +4 -0
- package/dist/lib/artifact-registry.js.map +1 -1
- package/dist/lib/connection-pool.js +390 -0
- package/dist/lib/connection-pool.js.map +1 -0
- package/dist/lib/environment-contract.js +258 -0
- package/dist/lib/environment-contract.js.map +1 -0
- package/dist/lib/query-optimizer.js +388 -0
- package/dist/lib/query-optimizer.js.map +1 -0
- package/dist/lib/result-cache.js +285 -0
- package/dist/lib/result-cache.js.map +1 -0
- package/dist/mcp/auth-middleware.js +2 -1
- package/dist/mcp/auth-middleware.js.map +1 -1
- package/dist/mcp/playwright-mcp-server-auth.js +2 -1
- package/dist/mcp/playwright-mcp-server-auth.js.map +1 -1
- package/package.json +3 -1
- package/scripts/build-agent-image.sh +1 -1
- package/scripts/cost-allocation-tracker.sh +632 -0
- package/scripts/docker-rebuild-all-agents.sh +2 -2
- package/scripts/reorganize-tests.sh +280 -0
- package/scripts/trigger-dev-setup.sh +12 -0
- package/tests/README.md +45 -0
- package/.claude/commands/cost-savings-status.md +0 -34
- package/.claude/commands/metrics-summary.md +0 -58
- package/claude-assets/agents/cfn-dev-team/dev-ops/monitoring-specialist.md +0 -768
- package/claude-assets/agents/custom/test-mcp-access.md +0 -24
- package/claude-assets/commands/cost-savings-status.md +0 -34
- package/claude-assets/commands/metrics-summary.md +0 -58
- package/tests/test-memory-leak-task-mode.sh +0 -435
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
# Git Hooks: Credential Exposure Prevention
|
|
2
|
+
|
|
3
|
+
Automated pre-commit security validation to prevent accidental credential exposure.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This system provides a multi-layered defense against credential exposure:
|
|
8
|
+
|
|
9
|
+
1. **Pre-Commit Hook** (.git/hooks/pre-commit)
|
|
10
|
+
- Scans staged files before commit
|
|
11
|
+
- Blocks commits with exposed credentials
|
|
12
|
+
- Provides clear remediation guidance
|
|
13
|
+
|
|
14
|
+
2. **Installation Script** (.claude/hooks/install-git-hooks.sh)
|
|
15
|
+
- Automated hook installation
|
|
16
|
+
- Validation and verification
|
|
17
|
+
- Project setup
|
|
18
|
+
|
|
19
|
+
3. **Integration Points**
|
|
20
|
+
- Post-edit credential scanner (.claude/hooks/validators/credential-scanner.sh)
|
|
21
|
+
- CI/CD credential scanning (.github/workflows/security-credential-scan.yml)
|
|
22
|
+
- Git history scanning (git-secrets)
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
### Quick Start
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
bash .claude/hooks/install-git-hooks.sh
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### With Force Overwrite (CI/CD)
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
bash .claude/hooks/install-git-hooks.sh --force
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Manual Installation
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Copy pre-commit hook
|
|
42
|
+
cp .git/hooks/pre-commit .git/hooks/pre-commit.bak # Backup existing
|
|
43
|
+
chmod +x .git/hooks/pre-commit
|
|
44
|
+
|
|
45
|
+
# Verify installation
|
|
46
|
+
ls -l .git/hooks/pre-commit
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Detected Credential Patterns
|
|
50
|
+
|
|
51
|
+
### API Keys
|
|
52
|
+
|
|
53
|
+
| Provider | Pattern | Example |
|
|
54
|
+
|----------|---------|---------|
|
|
55
|
+
| Anthropic | `sk-ant-[a-zA-Z0-9_-]{40,}` | `sk-ant-v1-abcd1234...` |
|
|
56
|
+
| Z.ai | `sk-zai-[a-zA-Z0-9._-]{20,}` | `sk-zai-12345678...` |
|
|
57
|
+
| NPM | `npm_[a-zA-Z0-9]{36}` | `npm_1a2b3c4d5e6f...` |
|
|
58
|
+
| Trigger.dev | `tr_dev_[a-zA-Z0-9]{16,}` | `tr_dev_abc123...` |
|
|
59
|
+
| Google | `AIzaSy[a-zA-Z0-9_-]{33}` | `AIzaSy_1234567...` |
|
|
60
|
+
| XAi/Grok | `xai-[a-zA-Z0-9]{32,}` | `xai-abc123...` |
|
|
61
|
+
|
|
62
|
+
### Z.ai Token Formats
|
|
63
|
+
|
|
64
|
+
| Format | Pattern |
|
|
65
|
+
|--------|---------|
|
|
66
|
+
| Current | `[a-zA-Z0-9]{32,}\.SUs3hnpAZAGsQDHX` |
|
|
67
|
+
| Legacy | `[a-zA-Z0-9]{32,}\.QO8R0JxF4fucsoWL` |
|
|
68
|
+
| Legacy | `[a-zA-Z0-9]{32,}\.gDXkwrMNlYcqE8mF` |
|
|
69
|
+
|
|
70
|
+
### Environment Variable Assignments
|
|
71
|
+
|
|
72
|
+
Detects suspicious assignments like:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
ANTHROPIC_API_KEY="sk-ant-..."
|
|
76
|
+
ZAI_API_KEY="sk-zai-..."
|
|
77
|
+
REDIS_PASSWORD="password123"
|
|
78
|
+
POSTGRES_PASSWORD="secure_pass"
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Database Credentials
|
|
82
|
+
|
|
83
|
+
- PostgreSQL passwords
|
|
84
|
+
- MySQL passwords
|
|
85
|
+
- MongoDB passwords
|
|
86
|
+
- Redis passwords
|
|
87
|
+
|
|
88
|
+
### JSON/YAML Structures
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"api_key": "long_credential_string",
|
|
93
|
+
"apiKey": "secret_value",
|
|
94
|
+
"auth_token": "bearer_token",
|
|
95
|
+
"password": "database_password"
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Whitelisted Patterns
|
|
100
|
+
|
|
101
|
+
The following patterns are automatically whitelisted and won't trigger blocks:
|
|
102
|
+
|
|
103
|
+
| Pattern | Usage |
|
|
104
|
+
|---------|-------|
|
|
105
|
+
| `[REDACTED]` | Already redacted credentials |
|
|
106
|
+
| `YOUR_API_KEY` | Documentation placeholders |
|
|
107
|
+
| `YOUR_.*_KEY` | Generic placeholders |
|
|
108
|
+
| `CHANGE_ME` | Configuration templates |
|
|
109
|
+
| `test_key` / `mock_key` | Test credentials |
|
|
110
|
+
| `sk-ant-mock` | Mock Anthropic keys |
|
|
111
|
+
| `npm_MockTestKey` | Mock NPM keys |
|
|
112
|
+
| `example.com` | Example domains |
|
|
113
|
+
|
|
114
|
+
## Usage
|
|
115
|
+
|
|
116
|
+
### Normal Development
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
# Stage and commit files
|
|
120
|
+
git add src/feature.ts docs/FEATURE.md
|
|
121
|
+
git commit -m "feat: add new feature"
|
|
122
|
+
|
|
123
|
+
# If credentials detected, you'll see:
|
|
124
|
+
# ❌ COMMIT BLOCKED: 1 credential(s) detected
|
|
125
|
+
# File: src/feature.ts
|
|
126
|
+
# Match: ANTHROPIC_API_KEY="[CREDENTIAL_REDACTED]"
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Remediation Steps
|
|
130
|
+
|
|
131
|
+
When the hook blocks your commit:
|
|
132
|
+
|
|
133
|
+
1. **Identify the exposed credential:**
|
|
134
|
+
```bash
|
|
135
|
+
git diff --cached src/feature.ts # Review staged changes
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
2. **Replace with placeholder:**
|
|
139
|
+
```bash
|
|
140
|
+
# Replace actual value with [REDACTED]
|
|
141
|
+
sed -i 's/sk-ant-.*/[REDACTED]/g' src/feature.ts
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
3. **Move to secure location:**
|
|
145
|
+
```bash
|
|
146
|
+
# Add to .env (add to .gitignore)
|
|
147
|
+
echo "ANTHROPIC_API_KEY=sk-ant-..." >> .env
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
4. **Update code to use environment variable:**
|
|
151
|
+
```typescript
|
|
152
|
+
// Before
|
|
153
|
+
const apiKey = "sk-ant-...";
|
|
154
|
+
|
|
155
|
+
// After
|
|
156
|
+
const apiKey = process.env.ANTHROPIC_API_KEY;
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
5. **Re-stage and commit:**
|
|
160
|
+
```bash
|
|
161
|
+
git add src/feature.ts
|
|
162
|
+
git commit -m "feat: add new feature"
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Test Files with Mock Credentials
|
|
166
|
+
|
|
167
|
+
For test files, use whitelisted mock credentials:
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
// tests/auth.test.ts
|
|
171
|
+
describe('Authentication', () => {
|
|
172
|
+
it('should validate API key format', () => {
|
|
173
|
+
const mockKey = 'sk-ant-mock'; // Whitelisted
|
|
174
|
+
expect(validateKey(mockKey)).toBe(true);
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Whitelisted mock patterns:
|
|
180
|
+
- `sk-ant-mock` (Anthropic)
|
|
181
|
+
- `npm_MockTestKey` (NPM)
|
|
182
|
+
- `test_key` or `test-key` (Generic)
|
|
183
|
+
- `mock_key` or `mock-key` (Generic)
|
|
184
|
+
- `[REDACTED]` (Documentation)
|
|
185
|
+
|
|
186
|
+
### Bypass (NOT RECOMMENDED)
|
|
187
|
+
|
|
188
|
+
To bypass the pre-commit hook:
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
git commit --no-verify
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
**WARNING:** This disables all pre-commit hooks. Only use if absolutely necessary, and ensure credentials are removed before pushing.
|
|
195
|
+
|
|
196
|
+
## File Scanning
|
|
197
|
+
|
|
198
|
+
### Files Scanned
|
|
199
|
+
|
|
200
|
+
The pre-commit hook scans these file types:
|
|
201
|
+
|
|
202
|
+
```
|
|
203
|
+
*.ts, *.tsx, *.js, *.jsx
|
|
204
|
+
*.json, *.md, *.sh, *.bash
|
|
205
|
+
*.env*, *.yaml, *.yml, *.txt
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Files Skipped
|
|
209
|
+
|
|
210
|
+
Files in these directories are automatically skipped:
|
|
211
|
+
|
|
212
|
+
- `.git/`
|
|
213
|
+
- `node_modules/`
|
|
214
|
+
- `.venv/`
|
|
215
|
+
- `dist/`, `build/`
|
|
216
|
+
- `.next/`, `.artifacts/`
|
|
217
|
+
|
|
218
|
+
Binary files larger than 1MB are also skipped.
|
|
219
|
+
|
|
220
|
+
## Integration with Other Tools
|
|
221
|
+
|
|
222
|
+
### Post-Edit Credential Scanner
|
|
223
|
+
|
|
224
|
+
The post-edit hook runs the same credential scanner:
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
.claude/hooks/validators/credential-scanner.sh
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### CI/CD Credential Scanning
|
|
231
|
+
|
|
232
|
+
GitHub Actions workflow validates credentials:
|
|
233
|
+
|
|
234
|
+
```yaml
|
|
235
|
+
# .github/workflows/security-credential-scan.yml
|
|
236
|
+
- Credential scanning (git-secrets)
|
|
237
|
+
- TruffleHog scanning
|
|
238
|
+
- Custom pattern validation
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### Git History Scanning
|
|
242
|
+
|
|
243
|
+
To scan git history for past credential exposure:
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
git secrets --scan-history --since=HEAD~10
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## Audit Trail
|
|
250
|
+
|
|
251
|
+
All pre-commit hook activity is logged to:
|
|
252
|
+
|
|
253
|
+
```
|
|
254
|
+
.artifacts/logs/git-hooks.log
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
Log entries include:
|
|
258
|
+
|
|
259
|
+
```
|
|
260
|
+
2025-11-23T10:30:45Z | PRE-COMMIT BLOCKED | CREDENTIALS:2 | FILES_SCANNED:5
|
|
261
|
+
2025-11-23T10:31:12Z | PRE-COMMIT SUCCESS | FILES_SCANNED:3
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
## Troubleshooting
|
|
265
|
+
|
|
266
|
+
### Hook Not Executing
|
|
267
|
+
|
|
268
|
+
Check if the hook is executable:
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
ls -l .git/hooks/pre-commit
|
|
272
|
+
# Should show: -rwxr-xr-x
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
Make it executable:
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
chmod +x .git/hooks/pre-commit
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
### Hook Conflicts
|
|
282
|
+
|
|
283
|
+
If you have other pre-commit hooks, they may conflict. Check:
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
cat .git/hooks/pre-commit
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Merge hooks using a wrapper script.
|
|
290
|
+
|
|
291
|
+
### False Positives
|
|
292
|
+
|
|
293
|
+
If a legitimate pattern is blocked, add it to WHITELIST in the hook:
|
|
294
|
+
|
|
295
|
+
```bash
|
|
296
|
+
# Edit .git/hooks/pre-commit
|
|
297
|
+
WHITELIST=(
|
|
298
|
+
# ... existing patterns ...
|
|
299
|
+
"my_specific_pattern"
|
|
300
|
+
)
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
Then reinstall:
|
|
304
|
+
|
|
305
|
+
```bash
|
|
306
|
+
bash .claude/hooks/install-git-hooks.sh --force
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
### Permission Issues
|
|
310
|
+
|
|
311
|
+
If you can't install hooks:
|
|
312
|
+
|
|
313
|
+
```bash
|
|
314
|
+
# Check .git directory permissions
|
|
315
|
+
ls -ld .git
|
|
316
|
+
chmod 755 .git
|
|
317
|
+
chmod 755 .git/hooks
|
|
318
|
+
|
|
319
|
+
# Retry installation
|
|
320
|
+
bash .claude/hooks/install-git-hooks.sh
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
## Best Practices
|
|
324
|
+
|
|
325
|
+
### 1. Use Environment Variables
|
|
326
|
+
|
|
327
|
+
Never hardcode credentials:
|
|
328
|
+
|
|
329
|
+
```typescript
|
|
330
|
+
// WRONG
|
|
331
|
+
const apiKey = "sk-ant-v1-...";
|
|
332
|
+
|
|
333
|
+
// RIGHT
|
|
334
|
+
const apiKey = process.env.ANTHROPIC_API_KEY;
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
### 2. Create .env.example
|
|
338
|
+
|
|
339
|
+
Document required variables without values:
|
|
340
|
+
|
|
341
|
+
```bash
|
|
342
|
+
# .env.example
|
|
343
|
+
ANTHROPIC_API_KEY=YOUR_API_KEY
|
|
344
|
+
DATABASE_URL=postgresql://user:pass@localhost/db
|
|
345
|
+
REDIS_PASSWORD=CHANGE_ME
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
### 3. Add .env to .gitignore
|
|
349
|
+
|
|
350
|
+
```bash
|
|
351
|
+
echo ".env*" >> .gitignore
|
|
352
|
+
git add .gitignore
|
|
353
|
+
git commit -m "chore: add .env to gitignore"
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
### 4. Use Secure Configuration
|
|
357
|
+
|
|
358
|
+
For deployments, use:
|
|
359
|
+
- Environment variable injection
|
|
360
|
+
- Secret management services (HashiCorp Vault, AWS Secrets Manager)
|
|
361
|
+
- Encrypted configuration files (git-crypt, SOPS)
|
|
362
|
+
|
|
363
|
+
### 5. Redact Documentation
|
|
364
|
+
|
|
365
|
+
When documenting credentials in code examples:
|
|
366
|
+
|
|
367
|
+
```bash
|
|
368
|
+
# DO: Use [REDACTED] placeholder
|
|
369
|
+
ANTHROPIC_API_KEY=sk-ant-[REDACTED]
|
|
370
|
+
|
|
371
|
+
# DON'T: Show actual credentials
|
|
372
|
+
ANTHROPIC_API_KEY=sk-ant-v1-abc123...
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
## Exit Codes
|
|
376
|
+
|
|
377
|
+
| Code | Meaning | Action |
|
|
378
|
+
|------|---------|--------|
|
|
379
|
+
| 0 | No credentials detected | Commit proceeds |
|
|
380
|
+
| 1 | Credentials detected | Commit blocked |
|
|
381
|
+
|
|
382
|
+
## Configuration
|
|
383
|
+
|
|
384
|
+
### Modify Detection Patterns
|
|
385
|
+
|
|
386
|
+
Edit `.git/hooks/pre-commit` and modify the PATTERNS array:
|
|
387
|
+
|
|
388
|
+
```bash
|
|
389
|
+
declare -a PATTERNS=(
|
|
390
|
+
"your-new-pattern"
|
|
391
|
+
# ... existing patterns ...
|
|
392
|
+
)
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
### Modify Whitelist
|
|
396
|
+
|
|
397
|
+
Edit `.git/hooks/pre-commit` and modify the WHITELIST array:
|
|
398
|
+
|
|
399
|
+
```bash
|
|
400
|
+
declare -a WHITELIST=(
|
|
401
|
+
"\\[REDACTED\\]"
|
|
402
|
+
"your-safe-pattern"
|
|
403
|
+
# ... existing patterns ...
|
|
404
|
+
)
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
### Customize Scanned File Types
|
|
408
|
+
|
|
409
|
+
Edit `.git/hooks/pre-commit` and modify SCANNABLE_TYPES:
|
|
410
|
+
|
|
411
|
+
```bash
|
|
412
|
+
declare -a SCANNABLE_TYPES=(
|
|
413
|
+
"*.ts" "*.tsx"
|
|
414
|
+
"*.custom" # Add custom type
|
|
415
|
+
)
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
## Related Documentation
|
|
419
|
+
|
|
420
|
+
- **Credential Scanner**: `.claude/hooks/validators/credential-scanner.sh`
|
|
421
|
+
- **CI/CD Workflow**: `.github/workflows/security-credential-scan.yml`
|
|
422
|
+
- **Installation Script**: `.claude/hooks/install-git-hooks.sh`
|
|
423
|
+
- **Project Standards**: `CLAUDE.md` (Redaction Protocol section)
|
|
424
|
+
|
|
425
|
+
## Support
|
|
426
|
+
|
|
427
|
+
For issues or improvements:
|
|
428
|
+
|
|
429
|
+
1. Review `.git/hooks/pre-commit` for current implementation
|
|
430
|
+
2. Check `.artifacts/logs/git-hooks.log` for audit trail
|
|
431
|
+
3. Test with: `git commit --no-verify` (temporary bypass)
|
|
432
|
+
4. Refer to post-edit scanner for pattern reference
|
|
433
|
+
|
|
434
|
+
## Summary
|
|
435
|
+
|
|
436
|
+
The git hooks system provides:
|
|
437
|
+
|
|
438
|
+
- **Automated Detection**: Pre-commit scanning catches credentials before commit
|
|
439
|
+
- **Consistent Patterns**: Same detection rules across pre-commit, post-edit, and CI/CD
|
|
440
|
+
- **Clear Remediation**: Detailed guidance when credentials are detected
|
|
441
|
+
- **Flexible Whitelisting**: Safe patterns for tests and documentation
|
|
442
|
+
- **Audit Trail**: Complete logging of all credential detection events
|
|
443
|
+
- **Easy Installation**: Single command setup with validation
|
|
@@ -38,6 +38,28 @@ set -euo pipefail
|
|
|
38
38
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
39
39
|
CONFIG_FILE="$SCRIPT_DIR/cfn-post-edit.config.json"
|
|
40
40
|
|
|
41
|
+
# Ensure jq is available (fallback to local download if sudo unavailable)
|
|
42
|
+
JQ_CMD="jq"
|
|
43
|
+
if ! command -v jq >/dev/null 2>&1; then
|
|
44
|
+
JQ_FALLBACK="$SCRIPT_DIR/../tools/jq"
|
|
45
|
+
if [ ! -x "$JQ_FALLBACK" ]; then
|
|
46
|
+
mkdir -p "$SCRIPT_DIR/../tools"
|
|
47
|
+
if command -v curl >/dev/null 2>&1; then
|
|
48
|
+
curl -fsSL -o "$JQ_FALLBACK" https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 && chmod +x "$JQ_FALLBACK" || true
|
|
49
|
+
elif command -v wget >/dev/null 2>&1; then
|
|
50
|
+
wget -q -O "$JQ_FALLBACK" https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 && chmod +x "$JQ_FALLBACK" || true
|
|
51
|
+
fi
|
|
52
|
+
fi
|
|
53
|
+
if [ -x "$JQ_FALLBACK" ]; then
|
|
54
|
+
JQ_CMD="$JQ_FALLBACK"
|
|
55
|
+
else
|
|
56
|
+
echo "Error: jq not found and download failed. Install jq or ensure curl/wget access." >&2
|
|
57
|
+
exit 1
|
|
58
|
+
fi
|
|
59
|
+
else
|
|
60
|
+
JQ_CMD="$(command -v jq)"
|
|
61
|
+
fi
|
|
62
|
+
|
|
41
63
|
# Parse arguments
|
|
42
64
|
FILE_PATH=""
|
|
43
65
|
AGENT_ID="${AGENT_ID:-unknown}"
|
|
@@ -46,6 +68,10 @@ BLOCKING=false
|
|
|
46
68
|
while [[ $# -gt 0 ]]; do
|
|
47
69
|
case $1 in
|
|
48
70
|
--agent-id)
|
|
71
|
+
if [[ -z "${2:-}" ]]; then
|
|
72
|
+
echo "Error: --agent-id requires a value" >&2
|
|
73
|
+
exit 1
|
|
74
|
+
fi
|
|
49
75
|
AGENT_ID="$2"
|
|
50
76
|
shift 2
|
|
51
77
|
;;
|
|
@@ -68,14 +94,14 @@ if [ -z "$FILE_PATH" ]; then
|
|
|
68
94
|
fi
|
|
69
95
|
|
|
70
96
|
# Check if hooks are enabled
|
|
71
|
-
ENABLED=$(
|
|
97
|
+
ENABLED=$("$JQ_CMD" -r '.enabled // true' "$CONFIG_FILE" 2>/dev/null || echo "true")
|
|
72
98
|
if [ "$ENABLED" != "true" ]; then
|
|
73
99
|
echo "Post-edit hooks disabled in config"
|
|
74
100
|
exit 0
|
|
75
101
|
fi
|
|
76
102
|
|
|
77
103
|
# Get pipeline path from config
|
|
78
|
-
PIPELINE=$(
|
|
104
|
+
PIPELINE=$("$JQ_CMD" -r '.pipeline // "config/hooks/post-edit-pipeline.js"' "$CONFIG_FILE")
|
|
79
105
|
|
|
80
106
|
# Build memory key
|
|
81
107
|
MEMORY_KEY="swarm/${AGENT_ID}/hook-results"
|
|
@@ -92,10 +118,10 @@ if [ "$BLOCKING" = true ] && [ $EXIT_CODE -ne 0 ]; then
|
|
|
92
118
|
fi
|
|
93
119
|
|
|
94
120
|
# Publish to Redis if enabled
|
|
95
|
-
REDIS_ENABLED=$(
|
|
121
|
+
REDIS_ENABLED=$("$JQ_CMD" -r '.redis.enabled // false' "$CONFIG_FILE")
|
|
96
122
|
if [ "$REDIS_ENABLED" = "true" ] && command -v redis-cli >/dev/null 2>&1; then
|
|
97
|
-
CHANNEL=$(
|
|
98
|
-
MESSAGE=$(
|
|
123
|
+
CHANNEL=$("$JQ_CMD" -r '.redis.publishChannel // "swarm:hooks:post-edit"' "$CONFIG_FILE")
|
|
124
|
+
MESSAGE=$("$JQ_CMD" -n \
|
|
99
125
|
--arg file "$FILE_PATH" \
|
|
100
126
|
--arg agent "$AGENT_ID" \
|
|
101
127
|
--arg exit "$EXIT_CODE" \
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"1": "ERROR",
|
|
11
11
|
"2": "SYNTAX_ERROR",
|
|
12
12
|
"9": "BASH_VALIDATOR_ERROR",
|
|
13
|
-
"10": "BASH_VALIDATOR_WARNING"
|
|
13
|
+
"10": "BASH_VALIDATOR_WARNING",
|
|
14
|
+
"11": "CREDENTIAL_DETECTED"
|
|
14
15
|
},
|
|
15
16
|
"redis": {
|
|
16
17
|
"enabled": true,
|
|
@@ -33,12 +34,18 @@
|
|
|
33
34
|
"enabled": true,
|
|
34
35
|
"validators": ["pipe-safety", "dependency-checker", "line-endings"],
|
|
35
36
|
"timeout": 5000
|
|
37
|
+
},
|
|
38
|
+
"credentials": {
|
|
39
|
+
"enabled": true,
|
|
40
|
+
"validator": ".claude/hooks/validators/credential-scanner.sh",
|
|
41
|
+
"blocking": true,
|
|
42
|
+
"timeout": 10000
|
|
36
43
|
}
|
|
37
44
|
},
|
|
38
45
|
"feedback": {
|
|
39
46
|
"provideSuggestions": true,
|
|
40
47
|
"autoFixable": ["LINT_ISSUES"],
|
|
41
48
|
"nonBlocking": ["TYPE_WARNING", "LINT_ISSUES", "BASH_VALIDATOR_WARNING"],
|
|
42
|
-
"blocking": ["SYNTAX_ERROR", "BASH_VALIDATOR_ERROR"]
|
|
49
|
+
"blocking": ["SYNTAX_ERROR", "BASH_VALIDATOR_ERROR", "CREDENTIAL_DETECTED"]
|
|
43
50
|
}
|
|
44
51
|
}
|