@codeharbor/agent-playbook 0.1.0 → 0.1.2
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/README.md +4 -2
- package/package.json +5 -2
- package/skills/api-designer/README.md +36 -0
- package/skills/api-designer/SKILL.md +232 -0
- package/skills/api-designer/references/graphql-patterns.md +12 -0
- package/skills/api-designer/references/rest-patterns.md +17 -0
- package/skills/api-designer/scripts/generate_api.py +87 -0
- package/skills/api-designer/scripts/validate_api.py +48 -0
- package/skills/api-documenter/README.md +41 -0
- package/skills/api-documenter/SKILL.md +209 -0
- package/skills/api-documenter/references/examples/README.md +3 -0
- package/skills/api-documenter/references/examples/openapi-example.yaml +10 -0
- package/skills/api-documenter/references/openapi-template.yaml +5 -0
- package/skills/api-documenter/scripts/generate_openapi.py +84 -0
- package/skills/api-documenter/scripts/validate_openapi.py +45 -0
- package/skills/architecting-solutions/README.md +22 -0
- package/skills/architecting-solutions/SKILL.md +459 -0
- package/skills/auto-trigger/README.md +23 -0
- package/skills/auto-trigger/SKILL.md +183 -0
- package/skills/code-reviewer/README.md +59 -0
- package/skills/code-reviewer/SKILL.md +220 -0
- package/skills/code-reviewer/references/checklist.md +80 -0
- package/skills/code-reviewer/references/patterns.md +226 -0
- package/skills/code-reviewer/references/security.md +88 -0
- package/skills/code-reviewer/scripts/review_checklist.py +191 -0
- package/skills/commit-helper/README.md +58 -0
- package/skills/commit-helper/SKILL.md +159 -0
- package/skills/commit-helper/references/conventional-commits.md +68 -0
- package/skills/commit-helper/references/examples.md +125 -0
- package/skills/commit-helper/references/scopes.md +49 -0
- package/skills/commit-helper/scripts/validate_commit.py +70 -0
- package/skills/create-pr/README.md +182 -0
- package/skills/create-pr/SKILL.md +340 -0
- package/skills/debugger/README.md +53 -0
- package/skills/debugger/SKILL.md +239 -0
- package/skills/debugger/references/checklist.md +7 -0
- package/skills/debugger/references/errors.md +6 -0
- package/skills/debugger/references/patterns.md +5 -0
- package/skills/debugger/scripts/debug_report.py +77 -0
- package/skills/deployment-engineer/README.md +40 -0
- package/skills/deployment-engineer/SKILL.md +242 -0
- package/skills/deployment-engineer/references/kubernetes.md +23 -0
- package/skills/deployment-engineer/references/monitoring.md +14 -0
- package/skills/deployment-engineer/references/pipelines.md +12 -0
- package/skills/deployment-engineer/scripts/generate_deploy.py +72 -0
- package/skills/deployment-engineer/scripts/validate_deploy.py +46 -0
- package/skills/documentation-engineer/README.md +41 -0
- package/skills/documentation-engineer/SKILL.md +164 -0
- package/skills/documentation-engineer/references/api-template.md +22 -0
- package/skills/documentation-engineer/references/readme-template.md +25 -0
- package/skills/documentation-engineer/references/style-guide.md +13 -0
- package/skills/documentation-engineer/scripts/generate_docs.py +68 -0
- package/skills/documentation-engineer/scripts/validate_docs.py +46 -0
- package/skills/figma-designer/README.md +222 -0
- package/skills/figma-designer/SKILL.md +407 -0
- package/skills/figma-designer/references/example-output.md +86 -0
- package/skills/performance-engineer/README.md +42 -0
- package/skills/performance-engineer/SKILL.md +236 -0
- package/skills/performance-engineer/references/checklist.md +6 -0
- package/skills/performance-engineer/references/monitoring.md +5 -0
- package/skills/performance-engineer/references/optimization.md +7 -0
- package/skills/performance-engineer/scripts/perf_report.py +64 -0
- package/skills/performance-engineer/scripts/profile.py +63 -0
- package/skills/planning-with-files/README.md +27 -0
- package/skills/planning-with-files/SKILL.md +103 -0
- package/skills/prd-implementation-precheck/README.md +97 -0
- package/skills/prd-implementation-precheck/SKILL.md +112 -0
- package/skills/prd-planner/README.md +102 -0
- package/skills/prd-planner/SKILL.md +449 -0
- package/skills/prd-planner/references/edge-case-analysis.md +111 -0
- package/skills/qa-expert/README.md +37 -0
- package/skills/qa-expert/SKILL.md +225 -0
- package/skills/qa-expert/references/gates.md +11 -0
- package/skills/qa-expert/references/metrics.md +6 -0
- package/skills/qa-expert/references/strategy.md +11 -0
- package/skills/qa-expert/scripts/coverage_analysis.py +61 -0
- package/skills/qa-expert/scripts/generate_test_plan.py +68 -0
- package/skills/refactoring-specialist/README.md +37 -0
- package/skills/refactoring-specialist/SKILL.md +283 -0
- package/skills/refactoring-specialist/references/checklist.md +6 -0
- package/skills/refactoring-specialist/references/smells.md +6 -0
- package/skills/refactoring-specialist/references/techniques.md +6 -0
- package/skills/security-auditor/README.md +48 -0
- package/skills/security-auditor/SKILL.md +256 -0
- package/skills/security-auditor/references/checklist.md +7 -0
- package/skills/security-auditor/references/owasp.md +12 -0
- package/skills/security-auditor/references/remediation.md +7 -0
- package/skills/security-auditor/scripts/find_secrets.py +58 -0
- package/skills/security-auditor/scripts/security_audit.py +64 -0
- package/skills/self-improving-agent/README.md +136 -0
- package/skills/self-improving-agent/SKILL.md +407 -0
- package/skills/self-improving-agent/hooks/post-bash.sh +10 -0
- package/skills/self-improving-agent/hooks/pre-tool.sh +10 -0
- package/skills/self-improving-agent/hooks/session-end.sh +4 -0
- package/skills/self-improving-agent/memory/semantic-patterns.json +288 -0
- package/skills/self-improving-agent/references/appendix.md +131 -0
- package/skills/self-improving-agent/templates/correction-template.md +11 -0
- package/skills/self-improving-agent/templates/pattern-template.md +15 -0
- package/skills/self-improving-agent/templates/validation-template.md +14 -0
- package/skills/session-logger/README.md +50 -0
- package/skills/session-logger/SKILL.md +156 -0
- package/skills/skill-router/README.md +155 -0
- package/skills/skill-router/SKILL.md +215 -0
- package/skills/test-automator/README.md +41 -0
- package/skills/test-automator/SKILL.md +202 -0
- package/skills/test-automator/references/best-practices.md +6 -0
- package/skills/test-automator/references/examples/README.md +3 -0
- package/skills/test-automator/references/examples/unit-test-example.md +8 -0
- package/skills/test-automator/references/mocking.md +5 -0
- package/skills/test-automator/scripts/coverage_report.py +59 -0
- package/skills/test-automator/scripts/generate_test.py +66 -0
- package/skills/workflow-orchestrator/README.md +20 -0
- package/skills/workflow-orchestrator/SKILL.md +342 -0
- package/src/cli.js +107 -20
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: refactoring-specialist
|
|
3
|
+
description: Code refactoring expert for improving code structure, readability, and maintainability. Use when user asks to refactor, clean up, or improve code quality.
|
|
4
|
+
allowed-tools: Read, Write, Edit, Bash, Grep, Glob
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Refactoring Specialist
|
|
8
|
+
|
|
9
|
+
Expert guidance on refactoring code to improve structure, readability, and maintainability while preserving functionality.
|
|
10
|
+
|
|
11
|
+
## When This Skill Activates
|
|
12
|
+
|
|
13
|
+
Activates when you:
|
|
14
|
+
- Ask to refactor code
|
|
15
|
+
- Request cleanup or improvement
|
|
16
|
+
- Mention "technical debt" or "code smell"
|
|
17
|
+
- Want to improve code quality
|
|
18
|
+
|
|
19
|
+
## Refactoring Principles
|
|
20
|
+
|
|
21
|
+
1. **Preserve Behavior**: Refactoring must not change external behavior
|
|
22
|
+
2. **Small Steps**: Make small, incremental changes
|
|
23
|
+
3. **Test Coverage**: Ensure tests pass before and after
|
|
24
|
+
4. **Commit Often**: Commit after each successful refactoring
|
|
25
|
+
|
|
26
|
+
## Code Smells to Address
|
|
27
|
+
|
|
28
|
+
### 1. Long Method
|
|
29
|
+
**Symptom:** Function > 20-30 lines
|
|
30
|
+
|
|
31
|
+
**Refactoring:** Extract Method
|
|
32
|
+
```typescript
|
|
33
|
+
// Before:
|
|
34
|
+
function processOrder(order) {
|
|
35
|
+
// 50 lines of code
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// After:
|
|
39
|
+
function processOrder(order) {
|
|
40
|
+
validateOrder(order);
|
|
41
|
+
calculateTotals(order);
|
|
42
|
+
saveOrder(order);
|
|
43
|
+
sendConfirmation(order);
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 2. Duplicate Code
|
|
48
|
+
**Symptom:** Similar code in multiple places
|
|
49
|
+
|
|
50
|
+
**Refactoring:** Extract Method / Template Method
|
|
51
|
+
```typescript
|
|
52
|
+
// Before:
|
|
53
|
+
class UserService {
|
|
54
|
+
async validateEmail(email) {
|
|
55
|
+
if (!email || !email.includes('@')) return false;
|
|
56
|
+
const domain = email.split('@')[1];
|
|
57
|
+
return domain.length > 0;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
class AdminService {
|
|
61
|
+
async validateEmail(email) {
|
|
62
|
+
if (!email || !email.includes('@')) return false;
|
|
63
|
+
const domain = email.split('@')[1];
|
|
64
|
+
return domain.length > 0;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// After:
|
|
69
|
+
class EmailValidator {
|
|
70
|
+
async validate(email) {
|
|
71
|
+
if (!email || !email.includes('@')) return false;
|
|
72
|
+
return email.split('@')[1].length > 0;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 3. Large Class
|
|
78
|
+
**Symptom:** Class doing too many things
|
|
79
|
+
|
|
80
|
+
**Refactoring:** Extract Class
|
|
81
|
+
```typescript
|
|
82
|
+
// Before:
|
|
83
|
+
class User {
|
|
84
|
+
// Authentication
|
|
85
|
+
// Profile management
|
|
86
|
+
// Notifications
|
|
87
|
+
// Reporting
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// After:
|
|
91
|
+
class User { /* Core user data */ }
|
|
92
|
+
class UserAuth { /* Authentication */ }
|
|
93
|
+
class UserProfile { /* Profile management */ }
|
|
94
|
+
class UserNotifier { /* Notifications */ }
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### 4. Long Parameter List
|
|
98
|
+
**Symptom:** Function with 4+ parameters
|
|
99
|
+
|
|
100
|
+
**Refactoring:** Introduce Parameter Object
|
|
101
|
+
```typescript
|
|
102
|
+
// Before:
|
|
103
|
+
function createUser(name, email, age, address, phone, role) { ... }
|
|
104
|
+
|
|
105
|
+
// After:
|
|
106
|
+
function createUser(user: UserData) { ... }
|
|
107
|
+
|
|
108
|
+
interface UserData {
|
|
109
|
+
name: string;
|
|
110
|
+
email: string;
|
|
111
|
+
age: number;
|
|
112
|
+
address: string;
|
|
113
|
+
phone: string;
|
|
114
|
+
role: string;
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### 5. Feature Envy
|
|
119
|
+
**Symptom:** Method uses more data from other classes
|
|
120
|
+
|
|
121
|
+
**Refactoring:** Move Method
|
|
122
|
+
```typescript
|
|
123
|
+
// Before:
|
|
124
|
+
class Order {
|
|
125
|
+
calculatePrice(customer) {
|
|
126
|
+
const discount = customer.getDiscountLevel();
|
|
127
|
+
// ...
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// After:
|
|
132
|
+
class Customer {
|
|
133
|
+
calculatePriceForOrder(order) {
|
|
134
|
+
const discount = this.discountLevel;
|
|
135
|
+
// ...
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### 6. Data Clumps
|
|
141
|
+
**Symptom**: Same data appearing together
|
|
142
|
+
|
|
143
|
+
**Refactoring**: Extract Value Object
|
|
144
|
+
```typescript
|
|
145
|
+
// Before:
|
|
146
|
+
function drawShape(x, y, width, height) { ... }
|
|
147
|
+
function moveShape(x, y, width, height, dx, dy) { ... }
|
|
148
|
+
|
|
149
|
+
// After:
|
|
150
|
+
class Rectangle {
|
|
151
|
+
constructor(x, y, width, height) { ... }
|
|
152
|
+
}
|
|
153
|
+
function drawShape(rect: Rectangle) { ... }
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### 7. Primitive Obsession
|
|
157
|
+
**Symptom**: Using primitives instead of small objects
|
|
158
|
+
|
|
159
|
+
**Refactoring**: Replace Primitive with Object
|
|
160
|
+
```typescript
|
|
161
|
+
// Before:
|
|
162
|
+
function createUser(name, email, phone) { ... }
|
|
163
|
+
|
|
164
|
+
// After:
|
|
165
|
+
class Email {
|
|
166
|
+
constructor(value) {
|
|
167
|
+
if (!this.isValid(value)) throw new Error('Invalid email');
|
|
168
|
+
this.value = value;
|
|
169
|
+
}
|
|
170
|
+
// ...
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### 8. Switch Statements
|
|
175
|
+
**Symptom**: Large switch on type
|
|
176
|
+
|
|
177
|
+
**Refactoring**: Replace Conditional with Polymorphism
|
|
178
|
+
```typescript
|
|
179
|
+
// Before:
|
|
180
|
+
function calculatePay(employee) {
|
|
181
|
+
switch (employee.type) {
|
|
182
|
+
case 'engineer': return employee.salary * 1.2;
|
|
183
|
+
case 'manager': return employee.salary * 1.5;
|
|
184
|
+
case 'sales': return employee.salary * 1.1;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// After:
|
|
189
|
+
interface Employee {
|
|
190
|
+
calculatePay(): number;
|
|
191
|
+
}
|
|
192
|
+
class Engineer implements Employee {
|
|
193
|
+
calculatePay() { return this.salary * 1.2; }
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### 9. Temporary Field
|
|
198
|
+
**Symptom**: Variables only used in certain scenarios
|
|
199
|
+
|
|
200
|
+
**Refactoring**: Extract Class
|
|
201
|
+
```typescript
|
|
202
|
+
// Before:
|
|
203
|
+
class User {
|
|
204
|
+
calculateRefund() {
|
|
205
|
+
this.tempRefundAmount = 0;
|
|
206
|
+
// complex calculation
|
|
207
|
+
return this.tempRefundAmount;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// After:
|
|
212
|
+
class RefundCalculator {
|
|
213
|
+
calculate(user) {
|
|
214
|
+
// ...
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### 10. Comments
|
|
220
|
+
**Symptom**: Code needs extensive comments
|
|
221
|
+
|
|
222
|
+
**Refactoring**: Extract Method with clear name
|
|
223
|
+
```typescript
|
|
224
|
+
// Before:
|
|
225
|
+
// Calculate the total price including discounts
|
|
226
|
+
// and tax based on user location
|
|
227
|
+
function calc(u, i) {
|
|
228
|
+
let t = 0;
|
|
229
|
+
// discount logic
|
|
230
|
+
if (u.vip) t *= 0.9;
|
|
231
|
+
// tax logic
|
|
232
|
+
if (u.state === 'CA') t *= 1.08;
|
|
233
|
+
return t;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// After:
|
|
237
|
+
function calculateTotalPrice(user: User, items: Item[]): number {
|
|
238
|
+
let total = items.sum(i => i.price);
|
|
239
|
+
if (user.isVIP) {
|
|
240
|
+
total = applyVIPDiscount(total);
|
|
241
|
+
}
|
|
242
|
+
return applyTax(total, user.state);
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## Refactoring Steps
|
|
247
|
+
|
|
248
|
+
1. **Identify the smell** - What makes this code hard to work with?
|
|
249
|
+
2. **Determine the refactoring** - Which technique applies?
|
|
250
|
+
3. **Ensure tests pass** - Green before starting
|
|
251
|
+
4. **Apply the refactoring** - Make the change
|
|
252
|
+
5. **Run tests** - Verify behavior unchanged
|
|
253
|
+
6. **Commit** - Small, atomic commits
|
|
254
|
+
|
|
255
|
+
## Safe Refactoring Practices
|
|
256
|
+
|
|
257
|
+
- Use your IDE's refactoring tools (Rename, Extract, Move)
|
|
258
|
+
- Run tests frequently (after each change)
|
|
259
|
+
- Keep commits small and focused
|
|
260
|
+
- Write a descriptive commit message
|
|
261
|
+
- Consider code reviews for complex refactorings
|
|
262
|
+
|
|
263
|
+
## Before Refactoring
|
|
264
|
+
|
|
265
|
+
- [ ] Tests are passing
|
|
266
|
+
- [ ] I understand what the code does
|
|
267
|
+
- [ ] I have identified the specific code smell
|
|
268
|
+
- [ ] I know which refactoring to apply
|
|
269
|
+
- [ ] I have a rollback plan
|
|
270
|
+
|
|
271
|
+
## After Refactoring
|
|
272
|
+
|
|
273
|
+
- [ ] Tests still pass
|
|
274
|
+
- [ ] Code is more readable
|
|
275
|
+
- [ ] Code is easier to maintain
|
|
276
|
+
- [ ] No new code smells introduced
|
|
277
|
+
- [ ] Documentation updated if needed
|
|
278
|
+
|
|
279
|
+
## References
|
|
280
|
+
|
|
281
|
+
- `references/smells.md` - Complete code smell catalog
|
|
282
|
+
- `references/techniques.md` - Refactoring techniques
|
|
283
|
+
- `references/checklist.md` - Refactoring checklist
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Security Auditor
|
|
2
|
+
|
|
3
|
+
> A Claude Code skill for security audits and vulnerability assessment.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
This skill is part of the [agent-playbook](https://github.com/Charon-Fan/agent-playbook) collection.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
You: Audit this code for security issues
|
|
13
|
+
You: Check for vulnerabilities
|
|
14
|
+
You: Is this code secure?
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## OWASP Top 10 Coverage
|
|
18
|
+
|
|
19
|
+
| Category | Checks |
|
|
20
|
+
|----------|--------|
|
|
21
|
+
| **A01** | Access Control |
|
|
22
|
+
| **A02** | Cryptographic Failures |
|
|
23
|
+
| **A03** | Injection |
|
|
24
|
+
| **A04** | Insecure Design |
|
|
25
|
+
| **A05** | Security Misconfiguration |
|
|
26
|
+
| **A06** | Vulnerable Components |
|
|
27
|
+
| **A07** | Authentication Failures |
|
|
28
|
+
| **A08** | Data Integrity |
|
|
29
|
+
| **A09** | Logging Failures |
|
|
30
|
+
| **A10** | SSRF |
|
|
31
|
+
|
|
32
|
+
## Scripts
|
|
33
|
+
|
|
34
|
+
Run security audit:
|
|
35
|
+
```bash
|
|
36
|
+
python scripts/security_audit.py
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Find secrets:
|
|
40
|
+
```bash
|
|
41
|
+
python scripts/find_secrets.py
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Resources
|
|
45
|
+
|
|
46
|
+
- [OWASP Top 10](https://owasp.org/www-project-top-ten/)
|
|
47
|
+
- [OWASP Cheat Sheet Series](https://cheatsheetseries.owasp.org/)
|
|
48
|
+
- [CWE Top 25](https://cwe.mitre.org/top25/)
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: security-auditor
|
|
3
|
+
description: Security vulnerability expert covering OWASP Top 10 and common security issues. Use when conducting security audits or reviewing code for vulnerabilities.
|
|
4
|
+
allowed-tools: Read, Grep, Glob, Bash, WebSearch
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Security Auditor
|
|
8
|
+
|
|
9
|
+
Expert in identifying security vulnerabilities following OWASP Top 10 and security best practices.
|
|
10
|
+
|
|
11
|
+
## When This Skill Activates
|
|
12
|
+
|
|
13
|
+
Activates when you:
|
|
14
|
+
- Request a security audit
|
|
15
|
+
- Mention "security" or "vulnerability"
|
|
16
|
+
- Need security review
|
|
17
|
+
- Ask about OWASP
|
|
18
|
+
|
|
19
|
+
## OWASP Top 10 Coverage
|
|
20
|
+
|
|
21
|
+
### A01: Broken Access Control
|
|
22
|
+
|
|
23
|
+
**Checks:**
|
|
24
|
+
```bash
|
|
25
|
+
# Check for missing auth on protected routes
|
|
26
|
+
grep -r "@RequireAuth\|@Protected" src/
|
|
27
|
+
|
|
28
|
+
# Check for IDOR vulnerabilities
|
|
29
|
+
grep -r "req.params.id\|req.query.id" src/
|
|
30
|
+
|
|
31
|
+
# Check for role-based access
|
|
32
|
+
grep -r "if.*role.*===" src/
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Common Issues:**
|
|
36
|
+
- Missing authentication on sensitive endpoints
|
|
37
|
+
- IDOR: Users can access other users' data
|
|
38
|
+
- Missing authorization checks
|
|
39
|
+
- API keys in URL
|
|
40
|
+
|
|
41
|
+
### A02: Cryptographic Failures
|
|
42
|
+
|
|
43
|
+
**Checks:**
|
|
44
|
+
```bash
|
|
45
|
+
# Check for hardcoded secrets
|
|
46
|
+
grep -ri "password.*=.*['\"]" src/
|
|
47
|
+
grep -ri "api_key.*=.*['\"]" src/
|
|
48
|
+
grep -ri "secret.*=.*['\"]" src/
|
|
49
|
+
|
|
50
|
+
# Check for weak hashing
|
|
51
|
+
grep -r "md5\|sha1" src/
|
|
52
|
+
|
|
53
|
+
# Check for http URLs
|
|
54
|
+
grep -r "http:\/\/" src/
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Common Issues:**
|
|
58
|
+
- Hardcoded credentials
|
|
59
|
+
- Weak hashing algorithms (MD5, SHA1)
|
|
60
|
+
- Unencrypted sensitive data
|
|
61
|
+
- HTTP instead of HTTPS
|
|
62
|
+
|
|
63
|
+
### A03: Injection
|
|
64
|
+
|
|
65
|
+
**Checks:**
|
|
66
|
+
```bash
|
|
67
|
+
# SQL injection patterns
|
|
68
|
+
grep -r "\".*SELECT.*+.*\"" src/
|
|
69
|
+
grep -r "\".*UPDATE.*SET.*+.*\"" src/
|
|
70
|
+
|
|
71
|
+
# Command injection
|
|
72
|
+
grep -r "exec(\|system(\|spawn(" src/
|
|
73
|
+
grep -r "child_process.exec" src/
|
|
74
|
+
|
|
75
|
+
# Template injection
|
|
76
|
+
grep -r "render.*req\." src/
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**Common Issues:**
|
|
80
|
+
- SQL injection
|
|
81
|
+
- NoSQL injection
|
|
82
|
+
- Command injection
|
|
83
|
+
- XSS (Cross-Site Scripting)
|
|
84
|
+
- Template injection
|
|
85
|
+
|
|
86
|
+
### A04: Insecure Design
|
|
87
|
+
|
|
88
|
+
**Checks:**
|
|
89
|
+
```bash
|
|
90
|
+
# Check for rate limiting
|
|
91
|
+
grep -r "rateLimit\|rate-limit\|throttle" src/
|
|
92
|
+
|
|
93
|
+
# Check for 2FA
|
|
94
|
+
grep -r "twoFactor\|2fa\|mfa" src/
|
|
95
|
+
|
|
96
|
+
# Check for session timeout
|
|
97
|
+
grep -r "maxAge\|expires\|timeout" src/
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**Common Issues:**
|
|
101
|
+
- No rate limiting on auth endpoints
|
|
102
|
+
- Missing 2FA for sensitive operations
|
|
103
|
+
- Session timeout too long
|
|
104
|
+
- No account lockout after failed attempts
|
|
105
|
+
|
|
106
|
+
### A05: Security Misconfiguration
|
|
107
|
+
|
|
108
|
+
**Checks:**
|
|
109
|
+
```bash
|
|
110
|
+
# Check for debug mode
|
|
111
|
+
grep -r "DEBUG.*=.*True\|debug.*=.*true" src/
|
|
112
|
+
|
|
113
|
+
# Check for CORS configuration
|
|
114
|
+
grep -r "origin.*\*" src/
|
|
115
|
+
|
|
116
|
+
# Check for error messages
|
|
117
|
+
grep -r "console\.log.*error\|console\.error" src/
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**Common Issues:**
|
|
121
|
+
- Debug mode enabled in production
|
|
122
|
+
- Overly permissive CORS
|
|
123
|
+
- Verbose error messages
|
|
124
|
+
- Default credentials not changed
|
|
125
|
+
|
|
126
|
+
### A06: Vulnerable Components
|
|
127
|
+
|
|
128
|
+
**Checks:**
|
|
129
|
+
```bash
|
|
130
|
+
# Check package files
|
|
131
|
+
cat package.json | grep -E "\"dependencies\"|\"devDependencies\""
|
|
132
|
+
cat requirements.txt
|
|
133
|
+
cat go.mod
|
|
134
|
+
|
|
135
|
+
# Run vulnerability scanner
|
|
136
|
+
npm audit
|
|
137
|
+
pip-audit
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**Common Issues:**
|
|
141
|
+
- Outdated dependencies
|
|
142
|
+
- Known vulnerabilities in dependencies
|
|
143
|
+
- Unused dependencies
|
|
144
|
+
- Unmaintained packages
|
|
145
|
+
|
|
146
|
+
### A07: Authentication Failures
|
|
147
|
+
|
|
148
|
+
**Checks:**
|
|
149
|
+
```bash
|
|
150
|
+
# Check password hashing
|
|
151
|
+
grep -r "bcrypt\|argon2\|scrypt" src/
|
|
152
|
+
|
|
153
|
+
# Check password requirements
|
|
154
|
+
grep -r "password.*length\|password.*complex" src/
|
|
155
|
+
|
|
156
|
+
# Check for password in URL
|
|
157
|
+
grep -r "password.*req\." src/
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**Common Issues:**
|
|
161
|
+
- Weak password hashing
|
|
162
|
+
- No password complexity requirements
|
|
163
|
+
- Password in URL
|
|
164
|
+
- Session fixation
|
|
165
|
+
|
|
166
|
+
### A08: Software/Data Integrity
|
|
167
|
+
|
|
168
|
+
**Checks:**
|
|
169
|
+
```bash
|
|
170
|
+
# Check for subresource integrity
|
|
171
|
+
grep -r "integrity\|crossorigin" src/
|
|
172
|
+
|
|
173
|
+
# Check for signature verification
|
|
174
|
+
grep -r "verify.*signature\|validate.*token" src/
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
**Common Issues:**
|
|
178
|
+
- No integrity checks
|
|
179
|
+
- Unsigned updates
|
|
180
|
+
- Unverified dependencies
|
|
181
|
+
|
|
182
|
+
### A09: Logging Failures
|
|
183
|
+
|
|
184
|
+
**Checks:**
|
|
185
|
+
```bash
|
|
186
|
+
# Check for sensitive data in logs
|
|
187
|
+
grep -r "log.*password\|log.*token\|log.*secret" src/
|
|
188
|
+
|
|
189
|
+
# Check for audit trail
|
|
190
|
+
grep -r "audit\|activity.*log" src/
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
**Common Issues:**
|
|
194
|
+
- Sensitive data in logs
|
|
195
|
+
- No audit trail for critical operations
|
|
196
|
+
- Logs not protected
|
|
197
|
+
- No log tampering detection
|
|
198
|
+
|
|
199
|
+
### A10: SSRF (Server-Side Request Forgery)
|
|
200
|
+
|
|
201
|
+
**Checks:**
|
|
202
|
+
```bash
|
|
203
|
+
# Check for arbitrary URL fetching
|
|
204
|
+
grep -r "fetch(\|axios(\|request(\|http\\.get" src/
|
|
205
|
+
|
|
206
|
+
# Check for webhook URLs
|
|
207
|
+
grep -r "webhook.*url\|callback.*url" src/
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
**Common Issues:**
|
|
211
|
+
- No URL validation
|
|
212
|
+
- Fetching user-supplied URLs
|
|
213
|
+
- No allowlist for external calls
|
|
214
|
+
|
|
215
|
+
## Security Audit Checklist
|
|
216
|
+
|
|
217
|
+
### Code Review
|
|
218
|
+
- [ ] No hardcoded secrets
|
|
219
|
+
- [ ] Input validation on all inputs
|
|
220
|
+
- [ ] Output encoding for XSS prevention
|
|
221
|
+
- [ ] Parameterized queries for SQL
|
|
222
|
+
- [ ] Proper error handling
|
|
223
|
+
- [ ] Authentication on protected routes
|
|
224
|
+
- [ ] Authorization checks
|
|
225
|
+
- [ ] Rate limiting on public APIs
|
|
226
|
+
|
|
227
|
+
### Configuration
|
|
228
|
+
- [ ] Debug mode off
|
|
229
|
+
- [ ) HTTPS enforced
|
|
230
|
+
- [ ] CORS configured correctly
|
|
231
|
+
- [ ] Security headers set
|
|
232
|
+
- [ ] Environment variables for secrets
|
|
233
|
+
- [ ] Database not exposed
|
|
234
|
+
|
|
235
|
+
### Dependencies
|
|
236
|
+
- [ ] No known vulnerabilities
|
|
237
|
+
- [ ] Dependencies up to date
|
|
238
|
+
- [ ] Unused dependencies removed
|
|
239
|
+
|
|
240
|
+
## Scripts
|
|
241
|
+
|
|
242
|
+
Run security audit:
|
|
243
|
+
```bash
|
|
244
|
+
python scripts/security_audit.py
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Check for secrets:
|
|
248
|
+
```bash
|
|
249
|
+
python scripts/find_secrets.py
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
## References
|
|
253
|
+
|
|
254
|
+
- `references/owasp.md` - OWASP Top 10 details
|
|
255
|
+
- `references/checklist.md` - Security audit checklist
|
|
256
|
+
- `references/remediation.md` - Vulnerability remediation guide
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# OWASP Top 10 (2021)
|
|
2
|
+
|
|
3
|
+
1. Broken Access Control
|
|
4
|
+
2. Cryptographic Failures
|
|
5
|
+
3. Injection
|
|
6
|
+
4. Insecure Design
|
|
7
|
+
5. Security Misconfiguration
|
|
8
|
+
6. Vulnerable and Outdated Components
|
|
9
|
+
7. Identification and Authentication Failures
|
|
10
|
+
8. Software and Data Integrity Failures
|
|
11
|
+
9. Security Logging and Monitoring Failures
|
|
12
|
+
10. Server-Side Request Forgery
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# Lightweight secret scanner for common patterns.
|
|
3
|
+
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
import argparse
|
|
6
|
+
import re
|
|
7
|
+
|
|
8
|
+
PATTERNS = [
|
|
9
|
+
re.compile(r"AKIA[0-9A-Z]{16}"),
|
|
10
|
+
re.compile(r"AIza[0-9A-Za-z_-]{35}"),
|
|
11
|
+
re.compile(r"sk-[0-9A-Za-z]{20,}"),
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def is_text_file(path: Path) -> bool:
|
|
16
|
+
try:
|
|
17
|
+
data = path.read_bytes()
|
|
18
|
+
except OSError:
|
|
19
|
+
return False
|
|
20
|
+
return b"\x00" not in data
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def main() -> int:
|
|
24
|
+
parser = argparse.ArgumentParser(description="Scan for common secret patterns.")
|
|
25
|
+
parser.add_argument("path", nargs="?", default=".", help="Path to scan")
|
|
26
|
+
args = parser.parse_args()
|
|
27
|
+
|
|
28
|
+
root = Path(args.path)
|
|
29
|
+
if not root.exists():
|
|
30
|
+
print("Path not found: " + str(root))
|
|
31
|
+
return 1
|
|
32
|
+
|
|
33
|
+
matches = []
|
|
34
|
+
for file_path in root.rglob("*"):
|
|
35
|
+
if not file_path.is_file():
|
|
36
|
+
continue
|
|
37
|
+
if file_path.suffix in {".png", ".jpg", ".jpeg", ".gif", ".pdf"}:
|
|
38
|
+
continue
|
|
39
|
+
if not is_text_file(file_path):
|
|
40
|
+
continue
|
|
41
|
+
text = file_path.read_text(encoding="utf-8", errors="ignore")
|
|
42
|
+
for pattern in PATTERNS:
|
|
43
|
+
if pattern.search(text):
|
|
44
|
+
matches.append(str(file_path))
|
|
45
|
+
break
|
|
46
|
+
|
|
47
|
+
if matches:
|
|
48
|
+
print("Potential secrets found:")
|
|
49
|
+
for match in matches:
|
|
50
|
+
print("- " + match)
|
|
51
|
+
return 1
|
|
52
|
+
|
|
53
|
+
print("No secrets found.")
|
|
54
|
+
return 0
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
if __name__ == "__main__":
|
|
58
|
+
raise SystemExit(main())
|