@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,404 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: secure-headers-csp-builder
|
|
3
|
+
description: Implements security headers and Content Security Policy with safe rollout strategy (report-only → enforce), testing, and compatibility checks. Use for "security headers", "CSP", "HTTP headers", or "XSS protection".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Secure Headers & CSP Builder
|
|
7
|
+
|
|
8
|
+
Add security headers safely without breaking functionality.
|
|
9
|
+
|
|
10
|
+
## Essential Security Headers
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
// middleware/security-headers.ts
|
|
14
|
+
import { Request, Response, NextFunction } from "express";
|
|
15
|
+
|
|
16
|
+
export function securityHeaders(
|
|
17
|
+
req: Request,
|
|
18
|
+
res: Response,
|
|
19
|
+
next: NextFunction
|
|
20
|
+
) {
|
|
21
|
+
// Prevent clickjacking
|
|
22
|
+
res.setHeader("X-Frame-Options", "DENY");
|
|
23
|
+
|
|
24
|
+
// Prevent MIME sniffing
|
|
25
|
+
res.setHeader("X-Content-Type-Options", "nosniff");
|
|
26
|
+
|
|
27
|
+
// XSS Protection (legacy browsers)
|
|
28
|
+
res.setHeader("X-XSS-Protection", "1; mode=block");
|
|
29
|
+
|
|
30
|
+
// Referrer Policy
|
|
31
|
+
res.setHeader("Referrer-Policy", "strict-origin-when-cross-origin");
|
|
32
|
+
|
|
33
|
+
// Permissions Policy (replaces Feature-Policy)
|
|
34
|
+
res.setHeader(
|
|
35
|
+
"Permissions-Policy",
|
|
36
|
+
"camera=(), microphone=(), geolocation=(self), payment=()"
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
// HSTS - Force HTTPS (only in production)
|
|
40
|
+
if (process.env.NODE_ENV === "production") {
|
|
41
|
+
res.setHeader(
|
|
42
|
+
"Strict-Transport-Security",
|
|
43
|
+
"max-age=31536000; includeSubDomains; preload"
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
next();
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Content Security Policy (CSP)
|
|
52
|
+
|
|
53
|
+
### Phase 1: Report-Only Mode
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
// config/csp-report-only.ts
|
|
57
|
+
export const cspReportOnly = {
|
|
58
|
+
"default-src": ["'self'"],
|
|
59
|
+
"script-src": [
|
|
60
|
+
"'self'",
|
|
61
|
+
"'report-sample'",
|
|
62
|
+
"https://cdn.jsdelivr.net",
|
|
63
|
+
"https://www.googletagmanager.com",
|
|
64
|
+
],
|
|
65
|
+
"style-src": ["'self'", "'unsafe-inline'", "https://fonts.googleapis.com"],
|
|
66
|
+
"img-src": ["'self'", "data:", "https:"],
|
|
67
|
+
"font-src": ["'self'", "https://fonts.gstatic.com"],
|
|
68
|
+
"connect-src": ["'self'", "https://api.example.com"],
|
|
69
|
+
"frame-ancestors": ["'none'"],
|
|
70
|
+
"base-uri": ["'self'"],
|
|
71
|
+
"form-action": ["'self'"],
|
|
72
|
+
"report-uri": ["/api/csp-report"],
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
function formatCSP(policy: Record<string, string[]>): string {
|
|
76
|
+
return Object.entries(policy)
|
|
77
|
+
.map(([key, values]) => `${key} ${values.join(" ")}`)
|
|
78
|
+
.join("; ");
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Apply report-only header
|
|
82
|
+
app.use((req, res, next) => {
|
|
83
|
+
res.setHeader(
|
|
84
|
+
"Content-Security-Policy-Report-Only",
|
|
85
|
+
formatCSP(cspReportOnly)
|
|
86
|
+
);
|
|
87
|
+
next();
|
|
88
|
+
});
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### CSP Violation Reporter
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
// routes/csp-report.ts
|
|
95
|
+
app.post(
|
|
96
|
+
"/api/csp-report",
|
|
97
|
+
express.json({ type: "application/csp-report" }),
|
|
98
|
+
(req, res) => {
|
|
99
|
+
const violation = req.body["csp-report"];
|
|
100
|
+
|
|
101
|
+
console.error("CSP Violation:", {
|
|
102
|
+
documentUri: violation["document-uri"],
|
|
103
|
+
violatedDirective: violation["violated-directive"],
|
|
104
|
+
blockedUri: violation["blocked-uri"],
|
|
105
|
+
sourceFile: violation["source-file"],
|
|
106
|
+
lineNumber: violation["line-number"],
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// Store in monitoring system
|
|
110
|
+
trackCSPViolation({
|
|
111
|
+
directive: violation["violated-directive"],
|
|
112
|
+
blockedUri: violation["blocked-uri"],
|
|
113
|
+
userAgent: req.headers["user-agent"],
|
|
114
|
+
timestamp: new Date(),
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
res.status(204).send();
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Phase 2: Enforce Mode
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
// config/csp-enforce.ts
|
|
126
|
+
export const cspEnforce = {
|
|
127
|
+
"default-src": ["'self'"],
|
|
128
|
+
"script-src": [
|
|
129
|
+
"'self'",
|
|
130
|
+
// Add nonces for inline scripts
|
|
131
|
+
"'nonce-{NONCE}'",
|
|
132
|
+
"https://cdn.jsdelivr.net",
|
|
133
|
+
"https://www.googletagmanager.com",
|
|
134
|
+
],
|
|
135
|
+
"style-src": [
|
|
136
|
+
"'self'",
|
|
137
|
+
// Replace unsafe-inline with nonces
|
|
138
|
+
"'nonce-{NONCE}'",
|
|
139
|
+
"https://fonts.googleapis.com",
|
|
140
|
+
],
|
|
141
|
+
"img-src": ["'self'", "data:", "https:"],
|
|
142
|
+
"font-src": ["'self'", "https://fonts.gstatic.com"],
|
|
143
|
+
"connect-src": ["'self'", "https://api.example.com"],
|
|
144
|
+
"frame-ancestors": ["'none'"],
|
|
145
|
+
"base-uri": ["'self'"],
|
|
146
|
+
"form-action": ["'self'"],
|
|
147
|
+
"upgrade-insecure-requests": [],
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
// Generate nonce for each request
|
|
151
|
+
app.use((req, res, next) => {
|
|
152
|
+
const nonce = crypto.randomBytes(16).toString("base64");
|
|
153
|
+
res.locals.cspNonce = nonce;
|
|
154
|
+
|
|
155
|
+
const policy = formatCSP(cspEnforce).replace(/{NONCE}/g, nonce);
|
|
156
|
+
|
|
157
|
+
res.setHeader("Content-Security-Policy", policy);
|
|
158
|
+
next();
|
|
159
|
+
});
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Nonce Implementation
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
// views/index.ejs
|
|
166
|
+
<!DOCTYPE html>
|
|
167
|
+
<html>
|
|
168
|
+
<head>
|
|
169
|
+
<!-- Inline script with nonce -->
|
|
170
|
+
<script nonce="<%= cspNonce %>">
|
|
171
|
+
console.log('This script is allowed by CSP');
|
|
172
|
+
</script>
|
|
173
|
+
|
|
174
|
+
<!-- Inline style with nonce -->
|
|
175
|
+
<style nonce="<%= cspNonce %>">
|
|
176
|
+
body { background: white; }
|
|
177
|
+
</style>
|
|
178
|
+
</head>
|
|
179
|
+
<body>
|
|
180
|
+
<h1>Secure Page</h1>
|
|
181
|
+
</body>
|
|
182
|
+
</html>
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Helmet.js Integration
|
|
186
|
+
|
|
187
|
+
```typescript
|
|
188
|
+
// Using Helmet for comprehensive security headers
|
|
189
|
+
import helmet from "helmet";
|
|
190
|
+
|
|
191
|
+
app.use(
|
|
192
|
+
helmet({
|
|
193
|
+
contentSecurityPolicy: {
|
|
194
|
+
directives: {
|
|
195
|
+
defaultSrc: ["'self'"],
|
|
196
|
+
scriptSrc: ["'self'", "'nonce-{NONCE}'"],
|
|
197
|
+
styleSrc: ["'self'", "'nonce-{NONCE}'"],
|
|
198
|
+
imgSrc: ["'self'", "data:", "https:"],
|
|
199
|
+
connectSrc: ["'self'", "https://api.example.com"],
|
|
200
|
+
fontSrc: ["'self'", "https://fonts.gstatic.com"],
|
|
201
|
+
objectSrc: ["'none'"],
|
|
202
|
+
mediaSrc: ["'self'"],
|
|
203
|
+
frameSrc: ["'none'"],
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
hsts: {
|
|
207
|
+
maxAge: 31536000,
|
|
208
|
+
includeSubDomains: true,
|
|
209
|
+
preload: true,
|
|
210
|
+
},
|
|
211
|
+
frameguard: {
|
|
212
|
+
action: "deny",
|
|
213
|
+
},
|
|
214
|
+
xssFilter: true,
|
|
215
|
+
noSniff: true,
|
|
216
|
+
referrerPolicy: {
|
|
217
|
+
policy: "strict-origin-when-cross-origin",
|
|
218
|
+
},
|
|
219
|
+
})
|
|
220
|
+
);
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## Rollout Plan
|
|
224
|
+
|
|
225
|
+
```markdown
|
|
226
|
+
# CSP Rollout Plan
|
|
227
|
+
|
|
228
|
+
## Week 1: Report-Only Mode
|
|
229
|
+
|
|
230
|
+
- [ ] Deploy CSP in report-only mode
|
|
231
|
+
- [ ] Monitor violation reports
|
|
232
|
+
- [ ] Identify problematic resources
|
|
233
|
+
- [ ] Whitelist legitimate sources
|
|
234
|
+
|
|
235
|
+
## Week 2: Analysis
|
|
236
|
+
|
|
237
|
+
- [ ] Analyze 1 week of violations
|
|
238
|
+
- [ ] Update CSP policy based on reports
|
|
239
|
+
- [ ] Fix inline scripts/styles
|
|
240
|
+
- [ ] Test on staging
|
|
241
|
+
|
|
242
|
+
## Week 3: Staged Rollout
|
|
243
|
+
|
|
244
|
+
- [ ] Enable enforcement for 10% of traffic
|
|
245
|
+
- [ ] Monitor error rates
|
|
246
|
+
- [ ] Check user reports
|
|
247
|
+
- [ ] Adjust policy if needed
|
|
248
|
+
|
|
249
|
+
## Week 4: Full Enforcement
|
|
250
|
+
|
|
251
|
+
- [ ] Enable for 50% of traffic
|
|
252
|
+
- [ ] Verify no issues
|
|
253
|
+
- [ ] Enable for 100% of traffic
|
|
254
|
+
- [ ] Keep report-only header for monitoring
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
## Testing CSP
|
|
258
|
+
|
|
259
|
+
```typescript
|
|
260
|
+
// tests/csp.test.ts
|
|
261
|
+
import { describe, it, expect } from "vitest";
|
|
262
|
+
import request from "supertest";
|
|
263
|
+
import { app } from "../src/app";
|
|
264
|
+
|
|
265
|
+
describe("Content Security Policy", () => {
|
|
266
|
+
it("should set CSP header", async () => {
|
|
267
|
+
const response = await request(app).get("/");
|
|
268
|
+
|
|
269
|
+
expect(response.headers["content-security-policy"]).toBeDefined();
|
|
270
|
+
expect(response.headers["content-security-policy"]).toContain(
|
|
271
|
+
"default-src 'self'"
|
|
272
|
+
);
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
it("should block inline scripts without nonce", async () => {
|
|
276
|
+
const html = `
|
|
277
|
+
<!DOCTYPE html>
|
|
278
|
+
<html>
|
|
279
|
+
<head>
|
|
280
|
+
<script>alert('blocked')</script>
|
|
281
|
+
</head>
|
|
282
|
+
</html>
|
|
283
|
+
`;
|
|
284
|
+
|
|
285
|
+
// This would be blocked by CSP
|
|
286
|
+
// Verify in browser console or automated tests
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
it("should allow scripts with valid nonce", async () => {
|
|
290
|
+
const response = await request(app).get("/");
|
|
291
|
+
|
|
292
|
+
// Extract nonce from response
|
|
293
|
+
const nonceMatch = response.text.match(/nonce="([^"]+)"/);
|
|
294
|
+
expect(nonceMatch).toBeDefined();
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
## Common CSP Issues & Fixes
|
|
300
|
+
|
|
301
|
+
```typescript
|
|
302
|
+
// Issue 1: Inline event handlers
|
|
303
|
+
// ❌ Bad
|
|
304
|
+
<button onclick="handleClick()">Click</button>
|
|
305
|
+
|
|
306
|
+
// ✅ Good
|
|
307
|
+
<button id="myButton">Click</button>
|
|
308
|
+
<script nonce="<%= cspNonce %>">
|
|
309
|
+
document.getElementById('myButton').addEventListener('click', handleClick);
|
|
310
|
+
</script>
|
|
311
|
+
|
|
312
|
+
// Issue 2: Inline styles
|
|
313
|
+
// ❌ Bad
|
|
314
|
+
<div style="color: red;">Text</div>
|
|
315
|
+
|
|
316
|
+
// ✅ Good
|
|
317
|
+
<style nonce="<%= cspNonce %>">
|
|
318
|
+
.red-text { color: red; }
|
|
319
|
+
</style>
|
|
320
|
+
<div class="red-text">Text</div>
|
|
321
|
+
|
|
322
|
+
// Issue 3: eval() usage
|
|
323
|
+
// ❌ Bad
|
|
324
|
+
eval('console.log("test")');
|
|
325
|
+
|
|
326
|
+
// ✅ Good
|
|
327
|
+
// Don't use eval - refactor code
|
|
328
|
+
|
|
329
|
+
// Issue 4: Third-party scripts
|
|
330
|
+
// ❌ Bad - no CSP entry
|
|
331
|
+
<script src="https://cdn.example.com/script.js"></script>
|
|
332
|
+
|
|
333
|
+
// ✅ Good - whitelisted in CSP
|
|
334
|
+
script-src: ['self', 'https://cdn.example.com']
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
## Monitoring & Alerts
|
|
338
|
+
|
|
339
|
+
```typescript
|
|
340
|
+
// monitoring/csp-violations.ts
|
|
341
|
+
import { CloudWatch } from "@aws-sdk/client-cloudwatch";
|
|
342
|
+
|
|
343
|
+
const cloudwatch = new CloudWatch();
|
|
344
|
+
|
|
345
|
+
export async function trackCSPViolation(violation: {
|
|
346
|
+
directive: string;
|
|
347
|
+
blockedUri: string;
|
|
348
|
+
userAgent: string;
|
|
349
|
+
timestamp: Date;
|
|
350
|
+
}) {
|
|
351
|
+
await cloudwatch.putMetricData({
|
|
352
|
+
Namespace: "Security/CSP",
|
|
353
|
+
MetricData: [
|
|
354
|
+
{
|
|
355
|
+
MetricName: "Violations",
|
|
356
|
+
Value: 1,
|
|
357
|
+
Unit: "Count",
|
|
358
|
+
Timestamp: violation.timestamp,
|
|
359
|
+
Dimensions: [
|
|
360
|
+
{
|
|
361
|
+
Name: "Directive",
|
|
362
|
+
Value: violation.directive,
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
Name: "BlockedUri",
|
|
366
|
+
Value: violation.blockedUri,
|
|
367
|
+
},
|
|
368
|
+
],
|
|
369
|
+
},
|
|
370
|
+
],
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
// Alert if violations spike
|
|
374
|
+
if (await isViolationSpike()) {
|
|
375
|
+
await sendAlert({
|
|
376
|
+
title: "CSP Violation Spike Detected",
|
|
377
|
+
message: `High number of violations for ${violation.directive}`,
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
## Best Practices
|
|
384
|
+
|
|
385
|
+
1. **Start report-only**: Don't break production
|
|
386
|
+
2. **Gradual rollout**: 10% → 50% → 100%
|
|
387
|
+
3. **Use nonces**: Better than unsafe-inline
|
|
388
|
+
4. **Monitor violations**: Track and analyze
|
|
389
|
+
5. **Test thoroughly**: All pages and features
|
|
390
|
+
6. **Document exceptions**: Why resources whitelisted
|
|
391
|
+
7. **Regular audits**: Quarterly CSP review
|
|
392
|
+
|
|
393
|
+
## Output Checklist
|
|
394
|
+
|
|
395
|
+
- [ ] Security headers implemented
|
|
396
|
+
- [ ] CSP policy defined (report-only)
|
|
397
|
+
- [ ] CSP violation reporter endpoint
|
|
398
|
+
- [ ] Nonce generation for inline scripts
|
|
399
|
+
- [ ] Helmet.js configured
|
|
400
|
+
- [ ] Rollout plan documented
|
|
401
|
+
- [ ] Testing strategy implemented
|
|
402
|
+
- [ ] Monitoring and alerts configured
|
|
403
|
+
- [ ] Team trained on CSP
|
|
404
|
+
- [ ] Staged rollout completed
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: security-incident-playbook-generator
|
|
3
|
+
description: Creates response procedures for security incidents with containment steps, communication templates, and evidence collection. Use for "incident response", "security playbook", "breach response", or "IR plan".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Security Incident Playbook Generator
|
|
7
|
+
|
|
8
|
+
Prepare for security incidents with structured response plans.
|
|
9
|
+
|
|
10
|
+
## Incident Response Phases
|
|
11
|
+
|
|
12
|
+
```markdown
|
|
13
|
+
# Security Incident Response Playbook
|
|
14
|
+
|
|
15
|
+
## Phase 1: Detection & Triage (0-15 min)
|
|
16
|
+
|
|
17
|
+
### Detection Sources
|
|
18
|
+
|
|
19
|
+
- Security alerts (CloudWatch, Sentry)
|
|
20
|
+
- User reports
|
|
21
|
+
- Anomaly detection
|
|
22
|
+
- Penetration test findings
|
|
23
|
+
|
|
24
|
+
### Initial Assessment
|
|
25
|
+
|
|
26
|
+
- [ ] Identify incident type
|
|
27
|
+
- [ ] Assess severity (P0-P3)
|
|
28
|
+
- [ ] Determine scope
|
|
29
|
+
- [ ] Alert on-call security
|
|
30
|
+
|
|
31
|
+
## Phase 2: Containment (15-60 min)
|
|
32
|
+
|
|
33
|
+
### Immediate Actions
|
|
34
|
+
|
|
35
|
+
- [ ] Isolate affected systems
|
|
36
|
+
- [ ] Revoke compromised credentials
|
|
37
|
+
- [ ] Block malicious IPs
|
|
38
|
+
- [ ] Enable enhanced monitoring
|
|
39
|
+
|
|
40
|
+
### Evidence Preservation
|
|
41
|
+
|
|
42
|
+
- [ ] Capture logs
|
|
43
|
+
- [ ] Take system snapshots
|
|
44
|
+
- [ ] Document timeline
|
|
45
|
+
- [ ] Preserve artifacts
|
|
46
|
+
|
|
47
|
+
## Phase 3: Eradication (1-24 hours)
|
|
48
|
+
|
|
49
|
+
- [ ] Remove malware
|
|
50
|
+
- [ ] Close vulnerabilities
|
|
51
|
+
- [ ] Reset passwords
|
|
52
|
+
- [ ] Update firewall rules
|
|
53
|
+
|
|
54
|
+
## Phase 4: Recovery (24-72 hours)
|
|
55
|
+
|
|
56
|
+
- [ ] Restore from backup
|
|
57
|
+
- [ ] Verify system integrity
|
|
58
|
+
- [ ] Resume operations
|
|
59
|
+
- [ ] Monitor for reinfection
|
|
60
|
+
|
|
61
|
+
## Phase 5: Post-Incident (1 week)
|
|
62
|
+
|
|
63
|
+
- [ ] Document lessons learned
|
|
64
|
+
- [ ] Update procedures
|
|
65
|
+
- [ ] Security training
|
|
66
|
+
- [ ] Notify affected users (if required)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Output Checklist
|
|
70
|
+
|
|
71
|
+
- [ ] Response phases defined
|
|
72
|
+
- [ ] Containment procedures
|
|
73
|
+
- [ ] Communication templates
|
|
74
|
+
- [ ] Evidence collection rules
|
|
75
|
+
- [ ] Post-incident review
|
|
76
|
+
ENDFILE
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: security-pr-checklist-skill
|
|
3
|
+
description: Creates repeatable security review checklist for PRs with required checks, common pitfalls, and automated gating. Use for "security review", "PR checklist", "code review", or "security gates".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Security PR Checklist Skill
|
|
7
|
+
|
|
8
|
+
Standardized security review for pull requests.
|
|
9
|
+
|
|
10
|
+
## PR Security Checklist
|
|
11
|
+
|
|
12
|
+
```markdown
|
|
13
|
+
## Security Review Checklist
|
|
14
|
+
|
|
15
|
+
### Authentication & Authorization
|
|
16
|
+
|
|
17
|
+
- [ ] No hardcoded credentials
|
|
18
|
+
- [ ] Authorization checks on all endpoints
|
|
19
|
+
- [ ] Session management secure
|
|
20
|
+
- [ ] Rate limiting on auth endpoints
|
|
21
|
+
|
|
22
|
+
### Input Validation
|
|
23
|
+
|
|
24
|
+
- [ ] All inputs validated
|
|
25
|
+
- [ ] Output properly encoded
|
|
26
|
+
- [ ] No SQL injection risks
|
|
27
|
+
- [ ] No XSS vulnerabilities
|
|
28
|
+
|
|
29
|
+
### Data Protection
|
|
30
|
+
|
|
31
|
+
- [ ] Sensitive data encrypted at rest
|
|
32
|
+
- [ ] HTTPS enforced
|
|
33
|
+
- [ ] No PII in logs
|
|
34
|
+
- [ ] Secure cookie configuration
|
|
35
|
+
|
|
36
|
+
### Dependencies
|
|
37
|
+
|
|
38
|
+
- [ ] No new high/critical vulnerabilities
|
|
39
|
+
- [ ] Dependencies up to date
|
|
40
|
+
- [ ] No suspicious packages
|
|
41
|
+
|
|
42
|
+
### Secrets Management
|
|
43
|
+
|
|
44
|
+
- [ ] No secrets in code
|
|
45
|
+
- [ ] Environment variables used
|
|
46
|
+
- [ ] .env files in .gitignore
|
|
47
|
+
|
|
48
|
+
### Error Handling
|
|
49
|
+
|
|
50
|
+
- [ ] No sensitive info in errors
|
|
51
|
+
- [ ] Generic error messages
|
|
52
|
+
- [ ] Proper logging
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Output Checklist
|
|
56
|
+
|
|
57
|
+
- [ ] PR template created
|
|
58
|
+
- [ ] Required security checks
|
|
59
|
+
- [ ] Common pitfalls documented
|
|
60
|
+
- [ ] Automated checks in CI
|
|
61
|
+
- [ ] Review guidelines
|
|
62
|
+
ENDFILE
|