clawpowers 1.0.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-plugin/manifest.json +19 -0
- package/.codex/INSTALL.md +36 -0
- package/.cursor-plugin/manifest.json +21 -0
- package/.opencode/INSTALL.md +52 -0
- package/ARCHITECTURE.md +69 -0
- package/README.md +381 -0
- package/bin/clawpowers.js +390 -0
- package/bin/clawpowers.sh +91 -0
- package/gemini-extension.json +32 -0
- package/hooks/session-start +205 -0
- package/hooks/session-start.cmd +43 -0
- package/hooks/session-start.js +163 -0
- package/package.json +54 -0
- package/runtime/feedback/analyze.js +621 -0
- package/runtime/feedback/analyze.sh +546 -0
- package/runtime/init.js +172 -0
- package/runtime/init.sh +145 -0
- package/runtime/metrics/collector.js +361 -0
- package/runtime/metrics/collector.sh +308 -0
- package/runtime/persistence/store.js +433 -0
- package/runtime/persistence/store.sh +303 -0
- package/skill.json +74 -0
- package/skills/agent-payments/SKILL.md +411 -0
- package/skills/brainstorming/SKILL.md +233 -0
- package/skills/content-pipeline/SKILL.md +282 -0
- package/skills/dispatching-parallel-agents/SKILL.md +305 -0
- package/skills/executing-plans/SKILL.md +255 -0
- package/skills/finishing-a-development-branch/SKILL.md +260 -0
- package/skills/learn-how-to-learn/SKILL.md +235 -0
- package/skills/market-intelligence/SKILL.md +288 -0
- package/skills/prospecting/SKILL.md +313 -0
- package/skills/receiving-code-review/SKILL.md +225 -0
- package/skills/requesting-code-review/SKILL.md +206 -0
- package/skills/security-audit/SKILL.md +308 -0
- package/skills/subagent-driven-development/SKILL.md +244 -0
- package/skills/systematic-debugging/SKILL.md +279 -0
- package/skills/test-driven-development/SKILL.md +299 -0
- package/skills/using-clawpowers/SKILL.md +137 -0
- package/skills/using-git-worktrees/SKILL.md +261 -0
- package/skills/verification-before-completion/SKILL.md +254 -0
- package/skills/writing-plans/SKILL.md +276 -0
- package/skills/writing-skills/SKILL.md +260 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: requesting-code-review
|
|
3
|
+
description: Prepare and submit a code review request with full context, risk areas, and reviewer guidance. Activate when a branch is finished and needs peer review.
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
requires:
|
|
6
|
+
tools: [git, bash]
|
|
7
|
+
runtime: false
|
|
8
|
+
metrics:
|
|
9
|
+
tracks: [review_response_time, review_cycles, reviewer_match_score, feedback_actionability]
|
|
10
|
+
improves: [context_completeness, risk_identification_accuracy, reviewer_selection]
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Requesting Code Review
|
|
14
|
+
|
|
15
|
+
## When to Use
|
|
16
|
+
|
|
17
|
+
Apply this skill when:
|
|
18
|
+
|
|
19
|
+
- `finishing-a-development-branch` is complete
|
|
20
|
+
- You need peer review before merging
|
|
21
|
+
- The change is non-trivial (> 50 lines of production code)
|
|
22
|
+
- You want to give reviewers the best chance of catching issues
|
|
23
|
+
|
|
24
|
+
**Skip when:**
|
|
25
|
+
- Trivial typo fix or single-line change
|
|
26
|
+
- Emergency hotfix where time doesn't permit (document post-hoc)
|
|
27
|
+
- The change is documentation-only with no logic
|
|
28
|
+
|
|
29
|
+
## Core Methodology
|
|
30
|
+
|
|
31
|
+
### Step 1: Pre-Review Self-Review
|
|
32
|
+
|
|
33
|
+
Before requesting review, do a self-review as if you were the reviewer:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
git diff main...HEAD
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Go through the diff and ask:
|
|
40
|
+
- Would I understand what this code does without explanation?
|
|
41
|
+
- Are there any obvious bugs I can see fresh?
|
|
42
|
+
- Is anything over-engineered or unnecessarily complex?
|
|
43
|
+
- Would a new team member be able to maintain this?
|
|
44
|
+
|
|
45
|
+
Fix anything you find. Requesting review of code you know has issues wastes the reviewer's time.
|
|
46
|
+
|
|
47
|
+
### Step 2: Identify Risk Areas
|
|
48
|
+
|
|
49
|
+
Proactively identify what deserves the most scrutiny:
|
|
50
|
+
|
|
51
|
+
**Risk categories:**
|
|
52
|
+
- **Security-sensitive paths** — authentication, authorization, input validation, crypto
|
|
53
|
+
- **Concurrency code** — locks, goroutines, async patterns, shared state
|
|
54
|
+
- **External integrations** — third-party APIs, payment processors, auth providers
|
|
55
|
+
- **Database changes** — schema migrations, query performance, transaction handling
|
|
56
|
+
- **Performance-critical paths** — hot loops, cached data invalidation, N+1 queries
|
|
57
|
+
- **Backward compatibility** — changed interfaces, removed fields, modified contracts
|
|
58
|
+
|
|
59
|
+
For each risk area, note:
|
|
60
|
+
- What the risk is
|
|
61
|
+
- What you did to mitigate it
|
|
62
|
+
- What the reviewer should specifically examine
|
|
63
|
+
|
|
64
|
+
### Step 3: Choose Reviewers
|
|
65
|
+
|
|
66
|
+
Select reviewers based on:
|
|
67
|
+
|
|
68
|
+
1. **Domain expertise** — Who has worked with this code area before?
|
|
69
|
+
2. **Security knowledge** — For any security-sensitive changes, at least one reviewer with security background
|
|
70
|
+
3. **Fresh eyes** — For complex logic, someone unfamiliar with the code (catches implicit assumptions)
|
|
71
|
+
4. **Availability** — Don't block on a reviewer who won't be available for 3+ days
|
|
72
|
+
|
|
73
|
+
**Reviewer load:** Don't request review from someone who already has 3+ open review requests.
|
|
74
|
+
|
|
75
|
+
**Minimum reviewers:** 1 for low-risk changes, 2 for security changes, 2 for schema migrations.
|
|
76
|
+
|
|
77
|
+
### Step 4: Write the Review Request
|
|
78
|
+
|
|
79
|
+
Build on the PR description from `finishing-a-development-branch` and add reviewer-specific guidance:
|
|
80
|
+
|
|
81
|
+
```markdown
|
|
82
|
+
## Code Review Request: [Feature Name]
|
|
83
|
+
|
|
84
|
+
**Branch:** feature/auth-service → main
|
|
85
|
+
**PR:** [link]
|
|
86
|
+
**Priority:** [Normal / Urgent / Low]
|
|
87
|
+
**Review by:** [date — give at least 24 hours]
|
|
88
|
+
|
|
89
|
+
### What This Does
|
|
90
|
+
[2-3 sentences for someone who hasn't seen any of the work]
|
|
91
|
+
|
|
92
|
+
### What's Changed (Key Files)
|
|
93
|
+
- `src/auth/service.py` — Core JWT issuance and validation logic (NEW)
|
|
94
|
+
- `src/middleware/auth.py` — Request authentication middleware (MODIFIED)
|
|
95
|
+
- `tests/test_auth.py` — 34 new tests (NEW)
|
|
96
|
+
- `migrations/003_auth_sessions.sql` — Session storage schema (NEW)
|
|
97
|
+
|
|
98
|
+
### What to Focus On
|
|
99
|
+
|
|
100
|
+
**[HIGH PRIORITY] `src/auth/service.py:47-89` — JWT validation logic**
|
|
101
|
+
This is the most security-critical path. Specifically review:
|
|
102
|
+
- Token expiry check (line 61) — must reject expired tokens before checking signature
|
|
103
|
+
- Algorithm enforcement (line 78) — must reject HS256, accept RS256 only
|
|
104
|
+
- Error handling (lines 84-89) — must not leak token contents in error messages
|
|
105
|
+
|
|
106
|
+
**[MEDIUM] `migrations/003_auth_sessions.sql`**
|
|
107
|
+
Irreversible change. Verify the rollback migration is correct before approving.
|
|
108
|
+
|
|
109
|
+
**[LOW] `src/middleware/auth.py`**
|
|
110
|
+
Standard middleware pattern. Verify session cache key structure is consistent.
|
|
111
|
+
|
|
112
|
+
### Known Tradeoffs Accepted
|
|
113
|
+
- Sessions stored in Redis (not DB) for performance — accepted: Redis is already a dependency
|
|
114
|
+
- TTL is fixed at 1 hour — accepted: configurable TTL deferred to follow-up issue #247
|
|
115
|
+
|
|
116
|
+
### Not in Scope
|
|
117
|
+
- Password reset flow — tracked in issue #248
|
|
118
|
+
- MFA support — tracked in issue #249
|
|
119
|
+
|
|
120
|
+
### Testing Summary
|
|
121
|
+
- 34 unit tests (all auth logic paths)
|
|
122
|
+
- 8 integration tests (real Redis, real DB)
|
|
123
|
+
- Manual test: registered, logged in, made authenticated request, logged out
|
|
124
|
+
- Security test: expired token rejected, tampered token rejected, algorithm confusion rejected
|
|
125
|
+
|
|
126
|
+
### Questions for Reviewers
|
|
127
|
+
1. Is the error message at line 88 safe to expose to clients? (no token contents, but mentions "signature verification failed")
|
|
128
|
+
2. Should the session TTL be in seconds or milliseconds in the Redis key expiry? Currently seconds — consistent with Python's time.time().
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Step 5: Notify Reviewers
|
|
132
|
+
|
|
133
|
+
Don't just assign in GitHub and wait. Notify:
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
[Message to reviewer]
|
|
137
|
+
Hey, I've opened a PR for the auth service implementation. About 400 lines of
|
|
138
|
+
new code + a schema migration. Review should take 30-45 minutes.
|
|
139
|
+
|
|
140
|
+
High priority focus: the JWT validation logic in src/auth/service.py (lines 47-89).
|
|
141
|
+
|
|
142
|
+
PR: [link]
|
|
143
|
+
No rush on today — tomorrow EOD works. Let me know if you have questions
|
|
144
|
+
before diving in.
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Direct notification (Slack, Teams, etc.) gets 3x faster response than GitHub assignment alone.
|
|
148
|
+
|
|
149
|
+
### Step 6: Be Available for Questions
|
|
150
|
+
|
|
151
|
+
During review:
|
|
152
|
+
- Check for review comments every few hours
|
|
153
|
+
- Answer questions promptly — blocking the reviewer = slower iteration
|
|
154
|
+
- If you need to make changes during review, push to the same branch (don't open a new PR)
|
|
155
|
+
- Respond to every comment — even "acknowledged" or "agreed, will fix" counts
|
|
156
|
+
|
|
157
|
+
## ClawPowers Enhancement
|
|
158
|
+
|
|
159
|
+
When `~/.clawpowers/` runtime is initialized:
|
|
160
|
+
|
|
161
|
+
**Reviewer Matching Based on Code Area:**
|
|
162
|
+
|
|
163
|
+
Track which reviewers have reviewed which paths:
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
bash runtime/persistence/store.sh set "reviewer:alice:areas" "src/auth/,src/middleware/"
|
|
167
|
+
bash runtime/persistence/store.sh set "reviewer:bob:areas" "migrations/,src/models/"
|
|
168
|
+
bash runtime/persistence/store.sh set "reviewer:carol:areas" "src/api/,tests/"
|
|
169
|
+
|
|
170
|
+
# Get suggested reviewers for current diff
|
|
171
|
+
CHANGED_DIRS=$(git diff main...HEAD --name-only | xargs -I{} dirname {} | sort -u | tr '\n' ',')
|
|
172
|
+
bash runtime/persistence/store.sh list "reviewer:*:areas" | grep -f <(echo "$CHANGED_DIRS" | tr ',' '\n')
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
**Review History:**
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
bash runtime/persistence/store.sh set "review:auth-service:requested_at" "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
179
|
+
bash runtime/persistence/store.sh set "review:auth-service:reviewers" "alice,bob"
|
|
180
|
+
# After review completes:
|
|
181
|
+
bash runtime/persistence/store.sh set "review:auth-service:response_time_hours" "6"
|
|
182
|
+
bash runtime/persistence/store.sh set "review:auth-service:cycles" "2"
|
|
183
|
+
bash runtime/persistence/store.sh set "review:auth-service:outcome" "approved"
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
**Review Request Quality Metrics:**
|
|
187
|
+
|
|
188
|
+
Correlates review request quality (risk areas identified, context completeness) with number of review cycles required. PRs with complete context average 1.3 cycles; PRs without average 2.8 cycles.
|
|
189
|
+
|
|
190
|
+
## Anti-Patterns
|
|
191
|
+
|
|
192
|
+
| Anti-Pattern | Why It Fails | Correct Approach |
|
|
193
|
+
|-------------|-------------|-----------------|
|
|
194
|
+
| No context in PR description | Reviewers waste time figuring out what the PR does | Complete description with focus areas |
|
|
195
|
+
| Requesting review of known-bad code | Wastes reviewer time, undermines trust | Self-review first, fix what you find |
|
|
196
|
+
| Assigning everyone to every PR | Diffusion of responsibility, everyone waits for someone else | 1-2 targeted reviewers |
|
|
197
|
+
| No risk areas identified | Reviewers apply uniform attention, miss high-risk areas | Explicitly call out what needs scrutiny |
|
|
198
|
+
| Requesting review on Friday afternoon | Review blocked until Monday | Time requests for prompt turnaround |
|
|
199
|
+
| Not notifying reviewers directly | Notification gets buried | Direct message in addition to GitHub assignment |
|
|
200
|
+
| "Take your time" with security changes | Security review gets deprioritized | State urgency explicitly |
|
|
201
|
+
|
|
202
|
+
## Integration with Other Skills
|
|
203
|
+
|
|
204
|
+
- Preceded by `finishing-a-development-branch`
|
|
205
|
+
- Followed by `receiving-code-review`
|
|
206
|
+
- Use `security-audit` to pre-scan before requesting security-sensitive reviews
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: security-audit
|
|
3
|
+
description: Run automated security scanning with Trivy, gitleaks, dependency audits, and SAST tools. Produces an actionable vulnerability report. Activate before any production deployment or release.
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
requires:
|
|
6
|
+
tools: [bash, trivy, gitleaks, npm, python3]
|
|
7
|
+
runtime: false
|
|
8
|
+
metrics:
|
|
9
|
+
tracks: [vulnerabilities_found, critical_count, high_count, false_positive_rate, fix_rate]
|
|
10
|
+
improves: [scan_coverage, reporting_clarity, fix_prioritization]
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Security Audit
|
|
14
|
+
|
|
15
|
+
## When to Use
|
|
16
|
+
|
|
17
|
+
Apply this skill when:
|
|
18
|
+
|
|
19
|
+
- Preparing for a production release
|
|
20
|
+
- A new dependency has been added
|
|
21
|
+
- Infrastructure code (Dockerfiles, K8s manifests) has changed
|
|
22
|
+
- A security incident occurred and you need to understand scope
|
|
23
|
+
- Before merging a PR with authentication/authorization changes
|
|
24
|
+
- Onboarding a new codebase (baseline security posture assessment)
|
|
25
|
+
|
|
26
|
+
**Skip when:**
|
|
27
|
+
- Running on every trivial PR (overhead too high — use pre-commit hooks for that)
|
|
28
|
+
- Dependencies haven't changed and no new code paths touch auth/IO/crypto
|
|
29
|
+
|
|
30
|
+
## Tools Reference
|
|
31
|
+
|
|
32
|
+
| Tool | What It Scans | Install |
|
|
33
|
+
|------|-------------|---------|
|
|
34
|
+
| `trivy` | Containers, filesystems, IaC, SBOMs for CVEs | `brew install trivy` / `apt install trivy` |
|
|
35
|
+
| `gitleaks` | Secret detection in git history | `brew install gitleaks` / `go install` |
|
|
36
|
+
| `npm audit` | Node.js dependency CVEs | Bundled with npm |
|
|
37
|
+
| `pip-audit` | Python dependency CVEs | `pip install pip-audit` |
|
|
38
|
+
| `bandit` | Python SAST (hardcoded creds, injection) | `pip install bandit` |
|
|
39
|
+
| `semgrep` | Multi-language SAST patterns | `pip install semgrep` |
|
|
40
|
+
| `cargo audit` | Rust dependency CVEs | `cargo install cargo-audit` |
|
|
41
|
+
|
|
42
|
+
## Core Methodology
|
|
43
|
+
|
|
44
|
+
### Step 1: Secret Scanning (Run First)
|
|
45
|
+
|
|
46
|
+
Secrets in code are the highest-priority finding. Scan before any other step:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# Scan the entire git history (not just current commit)
|
|
50
|
+
gitleaks detect --source . --verbose
|
|
51
|
+
|
|
52
|
+
# Scan current filesystem (for CI/CD pipelines where git history isn't available)
|
|
53
|
+
gitleaks detect --no-git --source . --verbose
|
|
54
|
+
|
|
55
|
+
# Scan a specific branch range
|
|
56
|
+
gitleaks detect --log-opts="main..HEAD"
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**What gitleaks finds:**
|
|
60
|
+
- API keys (AWS, Google Cloud, Stripe, GitHub, etc.)
|
|
61
|
+
- Database connection strings with credentials
|
|
62
|
+
- Private keys (RSA, ECDSA, PGP)
|
|
63
|
+
- OAuth tokens and session secrets
|
|
64
|
+
- Generic high-entropy strings that look like credentials
|
|
65
|
+
|
|
66
|
+
**Critical:** Any detected secret must be rotated immediately — not just removed from code. The secret was exposed from the moment it was committed, regardless of whether the commit still exists.
|
|
67
|
+
|
|
68
|
+
**Secret rotation protocol:**
|
|
69
|
+
1. Identify the secret type (API key, DB password, etc.)
|
|
70
|
+
2. Rotate/regenerate the secret at the source (AWS console, GitHub settings, etc.)
|
|
71
|
+
3. Update all deployments with the new secret
|
|
72
|
+
4. Remove the old secret from git history (`git filter-branch` or BFG Repo Cleaner)
|
|
73
|
+
5. Force-push the cleaned history (with team coordination)
|
|
74
|
+
6. Verify old secret no longer works
|
|
75
|
+
|
|
76
|
+
### Step 2: Dependency CVE Scanning
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# Node.js
|
|
80
|
+
npm audit --audit-level=moderate
|
|
81
|
+
# For a non-zero exit on vulnerabilities:
|
|
82
|
+
npm audit --audit-level=high 2>&1 | tee npm-audit-results.txt
|
|
83
|
+
|
|
84
|
+
# Python
|
|
85
|
+
pip-audit --desc on --output json > pip-audit-results.json
|
|
86
|
+
pip-audit --fix --dry-run # See what would be auto-fixed
|
|
87
|
+
|
|
88
|
+
# Containers (Dockerfile + base image)
|
|
89
|
+
trivy image your-image:tag --severity HIGH,CRITICAL --exit-code 1
|
|
90
|
+
trivy image your-image:tag --format json -o trivy-image-results.json
|
|
91
|
+
|
|
92
|
+
# Filesystem (all languages + config files)
|
|
93
|
+
trivy fs . --severity HIGH,CRITICAL
|
|
94
|
+
trivy fs . --format json -o trivy-fs-results.json
|
|
95
|
+
|
|
96
|
+
# Infrastructure as Code (Terraform, K8s, Helm, CloudFormation)
|
|
97
|
+
trivy config ./infrastructure/ --severity HIGH,CRITICAL
|
|
98
|
+
trivy config k8s/ --format table
|
|
99
|
+
|
|
100
|
+
# Rust
|
|
101
|
+
cargo audit
|
|
102
|
+
|
|
103
|
+
# Go
|
|
104
|
+
govulncheck ./...
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Step 3: SAST (Static Application Security Testing)
|
|
108
|
+
|
|
109
|
+
Find security-relevant code patterns:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
# Python — bandit
|
|
113
|
+
bandit -r src/ -ll -f json -o bandit-results.json
|
|
114
|
+
bandit -r src/ -ll --skip B101 # Skip assert_used if it's test code
|
|
115
|
+
|
|
116
|
+
# Multi-language — semgrep
|
|
117
|
+
semgrep --config=auto src/ --json -o semgrep-results.json
|
|
118
|
+
semgrep --config=p/python src/ --json # Language-specific rules
|
|
119
|
+
semgrep --config=p/javascript src/ --json
|
|
120
|
+
semgrep --config=p/owasp-top-ten src/ --json # OWASP rules
|
|
121
|
+
|
|
122
|
+
# Node.js — eslint-plugin-security
|
|
123
|
+
npx eslint --plugin security --rule 'security/detect-non-literal-regexp: warn' src/
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**High-priority bandit checks:**
|
|
127
|
+
- `B105-B107`: Hardcoded password/credentials
|
|
128
|
+
- `B301-B302`: Pickle deserialization (arbitrary code execution)
|
|
129
|
+
- `B501-B511`: TLS/SSL configuration weaknesses
|
|
130
|
+
- `B601-B614`: Shell injection, subprocess calls
|
|
131
|
+
- `B701-B703`: Jinja2/Mako template injection
|
|
132
|
+
|
|
133
|
+
**High-priority semgrep rules:**
|
|
134
|
+
- SQL injection patterns
|
|
135
|
+
- Path traversal
|
|
136
|
+
- XSS (reflected, stored)
|
|
137
|
+
- SSRF (server-side request forgery)
|
|
138
|
+
- Authentication bypass patterns
|
|
139
|
+
- Insecure deserialization
|
|
140
|
+
|
|
141
|
+
### Step 4: Container Security
|
|
142
|
+
|
|
143
|
+
If the project uses Docker:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
# Scan Dockerfile for misconfigurations
|
|
147
|
+
trivy config Dockerfile
|
|
148
|
+
|
|
149
|
+
# Common Dockerfile issues trivy finds:
|
|
150
|
+
# - Running as root (ADD USER directive missing)
|
|
151
|
+
# - COPY . . (copies .env, .git, sensitive files)
|
|
152
|
+
# - Latest tag (non-deterministic base image)
|
|
153
|
+
# - Exposed ports beyond what's necessary
|
|
154
|
+
# - Unverified downloads (curl | bash patterns)
|
|
155
|
+
# - Secrets passed as ENV vars or ARG
|
|
156
|
+
|
|
157
|
+
# Scan built image
|
|
158
|
+
docker build -t myapp:audit .
|
|
159
|
+
trivy image myapp:audit --severity HIGH,CRITICAL
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
**Critical Dockerfile security checks:**
|
|
163
|
+
```dockerfile
|
|
164
|
+
# BAD
|
|
165
|
+
FROM ubuntu:latest
|
|
166
|
+
RUN curl -fsSL https://example.com/install.sh | bash
|
|
167
|
+
ENV DB_PASSWORD=secretpassword123
|
|
168
|
+
COPY . .
|
|
169
|
+
CMD ["npm", "start"]
|
|
170
|
+
|
|
171
|
+
# GOOD
|
|
172
|
+
FROM node:20-alpine@sha256:PINNED_HASH
|
|
173
|
+
USER node
|
|
174
|
+
COPY --chown=node:node package*.json ./
|
|
175
|
+
RUN npm ci --only=production
|
|
176
|
+
COPY --chown=node:node src/ ./src/
|
|
177
|
+
CMD ["node", "src/index.js"]
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Step 5: Generate Actionable Report
|
|
181
|
+
|
|
182
|
+
```markdown
|
|
183
|
+
# Security Audit Report
|
|
184
|
+
|
|
185
|
+
**Date:** [timestamp]
|
|
186
|
+
**Scope:** [repository name, branch, version]
|
|
187
|
+
**Tools:** gitleaks v8, trivy v0.48, bandit v1.7, semgrep v1.50
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Executive Summary
|
|
192
|
+
|
|
193
|
+
| Severity | Count | Status |
|
|
194
|
+
|----------|-------|--------|
|
|
195
|
+
| Critical | 0 | ✅ None found |
|
|
196
|
+
| High | 3 | ⚠️ Action required |
|
|
197
|
+
| Medium | 7 | ℹ️ Review recommended |
|
|
198
|
+
| Low | 12 | — Informational |
|
|
199
|
+
| Secrets | 0 | ✅ None found |
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Critical Findings (Fix Before Deploy)
|
|
204
|
+
|
|
205
|
+
[None]
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## High Findings (Fix This Sprint)
|
|
210
|
+
|
|
211
|
+
### H1: CVE-2024-XXXXX in lodash@4.17.20
|
|
212
|
+
- **Tool:** npm audit
|
|
213
|
+
- **Severity:** High (CVSS 7.5)
|
|
214
|
+
- **Description:** Prototype pollution vulnerability
|
|
215
|
+
- **Affected:** `node_modules/lodash`
|
|
216
|
+
- **Fix:** `npm install lodash@4.17.21`
|
|
217
|
+
- **Effort:** 15 min
|
|
218
|
+
|
|
219
|
+
### H2: Running as root in production container
|
|
220
|
+
- **Tool:** trivy config
|
|
221
|
+
- **Severity:** High
|
|
222
|
+
- **Description:** Dockerfile has no USER directive — container runs as root
|
|
223
|
+
- **Fix:** Add `USER node` before CMD
|
|
224
|
+
- **Effort:** 5 min
|
|
225
|
+
|
|
226
|
+
### H3: Hardcoded development credential
|
|
227
|
+
- **Tool:** bandit B105
|
|
228
|
+
- **Severity:** High
|
|
229
|
+
- **File:** `src/config/defaults.py:47`
|
|
230
|
+
- **Description:** Default password `"dev_password_123"` in production config path
|
|
231
|
+
- **Fix:** Remove default; require explicit environment variable
|
|
232
|
+
- **Effort:** 20 min
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## Medium Findings (Fix This Month)
|
|
237
|
+
|
|
238
|
+
[...]
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## Remediation Priority
|
|
243
|
+
|
|
244
|
+
1. H3 (hardcoded credential) — rotate first, fix second
|
|
245
|
+
2. H1 (lodash CVE) — `npm install lodash@4.17.21`
|
|
246
|
+
3. H2 (root container) — add USER directive
|
|
247
|
+
|
|
248
|
+
**Estimated total remediation time:** 40 min
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Step 6: Fix and Verify
|
|
252
|
+
|
|
253
|
+
For each finding in priority order:
|
|
254
|
+
|
|
255
|
+
1. Fix the issue (specific code change or dependency update)
|
|
256
|
+
2. Re-run the specific scan that found it
|
|
257
|
+
3. Verify the finding is gone
|
|
258
|
+
4. Add to regression prevention (pre-commit hook, CI gate, or code review checklist)
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
# After fixing all High findings, re-run full suite to verify
|
|
262
|
+
gitleaks detect --no-git --source .
|
|
263
|
+
npm audit --audit-level=high
|
|
264
|
+
trivy fs . --severity HIGH,CRITICAL
|
|
265
|
+
bandit -r src/ -ll
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
## ClawPowers Enhancement
|
|
269
|
+
|
|
270
|
+
When `~/.clawpowers/` runtime is initialized:
|
|
271
|
+
|
|
272
|
+
**Historical Vulnerability Tracking:**
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
bash runtime/persistence/store.sh set "audit:$(date +%Y%m%d):critical" "0"
|
|
276
|
+
bash runtime/persistence/store.sh set "audit:$(date +%Y%m%d):high" "3"
|
|
277
|
+
bash runtime/persistence/store.sh set "audit:$(date +%Y%m%d):secrets" "0"
|
|
278
|
+
bash runtime/persistence/store.sh set "audit:$(date +%Y%m%d):tools" "gitleaks,trivy,bandit,semgrep"
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
**Trend Analysis:**
|
|
282
|
+
|
|
283
|
+
`runtime/feedback/analyze.sh` tracks:
|
|
284
|
+
- Vulnerability count over time (is your security posture improving?)
|
|
285
|
+
- Most common finding types (what to add to code review checklists)
|
|
286
|
+
- Fix rate and time (how quickly are findings remediated)
|
|
287
|
+
- Repeat findings (findings that recur indicate a systemic issue)
|
|
288
|
+
|
|
289
|
+
**Automated Report Generation:**
|
|
290
|
+
|
|
291
|
+
```bash
|
|
292
|
+
bash runtime/metrics/collector.sh record \
|
|
293
|
+
--skill security-audit \
|
|
294
|
+
--outcome success \
|
|
295
|
+
--notes "audit: 0 critical, 3 high, 7 medium — lodash CVE, root container, hardcoded default"
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
## Anti-Patterns
|
|
299
|
+
|
|
300
|
+
| Anti-Pattern | Why It Fails | Correct Approach |
|
|
301
|
+
|-------------|-------------|-----------------|
|
|
302
|
+
| Scanning only current HEAD | Misses secrets in history | `gitleaks detect --source .` scans full history |
|
|
303
|
+
| Dismissing medium findings as "not urgent" | Medium findings compound into exploitable chains | Review all medium findings; schedule fixes |
|
|
304
|
+
| Not rotating leaked secrets | Rotated-but-historical secrets are still active | Rotate at the source, not just in code |
|
|
305
|
+
| Suppressing all bandit warnings | Masks real issues | Suppress only proven false positives, with comment |
|
|
306
|
+
| No regression prevention | Same vulnerability reappears | Add findings to pre-commit hooks or CI gates |
|
|
307
|
+
| Scanning without context | False positives waste time | Run tools in repo root with proper config files |
|
|
308
|
+
| Fixing without re-scanning | Fix may be incomplete or introduce new issue | Re-run full scan after every remediation |
|