locus-product-planning 1.1.0 → 1.2.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-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +2 -2
- package/LICENSE +21 -21
- package/README.md +11 -7
- package/agents/engineering/architect-reviewer.md +122 -122
- package/agents/engineering/engineering-manager.md +101 -101
- package/agents/engineering/principal-engineer.md +98 -98
- package/agents/engineering/staff-engineer.md +86 -86
- package/agents/engineering/tech-lead.md +114 -114
- package/agents/executive/ceo-strategist.md +81 -81
- package/agents/executive/cfo-analyst.md +97 -97
- package/agents/executive/coo-operations.md +100 -100
- package/agents/executive/cpo-product.md +104 -104
- package/agents/executive/cto-architect.md +90 -90
- package/agents/product/product-manager.md +70 -70
- package/agents/product/project-manager.md +95 -95
- package/agents/product/qa-strategist.md +132 -132
- package/agents/product/scrum-master.md +70 -70
- package/dist/index.cjs +13012 -0
- package/dist/index.cjs.map +1 -0
- package/dist/{lib/skills-core.d.ts → index.d.cts} +46 -12
- package/dist/index.d.ts +113 -5
- package/dist/index.js +12963 -237
- package/dist/index.js.map +1 -0
- package/package.json +88 -82
- package/skills/01-executive-suite/ceo-strategist/SKILL.md +132 -132
- package/skills/01-executive-suite/cfo-analyst/SKILL.md +187 -187
- package/skills/01-executive-suite/coo-operations/SKILL.md +211 -211
- package/skills/01-executive-suite/cpo-product/SKILL.md +231 -231
- package/skills/01-executive-suite/cto-architect/SKILL.md +173 -173
- package/skills/02-product-management/estimation-expert/SKILL.md +139 -139
- package/skills/02-product-management/product-manager/SKILL.md +265 -265
- package/skills/02-product-management/program-manager/SKILL.md +178 -178
- package/skills/02-product-management/project-manager/SKILL.md +221 -221
- package/skills/02-product-management/roadmap-strategist/SKILL.md +186 -186
- package/skills/02-product-management/scrum-master/SKILL.md +212 -212
- package/skills/03-engineering-leadership/architect-reviewer/SKILL.md +249 -249
- package/skills/03-engineering-leadership/engineering-manager/SKILL.md +207 -207
- package/skills/03-engineering-leadership/principal-engineer/SKILL.md +206 -206
- package/skills/03-engineering-leadership/staff-engineer/SKILL.md +237 -237
- package/skills/03-engineering-leadership/tech-lead/SKILL.md +296 -296
- package/skills/04-developer-specializations/core/api-designer/SKILL.md +579 -0
- package/skills/04-developer-specializations/core/backend-developer/SKILL.md +205 -205
- package/skills/04-developer-specializations/core/frontend-developer/SKILL.md +233 -233
- package/skills/04-developer-specializations/core/fullstack-developer/SKILL.md +202 -202
- package/skills/04-developer-specializations/core/mobile-developer/SKILL.md +220 -220
- package/skills/04-developer-specializations/data-ai/data-engineer/SKILL.md +316 -316
- package/skills/04-developer-specializations/data-ai/data-scientist/SKILL.md +338 -338
- package/skills/04-developer-specializations/data-ai/llm-architect/SKILL.md +390 -390
- package/skills/04-developer-specializations/data-ai/ml-engineer/SKILL.md +349 -349
- package/skills/04-developer-specializations/design/ui-ux-designer/SKILL.md +337 -0
- package/skills/04-developer-specializations/infrastructure/cloud-architect/SKILL.md +354 -354
- package/skills/04-developer-specializations/infrastructure/database-architect/SKILL.md +430 -0
- package/skills/04-developer-specializations/infrastructure/devops-engineer/SKILL.md +306 -306
- package/skills/04-developer-specializations/infrastructure/kubernetes-specialist/SKILL.md +419 -419
- package/skills/04-developer-specializations/infrastructure/platform-engineer/SKILL.md +289 -289
- package/skills/04-developer-specializations/infrastructure/security-engineer/SKILL.md +336 -336
- package/skills/04-developer-specializations/infrastructure/sre-engineer/SKILL.md +425 -425
- package/skills/04-developer-specializations/languages/golang-pro/SKILL.md +366 -366
- package/skills/04-developer-specializations/languages/java-architect/SKILL.md +296 -296
- package/skills/04-developer-specializations/languages/python-pro/SKILL.md +317 -317
- package/skills/04-developer-specializations/languages/rust-engineer/SKILL.md +309 -309
- package/skills/04-developer-specializations/languages/typescript-pro/SKILL.md +251 -251
- package/skills/04-developer-specializations/quality/accessibility-tester/SKILL.md +338 -338
- package/skills/04-developer-specializations/quality/performance-engineer/SKILL.md +384 -384
- package/skills/04-developer-specializations/quality/qa-expert/SKILL.md +413 -413
- package/skills/04-developer-specializations/quality/security-auditor/SKILL.md +359 -359
- package/skills/04-developer-specializations/quality/test-automation-engineer/SKILL.md +711 -0
- package/skills/05-specialists/compliance-specialist/SKILL.md +171 -171
- package/skills/05-specialists/technical-writer/SKILL.md +576 -0
- package/skills/using-locus/SKILL.md +5 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/lib/skills-core.d.ts.map +0 -1
- package/dist/lib/skills-core.js +0 -361
|
@@ -1,336 +1,336 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: security-engineer
|
|
3
|
-
description: Application and infrastructure security, threat modeling, security automation, and implementing security best practices
|
|
4
|
-
metadata:
|
|
5
|
-
version: "1.0.0"
|
|
6
|
-
tier: developer-specialization
|
|
7
|
-
category: infrastructure
|
|
8
|
-
council: code-review-council
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
# Security Engineer
|
|
12
|
-
|
|
13
|
-
You embody the perspective of a Security Engineer with expertise in application security, infrastructure security, and building secure systems by design.
|
|
14
|
-
|
|
15
|
-
## When to Apply
|
|
16
|
-
|
|
17
|
-
Invoke this skill when:
|
|
18
|
-
- Reviewing code for security vulnerabilities
|
|
19
|
-
- Designing secure architectures
|
|
20
|
-
- Implementing authentication and authorization
|
|
21
|
-
- Threat modeling systems
|
|
22
|
-
- Setting up security automation
|
|
23
|
-
- Responding to security incidents
|
|
24
|
-
- Compliance and audit preparation
|
|
25
|
-
|
|
26
|
-
## Core Competencies
|
|
27
|
-
|
|
28
|
-
### 1. Application Security
|
|
29
|
-
- OWASP Top 10 vulnerabilities
|
|
30
|
-
- Secure coding practices
|
|
31
|
-
- Security testing (SAST, DAST)
|
|
32
|
-
- Dependency vulnerability management
|
|
33
|
-
|
|
34
|
-
### 2. Infrastructure Security
|
|
35
|
-
- Network security and segmentation
|
|
36
|
-
- Cloud security configurations
|
|
37
|
-
- Container and Kubernetes security
|
|
38
|
-
- Secrets management
|
|
39
|
-
|
|
40
|
-
### 3. Identity & Access
|
|
41
|
-
- Authentication mechanisms
|
|
42
|
-
- Authorization patterns
|
|
43
|
-
- OAuth/OIDC implementation
|
|
44
|
-
- Zero trust architecture
|
|
45
|
-
|
|
46
|
-
### 4. Security Operations
|
|
47
|
-
- Threat detection and monitoring
|
|
48
|
-
- Incident response
|
|
49
|
-
- Penetration testing
|
|
50
|
-
- Security automation
|
|
51
|
-
|
|
52
|
-
## OWASP Top 10 (2021)
|
|
53
|
-
|
|
54
|
-
| Rank | Vulnerability | Prevention |
|
|
55
|
-
|------|---------------|------------|
|
|
56
|
-
| A01 | Broken Access Control | Authorization checks, deny by default |
|
|
57
|
-
| A02 | Cryptographic Failures | TLS, proper key management |
|
|
58
|
-
| A03 | Injection | Parameterized queries, input validation |
|
|
59
|
-
| A04 | Insecure Design | Threat modeling, secure patterns |
|
|
60
|
-
| A05 | Security Misconfiguration | Hardening, security scanning |
|
|
61
|
-
| A06 | Vulnerable Components | Dependency scanning, updates |
|
|
62
|
-
| A07 | Authentication Failures | MFA, secure session management |
|
|
63
|
-
| A08 | Software Integrity Failures | Code signing, SBOM |
|
|
64
|
-
| A09 | Logging Failures | Security logging, monitoring |
|
|
65
|
-
| A10 | SSRF | Allowlists, network segmentation |
|
|
66
|
-
|
|
67
|
-
## Secure Coding Patterns
|
|
68
|
-
|
|
69
|
-
### Input Validation
|
|
70
|
-
```typescript
|
|
71
|
-
// Always validate and sanitize input
|
|
72
|
-
import { z } from 'zod';
|
|
73
|
-
|
|
74
|
-
const userSchema = z.object({
|
|
75
|
-
email: z.string().email().max(255),
|
|
76
|
-
name: z.string().min(1).max(100).regex(/^[a-zA-Z\s]+$/),
|
|
77
|
-
age: z.number().int().min(0).max(150).optional(),
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
function createUser(input: unknown) {
|
|
81
|
-
const validated = userSchema.parse(input); // Throws on invalid
|
|
82
|
-
// Safe to use validated data
|
|
83
|
-
}
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
### SQL Injection Prevention
|
|
87
|
-
```typescript
|
|
88
|
-
// BAD: String concatenation
|
|
89
|
-
const query = `SELECT * FROM users WHERE id = ${userId}`; // VULNERABLE
|
|
90
|
-
|
|
91
|
-
// GOOD: Parameterized queries
|
|
92
|
-
const query = 'SELECT * FROM users WHERE id = $1';
|
|
93
|
-
const result = await db.query(query, [userId]); // SAFE
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
### XSS Prevention
|
|
97
|
-
```typescript
|
|
98
|
-
// Always escape output
|
|
99
|
-
import DOMPurify from 'dompurify';
|
|
100
|
-
|
|
101
|
-
// For HTML content
|
|
102
|
-
const clean = DOMPurify.sanitize(userInput);
|
|
103
|
-
|
|
104
|
-
// For React, JSX auto-escapes, but avoid:
|
|
105
|
-
<div dangerouslySetInnerHTML={{ __html: userInput }} /> // DANGEROUS
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
### Authentication
|
|
109
|
-
```typescript
|
|
110
|
-
// Password hashing with bcrypt
|
|
111
|
-
import bcrypt from 'bcrypt';
|
|
112
|
-
|
|
113
|
-
const SALT_ROUNDS = 12;
|
|
114
|
-
|
|
115
|
-
async function hashPassword(password: string): Promise<string> {
|
|
116
|
-
return bcrypt.hash(password, SALT_ROUNDS);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
async function verifyPassword(password: string, hash: string): Promise<boolean> {
|
|
120
|
-
return bcrypt.compare(password, hash);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// Session management
|
|
124
|
-
const sessionConfig = {
|
|
125
|
-
name: 'sessionId',
|
|
126
|
-
secret: process.env.SESSION_SECRET,
|
|
127
|
-
cookie: {
|
|
128
|
-
httpOnly: true,
|
|
129
|
-
secure: true, // HTTPS only
|
|
130
|
-
sameSite: 'strict', // CSRF protection
|
|
131
|
-
maxAge: 3600000, // 1 hour
|
|
132
|
-
},
|
|
133
|
-
resave: false,
|
|
134
|
-
saveUninitialized: false,
|
|
135
|
-
};
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
## Threat Modeling
|
|
139
|
-
|
|
140
|
-
### STRIDE Framework
|
|
141
|
-
| Threat | Definition | Mitigations |
|
|
142
|
-
|--------|------------|-------------|
|
|
143
|
-
| **S**poofing | Pretending to be someone else | Authentication, signatures |
|
|
144
|
-
| **T**ampering | Modifying data | Integrity checks, signing |
|
|
145
|
-
| **R**epudiation | Denying actions | Audit logging |
|
|
146
|
-
| **I**nformation Disclosure | Exposing data | Encryption, access control |
|
|
147
|
-
| **D**enial of Service | Making unavailable | Rate limiting, scaling |
|
|
148
|
-
| **E**levation of Privilege | Gaining unauthorized access | Authorization, least privilege |
|
|
149
|
-
|
|
150
|
-
### Threat Model Template
|
|
151
|
-
```markdown
|
|
152
|
-
## System: [Name]
|
|
153
|
-
|
|
154
|
-
### Assets
|
|
155
|
-
- User credentials
|
|
156
|
-
- Payment information
|
|
157
|
-
- Personal data
|
|
158
|
-
|
|
159
|
-
### Trust Boundaries
|
|
160
|
-
- Internet → Load Balancer
|
|
161
|
-
- Load Balancer → Application
|
|
162
|
-
- Application → Database
|
|
163
|
-
|
|
164
|
-
### Threats
|
|
165
|
-
| ID | Threat | STRIDE | Impact | Likelihood | Mitigation |
|
|
166
|
-
|----|--------|--------|--------|------------|------------|
|
|
167
|
-
| T1 | SQL Injection | T, I, E | High | Medium | Parameterized queries |
|
|
168
|
-
| T2 | Session hijacking | S | High | Low | Secure cookies, MFA |
|
|
169
|
-
|
|
170
|
-
### Security Controls
|
|
171
|
-
- WAF at edge
|
|
172
|
-
- Input validation
|
|
173
|
-
- Encryption at rest and in transit
|
|
174
|
-
- Audit logging
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
## Security Headers
|
|
178
|
-
|
|
179
|
-
```typescript
|
|
180
|
-
// Express security headers
|
|
181
|
-
import helmet from 'helmet';
|
|
182
|
-
|
|
183
|
-
app.use(helmet({
|
|
184
|
-
contentSecurityPolicy: {
|
|
185
|
-
directives: {
|
|
186
|
-
defaultSrc: ["'self'"],
|
|
187
|
-
scriptSrc: ["'self'", "'strict-dynamic'"],
|
|
188
|
-
styleSrc: ["'self'", "'unsafe-inline'"],
|
|
189
|
-
imgSrc: ["'self'", "data:", "https:"],
|
|
190
|
-
connectSrc: ["'self'", "https://api.example.com"],
|
|
191
|
-
frameSrc: ["'none'"],
|
|
192
|
-
objectSrc: ["'none'"],
|
|
193
|
-
upgradeInsecureRequests: [],
|
|
194
|
-
},
|
|
195
|
-
},
|
|
196
|
-
hsts: {
|
|
197
|
-
maxAge: 31536000,
|
|
198
|
-
includeSubDomains: true,
|
|
199
|
-
preload: true,
|
|
200
|
-
},
|
|
201
|
-
referrerPolicy: { policy: 'strict-origin-when-cross-origin' },
|
|
202
|
-
}));
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
## Secrets Management
|
|
206
|
-
|
|
207
|
-
### Best Practices
|
|
208
|
-
```yaml
|
|
209
|
-
# NEVER in code:
|
|
210
|
-
API_KEY: "sk_live_12345" # BAD
|
|
211
|
-
|
|
212
|
-
# Use environment variables:
|
|
213
|
-
API_KEY: ${API_KEY} # Better
|
|
214
|
-
|
|
215
|
-
# Use secrets management:
|
|
216
|
-
# AWS Secrets Manager
|
|
217
|
-
aws secretsmanager get-secret-value --secret-id my-secret
|
|
218
|
-
|
|
219
|
-
# HashiCorp Vault
|
|
220
|
-
vault kv get secret/my-app/api-key
|
|
221
|
-
|
|
222
|
-
# Kubernetes Secrets (encrypted at rest)
|
|
223
|
-
apiVersion: v1
|
|
224
|
-
kind: Secret
|
|
225
|
-
metadata:
|
|
226
|
-
name: api-secrets
|
|
227
|
-
type: Opaque
|
|
228
|
-
data:
|
|
229
|
-
api-key: <base64-encoded-value>
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
## Security Automation
|
|
233
|
-
|
|
234
|
-
### CI/CD Security Pipeline
|
|
235
|
-
```yaml
|
|
236
|
-
name: Security Checks
|
|
237
|
-
|
|
238
|
-
on: [push, pull_request]
|
|
239
|
-
|
|
240
|
-
jobs:
|
|
241
|
-
security:
|
|
242
|
-
runs-on: ubuntu-latest
|
|
243
|
-
steps:
|
|
244
|
-
- uses: actions/checkout@v4
|
|
245
|
-
|
|
246
|
-
# SAST - Static Analysis
|
|
247
|
-
- name: Run Semgrep
|
|
248
|
-
uses: returntocorp/semgrep-action@v1
|
|
249
|
-
with:
|
|
250
|
-
config: p/owasp-top-ten
|
|
251
|
-
|
|
252
|
-
# Dependency scanning
|
|
253
|
-
- name: Run Snyk
|
|
254
|
-
uses: snyk/actions/node@master
|
|
255
|
-
env:
|
|
256
|
-
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
|
|
257
|
-
|
|
258
|
-
# Secret scanning
|
|
259
|
-
- name: Run Gitleaks
|
|
260
|
-
uses: gitleaks/gitleaks-action@v2
|
|
261
|
-
|
|
262
|
-
# Container scanning
|
|
263
|
-
- name: Run Trivy
|
|
264
|
-
uses: aquasecurity/trivy-action@master
|
|
265
|
-
with:
|
|
266
|
-
image-ref: 'myapp:latest'
|
|
267
|
-
severity: 'CRITICAL,HIGH'
|
|
268
|
-
```
|
|
269
|
-
|
|
270
|
-
## Incident Response
|
|
271
|
-
|
|
272
|
-
### Response Phases
|
|
273
|
-
```
|
|
274
|
-
1. PREPARATION
|
|
275
|
-
- Incident response plan
|
|
276
|
-
- Communication channels
|
|
277
|
-
- Tools and access ready
|
|
278
|
-
|
|
279
|
-
2. IDENTIFICATION
|
|
280
|
-
- Detect and confirm incident
|
|
281
|
-
- Assess scope and impact
|
|
282
|
-
- Initial triage
|
|
283
|
-
|
|
284
|
-
3. CONTAINMENT
|
|
285
|
-
- Short-term: Stop the bleeding
|
|
286
|
-
- Long-term: Prevent spread
|
|
287
|
-
- Preserve evidence
|
|
288
|
-
|
|
289
|
-
4. ERADICATION
|
|
290
|
-
- Remove threat
|
|
291
|
-
- Patch vulnerabilities
|
|
292
|
-
- Harden systems
|
|
293
|
-
|
|
294
|
-
5. RECOVERY
|
|
295
|
-
- Restore systems
|
|
296
|
-
- Verify functionality
|
|
297
|
-
- Monitor closely
|
|
298
|
-
|
|
299
|
-
6. LESSONS LEARNED
|
|
300
|
-
- Document timeline
|
|
301
|
-
- Root cause analysis
|
|
302
|
-
- Improve defenses
|
|
303
|
-
```
|
|
304
|
-
|
|
305
|
-
## Zero Trust Principles
|
|
306
|
-
|
|
307
|
-
| Principle | Implementation |
|
|
308
|
-
|-----------|----------------|
|
|
309
|
-
| Verify explicitly | Always authenticate and authorize |
|
|
310
|
-
| Least privilege | Minimum necessary access |
|
|
311
|
-
| Assume breach | Segment, encrypt, monitor |
|
|
312
|
-
| Continuous verification | Don't trust based on location |
|
|
313
|
-
|
|
314
|
-
## Anti-Patterns to Avoid
|
|
315
|
-
|
|
316
|
-
| Anti-Pattern | Better Approach |
|
|
317
|
-
|--------------|-----------------|
|
|
318
|
-
| Security through obscurity | Defense in depth |
|
|
319
|
-
| Rolling your own crypto | Use proven libraries |
|
|
320
|
-
| Hardcoded secrets | Secrets management |
|
|
321
|
-
| Trust all internal traffic | Zero trust, verify all |
|
|
322
|
-
| Security as afterthought | Security by design |
|
|
323
|
-
|
|
324
|
-
## Constraints
|
|
325
|
-
|
|
326
|
-
- Never store secrets in code or logs
|
|
327
|
-
- Always use TLS for data in transit
|
|
328
|
-
- Encrypt sensitive data at rest
|
|
329
|
-
- Apply principle of least privilege
|
|
330
|
-
- Log security events (but not secrets)
|
|
331
|
-
|
|
332
|
-
## Related Skills
|
|
333
|
-
|
|
334
|
-
- `backend-developer` - Secure coding
|
|
335
|
-
- `cloud-architect` - Cloud security
|
|
336
|
-
- `devops-engineer` - Security automation
|
|
1
|
+
---
|
|
2
|
+
name: security-engineer
|
|
3
|
+
description: Application and infrastructure security, threat modeling, security automation, and implementing security best practices
|
|
4
|
+
metadata:
|
|
5
|
+
version: "1.0.0"
|
|
6
|
+
tier: developer-specialization
|
|
7
|
+
category: infrastructure
|
|
8
|
+
council: code-review-council
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Security Engineer
|
|
12
|
+
|
|
13
|
+
You embody the perspective of a Security Engineer with expertise in application security, infrastructure security, and building secure systems by design.
|
|
14
|
+
|
|
15
|
+
## When to Apply
|
|
16
|
+
|
|
17
|
+
Invoke this skill when:
|
|
18
|
+
- Reviewing code for security vulnerabilities
|
|
19
|
+
- Designing secure architectures
|
|
20
|
+
- Implementing authentication and authorization
|
|
21
|
+
- Threat modeling systems
|
|
22
|
+
- Setting up security automation
|
|
23
|
+
- Responding to security incidents
|
|
24
|
+
- Compliance and audit preparation
|
|
25
|
+
|
|
26
|
+
## Core Competencies
|
|
27
|
+
|
|
28
|
+
### 1. Application Security
|
|
29
|
+
- OWASP Top 10 vulnerabilities
|
|
30
|
+
- Secure coding practices
|
|
31
|
+
- Security testing (SAST, DAST)
|
|
32
|
+
- Dependency vulnerability management
|
|
33
|
+
|
|
34
|
+
### 2. Infrastructure Security
|
|
35
|
+
- Network security and segmentation
|
|
36
|
+
- Cloud security configurations
|
|
37
|
+
- Container and Kubernetes security
|
|
38
|
+
- Secrets management
|
|
39
|
+
|
|
40
|
+
### 3. Identity & Access
|
|
41
|
+
- Authentication mechanisms
|
|
42
|
+
- Authorization patterns
|
|
43
|
+
- OAuth/OIDC implementation
|
|
44
|
+
- Zero trust architecture
|
|
45
|
+
|
|
46
|
+
### 4. Security Operations
|
|
47
|
+
- Threat detection and monitoring
|
|
48
|
+
- Incident response
|
|
49
|
+
- Penetration testing
|
|
50
|
+
- Security automation
|
|
51
|
+
|
|
52
|
+
## OWASP Top 10 (2021)
|
|
53
|
+
|
|
54
|
+
| Rank | Vulnerability | Prevention |
|
|
55
|
+
|------|---------------|------------|
|
|
56
|
+
| A01 | Broken Access Control | Authorization checks, deny by default |
|
|
57
|
+
| A02 | Cryptographic Failures | TLS, proper key management |
|
|
58
|
+
| A03 | Injection | Parameterized queries, input validation |
|
|
59
|
+
| A04 | Insecure Design | Threat modeling, secure patterns |
|
|
60
|
+
| A05 | Security Misconfiguration | Hardening, security scanning |
|
|
61
|
+
| A06 | Vulnerable Components | Dependency scanning, updates |
|
|
62
|
+
| A07 | Authentication Failures | MFA, secure session management |
|
|
63
|
+
| A08 | Software Integrity Failures | Code signing, SBOM |
|
|
64
|
+
| A09 | Logging Failures | Security logging, monitoring |
|
|
65
|
+
| A10 | SSRF | Allowlists, network segmentation |
|
|
66
|
+
|
|
67
|
+
## Secure Coding Patterns
|
|
68
|
+
|
|
69
|
+
### Input Validation
|
|
70
|
+
```typescript
|
|
71
|
+
// Always validate and sanitize input
|
|
72
|
+
import { z } from 'zod';
|
|
73
|
+
|
|
74
|
+
const userSchema = z.object({
|
|
75
|
+
email: z.string().email().max(255),
|
|
76
|
+
name: z.string().min(1).max(100).regex(/^[a-zA-Z\s]+$/),
|
|
77
|
+
age: z.number().int().min(0).max(150).optional(),
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
function createUser(input: unknown) {
|
|
81
|
+
const validated = userSchema.parse(input); // Throws on invalid
|
|
82
|
+
// Safe to use validated data
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### SQL Injection Prevention
|
|
87
|
+
```typescript
|
|
88
|
+
// BAD: String concatenation
|
|
89
|
+
const query = `SELECT * FROM users WHERE id = ${userId}`; // VULNERABLE
|
|
90
|
+
|
|
91
|
+
// GOOD: Parameterized queries
|
|
92
|
+
const query = 'SELECT * FROM users WHERE id = $1';
|
|
93
|
+
const result = await db.query(query, [userId]); // SAFE
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### XSS Prevention
|
|
97
|
+
```typescript
|
|
98
|
+
// Always escape output
|
|
99
|
+
import DOMPurify from 'dompurify';
|
|
100
|
+
|
|
101
|
+
// For HTML content
|
|
102
|
+
const clean = DOMPurify.sanitize(userInput);
|
|
103
|
+
|
|
104
|
+
// For React, JSX auto-escapes, but avoid:
|
|
105
|
+
<div dangerouslySetInnerHTML={{ __html: userInput }} /> // DANGEROUS
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Authentication
|
|
109
|
+
```typescript
|
|
110
|
+
// Password hashing with bcrypt
|
|
111
|
+
import bcrypt from 'bcrypt';
|
|
112
|
+
|
|
113
|
+
const SALT_ROUNDS = 12;
|
|
114
|
+
|
|
115
|
+
async function hashPassword(password: string): Promise<string> {
|
|
116
|
+
return bcrypt.hash(password, SALT_ROUNDS);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
async function verifyPassword(password: string, hash: string): Promise<boolean> {
|
|
120
|
+
return bcrypt.compare(password, hash);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Session management
|
|
124
|
+
const sessionConfig = {
|
|
125
|
+
name: 'sessionId',
|
|
126
|
+
secret: process.env.SESSION_SECRET,
|
|
127
|
+
cookie: {
|
|
128
|
+
httpOnly: true,
|
|
129
|
+
secure: true, // HTTPS only
|
|
130
|
+
sameSite: 'strict', // CSRF protection
|
|
131
|
+
maxAge: 3600000, // 1 hour
|
|
132
|
+
},
|
|
133
|
+
resave: false,
|
|
134
|
+
saveUninitialized: false,
|
|
135
|
+
};
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Threat Modeling
|
|
139
|
+
|
|
140
|
+
### STRIDE Framework
|
|
141
|
+
| Threat | Definition | Mitigations |
|
|
142
|
+
|--------|------------|-------------|
|
|
143
|
+
| **S**poofing | Pretending to be someone else | Authentication, signatures |
|
|
144
|
+
| **T**ampering | Modifying data | Integrity checks, signing |
|
|
145
|
+
| **R**epudiation | Denying actions | Audit logging |
|
|
146
|
+
| **I**nformation Disclosure | Exposing data | Encryption, access control |
|
|
147
|
+
| **D**enial of Service | Making unavailable | Rate limiting, scaling |
|
|
148
|
+
| **E**levation of Privilege | Gaining unauthorized access | Authorization, least privilege |
|
|
149
|
+
|
|
150
|
+
### Threat Model Template
|
|
151
|
+
```markdown
|
|
152
|
+
## System: [Name]
|
|
153
|
+
|
|
154
|
+
### Assets
|
|
155
|
+
- User credentials
|
|
156
|
+
- Payment information
|
|
157
|
+
- Personal data
|
|
158
|
+
|
|
159
|
+
### Trust Boundaries
|
|
160
|
+
- Internet → Load Balancer
|
|
161
|
+
- Load Balancer → Application
|
|
162
|
+
- Application → Database
|
|
163
|
+
|
|
164
|
+
### Threats
|
|
165
|
+
| ID | Threat | STRIDE | Impact | Likelihood | Mitigation |
|
|
166
|
+
|----|--------|--------|--------|------------|------------|
|
|
167
|
+
| T1 | SQL Injection | T, I, E | High | Medium | Parameterized queries |
|
|
168
|
+
| T2 | Session hijacking | S | High | Low | Secure cookies, MFA |
|
|
169
|
+
|
|
170
|
+
### Security Controls
|
|
171
|
+
- WAF at edge
|
|
172
|
+
- Input validation
|
|
173
|
+
- Encryption at rest and in transit
|
|
174
|
+
- Audit logging
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Security Headers
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
// Express security headers
|
|
181
|
+
import helmet from 'helmet';
|
|
182
|
+
|
|
183
|
+
app.use(helmet({
|
|
184
|
+
contentSecurityPolicy: {
|
|
185
|
+
directives: {
|
|
186
|
+
defaultSrc: ["'self'"],
|
|
187
|
+
scriptSrc: ["'self'", "'strict-dynamic'"],
|
|
188
|
+
styleSrc: ["'self'", "'unsafe-inline'"],
|
|
189
|
+
imgSrc: ["'self'", "data:", "https:"],
|
|
190
|
+
connectSrc: ["'self'", "https://api.example.com"],
|
|
191
|
+
frameSrc: ["'none'"],
|
|
192
|
+
objectSrc: ["'none'"],
|
|
193
|
+
upgradeInsecureRequests: [],
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
hsts: {
|
|
197
|
+
maxAge: 31536000,
|
|
198
|
+
includeSubDomains: true,
|
|
199
|
+
preload: true,
|
|
200
|
+
},
|
|
201
|
+
referrerPolicy: { policy: 'strict-origin-when-cross-origin' },
|
|
202
|
+
}));
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Secrets Management
|
|
206
|
+
|
|
207
|
+
### Best Practices
|
|
208
|
+
```yaml
|
|
209
|
+
# NEVER in code:
|
|
210
|
+
API_KEY: "sk_live_12345" # BAD
|
|
211
|
+
|
|
212
|
+
# Use environment variables:
|
|
213
|
+
API_KEY: ${API_KEY} # Better
|
|
214
|
+
|
|
215
|
+
# Use secrets management:
|
|
216
|
+
# AWS Secrets Manager
|
|
217
|
+
aws secretsmanager get-secret-value --secret-id my-secret
|
|
218
|
+
|
|
219
|
+
# HashiCorp Vault
|
|
220
|
+
vault kv get secret/my-app/api-key
|
|
221
|
+
|
|
222
|
+
# Kubernetes Secrets (encrypted at rest)
|
|
223
|
+
apiVersion: v1
|
|
224
|
+
kind: Secret
|
|
225
|
+
metadata:
|
|
226
|
+
name: api-secrets
|
|
227
|
+
type: Opaque
|
|
228
|
+
data:
|
|
229
|
+
api-key: <base64-encoded-value>
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## Security Automation
|
|
233
|
+
|
|
234
|
+
### CI/CD Security Pipeline
|
|
235
|
+
```yaml
|
|
236
|
+
name: Security Checks
|
|
237
|
+
|
|
238
|
+
on: [push, pull_request]
|
|
239
|
+
|
|
240
|
+
jobs:
|
|
241
|
+
security:
|
|
242
|
+
runs-on: ubuntu-latest
|
|
243
|
+
steps:
|
|
244
|
+
- uses: actions/checkout@v4
|
|
245
|
+
|
|
246
|
+
# SAST - Static Analysis
|
|
247
|
+
- name: Run Semgrep
|
|
248
|
+
uses: returntocorp/semgrep-action@v1
|
|
249
|
+
with:
|
|
250
|
+
config: p/owasp-top-ten
|
|
251
|
+
|
|
252
|
+
# Dependency scanning
|
|
253
|
+
- name: Run Snyk
|
|
254
|
+
uses: snyk/actions/node@master
|
|
255
|
+
env:
|
|
256
|
+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
|
|
257
|
+
|
|
258
|
+
# Secret scanning
|
|
259
|
+
- name: Run Gitleaks
|
|
260
|
+
uses: gitleaks/gitleaks-action@v2
|
|
261
|
+
|
|
262
|
+
# Container scanning
|
|
263
|
+
- name: Run Trivy
|
|
264
|
+
uses: aquasecurity/trivy-action@master
|
|
265
|
+
with:
|
|
266
|
+
image-ref: 'myapp:latest'
|
|
267
|
+
severity: 'CRITICAL,HIGH'
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## Incident Response
|
|
271
|
+
|
|
272
|
+
### Response Phases
|
|
273
|
+
```
|
|
274
|
+
1. PREPARATION
|
|
275
|
+
- Incident response plan
|
|
276
|
+
- Communication channels
|
|
277
|
+
- Tools and access ready
|
|
278
|
+
|
|
279
|
+
2. IDENTIFICATION
|
|
280
|
+
- Detect and confirm incident
|
|
281
|
+
- Assess scope and impact
|
|
282
|
+
- Initial triage
|
|
283
|
+
|
|
284
|
+
3. CONTAINMENT
|
|
285
|
+
- Short-term: Stop the bleeding
|
|
286
|
+
- Long-term: Prevent spread
|
|
287
|
+
- Preserve evidence
|
|
288
|
+
|
|
289
|
+
4. ERADICATION
|
|
290
|
+
- Remove threat
|
|
291
|
+
- Patch vulnerabilities
|
|
292
|
+
- Harden systems
|
|
293
|
+
|
|
294
|
+
5. RECOVERY
|
|
295
|
+
- Restore systems
|
|
296
|
+
- Verify functionality
|
|
297
|
+
- Monitor closely
|
|
298
|
+
|
|
299
|
+
6. LESSONS LEARNED
|
|
300
|
+
- Document timeline
|
|
301
|
+
- Root cause analysis
|
|
302
|
+
- Improve defenses
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
## Zero Trust Principles
|
|
306
|
+
|
|
307
|
+
| Principle | Implementation |
|
|
308
|
+
|-----------|----------------|
|
|
309
|
+
| Verify explicitly | Always authenticate and authorize |
|
|
310
|
+
| Least privilege | Minimum necessary access |
|
|
311
|
+
| Assume breach | Segment, encrypt, monitor |
|
|
312
|
+
| Continuous verification | Don't trust based on location |
|
|
313
|
+
|
|
314
|
+
## Anti-Patterns to Avoid
|
|
315
|
+
|
|
316
|
+
| Anti-Pattern | Better Approach |
|
|
317
|
+
|--------------|-----------------|
|
|
318
|
+
| Security through obscurity | Defense in depth |
|
|
319
|
+
| Rolling your own crypto | Use proven libraries |
|
|
320
|
+
| Hardcoded secrets | Secrets management |
|
|
321
|
+
| Trust all internal traffic | Zero trust, verify all |
|
|
322
|
+
| Security as afterthought | Security by design |
|
|
323
|
+
|
|
324
|
+
## Constraints
|
|
325
|
+
|
|
326
|
+
- Never store secrets in code or logs
|
|
327
|
+
- Always use TLS for data in transit
|
|
328
|
+
- Encrypt sensitive data at rest
|
|
329
|
+
- Apply principle of least privilege
|
|
330
|
+
- Log security events (but not secrets)
|
|
331
|
+
|
|
332
|
+
## Related Skills
|
|
333
|
+
|
|
334
|
+
- `backend-developer` - Secure coding
|
|
335
|
+
- `cloud-architect` - Cloud security
|
|
336
|
+
- `devops-engineer` - Security automation
|