@greenarmor/ges-doc-generator 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/LICENSE +21 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +675 -0
- package/dist/index.js.map +1 -0
- package/package.json +26 -0
- package/src/index.ts +702 -0
- package/tsconfig.json +6 -0
- package/tsconfig.tsbuildinfo +1 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,702 @@
|
|
|
1
|
+
import type { ProjectType, ProjectConfig } from "@greenarmor/ges-core";
|
|
2
|
+
import { GESF_VERSION, GES_DIR, COMPLIANCE_DIR, SECURITY_DIR, CONTROLS_DIR, POLICIES_DIR, CHECKLISTS_DIR, DOCS_DIR, REPORTS_DIR } from "@greenarmor/ges-core";
|
|
3
|
+
import * as fs from "node:fs";
|
|
4
|
+
import * as path from "node:path";
|
|
5
|
+
|
|
6
|
+
export interface GeneratedFile {
|
|
7
|
+
filePath: string;
|
|
8
|
+
content: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function generateComplianceDocs(projectName: string, projectType: ProjectType): GeneratedFile[] {
|
|
12
|
+
return [
|
|
13
|
+
{
|
|
14
|
+
filePath: path.join(COMPLIANCE_DIR, "gdpr.md"),
|
|
15
|
+
content: generateGDPRDoc(projectName, projectType),
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
filePath: path.join(COMPLIANCE_DIR, "data-inventory.md"),
|
|
19
|
+
content: generateDataInventoryDoc(projectName),
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
filePath: path.join(COMPLIANCE_DIR, "retention-policy.md"),
|
|
23
|
+
content: generateRetentionPolicyDoc(projectName),
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
filePath: path.join(COMPLIANCE_DIR, "processing-records.md"),
|
|
27
|
+
content: generateProcessingRecordsDoc(projectName),
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
filePath: path.join(COMPLIANCE_DIR, "risk-register.md"),
|
|
31
|
+
content: generateRiskRegisterDoc(projectName),
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
filePath: path.join(COMPLIANCE_DIR, "access-control-matrix.md"),
|
|
35
|
+
content: generateAccessControlMatrixDoc(projectName),
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
filePath: path.join(COMPLIANCE_DIR, "privacy-impact-assessment.md"),
|
|
39
|
+
content: generatePIADoc(projectName, projectType),
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function generateSecurityDocs(projectName: string, projectType: ProjectType): GeneratedFile[] {
|
|
45
|
+
return [
|
|
46
|
+
{
|
|
47
|
+
filePath: path.join(SECURITY_DIR, "threat-model.md"),
|
|
48
|
+
content: generateThreatModelDoc(projectName, projectType),
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
filePath: path.join(SECURITY_DIR, "key-management.md"),
|
|
52
|
+
content: generateKeyManagementDoc(projectName),
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
filePath: path.join(SECURITY_DIR, "logging-policy.md"),
|
|
56
|
+
content: generateLoggingPolicyDoc(projectName),
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
filePath: path.join(SECURITY_DIR, "backup-policy.md"),
|
|
60
|
+
content: generateBackupPolicyDoc(projectName),
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
filePath: path.join(SECURITY_DIR, "incident-response.md"),
|
|
64
|
+
content: generateIncidentResponseDoc(projectName),
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
filePath: path.join(SECURITY_DIR, "disaster-recovery.md"),
|
|
68
|
+
content: generateDisasterRecoveryDoc(projectName),
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
filePath: path.join(SECURITY_DIR, "encryption-standard.md"),
|
|
72
|
+
content: generateEncryptionStandardDoc(projectName),
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function generateConfigYaml(config: ProjectConfig): GeneratedFile {
|
|
78
|
+
return {
|
|
79
|
+
filePath: path.join(GES_DIR, "config.yaml"),
|
|
80
|
+
content: [
|
|
81
|
+
`project_name: ${config.project_name}`,
|
|
82
|
+
`project_type: ${config.project_type}`,
|
|
83
|
+
`version: ${config.version}`,
|
|
84
|
+
`created_at: ${config.created_at}`,
|
|
85
|
+
``,
|
|
86
|
+
`frameworks:`,
|
|
87
|
+
...config.frameworks.map(f => ` - ${f}`),
|
|
88
|
+
``,
|
|
89
|
+
`requirements:`,
|
|
90
|
+
...Object.entries(config.requirements).map(([key, val]) => [
|
|
91
|
+
` ${key}:`,
|
|
92
|
+
` required: ${val.required}`,
|
|
93
|
+
val.level ? ` level: ${val.level}` : null,
|
|
94
|
+
].filter(Boolean).join("\n")),
|
|
95
|
+
].join("\n"),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function generateMetadataJson(config: ProjectConfig): GeneratedFile {
|
|
100
|
+
return {
|
|
101
|
+
filePath: path.join(GES_DIR, "metadata.json"),
|
|
102
|
+
content: JSON.stringify({
|
|
103
|
+
project_name: config.project_name,
|
|
104
|
+
project_type: config.project_type,
|
|
105
|
+
initialized_at: config.created_at,
|
|
106
|
+
gesf_version: GESF_VERSION,
|
|
107
|
+
}, null, 2),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function generateConfigJson(config: ProjectConfig): GeneratedFile {
|
|
112
|
+
return {
|
|
113
|
+
filePath: path.join(GES_DIR, "config.json"),
|
|
114
|
+
content: JSON.stringify(config, null, 2),
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function generateFrameworkVersionJson(): GeneratedFile {
|
|
119
|
+
return {
|
|
120
|
+
filePath: path.join(GES_DIR, "framework-version.json"),
|
|
121
|
+
content: JSON.stringify({
|
|
122
|
+
gesf_version: GESF_VERSION,
|
|
123
|
+
packs: {
|
|
124
|
+
gdpr: "1.0.0",
|
|
125
|
+
owasp: "1.0.0",
|
|
126
|
+
ai: "1.0.0",
|
|
127
|
+
blockchain: "1.0.0",
|
|
128
|
+
government: "1.0.0",
|
|
129
|
+
cis: "1.0.0",
|
|
130
|
+
nist: "1.0.0",
|
|
131
|
+
},
|
|
132
|
+
}, null, 2),
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export function generateScoreJson(): GeneratedFile {
|
|
137
|
+
return {
|
|
138
|
+
filePath: path.join(GES_DIR, "score.json"),
|
|
139
|
+
content: JSON.stringify({
|
|
140
|
+
overall: 0,
|
|
141
|
+
frameworks: {},
|
|
142
|
+
evaluated_at: new Date().toISOString(),
|
|
143
|
+
}, null, 2),
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function generateGDPRDoc(name: string, type: ProjectType): string {
|
|
148
|
+
return `# GDPR Compliance - ${name}
|
|
149
|
+
|
|
150
|
+
## Overview
|
|
151
|
+
|
|
152
|
+
This document tracks GDPR compliance for the **${name}** project (type: ${type}).
|
|
153
|
+
|
|
154
|
+
## Applicable Articles
|
|
155
|
+
|
|
156
|
+
- Article 5: Principles relating to processing of personal data
|
|
157
|
+
- Article 25: Data protection by design and by default
|
|
158
|
+
- Article 30: Records of processing activities
|
|
159
|
+
- Article 32: Security of processing
|
|
160
|
+
- Article 33: Notification of a personal data breach to the supervisory authority
|
|
161
|
+
- Article 34: Communication of a personal data breach to the data subject
|
|
162
|
+
|
|
163
|
+
## Status
|
|
164
|
+
|
|
165
|
+
> Run \`ges audit\` to evaluate current compliance status.
|
|
166
|
+
|
|
167
|
+
## Legal Basis
|
|
168
|
+
|
|
169
|
+
Document the legal basis for each processing activity:
|
|
170
|
+
- [ ] Consent
|
|
171
|
+
- [ ] Contract
|
|
172
|
+
- [ ] Legal obligation
|
|
173
|
+
- [ ] Vital interests
|
|
174
|
+
- [ ] Public task
|
|
175
|
+
- [ ] Legitimate interests
|
|
176
|
+
|
|
177
|
+
## Data Subject Rights
|
|
178
|
+
|
|
179
|
+
Ensure mechanisms exist for:
|
|
180
|
+
- [ ] Right of access (Article 15)
|
|
181
|
+
- [ ] Right to rectification (Article 16)
|
|
182
|
+
- [ ] Right to erasure (Article 17)
|
|
183
|
+
- [ ] Right to restriction (Article 18)
|
|
184
|
+
- [ ] Right to data portability (Article 20)
|
|
185
|
+
- [ ] Right to object (Article 21)
|
|
186
|
+
`;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function generateDataInventoryDoc(name: string): string {
|
|
190
|
+
return `# Data Inventory - ${name}
|
|
191
|
+
|
|
192
|
+
## Data Categories
|
|
193
|
+
|
|
194
|
+
| Category | Type | Classification | Retention | Legal Basis |
|
|
195
|
+
|----------|------|---------------|-----------|-------------|
|
|
196
|
+
| User profiles | Personal | Restricted | Account lifetime + 30 days | Contract |
|
|
197
|
+
| Email addresses | Personal | Confidential | Account lifetime + 30 days | Contract |
|
|
198
|
+
| Authentication data | Personal | Restricted | Session duration | Contract |
|
|
199
|
+
| Audit logs | Operational | Internal | 1 year | Legal obligation |
|
|
200
|
+
|
|
201
|
+
## Data Flows
|
|
202
|
+
|
|
203
|
+
Document all data flows including:
|
|
204
|
+
- Data collection points
|
|
205
|
+
- Processing activities
|
|
206
|
+
- Data storage locations
|
|
207
|
+
- Third-party data sharing
|
|
208
|
+
- Cross-border transfers
|
|
209
|
+
|
|
210
|
+
## Third-Party Processors
|
|
211
|
+
|
|
212
|
+
| Processor | Purpose | Data Shared | DPA Signed | Location |
|
|
213
|
+
|-----------|---------|-------------|------------|----------|
|
|
214
|
+
| | | | | |
|
|
215
|
+
`;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function generateRetentionPolicyDoc(name: string): string {
|
|
219
|
+
return `# Data Retention Policy - ${name}
|
|
220
|
+
|
|
221
|
+
## Retention Periods
|
|
222
|
+
|
|
223
|
+
| Data Category | Retention Period | Justification | Deletion Method |
|
|
224
|
+
|---------------|-----------------|---------------|-----------------|
|
|
225
|
+
| User accounts | Account lifetime + 30 days | Contract fulfillment | Automated deletion |
|
|
226
|
+
| Authentication logs | 90 days | Security monitoring | Automated rotation |
|
|
227
|
+
| Audit logs | 1 year | Legal obligation | Automated archival |
|
|
228
|
+
| Session data | Session duration | Operational | Automatic expiry |
|
|
229
|
+
| Backup data | 90 days | Disaster recovery | Automated rotation |
|
|
230
|
+
|
|
231
|
+
## Deletion Procedures
|
|
232
|
+
|
|
233
|
+
1. Automated deletion via scheduled jobs
|
|
234
|
+
2. Soft delete with scheduled hard delete
|
|
235
|
+
3. Anonymisation where deletion is not feasible
|
|
236
|
+
4. Backup exclusion for deleted records
|
|
237
|
+
|
|
238
|
+
## Review Schedule
|
|
239
|
+
|
|
240
|
+
- Monthly: Review deletion jobs
|
|
241
|
+
- Quarterly: Review retention periods
|
|
242
|
+
- Annually: Full retention policy review
|
|
243
|
+
`;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function generateProcessingRecordsDoc(name: string): string {
|
|
247
|
+
return `# Records of Processing Activities - ${name}
|
|
248
|
+
|
|
249
|
+
## Article 30 Requirements
|
|
250
|
+
|
|
251
|
+
### Controller Information
|
|
252
|
+
|
|
253
|
+
- **Organization**: [To be completed]
|
|
254
|
+
- **Contact**: [To be completed]
|
|
255
|
+
- **DPO**: [To be completed]
|
|
256
|
+
|
|
257
|
+
### Processing Activities
|
|
258
|
+
|
|
259
|
+
| Activity | Purpose | Data Categories | Recipients | Retention | Transfers | Security Measures |
|
|
260
|
+
|----------|---------|----------------|------------|-----------|-----------|-------------------|
|
|
261
|
+
| | | | | | | |
|
|
262
|
+
|
|
263
|
+
## Documentation
|
|
264
|
+
|
|
265
|
+
Each processing activity must document:
|
|
266
|
+
1. Purpose of processing
|
|
267
|
+
2. Legal basis
|
|
268
|
+
3. Categories of data subjects
|
|
269
|
+
4. Categories of personal data
|
|
270
|
+
5. Categories of recipients
|
|
271
|
+
6. International transfers
|
|
272
|
+
7. Retention periods
|
|
273
|
+
8. Technical and organisational security measures
|
|
274
|
+
`;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function generateRiskRegisterDoc(name: string): string {
|
|
278
|
+
return `# Risk Register - ${name}
|
|
279
|
+
|
|
280
|
+
## Risk Assessment
|
|
281
|
+
|
|
282
|
+
| ID | Risk | Likelihood | Impact | Severity | Mitigation | Status |
|
|
283
|
+
|----|------|-----------|--------|----------|------------|--------|
|
|
284
|
+
| R001 | Data breach - unauthorized access | Medium | High | Critical | Encryption, access controls, MFA | Open |
|
|
285
|
+
| R002 | Data breach - external attack | Medium | High | Critical | WAF, vulnerability scanning, patching | Open |
|
|
286
|
+
| R003 | Insider threat | Low | High | High | RBAC, audit logging, least privilege | Open |
|
|
287
|
+
| R004 | Data loss | Low | Critical | Critical | Backups, disaster recovery plan | Open |
|
|
288
|
+
| R005 | Non-compliance | Medium | High | High | Regular audits, compliance scanning | Open |
|
|
289
|
+
|
|
290
|
+
## Review Schedule
|
|
291
|
+
|
|
292
|
+
- Monthly: Update risk register
|
|
293
|
+
- Quarterly: Risk assessment review
|
|
294
|
+
- Annually: Full risk assessment
|
|
295
|
+
`;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
function generateAccessControlMatrixDoc(name: string): string {
|
|
299
|
+
return `# Access Control Matrix - ${name}
|
|
300
|
+
|
|
301
|
+
## Roles
|
|
302
|
+
|
|
303
|
+
| Role | Description |
|
|
304
|
+
|------|-------------|
|
|
305
|
+
| Admin | Full system access with audit trail |
|
|
306
|
+
| User | Standard user access |
|
|
307
|
+
| Auditor | Read-only access to audit data |
|
|
308
|
+
| System | Service account for automated processes |
|
|
309
|
+
|
|
310
|
+
## Permissions Matrix
|
|
311
|
+
|
|
312
|
+
| Resource | Admin | User | Auditor | System |
|
|
313
|
+
|----------|-------|------|---------|--------|
|
|
314
|
+
| User Management | CRUD | R (own) | R | R |
|
|
315
|
+
| Data Access | CRUD | CR (own) | R | CR |
|
|
316
|
+
| Audit Logs | R | - | R | W |
|
|
317
|
+
| Configuration | CRUD | - | R | R |
|
|
318
|
+
| Reports | CRUD | R (own) | R | CR |
|
|
319
|
+
|
|
320
|
+
## Principles
|
|
321
|
+
|
|
322
|
+
- **Least Privilege**: Users have minimum required access
|
|
323
|
+
- **Deny by Default**: Access denied unless explicitly granted
|
|
324
|
+
- **Separation of Duties**: Critical operations require multiple roles
|
|
325
|
+
`;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function generatePIADoc(name: string, type: ProjectType): string {
|
|
329
|
+
return `# Privacy Impact Assessment - ${name}
|
|
330
|
+
|
|
331
|
+
## Project Details
|
|
332
|
+
|
|
333
|
+
- **Project**: ${name}
|
|
334
|
+
- **Type**: ${type}
|
|
335
|
+
- **Assessment Date**: ${new Date().toISOString().split("T")[0]}
|
|
336
|
+
- **Assessor**: [To be completed]
|
|
337
|
+
|
|
338
|
+
## Data Processing Description
|
|
339
|
+
|
|
340
|
+
### What data is being processed?
|
|
341
|
+
[To be completed]
|
|
342
|
+
|
|
343
|
+
### Why is the data being processed?
|
|
344
|
+
[To be completed]
|
|
345
|
+
|
|
346
|
+
### How is the data being processed?
|
|
347
|
+
[To be completed]
|
|
348
|
+
|
|
349
|
+
### Where is the data stored?
|
|
350
|
+
[To be completed]
|
|
351
|
+
|
|
352
|
+
### Who has access?
|
|
353
|
+
[To be completed]
|
|
354
|
+
|
|
355
|
+
### How long is data retained?
|
|
356
|
+
[To be completed]
|
|
357
|
+
|
|
358
|
+
## Necessity and Proportionality
|
|
359
|
+
|
|
360
|
+
- [ ] Data processing is necessary for the stated purpose
|
|
361
|
+
- [ ] Data minimisation principles are applied
|
|
362
|
+
- [ ] No less intrusive alternative exists
|
|
363
|
+
|
|
364
|
+
## Risk Assessment
|
|
365
|
+
|
|
366
|
+
| Risk | Severity | Mitigation |
|
|
367
|
+
|------|----------|------------|
|
|
368
|
+
| Unauthorized access to personal data | High | Encryption, MFA, RBAC |
|
|
369
|
+
| Data breach | High | Security controls, incident response plan |
|
|
370
|
+
| Excessive data collection | Medium | Data minimisation review |
|
|
371
|
+
| Non-compliant data transfer | Medium | Transfer mechanisms in place |
|
|
372
|
+
|
|
373
|
+
## Compliance Measures
|
|
374
|
+
|
|
375
|
+
- [ ] Legal basis documented
|
|
376
|
+
- [ ] Privacy notice provided
|
|
377
|
+
- [ ] Consent mechanism implemented
|
|
378
|
+
- [ ] Data subject rights supported
|
|
379
|
+
- [ ] Retention policy defined
|
|
380
|
+
- [ ] Security measures implemented
|
|
381
|
+
- [ ] DPIA completed (if required)
|
|
382
|
+
|
|
383
|
+
## Approval
|
|
384
|
+
|
|
385
|
+
- **DPO Review**: [Pending]
|
|
386
|
+
- **Sign-off**: [Pending]
|
|
387
|
+
`;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
function generateThreatModelDoc(name: string, type: ProjectType): string {
|
|
391
|
+
return `# Threat Model - ${name}
|
|
392
|
+
|
|
393
|
+
## System Overview
|
|
394
|
+
|
|
395
|
+
- **Project**: ${name}
|
|
396
|
+
- **Type**: ${type}
|
|
397
|
+
|
|
398
|
+
## Assets
|
|
399
|
+
|
|
400
|
+
- User personal data
|
|
401
|
+
- Authentication credentials
|
|
402
|
+
- Session tokens
|
|
403
|
+
- API keys and secrets
|
|
404
|
+
- Application source code
|
|
405
|
+
- Infrastructure configuration
|
|
406
|
+
|
|
407
|
+
## Threat Categories (STRIDE)
|
|
408
|
+
|
|
409
|
+
### Spoofing
|
|
410
|
+
- Unauthorized access via stolen credentials
|
|
411
|
+
- Session hijacking
|
|
412
|
+
|
|
413
|
+
### Tampering
|
|
414
|
+
- Data modification by unauthorized users
|
|
415
|
+
- SQL injection / NoSQL injection
|
|
416
|
+
- Parameter tampering
|
|
417
|
+
|
|
418
|
+
### Repudiation
|
|
419
|
+
- Actions performed without audit trail
|
|
420
|
+
- Denial of data access
|
|
421
|
+
|
|
422
|
+
### Information Disclosure
|
|
423
|
+
- Data breach via API vulnerability
|
|
424
|
+
- Logging of sensitive data
|
|
425
|
+
- Error messages leaking information
|
|
426
|
+
|
|
427
|
+
### Denial of Service
|
|
428
|
+
- Rate limiting bypass
|
|
429
|
+
- Resource exhaustion
|
|
430
|
+
|
|
431
|
+
### Elevation of Privilege
|
|
432
|
+
- Role escalation via API
|
|
433
|
+
- IDOR vulnerabilities
|
|
434
|
+
- JWT manipulation
|
|
435
|
+
|
|
436
|
+
## Mitigations
|
|
437
|
+
|
|
438
|
+
| Threat | Mitigation | Status |
|
|
439
|
+
|--------|------------|--------|
|
|
440
|
+
| Stolen credentials | MFA, Argon2id hashing | [ ] |
|
|
441
|
+
| SQL injection | Parameterized queries, input validation | [ ] |
|
|
442
|
+
| XSS | Output encoding, CSP headers | [ ] |
|
|
443
|
+
| CSRF | CSRF tokens, SameSite cookies | [ ] |
|
|
444
|
+
| Data breach | Encryption at rest and in transit | [ ] |
|
|
445
|
+
| Insider threat | RBAC, audit logging, least privilege | [ ] |
|
|
446
|
+
`;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
function generateKeyManagementDoc(name: string): string {
|
|
450
|
+
return `# Key Management Policy - ${name}
|
|
451
|
+
|
|
452
|
+
## Approved Algorithms
|
|
453
|
+
|
|
454
|
+
- **Symmetric Encryption**: AES-256-GCM, ChaCha20-Poly1305
|
|
455
|
+
- **Asymmetric Encryption**: RSA-4096, Ed25519
|
|
456
|
+
- **Hashing**: SHA-256, SHA-384, SHA-512
|
|
457
|
+
- **Password Hashing**: Argon2id (recommended), bcrypt
|
|
458
|
+
|
|
459
|
+
## Key Lifecycle
|
|
460
|
+
|
|
461
|
+
1. **Generation**: Use cryptographically secure random generators
|
|
462
|
+
2. **Distribution**: Via secure key management system
|
|
463
|
+
3. **Storage**: Encrypted at rest, access controlled
|
|
464
|
+
4. **Rotation**: Regular rotation schedule (90 days minimum)
|
|
465
|
+
5. **Revocation**: Immediate revocation capability
|
|
466
|
+
6. **Destruction**: Secure deletion with verification
|
|
467
|
+
|
|
468
|
+
## Key Storage
|
|
469
|
+
|
|
470
|
+
- [ ] HashiCorp Vault
|
|
471
|
+
- [ ] AWS KMS
|
|
472
|
+
- [ ] Azure Key Vault
|
|
473
|
+
- [ ] GCP Secret Manager
|
|
474
|
+
|
|
475
|
+
## Rotation Schedule
|
|
476
|
+
|
|
477
|
+
| Key Type | Rotation Period |
|
|
478
|
+
|----------|----------------|
|
|
479
|
+
| Encryption keys | 90 days |
|
|
480
|
+
| API keys | 180 days |
|
|
481
|
+
| TLS certificates | 90 days (auto-renew) |
|
|
482
|
+
| Database credentials | 90 days |
|
|
483
|
+
`;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
function generateLoggingPolicyDoc(name: string): string {
|
|
487
|
+
return `# Logging Policy - ${name}
|
|
488
|
+
|
|
489
|
+
## Must Log
|
|
490
|
+
|
|
491
|
+
- Authentication events (success and failure)
|
|
492
|
+
- Authorization decisions (access granted/denied)
|
|
493
|
+
- Data export operations
|
|
494
|
+
- Role and permission changes
|
|
495
|
+
- Administrative actions
|
|
496
|
+
- API access (method, path, status code)
|
|
497
|
+
|
|
498
|
+
## Must NOT Log
|
|
499
|
+
|
|
500
|
+
- Passwords (even hashed)
|
|
501
|
+
- Authentication tokens
|
|
502
|
+
- Private keys
|
|
503
|
+
- Sensitive personal data (SSN, health data, etc.)
|
|
504
|
+
- Full credit card numbers
|
|
505
|
+
- Session cookies
|
|
506
|
+
|
|
507
|
+
## Audit Trail Fields
|
|
508
|
+
|
|
509
|
+
Every audit log entry must include:
|
|
510
|
+
- \`userId\`: Who performed the action
|
|
511
|
+
- \`action\`: What action was performed
|
|
512
|
+
- \`resource\`: What resource was affected
|
|
513
|
+
- \`timestamp\`: When the action occurred (ISO 8601)
|
|
514
|
+
- \`ipAddress\`: Source IP address
|
|
515
|
+
|
|
516
|
+
## Log Retention
|
|
517
|
+
|
|
518
|
+
| Log Type | Retention Period |
|
|
519
|
+
|----------|-----------------|
|
|
520
|
+
| Audit logs | 1 year |
|
|
521
|
+
| Security logs | 90 days |
|
|
522
|
+
| Access logs | 30 days |
|
|
523
|
+
| Error logs | 30 days |
|
|
524
|
+
|
|
525
|
+
## Immutability
|
|
526
|
+
|
|
527
|
+
All audit logs must be append-only. No modification or deletion is permitted.
|
|
528
|
+
`;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
function generateBackupPolicyDoc(name: string): string {
|
|
532
|
+
return `# Backup Policy - ${name}
|
|
533
|
+
|
|
534
|
+
## Backup Schedule
|
|
535
|
+
|
|
536
|
+
- **Daily**: Full database backup at 02:00 UTC
|
|
537
|
+
- **Hourly**: Incremental backup of critical data
|
|
538
|
+
- **Weekly**: Full system backup including configuration
|
|
539
|
+
|
|
540
|
+
## Backup Requirements
|
|
541
|
+
|
|
542
|
+
- [ ] All backups are encrypted (AES-256-GCM)
|
|
543
|
+
- [ ] Backups stored in separate geographic region
|
|
544
|
+
- [ ] Backup access restricted to authorized personnel
|
|
545
|
+
- [ ] Backup integrity verified after creation
|
|
546
|
+
|
|
547
|
+
## Restore Testing
|
|
548
|
+
|
|
549
|
+
- **Weekly**: Restore test to staging environment
|
|
550
|
+
- **Monthly**: Full recovery test with data verification
|
|
551
|
+
|
|
552
|
+
## Recovery Objectives
|
|
553
|
+
|
|
554
|
+
- **RPO (Recovery Point Objective)**: 1 hour
|
|
555
|
+
- **RTO (Recovery Time Objective)**: 4 hours
|
|
556
|
+
|
|
557
|
+
## Backup Inventory
|
|
558
|
+
|
|
559
|
+
| System | Schedule | Encryption | Last Restore Test |
|
|
560
|
+
|--------|----------|------------|-------------------|
|
|
561
|
+
| Database | Daily | AES-256-GCM | [Pending] |
|
|
562
|
+
| File Storage | Daily | AES-256-GCM | [Pending] |
|
|
563
|
+
| Configuration | Weekly | AES-256-GCM | [Pending] |
|
|
564
|
+
`;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
function generateIncidentResponseDoc(name: string): string {
|
|
568
|
+
return `# Incident Response Plan - ${name}
|
|
569
|
+
|
|
570
|
+
## Severity Levels
|
|
571
|
+
|
|
572
|
+
| Level | Description | Response Time |
|
|
573
|
+
|-------|-------------|---------------|
|
|
574
|
+
| P1 - Critical | Active data breach, system compromise | 15 minutes |
|
|
575
|
+
| P2 - High | Vulnerability being exploited, data at risk | 1 hour |
|
|
576
|
+
| P3 - Medium | Vulnerability identified, no active exploit | 4 hours |
|
|
577
|
+
| P4 - Low | Security improvement needed | 24 hours |
|
|
578
|
+
|
|
579
|
+
## Response Process
|
|
580
|
+
|
|
581
|
+
### 1. Detection and Reporting
|
|
582
|
+
- Automated monitoring alerts
|
|
583
|
+
- Team member reports
|
|
584
|
+
- External vulnerability reports
|
|
585
|
+
|
|
586
|
+
### 2. Assessment
|
|
587
|
+
- Determine severity level
|
|
588
|
+
- Identify affected systems and data
|
|
589
|
+
- Assess impact on personal data
|
|
590
|
+
|
|
591
|
+
### 3. Containment
|
|
592
|
+
- Isolate affected systems
|
|
593
|
+
- Preserve evidence
|
|
594
|
+
- Prevent further data loss
|
|
595
|
+
|
|
596
|
+
### 4. Eradication
|
|
597
|
+
- Remove threat
|
|
598
|
+
- Patch vulnerabilities
|
|
599
|
+
- Rotate compromised credentials
|
|
600
|
+
|
|
601
|
+
### 5. Recovery
|
|
602
|
+
- Restore from clean backups
|
|
603
|
+
- Verify system integrity
|
|
604
|
+
- Resume normal operations
|
|
605
|
+
|
|
606
|
+
### 6. Post-Incident
|
|
607
|
+
- Document lessons learned
|
|
608
|
+
- Update security controls
|
|
609
|
+
- Review and update incident response plan
|
|
610
|
+
|
|
611
|
+
## GDPR Breach Notification
|
|
612
|
+
|
|
613
|
+
- **72 hours**: Notify supervisory authority (Article 33)
|
|
614
|
+
- **Without undue delay**: Notify affected data subjects if high risk (Article 34)
|
|
615
|
+
|
|
616
|
+
## Contacts
|
|
617
|
+
|
|
618
|
+
| Role | Contact |
|
|
619
|
+
|------|---------|
|
|
620
|
+
| Incident Lead | [To be completed] |
|
|
621
|
+
| DPO | [To be completed] |
|
|
622
|
+
| Legal | [To be completed] |
|
|
623
|
+
| Supervisory Authority | [To be completed] |
|
|
624
|
+
`;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
function generateDisasterRecoveryDoc(name: string): string {
|
|
628
|
+
return `# Disaster Recovery Plan - ${name}
|
|
629
|
+
|
|
630
|
+
## Objectives
|
|
631
|
+
|
|
632
|
+
- **RPO (Recovery Point Objective)**: 1 hour
|
|
633
|
+
- **RTO (Recovery Time Objective)**: 4 hours
|
|
634
|
+
|
|
635
|
+
## Disaster Scenarios
|
|
636
|
+
|
|
637
|
+
| Scenario | Impact | Recovery Strategy |
|
|
638
|
+
|----------|--------|-------------------|
|
|
639
|
+
| Database failure | Critical | Failover to replica, restore from backup |
|
|
640
|
+
| Application server failure | High | Auto-scaling, deploy to new instances |
|
|
641
|
+
| Storage failure | High | Replicated storage, backup restore |
|
|
642
|
+
| Network failure | High | Multi-AZ deployment, CDN failover |
|
|
643
|
+
| Complete region failure | Critical | DR region activation |
|
|
644
|
+
| Ransomware | Critical | Isolated backups, clean restore |
|
|
645
|
+
|
|
646
|
+
## Recovery Procedures
|
|
647
|
+
|
|
648
|
+
### Database Recovery
|
|
649
|
+
1. Assess extent of failure
|
|
650
|
+
2. Activate replica if available
|
|
651
|
+
3. Restore from most recent backup
|
|
652
|
+
4. Verify data integrity
|
|
653
|
+
5. Resume application connectivity
|
|
654
|
+
|
|
655
|
+
### Application Recovery
|
|
656
|
+
1. Deploy to new infrastructure
|
|
657
|
+
2. Restore configuration from IaC
|
|
658
|
+
3. Verify all services operational
|
|
659
|
+
4. Run smoke tests
|
|
660
|
+
5. Open to traffic
|
|
661
|
+
|
|
662
|
+
## Testing Schedule
|
|
663
|
+
|
|
664
|
+
- **Monthly**: Component recovery tests
|
|
665
|
+
- **Quarterly**: Full DR scenario test
|
|
666
|
+
- **Annually**: Complete DR exercise with stakeholders
|
|
667
|
+
`;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
function generateEncryptionStandardDoc(name: string): string {
|
|
671
|
+
return `# Encryption Standard - ${name}
|
|
672
|
+
|
|
673
|
+
## Approved Algorithms
|
|
674
|
+
|
|
675
|
+
### Data at Rest
|
|
676
|
+
- **Primary**: AES-256-GCM
|
|
677
|
+
- **Alternative**: ChaCha20-Poly1305
|
|
678
|
+
|
|
679
|
+
### Data in Transit
|
|
680
|
+
- **Preferred**: TLS 1.3
|
|
681
|
+
- **Minimum**: TLS 1.2
|
|
682
|
+
- **Prohibited**: TLS 1.0, TLS 1.1, SSL
|
|
683
|
+
|
|
684
|
+
### Password Hashing
|
|
685
|
+
- **Required**: Argon2id
|
|
686
|
+
- **Parameters**: memory=65536, iterations=3, parallelism=4
|
|
687
|
+
- **Prohibited**: MD5, SHA1, plain text
|
|
688
|
+
|
|
689
|
+
### Key Hashing
|
|
690
|
+
- SHA-256 minimum
|
|
691
|
+
- HMAC for message authentication
|
|
692
|
+
|
|
693
|
+
## Implementation Requirements
|
|
694
|
+
|
|
695
|
+
- [ ] All databases encrypted at rest
|
|
696
|
+
- [ ] All file storage encrypted
|
|
697
|
+
- [ ] All API communications over TLS 1.2+
|
|
698
|
+
- [ ] All backups encrypted
|
|
699
|
+
- [ ] HSTS headers configured
|
|
700
|
+
- [ ] Certificate pinning for mobile clients
|
|
701
|
+
`;
|
|
702
|
+
}
|