codingbuddy-rules 4.2.0 → 4.4.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/.ai-rules/adapters/antigravity.md +648 -160
- package/.ai-rules/adapters/codex.md +500 -10
- package/.ai-rules/adapters/cursor.md +252 -8
- package/.ai-rules/adapters/kiro.md +551 -93
- package/.ai-rules/adapters/opencode-skills.md +179 -188
- package/.ai-rules/adapters/opencode.md +251 -47
- package/.ai-rules/agents/README.md +179 -9
- package/.ai-rules/agents/act-mode.json +14 -7
- package/.ai-rules/agents/data-scientist.json +156 -0
- package/.ai-rules/agents/security-engineer.json +98 -0
- package/.ai-rules/agents/software-engineer.json +74 -0
- package/.ai-rules/agents/systems-developer.json +83 -0
- package/.ai-rules/agents/test-engineer.json +69 -0
- package/.ai-rules/skills/README.md +92 -24
- package/.ai-rules/skills/agent-design/SKILL.md +269 -0
- package/.ai-rules/skills/code-explanation/SKILL.md +259 -0
- package/.ai-rules/skills/context-management/SKILL.md +244 -0
- package/.ai-rules/skills/deployment-checklist/SKILL.md +233 -0
- package/.ai-rules/skills/documentation-generation/SKILL.md +293 -0
- package/.ai-rules/skills/error-analysis/SKILL.md +250 -0
- package/.ai-rules/skills/legacy-modernization/SKILL.md +292 -0
- package/.ai-rules/skills/mcp-builder/SKILL.md +356 -0
- package/.ai-rules/skills/prompt-engineering/SKILL.md +318 -0
- package/.ai-rules/skills/rule-authoring/SKILL.md +273 -0
- package/.ai-rules/skills/security-audit/SKILL.md +241 -0
- package/.ai-rules/skills/tech-debt/SKILL.md +224 -0
- package/package.json +1 -1
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rule-authoring
|
|
3
|
+
description: Use when writing AI coding rules for codingbuddy that must work consistently across multiple AI tools (Cursor, Claude Code, Codex, GitHub Copilot, Amazon Q, Kiro). Covers rule clarity, trigger design, and multi-tool compatibility.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Rule Authoring
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
AI coding rules are instructions that shape how AI assistants behave. Poorly written rules are ignored, misinterpreted, or cause inconsistent behavior across tools.
|
|
11
|
+
|
|
12
|
+
**Core principle:** Rules must be unambiguous, actionable, and testable. If an AI assistant can interpret a rule two different ways, it will choose the wrong one at the worst moment.
|
|
13
|
+
|
|
14
|
+
**Iron Law:**
|
|
15
|
+
```
|
|
16
|
+
EVERY RULE MUST HAVE A TESTABLE "DID IT WORK?" CRITERION
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## When to Use
|
|
20
|
+
|
|
21
|
+
- Writing new rules for `.ai-rules/rules/`
|
|
22
|
+
- Updating existing rules that produce inconsistent behavior
|
|
23
|
+
- Adapting rules for a new AI tool (cursor, codex, q, kiro)
|
|
24
|
+
- Auditing rules for ambiguity or overlap
|
|
25
|
+
|
|
26
|
+
## Rule Quality Criteria
|
|
27
|
+
|
|
28
|
+
A good rule is:
|
|
29
|
+
|
|
30
|
+
| Quality | Bad Example | Good Example |
|
|
31
|
+
|---------|-------------|--------------|
|
|
32
|
+
| **Specific** | "Write good code" | "Functions must have a single return type" |
|
|
33
|
+
| **Actionable** | "Be careful with auth" | "All endpoints must check authentication before executing" |
|
|
34
|
+
| **Testable** | "Follow best practices" | "Test coverage must be ≥ 80% for new files" |
|
|
35
|
+
| **Bounded** | "Always use TypeScript" | "Use TypeScript strict mode in all .ts files" |
|
|
36
|
+
| **Non-overlapping** | Two rules about the same thing | One rule per concern |
|
|
37
|
+
|
|
38
|
+
## Rule Structure
|
|
39
|
+
|
|
40
|
+
### Core Rule Format
|
|
41
|
+
|
|
42
|
+
```markdown
|
|
43
|
+
## [Rule Category]: [Rule Name]
|
|
44
|
+
|
|
45
|
+
**When:** [Trigger condition — when does this rule apply?]
|
|
46
|
+
|
|
47
|
+
**Do:** [Specific action to take]
|
|
48
|
+
|
|
49
|
+
**Don't:** [Specific anti-pattern to avoid]
|
|
50
|
+
|
|
51
|
+
**Example:**
|
|
52
|
+
\`\`\`typescript
|
|
53
|
+
// ✅ Good
|
|
54
|
+
function getUser(id: string): Promise<User>
|
|
55
|
+
|
|
56
|
+
// ❌ Bad
|
|
57
|
+
function getUser(id: any): any
|
|
58
|
+
\`\`\`
|
|
59
|
+
|
|
60
|
+
**Why:** [One-sentence rationale]
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Rule File Structure
|
|
64
|
+
|
|
65
|
+
```markdown
|
|
66
|
+
# [Category Name]
|
|
67
|
+
|
|
68
|
+
Brief description of what rules in this file govern.
|
|
69
|
+
|
|
70
|
+
## Rules
|
|
71
|
+
|
|
72
|
+
### Rule 1: [Name]
|
|
73
|
+
...
|
|
74
|
+
|
|
75
|
+
### Rule 2: [Name]
|
|
76
|
+
...
|
|
77
|
+
|
|
78
|
+
## Rationale
|
|
79
|
+
|
|
80
|
+
Why these rules exist for this project.
|
|
81
|
+
|
|
82
|
+
## Exceptions
|
|
83
|
+
|
|
84
|
+
Cases where these rules do not apply (keep this list short).
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Writing Process
|
|
88
|
+
|
|
89
|
+
### Phase 1: Identify the Rule Need
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
1. What behavior is inconsistent or incorrect?
|
|
93
|
+
→ "AI assistants sometimes use 'any' type in TypeScript"
|
|
94
|
+
|
|
95
|
+
2. What is the desired behavior?
|
|
96
|
+
→ "All variables must have explicit types"
|
|
97
|
+
|
|
98
|
+
3. What is the trigger condition?
|
|
99
|
+
→ "When writing TypeScript code"
|
|
100
|
+
|
|
101
|
+
4. Can an AI verify compliance?
|
|
102
|
+
→ "Yes: TypeScript compiler will error on 'any' in strict mode"
|
|
103
|
+
|
|
104
|
+
5. Is there already a rule covering this?
|
|
105
|
+
→ Check existing rules in .ai-rules/rules/
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Phase 2: Write the Rule
|
|
109
|
+
|
|
110
|
+
**Template:**
|
|
111
|
+
```markdown
|
|
112
|
+
### [Rule Name]
|
|
113
|
+
|
|
114
|
+
**When:** [Specific trigger condition]
|
|
115
|
+
|
|
116
|
+
**Do:** [Concrete action in imperative mood]
|
|
117
|
+
|
|
118
|
+
**Don't:** [Specific anti-pattern]
|
|
119
|
+
|
|
120
|
+
**Check:** [How to verify the rule was followed]
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**Good examples:**
|
|
124
|
+
```markdown
|
|
125
|
+
### No `any` Type
|
|
126
|
+
|
|
127
|
+
**When:** Writing TypeScript code
|
|
128
|
+
|
|
129
|
+
**Do:** Always specify explicit types for function parameters and return values
|
|
130
|
+
|
|
131
|
+
**Don't:** Use `any` type — use `unknown` for truly unknown types, then narrow
|
|
132
|
+
|
|
133
|
+
**Check:** TypeScript compiler passes with `noImplicitAny: true` in tsconfig
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
### Test Before Implement (TDD)
|
|
138
|
+
|
|
139
|
+
**When:** Implementing a new function or feature
|
|
140
|
+
|
|
141
|
+
**Do:** Write the failing test first, then write minimal implementation to pass it
|
|
142
|
+
|
|
143
|
+
**Don't:** Write implementation first and add tests after
|
|
144
|
+
|
|
145
|
+
**Check:** Running tests shows RED (failure) before GREEN (pass)
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Phase 3: Test Multi-Tool Compatibility
|
|
149
|
+
|
|
150
|
+
Different AI tools parse rules differently. Test your rules with each tool:
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
Compatibility checklist for each new rule:
|
|
154
|
+
|
|
155
|
+
Claude Code:
|
|
156
|
+
- [ ] Rule triggers correctly from CLAUDE.md or custom-instructions.md
|
|
157
|
+
- [ ] Rule doesn't conflict with default Claude behavior
|
|
158
|
+
|
|
159
|
+
Cursor:
|
|
160
|
+
- [ ] Rule works in .cursorrules or .cursor/rules/
|
|
161
|
+
- [ ] Pattern matching works as expected
|
|
162
|
+
|
|
163
|
+
GitHub Copilot / Codex:
|
|
164
|
+
- [ ] Rule understandable from .github/copilot-instructions.md
|
|
165
|
+
- [ ] No Copilot-specific syntax required
|
|
166
|
+
|
|
167
|
+
Amazon Q:
|
|
168
|
+
- [ ] Compatible with .q/rules/ format
|
|
169
|
+
|
|
170
|
+
Kiro:
|
|
171
|
+
- [ ] Compatible with .kiro/ format
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Phase 4: Anti-Ambiguity Review
|
|
175
|
+
|
|
176
|
+
Read each rule and ask: "Could this be interpreted two different ways?"
|
|
177
|
+
|
|
178
|
+
**Ambiguity red flags:**
|
|
179
|
+
```
|
|
180
|
+
❌ "appropriate" → What's appropriate? Define it.
|
|
181
|
+
❌ "when necessary" → When is that? Specify the condition.
|
|
182
|
+
❌ "best practices" → Which ones? List them.
|
|
183
|
+
❌ "avoid" → How strongly? Use "never" or "prefer X over Y".
|
|
184
|
+
❌ "clean code" → What does clean mean? Measurable criteria only.
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
**Ambiguity fixes:**
|
|
188
|
+
```
|
|
189
|
+
❌ "Use appropriate error handling"
|
|
190
|
+
✅ "Catch specific error types, never catch Exception or Error base class"
|
|
191
|
+
|
|
192
|
+
❌ "Write clean functions"
|
|
193
|
+
✅ "Functions must be ≤ 30 lines and have a single return type"
|
|
194
|
+
|
|
195
|
+
❌ "When necessary, add comments"
|
|
196
|
+
✅ "Add comments only for non-obvious logic. Self-documenting code needs no comments."
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## Rule Categories
|
|
200
|
+
|
|
201
|
+
| Category | File | Covers |
|
|
202
|
+
|----------|------|--------|
|
|
203
|
+
| Core workflow | `rules/core.md` | PLAN/ACT/EVAL modes, TDD |
|
|
204
|
+
| Project | `rules/project.md` | Tech stack, architecture |
|
|
205
|
+
| Augmented coding | `rules/augmented-coding.md` | Code quality, testing |
|
|
206
|
+
|
|
207
|
+
## Adapter-Specific Formatting
|
|
208
|
+
|
|
209
|
+
### Claude Code (`adapters/claude-code.md`)
|
|
210
|
+
|
|
211
|
+
```markdown
|
|
212
|
+
## Claude Code Specific Rules
|
|
213
|
+
|
|
214
|
+
- Use `parse_mode` for PLAN/ACT/EVAL detection
|
|
215
|
+
- Follow `dispatch_agents` pattern for parallel agents
|
|
216
|
+
- Context persists via `docs/codingbuddy/context.md`
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Cursor (`adapters/cursor.md`)
|
|
220
|
+
|
|
221
|
+
```markdown
|
|
222
|
+
## Cursor-Specific Rules
|
|
223
|
+
|
|
224
|
+
Rules in `.cursorrules` are parsed line-by-line.
|
|
225
|
+
Keep rules to one line each for Cursor compatibility.
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Codex (`adapters/codex.md`)
|
|
229
|
+
|
|
230
|
+
```markdown
|
|
231
|
+
## GitHub Copilot / Codex Rules
|
|
232
|
+
|
|
233
|
+
Place in `.github/copilot-instructions.md`.
|
|
234
|
+
Copilot prefers explicit examples over abstract rules.
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## Rule Maintenance
|
|
238
|
+
|
|
239
|
+
### Auditing Existing Rules
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
# Find rules that haven't been updated recently
|
|
243
|
+
git log --since="6 months ago" -- packages/rules/.ai-rules/rules/
|
|
244
|
+
|
|
245
|
+
# Find duplicate rule concepts
|
|
246
|
+
grep -h "^###" packages/rules/.ai-rules/rules/*.md | sort | uniq -d
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
**Quarterly audit questions:**
|
|
250
|
+
1. Is this rule still relevant to our current stack?
|
|
251
|
+
2. Is this rule being followed consistently?
|
|
252
|
+
3. Does this rule conflict with any new tool defaults?
|
|
253
|
+
4. Are there new patterns that need new rules?
|
|
254
|
+
|
|
255
|
+
## Quick Reference
|
|
256
|
+
|
|
257
|
+
```
|
|
258
|
+
Rule Strength Vocabulary:
|
|
259
|
+
─────────────────────────
|
|
260
|
+
MUST / ALWAYS → Required, no exceptions
|
|
261
|
+
SHOULD / PREFER → Default behavior, exceptions allowed
|
|
262
|
+
AVOID / PREFER NOT → Discouraged, explain if used
|
|
263
|
+
NEVER / MUST NOT → Prohibited
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
## Red Flags — STOP
|
|
267
|
+
|
|
268
|
+
| Thought | Reality |
|
|
269
|
+
|---------|---------|
|
|
270
|
+
| "This rule is obvious" | Write it anyway — different AI tools need explicit guidance |
|
|
271
|
+
| "The existing rule covers this" | Check carefully — overlap causes conflicts |
|
|
272
|
+
| "Rules don't need testing" | Test with each target AI tool |
|
|
273
|
+
| "Abstract rules are more flexible" | Abstract rules are ignored or misapplied |
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: security-audit
|
|
3
|
+
description: Use when reviewing code for security vulnerabilities, before shipping features, or conducting security assessments. Covers OWASP Top 10, secrets exposure, authentication, and authorization flaws.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Security Audit
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Security vulnerabilities are invisible until exploited. This skill provides a systematic approach to finding them before attackers do.
|
|
11
|
+
|
|
12
|
+
**Core principle:** ASSUME BREACH. Review every input, every output, every boundary.
|
|
13
|
+
|
|
14
|
+
**Iron Law:**
|
|
15
|
+
```
|
|
16
|
+
NO SECURITY REVIEW WITHOUT THREAT MODELING FIRST
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## When to Use
|
|
20
|
+
|
|
21
|
+
- Before merging any authentication or authorization code
|
|
22
|
+
- Before shipping features that handle user data
|
|
23
|
+
- When adding third-party dependencies
|
|
24
|
+
- After environment variable / secrets changes
|
|
25
|
+
- Periodic security sweeps on production code
|
|
26
|
+
- Reviewing MCP server endpoints (especially SSE/HTTP transport)
|
|
27
|
+
|
|
28
|
+
## The Four Phases
|
|
29
|
+
|
|
30
|
+
### Phase 1: Threat Modeling
|
|
31
|
+
|
|
32
|
+
**Before reviewing any code:**
|
|
33
|
+
|
|
34
|
+
1. **Identify Assets** — What are we protecting? (user data, tokens, credentials, business logic)
|
|
35
|
+
2. **Identify Attack Surfaces** — HTTP endpoints, file uploads, environment vars, third-party integrations
|
|
36
|
+
3. **Identify Threat Actors** — External attackers, malicious insiders, compromised dependencies
|
|
37
|
+
4. **Map Data Flow** — Where does sensitive data enter, travel, and exit?
|
|
38
|
+
|
|
39
|
+
### Phase 2: OWASP Top 10 Checklist
|
|
40
|
+
|
|
41
|
+
Work through each category systematically:
|
|
42
|
+
|
|
43
|
+
#### A01: Broken Access Control
|
|
44
|
+
```
|
|
45
|
+
- [ ] Every endpoint checks authentication
|
|
46
|
+
- [ ] Authorization verified per-resource, not just per-route
|
|
47
|
+
- [ ] IDOR: Can user A access user B's data by changing ID?
|
|
48
|
+
- [ ] Admin routes protected from regular users
|
|
49
|
+
- [ ] CORS policy restricts allowed origins
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
#### A02: Cryptographic Failures
|
|
53
|
+
```
|
|
54
|
+
- [ ] No plaintext passwords stored
|
|
55
|
+
- [ ] Sensitive data encrypted at rest (PII, tokens, keys)
|
|
56
|
+
- [ ] TLS enforced for all connections
|
|
57
|
+
- [ ] Weak algorithms absent (MD5, SHA1 for passwords, DES)
|
|
58
|
+
- [ ] Secrets not in code, logs, or URLs
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
#### A03: Injection
|
|
62
|
+
```sql
|
|
63
|
+
-- ❌ SQL Injection vulnerable
|
|
64
|
+
db.query(`SELECT * FROM users WHERE id = ${userId}`);
|
|
65
|
+
|
|
66
|
+
-- ✅ Parameterized
|
|
67
|
+
db.query('SELECT * FROM users WHERE id = ?', [userId]);
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
// ❌ Command Injection
|
|
72
|
+
exec(`ls ${userInput}`);
|
|
73
|
+
|
|
74
|
+
// ✅ Safe
|
|
75
|
+
execFile('ls', [userInput]);
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
// ❌ XSS
|
|
80
|
+
element.innerHTML = userInput;
|
|
81
|
+
|
|
82
|
+
// ✅ Safe
|
|
83
|
+
element.textContent = userInput;
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
#### A04: Insecure Design
|
|
87
|
+
```
|
|
88
|
+
- [ ] Rate limiting on sensitive endpoints (login, password reset)
|
|
89
|
+
- [ ] Account lockout after failed attempts
|
|
90
|
+
- [ ] Password reset tokens expire (< 15 minutes)
|
|
91
|
+
- [ ] Sensitive operations require re-authentication
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
#### A05: Security Misconfiguration
|
|
95
|
+
```
|
|
96
|
+
- [ ] Debug mode disabled in production
|
|
97
|
+
- [ ] Default credentials changed
|
|
98
|
+
- [ ] Unnecessary features/endpoints disabled
|
|
99
|
+
- [ ] Security headers present (CSP, HSTS, X-Frame-Options)
|
|
100
|
+
- [ ] Error messages don't expose stack traces to users
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
#### A06: Vulnerable Components
|
|
104
|
+
```bash
|
|
105
|
+
# Check for known CVEs
|
|
106
|
+
npm audit
|
|
107
|
+
yarn audit
|
|
108
|
+
|
|
109
|
+
# Check for outdated packages with vulnerabilities
|
|
110
|
+
npx audit-ci --moderate
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
#### A07: Authentication Failures
|
|
114
|
+
```
|
|
115
|
+
- [ ] Session IDs invalidated on logout
|
|
116
|
+
- [ ] JWT secrets sufficiently random (>= 256 bits)
|
|
117
|
+
- [ ] JWT expiry set appropriately (access: minutes, refresh: days)
|
|
118
|
+
- [ ] Brute force protection on login
|
|
119
|
+
- [ ] Multi-factor authentication available for sensitive actions
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
#### A08: Software Integrity Failures
|
|
123
|
+
```
|
|
124
|
+
- [ ] Dependencies pinned to exact versions
|
|
125
|
+
- [ ] Subresource integrity (SRI) for CDN assets
|
|
126
|
+
- [ ] CI/CD pipeline secured (no untrusted code execution)
|
|
127
|
+
- [ ] Package signatures verified where possible
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
#### A09: Logging Failures
|
|
131
|
+
```
|
|
132
|
+
- [ ] Authentication events logged (success + failure)
|
|
133
|
+
- [ ] Authorization failures logged
|
|
134
|
+
- [ ] No sensitive data (passwords, tokens, PII) in logs
|
|
135
|
+
- [ ] Log tampering prevented
|
|
136
|
+
- [ ] Alerts set for suspicious patterns
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
#### A10: Server-Side Request Forgery (SSRF)
|
|
140
|
+
```
|
|
141
|
+
- [ ] User-supplied URLs validated against allowlist
|
|
142
|
+
- [ ] Internal network addresses blocked from user input
|
|
143
|
+
- [ ] DNS rebinding protection
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Phase 3: Secrets & Credentials Scan
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
# Scan for hardcoded secrets
|
|
150
|
+
grep -rn "password\|secret\|token\|api_key\|apikey\|private_key" \
|
|
151
|
+
--include="*.ts" --include="*.js" --include="*.env*" \
|
|
152
|
+
--exclude-dir=node_modules .
|
|
153
|
+
|
|
154
|
+
# Check .gitignore covers sensitive files
|
|
155
|
+
cat .gitignore | grep -E "\.env|\.key|credentials"
|
|
156
|
+
|
|
157
|
+
# Verify no secrets in git history
|
|
158
|
+
git log --all --full-history -- "*.env" "*.key" "credentials*"
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
**Common secret patterns to find:**
|
|
162
|
+
```
|
|
163
|
+
❌ const API_KEY = "sk-abc123..."
|
|
164
|
+
❌ password: "admin123"
|
|
165
|
+
❌ Authorization: "Bearer eyJ..." (hardcoded)
|
|
166
|
+
❌ connectionString = "mongodb://user:pass@host"
|
|
167
|
+
|
|
168
|
+
✅ const API_KEY = process.env.API_KEY
|
|
169
|
+
✅ password: process.env.DB_PASSWORD
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Phase 4: MCP Server Specific (codingbuddy)
|
|
173
|
+
|
|
174
|
+
For MCP servers using SSE/HTTP transport:
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
// ❌ No authentication
|
|
178
|
+
app.use('/sse', sseHandler);
|
|
179
|
+
|
|
180
|
+
// ✅ Bearer token validation
|
|
181
|
+
app.use('/sse', (req, res, next) => {
|
|
182
|
+
const token = req.headers.authorization?.replace('Bearer ', '');
|
|
183
|
+
if (process.env.MCP_SSE_TOKEN && token !== process.env.MCP_SSE_TOKEN) {
|
|
184
|
+
return res.status(401).json({ error: 'Unauthorized' });
|
|
185
|
+
}
|
|
186
|
+
next();
|
|
187
|
+
});
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
```
|
|
191
|
+
- [ ] SSE endpoint authenticates when MCP_SSE_TOKEN is set
|
|
192
|
+
- [ ] CORS configured for trusted origins only
|
|
193
|
+
- [ ] Rate limiting on MCP tool calls
|
|
194
|
+
- [ ] Input validation on all tool parameters
|
|
195
|
+
- [ ] No sensitive data in MCP resource URIs
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Red Flags — STOP
|
|
199
|
+
|
|
200
|
+
| Thought | Reality |
|
|
201
|
+
|---------|---------|
|
|
202
|
+
| "We're not a target" | Every internet-facing system is a target |
|
|
203
|
+
| "This is internal only" | Insider threats are real; internal ≠ trusted |
|
|
204
|
+
| "The framework handles it" | Frameworks have defaults that must be configured |
|
|
205
|
+
| "We'll add security later" | Retrofitting security costs 10× more |
|
|
206
|
+
| "Tests don't cover security" | Security requires dedicated review, not just tests |
|
|
207
|
+
|
|
208
|
+
## Quick Reference
|
|
209
|
+
|
|
210
|
+
| Category | Check | Tool |
|
|
211
|
+
|----------|-------|------|
|
|
212
|
+
| Dependencies | CVE scan | `npm audit` |
|
|
213
|
+
| Secrets | Hardcoded creds | grep + git-secrets |
|
|
214
|
+
| Injection | SQL, XSS, Command | Manual + ESLint |
|
|
215
|
+
| Auth | JWT, sessions | Manual review |
|
|
216
|
+
| Headers | CSP, HSTS | securityheaders.com |
|
|
217
|
+
| OWASP | Top 10 | ZAP, Burp Suite |
|
|
218
|
+
|
|
219
|
+
## Output Format
|
|
220
|
+
|
|
221
|
+
Document findings as:
|
|
222
|
+
|
|
223
|
+
```markdown
|
|
224
|
+
## Security Audit Report — YYYY-MM-DD
|
|
225
|
+
|
|
226
|
+
### Critical (fix before deploy)
|
|
227
|
+
- [ ] SQL injection in /api/users endpoint (line 42, users.service.ts)
|
|
228
|
+
|
|
229
|
+
### High (fix within 24h)
|
|
230
|
+
- [ ] JWT secret too short (< 256 bits)
|
|
231
|
+
|
|
232
|
+
### Medium (fix this sprint)
|
|
233
|
+
- [ ] Missing rate limiting on /auth/login
|
|
234
|
+
|
|
235
|
+
### Low (backlog)
|
|
236
|
+
- [ ] Verbose error messages in development mode
|
|
237
|
+
|
|
238
|
+
### Passed Checks
|
|
239
|
+
- [x] No hardcoded secrets found
|
|
240
|
+
- [x] All endpoints require authentication
|
|
241
|
+
```
|