@patricio0312rev/skillset 0.1.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/CHANGELOG.md +29 -0
- package/LICENSE +21 -0
- package/README.md +176 -0
- package/bin/cli.js +37 -0
- package/package.json +55 -0
- package/src/commands/init.js +301 -0
- package/src/index.js +168 -0
- package/src/lib/config.js +200 -0
- package/src/lib/generator.js +166 -0
- package/src/utils/display.js +95 -0
- package/src/utils/readme.js +196 -0
- package/src/utils/tool-specific.js +233 -0
- package/templates/ai-engineering/agent-orchestration-planner/ SKILL.md +266 -0
- package/templates/ai-engineering/cost-latency-optimizer/ SKILL.md +270 -0
- package/templates/ai-engineering/doc-to-vector-dataset-generator/ SKILL.md +239 -0
- package/templates/ai-engineering/evaluation-harness/ SKILL.md +219 -0
- package/templates/ai-engineering/guardrails-safety-filter-builder/ SKILL.md +226 -0
- package/templates/ai-engineering/llm-debugger/ SKILL.md +283 -0
- package/templates/ai-engineering/prompt-regression-tester/ SKILL.md +216 -0
- package/templates/ai-engineering/prompt-template-builder/ SKILL.md +393 -0
- package/templates/ai-engineering/rag-pipeline-builder/ SKILL.md +244 -0
- package/templates/ai-engineering/tool-function-schema-designer/ SKILL.md +219 -0
- package/templates/architecture/adr-writer/ SKILL.md +250 -0
- package/templates/architecture/api-versioning-deprecation-planner/ SKILL.md +331 -0
- package/templates/architecture/domain-model-boundaries-mapper/ SKILL.md +300 -0
- package/templates/architecture/migration-planner/ SKILL.md +376 -0
- package/templates/architecture/performance-budget-setter/ SKILL.md +318 -0
- package/templates/architecture/reliability-strategy-builder/ SKILL.md +286 -0
- package/templates/architecture/rfc-generator/ SKILL.md +362 -0
- package/templates/architecture/scalability-playbook/ SKILL.md +279 -0
- package/templates/architecture/system-design-generator/ SKILL.md +339 -0
- package/templates/architecture/tech-debt-prioritizer/ SKILL.md +329 -0
- package/templates/backend/api-contract-normalizer/ SKILL.md +487 -0
- package/templates/backend/api-endpoint-generator/ SKILL.md +415 -0
- package/templates/backend/auth-module-builder/ SKILL.md +99 -0
- package/templates/backend/background-jobs-designer/ SKILL.md +166 -0
- package/templates/backend/caching-strategist/ SKILL.md +190 -0
- package/templates/backend/error-handling-standardizer/ SKILL.md +174 -0
- package/templates/backend/rate-limiting-abuse-protection/ SKILL.md +147 -0
- package/templates/backend/rbac-permissions-builder/ SKILL.md +158 -0
- package/templates/backend/service-layer-extractor/ SKILL.md +269 -0
- package/templates/backend/webhook-receiver-hardener/ SKILL.md +211 -0
- package/templates/ci-cd/artifact-sbom-publisher/ SKILL.md +236 -0
- package/templates/ci-cd/caching-strategy-optimizer/ SKILL.md +195 -0
- package/templates/ci-cd/deployment-checklist-generator/ SKILL.md +381 -0
- package/templates/ci-cd/github-actions-pipeline-creator/ SKILL.md +348 -0
- package/templates/ci-cd/monorepo-ci-optimizer/ SKILL.md +298 -0
- package/templates/ci-cd/preview-environments-builder/ SKILL.md +187 -0
- package/templates/ci-cd/quality-gates-enforcer/ SKILL.md +342 -0
- package/templates/ci-cd/release-automation-builder/ SKILL.md +281 -0
- package/templates/ci-cd/rollback-workflow-builder/ SKILL.md +372 -0
- package/templates/ci-cd/secrets-env-manager/ SKILL.md +242 -0
- package/templates/db-management/backup-restore-runbook-generator/ SKILL.md +505 -0
- package/templates/db-management/data-integrity-auditor/ SKILL.md +505 -0
- package/templates/db-management/data-retention-archiving-planner/ SKILL.md +430 -0
- package/templates/db-management/data-seeding-fixtures-builder/ SKILL.md +375 -0
- package/templates/db-management/db-performance-watchlist/ SKILL.md +425 -0
- package/templates/db-management/etl-sync-job-builder/ SKILL.md +457 -0
- package/templates/db-management/multi-tenant-safety-checker/ SKILL.md +398 -0
- package/templates/db-management/prisma-migration-assistant/ SKILL.md +379 -0
- package/templates/db-management/schema-consistency-checker/ SKILL.md +440 -0
- package/templates/db-management/sql-query-optimizer/ SKILL.md +324 -0
- package/templates/foundation/changelog-writer/ SKILL.md +431 -0
- package/templates/foundation/code-formatter-installer/ SKILL.md +320 -0
- package/templates/foundation/codebase-summarizer/ SKILL.md +360 -0
- package/templates/foundation/dependency-doctor/ SKILL.md +163 -0
- package/templates/foundation/dev-environment-bootstrapper/ SKILL.md +259 -0
- package/templates/foundation/dev-onboarding-builder/ SKILL.md +556 -0
- package/templates/foundation/docs-starter-kit/ SKILL.md +574 -0
- package/templates/foundation/explaining-code/SKILL.md +13 -0
- package/templates/foundation/git-hygiene-enforcer/ SKILL.md +455 -0
- package/templates/foundation/project-scaffolder/ SKILL.md +65 -0
- package/templates/foundation/project-scaffolder/references/templates.md +126 -0
- package/templates/foundation/repo-structure-linter/ SKILL.md +0 -0
- package/templates/foundation/repo-structure-linter/references/conventions.md +98 -0
- package/templates/frontend/animation-micro-interaction-pack/ SKILL.md +41 -0
- package/templates/frontend/component-scaffold-generator/ SKILL.md +562 -0
- package/templates/frontend/design-to-component-translator/ SKILL.md +547 -0
- package/templates/frontend/form-wizard-builder/ SKILL.md +553 -0
- package/templates/frontend/frontend-refactor-planner/ SKILL.md +37 -0
- package/templates/frontend/i18n-frontend-implementer/ SKILL.md +44 -0
- package/templates/frontend/modal-drawer-system/ SKILL.md +377 -0
- package/templates/frontend/page-layout-builder/ SKILL.md +630 -0
- package/templates/frontend/state-ux-flow-builder/ SKILL.md +23 -0
- package/templates/frontend/table-builder/ SKILL.md +350 -0
- package/templates/performance/alerting-dashboard-builder/ SKILL.md +162 -0
- package/templates/performance/backend-latency-profiler-helper/ SKILL.md +108 -0
- package/templates/performance/caching-cdn-strategy-planner/ SKILL.md +150 -0
- package/templates/performance/capacity-planning-helper/ SKILL.md +242 -0
- package/templates/performance/core-web-vitals-tuner/ SKILL.md +126 -0
- package/templates/performance/incident-runbook-generator/ SKILL.md +162 -0
- package/templates/performance/load-test-scenario-builder/ SKILL.md +256 -0
- package/templates/performance/observability-setup/ SKILL.md +232 -0
- package/templates/performance/postmortem-writer/ SKILL.md +203 -0
- package/templates/performance/structured-logging-standardizer/ SKILL.md +122 -0
- package/templates/security/auth-security-reviewer/ SKILL.md +428 -0
- package/templates/security/dependency-vulnerability-triage/ SKILL.md +495 -0
- package/templates/security/input-validation-sanitization-auditor/ SKILL.md +76 -0
- package/templates/security/pii-redaction-logging-policy-builder/ SKILL.md +65 -0
- package/templates/security/rbac-policy-tester/ SKILL.md +80 -0
- package/templates/security/secrets-scanner/ SKILL.md +462 -0
- package/templates/security/secure-headers-csp-builder/ SKILL.md +404 -0
- package/templates/security/security-incident-playbook-generator/ SKILL.md +76 -0
- package/templates/security/security-pr-checklist-skill/ SKILL.md +62 -0
- package/templates/security/threat-model-generator/ SKILL.md +394 -0
- package/templates/testing/contract-testing-builder/ SKILL.md +492 -0
- package/templates/testing/coverage-strategist/ SKILL.md +436 -0
- package/templates/testing/e2e-test-builder/ SKILL.md +382 -0
- package/templates/testing/flaky-test-detective/ SKILL.md +416 -0
- package/templates/testing/integration-test-builder/ SKILL.md +525 -0
- package/templates/testing/mocking-assistant/ SKILL.md +383 -0
- package/templates/testing/snapshot-test-refactorer/ SKILL.md +375 -0
- package/templates/testing/test-data-factory-builder/ SKILL.md +449 -0
- package/templates/testing/test-reporting-triage-skill/ SKILL.md +469 -0
- package/templates/testing/unit-test-generator/ SKILL.md +548 -0
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: threat-model-generator
|
|
3
|
+
description: Creates comprehensive threat models using STRIDE methodology with asset identification, threat enumeration, mitigation strategies, and residual risk assessment. Use for "threat modeling", "security analysis", "STRIDE", or "risk assessment".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Threat Model Generator
|
|
7
|
+
|
|
8
|
+
Systematically identify and mitigate security threats.
|
|
9
|
+
|
|
10
|
+
## STRIDE Methodology
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
S - Spoofing: Impersonating someone/something
|
|
14
|
+
T - Tampering: Modifying data or code
|
|
15
|
+
R - Repudiation: Claiming you didn't do something
|
|
16
|
+
I - Information Disclosure: Exposing protected information
|
|
17
|
+
D - Denial of Service: Making system unavailable
|
|
18
|
+
E - Elevation of Privilege: Gaining unauthorized permissions
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Asset Identification
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
interface Asset {
|
|
25
|
+
name: string;
|
|
26
|
+
type: "data" | "service" | "user" | "infrastructure";
|
|
27
|
+
sensitivity: "public" | "internal" | "confidential" | "restricted";
|
|
28
|
+
criticality: "low" | "medium" | "high" | "critical";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const assets: Asset[] = [
|
|
32
|
+
{
|
|
33
|
+
name: "User Credentials (passwords, tokens)",
|
|
34
|
+
type: "data",
|
|
35
|
+
sensitivity: "restricted",
|
|
36
|
+
criticality: "critical",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "Payment Information (credit cards)",
|
|
40
|
+
type: "data",
|
|
41
|
+
sensitivity: "restricted",
|
|
42
|
+
criticality: "critical",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "API Service",
|
|
46
|
+
type: "service",
|
|
47
|
+
sensitivity: "internal",
|
|
48
|
+
criticality: "high",
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "User Profile Data",
|
|
52
|
+
type: "data",
|
|
53
|
+
sensitivity: "confidential",
|
|
54
|
+
criticality: "medium",
|
|
55
|
+
},
|
|
56
|
+
];
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Threat Enumeration
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
interface Threat {
|
|
63
|
+
id: string;
|
|
64
|
+
category: "S" | "T" | "R" | "I" | "D" | "E";
|
|
65
|
+
description: string;
|
|
66
|
+
asset: string;
|
|
67
|
+
attackVector: string;
|
|
68
|
+
likelihood: "low" | "medium" | "high";
|
|
69
|
+
impact: "low" | "medium" | "high" | "critical";
|
|
70
|
+
riskScore: number;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const threats: Threat[] = [
|
|
74
|
+
{
|
|
75
|
+
id: "T-001",
|
|
76
|
+
category: "S",
|
|
77
|
+
description: "Attacker impersonates user with stolen credentials",
|
|
78
|
+
asset: "User Credentials",
|
|
79
|
+
attackVector: "Phishing, credential stuffing, brute force",
|
|
80
|
+
likelihood: "high",
|
|
81
|
+
impact: "critical",
|
|
82
|
+
riskScore: 9,
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: "T-002",
|
|
86
|
+
category: "T",
|
|
87
|
+
description: "SQL injection allows data modification",
|
|
88
|
+
asset: "User Profile Data",
|
|
89
|
+
attackVector: "Malicious SQL in input fields",
|
|
90
|
+
likelihood: "medium",
|
|
91
|
+
impact: "high",
|
|
92
|
+
riskScore: 7,
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
id: "T-003",
|
|
96
|
+
category: "I",
|
|
97
|
+
description: "API exposes sensitive user data without auth",
|
|
98
|
+
asset: "User Profile Data",
|
|
99
|
+
attackVector: "Direct API access, IDOR",
|
|
100
|
+
likelihood: "medium",
|
|
101
|
+
impact: "high",
|
|
102
|
+
riskScore: 7,
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
id: "T-004",
|
|
106
|
+
category: "D",
|
|
107
|
+
description: "DDoS attack overwhelms API",
|
|
108
|
+
asset: "API Service",
|
|
109
|
+
attackVector: "Volumetric attack, application-layer flood",
|
|
110
|
+
likelihood: "medium",
|
|
111
|
+
impact: "high",
|
|
112
|
+
riskScore: 7,
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
id: "T-005",
|
|
116
|
+
category: "E",
|
|
117
|
+
description: "Privilege escalation via role manipulation",
|
|
118
|
+
asset: "User Profile Data",
|
|
119
|
+
attackVector: "Parameter tampering, insecure direct object reference",
|
|
120
|
+
likelihood: "low",
|
|
121
|
+
impact: "critical",
|
|
122
|
+
riskScore: 6,
|
|
123
|
+
},
|
|
124
|
+
];
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Mitigation Strategies
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
interface Mitigation {
|
|
131
|
+
threatId: string;
|
|
132
|
+
strategy: string;
|
|
133
|
+
implementation: string;
|
|
134
|
+
effectiveness: "low" | "medium" | "high";
|
|
135
|
+
cost: "low" | "medium" | "high";
|
|
136
|
+
priority: 1 | 2 | 3;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const mitigations: Mitigation[] = [
|
|
140
|
+
{
|
|
141
|
+
threatId: "T-001",
|
|
142
|
+
strategy: "Multi-factor authentication",
|
|
143
|
+
implementation: "TOTP via authenticator app + SMS backup",
|
|
144
|
+
effectiveness: "high",
|
|
145
|
+
cost: "medium",
|
|
146
|
+
priority: 1,
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
threatId: "T-001",
|
|
150
|
+
strategy: "Rate limiting on login attempts",
|
|
151
|
+
implementation: "Max 5 attempts per 15 minutes per IP",
|
|
152
|
+
effectiveness: "medium",
|
|
153
|
+
cost: "low",
|
|
154
|
+
priority: 1,
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
threatId: "T-002",
|
|
158
|
+
strategy: "Parameterized queries",
|
|
159
|
+
implementation: "Use ORM (Prisma) for all database access",
|
|
160
|
+
effectiveness: "high",
|
|
161
|
+
cost: "low",
|
|
162
|
+
priority: 1,
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
threatId: "T-003",
|
|
166
|
+
strategy: "Authentication & Authorization",
|
|
167
|
+
implementation: "JWT tokens + RBAC middleware on all routes",
|
|
168
|
+
effectiveness: "high",
|
|
169
|
+
cost: "low",
|
|
170
|
+
priority: 1,
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
threatId: "T-004",
|
|
174
|
+
strategy: "Rate limiting & CDN",
|
|
175
|
+
implementation: "CloudFlare with rate limits + WAF rules",
|
|
176
|
+
effectiveness: "high",
|
|
177
|
+
cost: "medium",
|
|
178
|
+
priority: 2,
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
threatId: "T-005",
|
|
182
|
+
strategy: "Role-based access control",
|
|
183
|
+
implementation: "Enforce RBAC checks on all mutations",
|
|
184
|
+
effectiveness: "high",
|
|
185
|
+
cost: "low",
|
|
186
|
+
priority: 1,
|
|
187
|
+
},
|
|
188
|
+
];
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Residual Risk Assessment
|
|
192
|
+
|
|
193
|
+
```typescript
|
|
194
|
+
interface ResidualRisk {
|
|
195
|
+
threatId: string;
|
|
196
|
+
originalRisk: number;
|
|
197
|
+
mitigatedRisk: number;
|
|
198
|
+
residualRisk: number;
|
|
199
|
+
acceptanceReason?: string;
|
|
200
|
+
monitoringRequired: boolean;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function calculateResidualRisk(
|
|
204
|
+
threat: Threat,
|
|
205
|
+
mitigations: Mitigation[]
|
|
206
|
+
): ResidualRisk {
|
|
207
|
+
const threatMitigations = mitigations.filter((m) => m.threatId === threat.id);
|
|
208
|
+
|
|
209
|
+
// Calculate risk reduction
|
|
210
|
+
const maxEffectiveness = Math.max(
|
|
211
|
+
...threatMitigations.map((m) => {
|
|
212
|
+
if (m.effectiveness === "high") return 0.8;
|
|
213
|
+
if (m.effectiveness === "medium") return 0.5;
|
|
214
|
+
return 0.2;
|
|
215
|
+
})
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
const mitigatedRisk = threat.riskScore * (1 - maxEffectiveness);
|
|
219
|
+
|
|
220
|
+
return {
|
|
221
|
+
threatId: threat.id,
|
|
222
|
+
originalRisk: threat.riskScore,
|
|
223
|
+
mitigatedRisk,
|
|
224
|
+
residualRisk: Math.round(mitigatedRisk),
|
|
225
|
+
acceptanceReason:
|
|
226
|
+
mitigatedRisk < 3 ? "Risk reduced to acceptable level" : undefined,
|
|
227
|
+
monitoringRequired: mitigatedRisk >= 3,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## Threat Model Document Template
|
|
233
|
+
|
|
234
|
+
```markdown
|
|
235
|
+
# Threat Model: User Authentication System
|
|
236
|
+
|
|
237
|
+
**Date:** 2024-01-15
|
|
238
|
+
**Owner:** Security Team
|
|
239
|
+
**Reviewers:** Engineering, Product
|
|
240
|
+
|
|
241
|
+
## 1. System Overview
|
|
242
|
+
|
|
243
|
+
### Architecture
|
|
244
|
+
|
|
245
|
+
- Frontend: React SPA
|
|
246
|
+
- Backend: Node.js + Express
|
|
247
|
+
- Database: PostgreSQL
|
|
248
|
+
- Auth: JWT tokens
|
|
249
|
+
|
|
250
|
+
### Trust Boundaries
|
|
251
|
+
|
|
252
|
+
- Internet → CDN
|
|
253
|
+
- CDN → Backend API
|
|
254
|
+
- Backend API → Database
|
|
255
|
+
|
|
256
|
+
## 2. Assets
|
|
257
|
+
|
|
258
|
+
| Asset | Type | Sensitivity | Criticality |
|
|
259
|
+
| ---------------- | ---- | ------------ | ----------- |
|
|
260
|
+
| User Credentials | Data | Restricted | Critical |
|
|
261
|
+
| Session Tokens | Data | Restricted | Critical |
|
|
262
|
+
| User Profile | Data | Confidential | Medium |
|
|
263
|
+
|
|
264
|
+
## 3. Threats (STRIDE)
|
|
265
|
+
|
|
266
|
+
### Spoofing (S)
|
|
267
|
+
|
|
268
|
+
**T-001: Credential Theft**
|
|
269
|
+
|
|
270
|
+
- **Likelihood:** High
|
|
271
|
+
- **Impact:** Critical
|
|
272
|
+
- **Risk Score:** 9
|
|
273
|
+
- **Attack Vector:** Phishing, credential stuffing
|
|
274
|
+
- **Mitigations:**
|
|
275
|
+
- MFA required for all accounts
|
|
276
|
+
- Rate limiting on login (5 attempts/15min)
|
|
277
|
+
- Breach password detection
|
|
278
|
+
- **Residual Risk:** 3 (Low)
|
|
279
|
+
|
|
280
|
+
### Tampering (T)
|
|
281
|
+
|
|
282
|
+
**T-002: Token Modification**
|
|
283
|
+
|
|
284
|
+
- **Likelihood:** Medium
|
|
285
|
+
- **Impact:** High
|
|
286
|
+
- **Risk Score:** 7
|
|
287
|
+
- **Attack Vector:** Token tampering, replay attacks
|
|
288
|
+
- **Mitigations:**
|
|
289
|
+
- HMAC signature on JWT
|
|
290
|
+
- Short token expiry (15 min)
|
|
291
|
+
- Refresh token rotation
|
|
292
|
+
- **Residual Risk:** 2 (Low)
|
|
293
|
+
|
|
294
|
+
### Information Disclosure (I)
|
|
295
|
+
|
|
296
|
+
**T-003: Sensitive Data Leakage**
|
|
297
|
+
|
|
298
|
+
- **Likelihood:** Medium
|
|
299
|
+
- **Impact:** High
|
|
300
|
+
- **Risk Score:** 7
|
|
301
|
+
- **Attack Vector:** Error messages, logs, API responses
|
|
302
|
+
- **Mitigations:**
|
|
303
|
+
- Generic error messages
|
|
304
|
+
- PII redaction in logs
|
|
305
|
+
- HTTPS everywhere
|
|
306
|
+
- **Residual Risk:** 2 (Low)
|
|
307
|
+
|
|
308
|
+
## 4. Risk Summary
|
|
309
|
+
|
|
310
|
+
| Priority | Threats | Mitigated | Residual Risk |
|
|
311
|
+
| -------- | ------- | --------- | ------------- |
|
|
312
|
+
| P1 | 3 | 3 | Low |
|
|
313
|
+
| P2 | 2 | 1 | Medium |
|
|
314
|
+
| P3 | 1 | 0 | Medium |
|
|
315
|
+
|
|
316
|
+
## 5. Recommendations
|
|
317
|
+
|
|
318
|
+
1. **Immediate (P1)**
|
|
319
|
+
|
|
320
|
+
- Implement MFA
|
|
321
|
+
- Add rate limiting
|
|
322
|
+
- Deploy PII redaction
|
|
323
|
+
|
|
324
|
+
2. **Short-term (P2)**
|
|
325
|
+
|
|
326
|
+
- Add DDoS protection
|
|
327
|
+
- Implement RBAC auditing
|
|
328
|
+
|
|
329
|
+
3. **Long-term (P3)**
|
|
330
|
+
- Security training for team
|
|
331
|
+
- Penetration testing
|
|
332
|
+
|
|
333
|
+
## 6. Acceptance
|
|
334
|
+
|
|
335
|
+
- [ ] Security Team Approval
|
|
336
|
+
- [ ] Engineering Lead Approval
|
|
337
|
+
- [ ] Product Manager Approval
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
## Automated Threat Detection
|
|
341
|
+
|
|
342
|
+
```typescript
|
|
343
|
+
// scripts/detect-threats.ts
|
|
344
|
+
interface CodePattern {
|
|
345
|
+
pattern: RegExp;
|
|
346
|
+
threat: string;
|
|
347
|
+
severity: "low" | "medium" | "high" | "critical";
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
const patterns: CodePattern[] = [
|
|
351
|
+
{
|
|
352
|
+
pattern: /eval\(/,
|
|
353
|
+
threat: "Code injection via eval()",
|
|
354
|
+
severity: "critical",
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
pattern: /innerHTML\s*=/,
|
|
358
|
+
threat: "XSS via innerHTML",
|
|
359
|
+
severity: "high",
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
pattern: /process\.env\./,
|
|
363
|
+
threat: "Hardcoded environment variable",
|
|
364
|
+
severity: "medium",
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
pattern: /password|secret|key/i,
|
|
368
|
+
threat: "Potential secret in code",
|
|
369
|
+
severity: "high",
|
|
370
|
+
},
|
|
371
|
+
];
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
## Best Practices
|
|
375
|
+
|
|
376
|
+
1. **Regular updates**: Quarterly threat model reviews
|
|
377
|
+
2. **Include stakeholders**: Security, Engineering, Product
|
|
378
|
+
3. **Document decisions**: Why threats accepted/mitigated
|
|
379
|
+
4. **Test mitigations**: Verify controls work
|
|
380
|
+
5. **Monitor residual risks**: Track over time
|
|
381
|
+
6. **Automate where possible**: Integrate into CI/CD
|
|
382
|
+
|
|
383
|
+
## Output Checklist
|
|
384
|
+
|
|
385
|
+
- [ ] Assets identified and classified
|
|
386
|
+
- [ ] Threats enumerated using STRIDE
|
|
387
|
+
- [ ] Attack vectors documented
|
|
388
|
+
- [ ] Mitigations defined for each threat
|
|
389
|
+
- [ ] Residual risk calculated
|
|
390
|
+
- [ ] Risk acceptance documented
|
|
391
|
+
- [ ] Monitoring plan created
|
|
392
|
+
- [ ] Threat model document generated
|
|
393
|
+
- [ ] Stakeholder approval obtained
|
|
394
|
+
- [ ] Review schedule set
|