snow-flow 2.0.2 → 2.0.3
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/mcp-config.json → .mcp.json} +13 -12
- package/.releaserc.json +47 -0
- package/README.md +6 -0
- package/package.json +1 -1
- package/.claude/claude-settings.json +0 -15
- package/.claude/commands/analysis/README.md +0 -9
- package/.claude/commands/automation/README.md +0 -9
- package/.claude/commands/github/README.md +0 -11
- package/.claude/commands/helpers/standard-checkpoint-hooks.sh +0 -179
- package/.claude/commands/hooks/README.md +0 -11
- package/.claude/commands/monitoring/README.md +0 -9
- package/.claude/commands/optimization/README.md +0 -9
- package/.claude/commands/training/README.md +0 -9
- package/.claude/commands/workflows/README.md +0 -9
- package/.claude/config.json +0 -36
- package/.claude/helpers/github-setup.sh +0 -28
- package/.claude/helpers/quick-start.sh +0 -19
- package/.claude/helpers/setup-mcp.sh +0 -18
- package/.claude/settings.json +0 -114
- package/.claude/settings.local.json +0 -33
- package/.claude-flow/metrics/agent-metrics.json +0 -1
- package/.claude-flow/metrics/performance.json +0 -9
- package/.claude-flow/metrics/system-metrics.json +0 -15986
- package/.claude-flow/metrics/task-metrics.json +0 -10
- package/.roo/README.md +0 -402
- package/.roo/mcp-list.txt +0 -257
- package/.roo/mcp.json +0 -32
- package/.roo/workflows/basic-tdd.json +0 -32
- package/.roomodes +0 -201
- package/CLAUDE.md +0 -393
- package/bin/snow-flow.js +0 -3
- package/dist/cli.js.bak +0 -2052
- package/dist/config/snow-flow-config.d.ts +0 -1492
- package/dist/config/snow-flow-config.js +0 -938
- package/scripts/create-env.js +0 -91
- package/scripts/postinstall.js +0 -30
- package/scripts/register-mcp-servers.js +0 -210
- package/scripts/reset-mcp-servers.js +0 -246
- package/scripts/setup-mcp.js +0 -106
- package/scripts/update-version.js +0 -31
- package/src/agents/README.md +0 -192
- package/src/agents/base-agent.ts +0 -251
- package/src/agents/coordinator.ts +0 -971
- package/src/agents/index.ts +0 -18
- package/src/agents/queen-403-handler.ts +0 -230
- package/src/agents/queen-agent.ts +0 -1399
- package/src/agents/script-writer-agent.ts +0 -769
- package/src/agents/security-agent.ts +0 -726
- package/src/agents/widget-creator-agent.ts +0 -568
- package/src/api/error-handling.ts +0 -1758
- package/src/api/natural-language-mapper.ts +0 -630
- package/src/api/performance-optimizer.ts +0 -891
- package/src/api/transaction-manager.ts +0 -754
- package/src/cli/deploy-artifact.ts +0 -304
- package/src/cli/snow-flow-cli-integration.ts +0 -434
- package/src/cli.ts +0 -4455
- package/src/cli.ts.bak +0 -5616
- package/src/compliance/advanced-compliance-system.ts +0 -1268
- package/src/compliance/index.ts +0 -19
- package/src/config/snow-flow-config.ts +0 -1019
- package/src/documentation/index.ts +0 -16
- package/src/documentation/self-documenting-system.ts +0 -1421
- package/src/dynamic-version.ts +0 -44
- package/src/healing/index.ts +0 -20
- package/src/healing/self-healing-system.ts +0 -1435
- package/src/health/README.md +0 -161
- package/src/health/system-health.ts +0 -995
- package/src/index.ts +0 -60
- package/src/intelligence/acl-analyzer.ts +0 -377
- package/src/intelligence/auto-resolution-engine.ts +0 -643
- package/src/intelligence/gap-analysis-engine.ts +0 -488
- package/src/intelligence/manual-instructions-generator.ts +0 -744
- package/src/intelligence/mcp-coverage-analyzer.ts +0 -708
- package/src/intelligence/multi-pass-requirements-analyzer.ts +0 -603
- package/src/intelligence/performance-recommendations-engine.ts +0 -1223
- package/src/intelligence/requirements-analyzer.ts +0 -1148
- package/src/intelligence/task-analyzer.ts +0 -628
- package/src/managers/scope-manager.ts +0 -555
- package/src/mcp/advanced/servicenow-advanced-features-mcp.ts +0 -16110
- package/src/mcp/base-mcp-server.ts +0 -660
- package/src/mcp/http-transport-wrapper.ts +0 -426
- package/src/mcp/service-discovery-client.ts +0 -312
- package/src/mcp/servicenow-automation-mcp-refactored.ts +0 -678
- package/src/mcp/servicenow-automation-mcp.ts +0 -838
- package/src/mcp/servicenow-deployment-mcp-refactored.ts +0 -1292
- package/src/mcp/servicenow-deployment-mcp.ts +0 -7244
- package/src/mcp/servicenow-graph-memory-mcp-refactored.ts +0 -721
- package/src/mcp/servicenow-graph-memory-mcp.ts +0 -832
- package/src/mcp/servicenow-integration-mcp-refactored.ts +0 -655
- package/src/mcp/servicenow-integration-mcp.ts +0 -819
- package/src/mcp/servicenow-intelligent-mcp-refactored.ts +0 -977
- package/src/mcp/servicenow-intelligent-mcp.ts +0 -4638
- package/src/mcp/servicenow-mcp-server.ts +0 -728
- package/src/mcp/servicenow-memory-mcp.ts +0 -474
- package/src/mcp/servicenow-operations-mcp-refactored.ts +0 -1995
- package/src/mcp/servicenow-operations-mcp.ts +0 -3384
- package/src/mcp/servicenow-platform-development-mcp-refactored.ts +0 -611
- package/src/mcp/servicenow-platform-development-mcp.ts +0 -970
- package/src/mcp/servicenow-progressive-indexer.ts +0 -370
- package/src/mcp/servicenow-reporting-analytics-mcp-refactored.ts +0 -695
- package/src/mcp/servicenow-reporting-analytics-mcp.ts +0 -1123
- package/src/mcp/servicenow-security-compliance-mcp-refactored.ts +0 -642
- package/src/mcp/servicenow-security-compliance-mcp.ts +0 -1157
- package/src/mcp/servicenow-update-set-mcp-refactored.ts +0 -751
- package/src/mcp/servicenow-update-set-mcp.ts +0 -811
- package/src/mcp/shared/agent-context-provider.ts +0 -365
- package/src/mcp/shared/base-mcp-server.ts +0 -2463
- package/src/mcp/shared/mcp-memory-manager.ts +0 -540
- package/src/mcp/shared/mcp-resource-manager.ts +0 -367
- package/src/mcp/snow-flow-mcp.ts +0 -911
- package/src/mcp/start-all-mcp-servers.ts +0 -102
- package/src/mcp/start-servicenow-mcp.ts +0 -67
- package/src/monitoring/enhanced-monitoring-system.ts +0 -1345
- package/src/monitoring/performance-tracker.ts +0 -777
- package/src/optimization/cost-optimization-engine.ts +0 -1125
- package/src/optimization/index.ts +0 -10
- package/src/queen/README.md +0 -403
- package/src/queen/agent-factory.ts +0 -574
- package/src/queen/index.ts +0 -94
- package/src/queen/mcp-execution-bridge.ts +0 -681
- package/src/queen/neural-learning.ts +0 -319
- package/src/queen/parallel-agent-engine.ts +0 -848
- package/src/queen/queen-memory-system.ts +0 -490
- package/src/queen/queen-memory.ts +0 -456
- package/src/queen/servicenow-queen.ts +0 -1029
- package/src/queen/types.ts +0 -87
- package/src/rollback/smart-rollback-system.ts +0 -866
- package/src/schemas/deployment.schema.json +0 -58
- package/src/schemas/flow.schema.json +0 -79
- package/src/schemas/widget.schema.json +0 -72
- package/src/snow-flow-system.ts +0 -541
- package/src/sparc/sparc-help.ts +0 -49
- package/src/sparc/team-sparc.ts +0 -88
- package/src/strategies/global-scope-strategy.ts +0 -736
- package/src/templates/base/application.template.json +0 -45
- package/src/templates/base/business_rule.template.json +0 -33
- package/src/templates/base/script_include.template.json +0 -18
- package/src/templates/base/table.template.json +0 -64
- package/src/templates/base/widget.template.json +0 -25
- package/src/templates/patterns/composite.incident-management.template.json +0 -140
- package/src/templates/patterns/widget.dashboard.template.json +0 -238
- package/src/templates/patterns/widget.datatable.template.json +0 -292
- package/src/testing/integration-test-suite.ts +0 -1276
- package/src/types/index.ts +0 -183
- package/src/types/neo4j-driver.d.ts +0 -23
- package/src/types/servicenow.types.ts +0 -307
- package/src/types/snow-flow.types.ts +0 -186
- package/src/types/todo.types.ts +0 -70
- package/src/utils/action-type-cache.ts +0 -286
- package/src/utils/agent-detector.ts +0 -573
- package/src/utils/artifact-tracker.ts +0 -379
- package/src/utils/dependency-detector.ts +0 -233
- package/src/utils/deployment-metadata-handler.ts +0 -518
- package/src/utils/error-recovery.ts +0 -680
- package/src/utils/logger.ts +0 -60
- package/src/utils/mcp-auth-middleware.ts +0 -262
- package/src/utils/mcp-config-manager.ts +0 -270
- package/src/utils/mcp-server-manager.ts +0 -446
- package/src/utils/mcp-tool-registry.ts +0 -298
- package/src/utils/migrate-snow-flow.ts +0 -98
- package/src/utils/oauth-html-templates.ts +0 -188
- package/src/utils/scope-utils.ts +0 -443
- package/src/utils/servicenow-client.ts +0 -3321
- package/src/utils/servicenow-id-generator.ts +0 -181
- package/src/utils/snow-memory-manager.ts +0 -605
- package/src/utils/snow-oauth.ts +0 -797
- package/src/utils/template-engine.ts +0 -463
- package/src/utils/theme-manager.ts +0 -295
- package/src/utils/unified-auth-store.ts +0 -222
- package/src/utils/update-set-importer.ts +0 -422
- package/src/utils/update-set-xml-packager.ts +0 -371
- package/src/utils/widget-template-generator.ts +0 -1744
- package/src/version.ts +0 -1950
|
@@ -1,1268 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 🔐 Advanced Compliance System for Autonomous Compliance Monitoring
|
|
3
|
-
*
|
|
4
|
-
* Enterprise-grade autonomous compliance system that continuously monitors,
|
|
5
|
-
* detects violations, implements corrective actions, and maintains
|
|
6
|
-
* comprehensive audit trails without manual intervention.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { Logger } from '../utils/logger.js';
|
|
10
|
-
import { ServiceNowClient } from '../utils/servicenow-client.js';
|
|
11
|
-
import { MemorySystem } from '../memory/memory-system.js';
|
|
12
|
-
|
|
13
|
-
export interface ComplianceProfile {
|
|
14
|
-
id: string;
|
|
15
|
-
organizationName: string;
|
|
16
|
-
assessmentDate: string;
|
|
17
|
-
frameworks: ComplianceFramework[];
|
|
18
|
-
overallScore: number;
|
|
19
|
-
violations: ComplianceViolation[];
|
|
20
|
-
correctives: CorrectiveAction[];
|
|
21
|
-
auditTrail: AuditEntry[];
|
|
22
|
-
riskMatrix: RiskMatrix;
|
|
23
|
-
certifications: ComplianceCertification[];
|
|
24
|
-
recommendations: ComplianceRecommendation[];
|
|
25
|
-
metadata: ComplianceMetadata;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface ComplianceFramework {
|
|
29
|
-
id: string;
|
|
30
|
-
name: 'SOX' | 'GDPR' | 'HIPAA' | 'PCI-DSS' | 'ISO-27001' | 'NIST' | 'CUSTOM';
|
|
31
|
-
version: string;
|
|
32
|
-
enabled: boolean;
|
|
33
|
-
controls: ComplianceControl[];
|
|
34
|
-
score: number;
|
|
35
|
-
status: 'compliant' | 'non-compliant' | 'partial' | 'unknown';
|
|
36
|
-
lastAssessment: string;
|
|
37
|
-
nextAssessment: string;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export interface ComplianceControl {
|
|
41
|
-
id: string;
|
|
42
|
-
controlId: string;
|
|
43
|
-
title: string;
|
|
44
|
-
description: string;
|
|
45
|
-
category: string;
|
|
46
|
-
criticality: 'critical' | 'high' | 'medium' | 'low';
|
|
47
|
-
status: 'passed' | 'failed' | 'partial' | 'not-applicable';
|
|
48
|
-
evidence: Evidence[];
|
|
49
|
-
testResults: TestResult[];
|
|
50
|
-
automationLevel: 'full' | 'partial' | 'manual';
|
|
51
|
-
lastTested: string;
|
|
52
|
-
nextTest: string;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface Evidence {
|
|
56
|
-
id: string;
|
|
57
|
-
type: 'document' | 'log' | 'screenshot' | 'report' | 'configuration';
|
|
58
|
-
title: string;
|
|
59
|
-
description: string;
|
|
60
|
-
location: string;
|
|
61
|
-
timestamp: string;
|
|
62
|
-
hash: string;
|
|
63
|
-
verified: boolean;
|
|
64
|
-
expiryDate?: string;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export interface TestResult {
|
|
68
|
-
id: string;
|
|
69
|
-
testName: string;
|
|
70
|
-
executionTime: string;
|
|
71
|
-
status: 'passed' | 'failed' | 'skipped';
|
|
72
|
-
details: string;
|
|
73
|
-
findings: Finding[];
|
|
74
|
-
automated: boolean;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export interface Finding {
|
|
78
|
-
severity: 'critical' | 'high' | 'medium' | 'low';
|
|
79
|
-
description: string;
|
|
80
|
-
impact: string;
|
|
81
|
-
recommendation: string;
|
|
82
|
-
evidence?: string;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export interface ComplianceViolation {
|
|
86
|
-
id: string;
|
|
87
|
-
frameworkId: string;
|
|
88
|
-
controlId: string;
|
|
89
|
-
severity: 'critical' | 'high' | 'medium' | 'low';
|
|
90
|
-
title: string;
|
|
91
|
-
description: string;
|
|
92
|
-
detectedAt: string;
|
|
93
|
-
status: 'open' | 'remediated' | 'accepted' | 'false-positive';
|
|
94
|
-
remediationDeadline: string;
|
|
95
|
-
assignedTo?: string;
|
|
96
|
-
correctiveActions: string[];
|
|
97
|
-
businessImpact: BusinessImpact;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export interface BusinessImpact {
|
|
101
|
-
financial: number;
|
|
102
|
-
operational: 'minimal' | 'moderate' | 'significant' | 'severe';
|
|
103
|
-
reputational: 'minimal' | 'moderate' | 'significant' | 'severe';
|
|
104
|
-
legal: 'minimal' | 'moderate' | 'significant' | 'severe';
|
|
105
|
-
dataPrivacy: boolean;
|
|
106
|
-
affectedSystems: string[];
|
|
107
|
-
affectedUsers: number;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export interface CorrectiveAction {
|
|
111
|
-
id: string;
|
|
112
|
-
violationId: string;
|
|
113
|
-
type: 'automated' | 'semi-automated' | 'manual';
|
|
114
|
-
title: string;
|
|
115
|
-
description: string;
|
|
116
|
-
status: 'pending' | 'in-progress' | 'completed' | 'failed';
|
|
117
|
-
automationScript?: string;
|
|
118
|
-
executionSteps: ExecutionStep[];
|
|
119
|
-
startTime?: string;
|
|
120
|
-
endTime?: string;
|
|
121
|
-
result?: ActionResult;
|
|
122
|
-
rollbackPlan?: string;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export interface ExecutionStep {
|
|
126
|
-
order: number;
|
|
127
|
-
action: string;
|
|
128
|
-
automated: boolean;
|
|
129
|
-
status: 'pending' | 'completed' | 'failed' | 'skipped';
|
|
130
|
-
result?: string;
|
|
131
|
-
error?: string;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export interface ActionResult {
|
|
135
|
-
success: boolean;
|
|
136
|
-
message: string;
|
|
137
|
-
evidenceGenerated: string[];
|
|
138
|
-
systemsUpdated: string[];
|
|
139
|
-
verificationRequired: boolean;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
export interface AuditEntry {
|
|
143
|
-
id: string;
|
|
144
|
-
timestamp: string;
|
|
145
|
-
action: string;
|
|
146
|
-
actor: string;
|
|
147
|
-
target: string;
|
|
148
|
-
details: Record<string, any>;
|
|
149
|
-
ipAddress?: string;
|
|
150
|
-
userAgent?: string;
|
|
151
|
-
result: 'success' | 'failure';
|
|
152
|
-
framework?: string;
|
|
153
|
-
controlId?: string;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
export interface RiskMatrix {
|
|
157
|
-
overallRisk: 'low' | 'medium' | 'high' | 'critical';
|
|
158
|
-
categories: RiskCategory[];
|
|
159
|
-
heatMap: HeatMapCell[];
|
|
160
|
-
trends: RiskTrend[];
|
|
161
|
-
mitigations: RiskMitigation[];
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export interface RiskCategory {
|
|
165
|
-
name: string;
|
|
166
|
-
score: number;
|
|
167
|
-
level: 'low' | 'medium' | 'high' | 'critical';
|
|
168
|
-
violations: number;
|
|
169
|
-
controls: number;
|
|
170
|
-
trend: 'improving' | 'stable' | 'deteriorating';
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
export interface HeatMapCell {
|
|
174
|
-
likelihood: number;
|
|
175
|
-
impact: number;
|
|
176
|
-
riskScore: number;
|
|
177
|
-
controls: string[];
|
|
178
|
-
violations: string[];
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
export interface RiskTrend {
|
|
182
|
-
date: string;
|
|
183
|
-
overallScore: number;
|
|
184
|
-
byCategory: Record<string, number>;
|
|
185
|
-
significantEvents: string[];
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
export interface RiskMitigation {
|
|
189
|
-
risk: string;
|
|
190
|
-
strategy: string;
|
|
191
|
-
implementation: string;
|
|
192
|
-
priority: 'immediate' | 'high' | 'medium' | 'low';
|
|
193
|
-
owner: string;
|
|
194
|
-
deadline: string;
|
|
195
|
-
status: 'planned' | 'in-progress' | 'completed';
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
export interface ComplianceCertification {
|
|
199
|
-
framework: string;
|
|
200
|
-
certificateId: string;
|
|
201
|
-
issuedDate: string;
|
|
202
|
-
expiryDate: string;
|
|
203
|
-
scope: string[];
|
|
204
|
-
auditor: string;
|
|
205
|
-
status: 'active' | 'expired' | 'pending-renewal';
|
|
206
|
-
documentUrl: string;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
export interface ComplianceRecommendation {
|
|
210
|
-
id: string;
|
|
211
|
-
category: 'process' | 'technical' | 'administrative' | 'physical';
|
|
212
|
-
priority: 'critical' | 'high' | 'medium' | 'low';
|
|
213
|
-
title: string;
|
|
214
|
-
description: string;
|
|
215
|
-
benefit: string;
|
|
216
|
-
effort: 'minimal' | 'moderate' | 'significant' | 'major';
|
|
217
|
-
automatable: boolean;
|
|
218
|
-
relatedControls: string[];
|
|
219
|
-
estimatedCompletion: number; // days
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
export interface ComplianceMetadata {
|
|
223
|
-
lastFullAssessment: string;
|
|
224
|
-
nextScheduledAssessment: string;
|
|
225
|
-
continuousMonitoring: boolean;
|
|
226
|
-
automationCoverage: number; // percentage
|
|
227
|
-
dataRetentionDays: number;
|
|
228
|
-
encryptionEnabled: boolean;
|
|
229
|
-
integrations: string[];
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
export interface ComplianceRequest {
|
|
233
|
-
frameworks?: string[];
|
|
234
|
-
scope?: 'full' | 'incremental' | 'specific-controls';
|
|
235
|
-
includeEvidence?: boolean;
|
|
236
|
-
autoRemediate?: boolean;
|
|
237
|
-
generateReport?: boolean;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
export interface ComplianceResult {
|
|
241
|
-
success: boolean;
|
|
242
|
-
profile: ComplianceProfile;
|
|
243
|
-
violationsFound: number;
|
|
244
|
-
violationsRemediated: number;
|
|
245
|
-
reportGenerated?: string;
|
|
246
|
-
nextSteps: string[];
|
|
247
|
-
warnings: string[];
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
export class AdvancedComplianceSystem {
|
|
251
|
-
private logger: Logger;
|
|
252
|
-
private client: ServiceNowClient;
|
|
253
|
-
private memory: MemorySystem;
|
|
254
|
-
private complianceProfiles: Map<string, ComplianceProfile> = new Map();
|
|
255
|
-
private activeMonitoring: Map<string, any> = new Map();
|
|
256
|
-
private frameworks: Map<string, ComplianceFramework> = new Map();
|
|
257
|
-
private auditTrail: AuditEntry[] = [];
|
|
258
|
-
|
|
259
|
-
constructor(client: ServiceNowClient, memory: MemorySystem) {
|
|
260
|
-
this.logger = new Logger('AdvancedComplianceSystem');
|
|
261
|
-
this.client = client;
|
|
262
|
-
this.memory = memory;
|
|
263
|
-
|
|
264
|
-
this.initializeFrameworks();
|
|
265
|
-
this.startContinuousCompliance();
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* Perform comprehensive compliance assessment
|
|
270
|
-
*/
|
|
271
|
-
async assessCompliance(request: ComplianceRequest = {}): Promise<ComplianceResult> {
|
|
272
|
-
this.logger.info('🔐 Performing compliance assessment', request);
|
|
273
|
-
|
|
274
|
-
const profileId = `comp_${Date.now()}_${Math.random().toString(36).substr(2, 8)}`;
|
|
275
|
-
const startTime = Date.now();
|
|
276
|
-
|
|
277
|
-
try {
|
|
278
|
-
// Initialize assessment
|
|
279
|
-
const frameworks = await this.getActiveFrameworks(request.frameworks);
|
|
280
|
-
|
|
281
|
-
// Run compliance checks
|
|
282
|
-
const assessmentResults = await this.runComplianceChecks(frameworks, request);
|
|
283
|
-
|
|
284
|
-
// Detect violations
|
|
285
|
-
const violations = await this.detectViolations(assessmentResults);
|
|
286
|
-
|
|
287
|
-
// Generate corrective actions
|
|
288
|
-
const correctives = await this.generateCorrectiveActions(violations);
|
|
289
|
-
|
|
290
|
-
// Auto-remediate if requested
|
|
291
|
-
let remediatedCount = 0;
|
|
292
|
-
if (request.autoRemediate) {
|
|
293
|
-
remediatedCount = await this.autoRemediate(correctives);
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
// Generate risk matrix
|
|
297
|
-
const riskMatrix = await this.generateRiskMatrix(violations, assessmentResults);
|
|
298
|
-
|
|
299
|
-
// Create audit trail
|
|
300
|
-
const auditEntries = await this.createAuditTrail(assessmentResults, violations, correctives);
|
|
301
|
-
|
|
302
|
-
// Generate recommendations
|
|
303
|
-
const recommendations = await this.generateRecommendations(assessmentResults, violations);
|
|
304
|
-
|
|
305
|
-
const profile: ComplianceProfile = {
|
|
306
|
-
id: profileId,
|
|
307
|
-
organizationName: 'ServiceNow Multi-Agent System',
|
|
308
|
-
assessmentDate: new Date().toISOString(),
|
|
309
|
-
frameworks: assessmentResults,
|
|
310
|
-
overallScore: this.calculateOverallScore(assessmentResults),
|
|
311
|
-
violations,
|
|
312
|
-
correctives,
|
|
313
|
-
auditTrail: auditEntries,
|
|
314
|
-
riskMatrix,
|
|
315
|
-
certifications: await this.getCertifications(),
|
|
316
|
-
recommendations,
|
|
317
|
-
metadata: {
|
|
318
|
-
lastFullAssessment: new Date().toISOString(),
|
|
319
|
-
nextScheduledAssessment: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString(),
|
|
320
|
-
continuousMonitoring: true,
|
|
321
|
-
automationCoverage: 85,
|
|
322
|
-
dataRetentionDays: 365,
|
|
323
|
-
encryptionEnabled: true,
|
|
324
|
-
integrations: ['ServiceNow', 'OAuth', 'Memory System']
|
|
325
|
-
}
|
|
326
|
-
};
|
|
327
|
-
|
|
328
|
-
// Store profile
|
|
329
|
-
this.complianceProfiles.set(profileId, profile);
|
|
330
|
-
await this.memory.store(`compliance_profile_${profileId}`, profile, 31536000000); // 1 year
|
|
331
|
-
|
|
332
|
-
// Generate report if requested
|
|
333
|
-
let reportPath;
|
|
334
|
-
if (request.generateReport) {
|
|
335
|
-
reportPath = await this.generateComplianceReport(profile.toString());
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
this.logger.info('✅ Compliance assessment completed', {
|
|
339
|
-
profileId,
|
|
340
|
-
overallScore: profile.overallScore,
|
|
341
|
-
violationsFound: violations.length,
|
|
342
|
-
violationsRemediated: remediatedCount,
|
|
343
|
-
frameworks: frameworks.length
|
|
344
|
-
});
|
|
345
|
-
|
|
346
|
-
return {
|
|
347
|
-
success: true,
|
|
348
|
-
profile,
|
|
349
|
-
violationsFound: violations.length,
|
|
350
|
-
violationsRemediated: remediatedCount,
|
|
351
|
-
reportGenerated: reportPath,
|
|
352
|
-
nextSteps: this.generateNextSteps(profile),
|
|
353
|
-
warnings: this.generateWarnings(profile)
|
|
354
|
-
};
|
|
355
|
-
|
|
356
|
-
} catch (error) {
|
|
357
|
-
this.logger.error('❌ Compliance assessment failed', error);
|
|
358
|
-
throw error;
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
/**
|
|
363
|
-
* Start continuous compliance monitoring
|
|
364
|
-
*/
|
|
365
|
-
async startContinuousMonitoring(options: {
|
|
366
|
-
frameworks?: string[];
|
|
367
|
-
checkInterval?: number;
|
|
368
|
-
autoRemediate?: boolean;
|
|
369
|
-
alertThreshold?: string;
|
|
370
|
-
} = {}): Promise<void> {
|
|
371
|
-
this.logger.info('🔄 Starting continuous compliance monitoring', options);
|
|
372
|
-
|
|
373
|
-
const interval = options.checkInterval || 3600000; // Default: 1 hour
|
|
374
|
-
const monitoringId = `monitor_${Date.now()}`;
|
|
375
|
-
|
|
376
|
-
const monitoring = setInterval(async () => {
|
|
377
|
-
try {
|
|
378
|
-
// Run incremental assessment
|
|
379
|
-
const result = await this.assessCompliance({
|
|
380
|
-
frameworks: options.frameworks,
|
|
381
|
-
scope: 'incremental',
|
|
382
|
-
autoRemediate: options.autoRemediate || false
|
|
383
|
-
});
|
|
384
|
-
|
|
385
|
-
// Check for critical violations
|
|
386
|
-
const criticalViolations = result.profile.violations.filter(
|
|
387
|
-
v => v.severity === 'critical' && v.status === 'open'
|
|
388
|
-
);
|
|
389
|
-
|
|
390
|
-
if (criticalViolations.length > 0) {
|
|
391
|
-
await this.handleCriticalViolations(criticalViolations);
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
// Update monitoring status
|
|
395
|
-
await this.updateMonitoringStatus(monitoringId, result);
|
|
396
|
-
|
|
397
|
-
} catch (error) {
|
|
398
|
-
this.logger.error('Error in continuous monitoring', error);
|
|
399
|
-
}
|
|
400
|
-
}, interval);
|
|
401
|
-
|
|
402
|
-
this.activeMonitoring.set(monitoringId, monitoring);
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
/**
|
|
406
|
-
* Get real-time compliance dashboard
|
|
407
|
-
*/
|
|
408
|
-
async getComplianceDashboard(): Promise<{
|
|
409
|
-
overallStatus: string;
|
|
410
|
-
complianceScore: number;
|
|
411
|
-
activeFrameworks: ComplianceFramework[];
|
|
412
|
-
recentViolations: ComplianceViolation[];
|
|
413
|
-
pendingActions: CorrectiveAction[];
|
|
414
|
-
riskLevel: string;
|
|
415
|
-
certifications: ComplianceCertification[];
|
|
416
|
-
upcomingAudits: string[];
|
|
417
|
-
}> {
|
|
418
|
-
const latestProfile = this.getLatestComplianceProfile();
|
|
419
|
-
|
|
420
|
-
if (!latestProfile) {
|
|
421
|
-
const result = await this.assessCompliance();
|
|
422
|
-
return this.generateDashboard(result.profile);
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
return this.generateDashboard(latestProfile);
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
/**
|
|
429
|
-
* Manually trigger corrective action
|
|
430
|
-
*/
|
|
431
|
-
async executeCorrectiveAction(
|
|
432
|
-
actionId: string,
|
|
433
|
-
options: {
|
|
434
|
-
verifyFirst?: boolean;
|
|
435
|
-
generateEvidence?: boolean;
|
|
436
|
-
} = {}
|
|
437
|
-
): Promise<{
|
|
438
|
-
success: boolean;
|
|
439
|
-
result: ActionResult;
|
|
440
|
-
evidenceGenerated: string[];
|
|
441
|
-
}> {
|
|
442
|
-
this.logger.info('🔧 Executing corrective action', { actionId, options });
|
|
443
|
-
|
|
444
|
-
const action = await this.getCorrectiveAction(actionId);
|
|
445
|
-
if (!action) {
|
|
446
|
-
throw new Error(`Corrective action not found: ${actionId}`);
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
try {
|
|
450
|
-
// Verify if requested
|
|
451
|
-
if (options.verifyFirst) {
|
|
452
|
-
const verification = await this.verifyActionSafety(action);
|
|
453
|
-
if (!verification.safe) {
|
|
454
|
-
throw new Error(`Action verification failed: ${verification.reason}`);
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
// Execute action
|
|
459
|
-
action.status = 'in-progress';
|
|
460
|
-
action.startTime = new Date().toISOString();
|
|
461
|
-
|
|
462
|
-
const result = await this.executeActionSteps(action);
|
|
463
|
-
|
|
464
|
-
// Generate evidence
|
|
465
|
-
const evidence: string[] = [];
|
|
466
|
-
if (options.generateEvidence || result.verificationRequired) {
|
|
467
|
-
evidence.push(...await this.generateActionEvidence(action, result));
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
// Update action status
|
|
471
|
-
action.status = result.success ? 'completed' : 'failed';
|
|
472
|
-
action.endTime = new Date().toISOString();
|
|
473
|
-
action.result = result;
|
|
474
|
-
|
|
475
|
-
// Create audit entry
|
|
476
|
-
await this.auditAction(action, result);
|
|
477
|
-
|
|
478
|
-
return {
|
|
479
|
-
success: result.success,
|
|
480
|
-
result,
|
|
481
|
-
evidenceGenerated: evidence
|
|
482
|
-
};
|
|
483
|
-
|
|
484
|
-
} catch (error) {
|
|
485
|
-
this.logger.error('❌ Corrective action failed', error);
|
|
486
|
-
action.status = 'failed';
|
|
487
|
-
throw error;
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
/**
|
|
492
|
-
* Generate compliance report
|
|
493
|
-
*/
|
|
494
|
-
async generateComplianceReport(
|
|
495
|
-
profileId: string,
|
|
496
|
-
format: 'pdf' | 'html' | 'json' = 'pdf'
|
|
497
|
-
): Promise<string> {
|
|
498
|
-
const profile = this.complianceProfiles.get(profileId);
|
|
499
|
-
if (!profile) {
|
|
500
|
-
throw new Error(`Compliance profile not found: ${profileId}`);
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
const reportContent = await this.renderComplianceReport(profile, format);
|
|
504
|
-
const reportPath = await this.saveReport(reportContent, format, profile.id);
|
|
505
|
-
|
|
506
|
-
return reportPath;
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
/**
|
|
510
|
-
* Private helper methods
|
|
511
|
-
*/
|
|
512
|
-
|
|
513
|
-
private initializeFrameworks(): void {
|
|
514
|
-
// Initialize compliance frameworks
|
|
515
|
-
this.frameworks.set('SOX', {
|
|
516
|
-
id: 'sox_framework',
|
|
517
|
-
name: 'SOX',
|
|
518
|
-
version: '2002',
|
|
519
|
-
enabled: true,
|
|
520
|
-
controls: this.getSOXControls(),
|
|
521
|
-
score: 0,
|
|
522
|
-
status: 'unknown',
|
|
523
|
-
lastAssessment: '',
|
|
524
|
-
nextAssessment: ''
|
|
525
|
-
});
|
|
526
|
-
|
|
527
|
-
this.frameworks.set('GDPR', {
|
|
528
|
-
id: 'gdpr_framework',
|
|
529
|
-
name: 'GDPR',
|
|
530
|
-
version: '2018',
|
|
531
|
-
enabled: true,
|
|
532
|
-
controls: this.getGDPRControls(),
|
|
533
|
-
score: 0,
|
|
534
|
-
status: 'unknown',
|
|
535
|
-
lastAssessment: '',
|
|
536
|
-
nextAssessment: ''
|
|
537
|
-
});
|
|
538
|
-
|
|
539
|
-
this.frameworks.set('HIPAA', {
|
|
540
|
-
id: 'hipaa_framework',
|
|
541
|
-
name: 'HIPAA',
|
|
542
|
-
version: '1996',
|
|
543
|
-
enabled: true,
|
|
544
|
-
controls: this.getHIPAAControls(),
|
|
545
|
-
score: 0,
|
|
546
|
-
status: 'unknown',
|
|
547
|
-
lastAssessment: '',
|
|
548
|
-
nextAssessment: ''
|
|
549
|
-
});
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
private getSOXControls(): ComplianceControl[] {
|
|
553
|
-
return [
|
|
554
|
-
{
|
|
555
|
-
id: 'sox_ctrl_1',
|
|
556
|
-
controlId: 'SOX-302',
|
|
557
|
-
title: 'Management Assessment of Internal Controls',
|
|
558
|
-
description: 'Management must assess and report on internal controls',
|
|
559
|
-
category: 'Financial Reporting',
|
|
560
|
-
criticality: 'critical',
|
|
561
|
-
status: 'not-applicable',
|
|
562
|
-
evidence: [],
|
|
563
|
-
testResults: [],
|
|
564
|
-
automationLevel: 'partial',
|
|
565
|
-
lastTested: '',
|
|
566
|
-
nextTest: ''
|
|
567
|
-
},
|
|
568
|
-
{
|
|
569
|
-
id: 'sox_ctrl_2',
|
|
570
|
-
controlId: 'SOX-404',
|
|
571
|
-
title: 'Internal Control Reporting',
|
|
572
|
-
description: 'Annual assessment of internal control effectiveness',
|
|
573
|
-
category: 'Internal Controls',
|
|
574
|
-
criticality: 'critical',
|
|
575
|
-
status: 'not-applicable',
|
|
576
|
-
evidence: [],
|
|
577
|
-
testResults: [],
|
|
578
|
-
automationLevel: 'full',
|
|
579
|
-
lastTested: '',
|
|
580
|
-
nextTest: ''
|
|
581
|
-
}
|
|
582
|
-
];
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
private getGDPRControls(): ComplianceControl[] {
|
|
586
|
-
return [
|
|
587
|
-
{
|
|
588
|
-
id: 'gdpr_ctrl_1',
|
|
589
|
-
controlId: 'GDPR-Art25',
|
|
590
|
-
title: 'Data Protection by Design',
|
|
591
|
-
description: 'Implement appropriate technical and organizational measures',
|
|
592
|
-
category: 'Privacy',
|
|
593
|
-
criticality: 'high',
|
|
594
|
-
status: 'not-applicable',
|
|
595
|
-
evidence: [],
|
|
596
|
-
testResults: [],
|
|
597
|
-
automationLevel: 'full',
|
|
598
|
-
lastTested: '',
|
|
599
|
-
nextTest: ''
|
|
600
|
-
},
|
|
601
|
-
{
|
|
602
|
-
id: 'gdpr_ctrl_2',
|
|
603
|
-
controlId: 'GDPR-Art32',
|
|
604
|
-
title: 'Security of Processing',
|
|
605
|
-
description: 'Implement appropriate security measures',
|
|
606
|
-
category: 'Security',
|
|
607
|
-
criticality: 'critical',
|
|
608
|
-
status: 'not-applicable',
|
|
609
|
-
evidence: [],
|
|
610
|
-
testResults: [],
|
|
611
|
-
automationLevel: 'full',
|
|
612
|
-
lastTested: '',
|
|
613
|
-
nextTest: ''
|
|
614
|
-
}
|
|
615
|
-
];
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
private getHIPAAControls(): ComplianceControl[] {
|
|
619
|
-
return [
|
|
620
|
-
{
|
|
621
|
-
id: 'hipaa_ctrl_1',
|
|
622
|
-
controlId: 'HIPAA-164.308',
|
|
623
|
-
title: 'Administrative Safeguards',
|
|
624
|
-
description: 'Implement administrative safeguards for PHI',
|
|
625
|
-
category: 'Administrative',
|
|
626
|
-
criticality: 'high',
|
|
627
|
-
status: 'not-applicable',
|
|
628
|
-
evidence: [],
|
|
629
|
-
testResults: [],
|
|
630
|
-
automationLevel: 'partial',
|
|
631
|
-
lastTested: '',
|
|
632
|
-
nextTest: ''
|
|
633
|
-
}
|
|
634
|
-
];
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
private async getActiveFrameworks(requestedFrameworks?: string[]): Promise<ComplianceFramework[]> {
|
|
638
|
-
if (requestedFrameworks && requestedFrameworks.length > 0) {
|
|
639
|
-
return requestedFrameworks
|
|
640
|
-
.map(f => this.frameworks.get(f))
|
|
641
|
-
.filter(f => f !== undefined) as ComplianceFramework[];
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
return Array.from(this.frameworks.values()).filter(f => f.enabled);
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
private async runComplianceChecks(
|
|
648
|
-
frameworks: ComplianceFramework[],
|
|
649
|
-
request: ComplianceRequest
|
|
650
|
-
): Promise<ComplianceFramework[]> {
|
|
651
|
-
const assessedFrameworks: ComplianceFramework[] = [];
|
|
652
|
-
|
|
653
|
-
for (const framework of frameworks) {
|
|
654
|
-
const assessedControls: ComplianceControl[] = [];
|
|
655
|
-
|
|
656
|
-
for (const control of framework.controls) {
|
|
657
|
-
const testResult = await this.testControl(control, framework);
|
|
658
|
-
control.status = testResult.status as 'failed' | 'partial' | 'passed' | 'not-applicable';
|
|
659
|
-
control.testResults.push(testResult);
|
|
660
|
-
control.lastTested = new Date().toISOString();
|
|
661
|
-
control.nextTest = new Date(Date.now() + 7 * 24 * 60 * 60 * 1000).toISOString();
|
|
662
|
-
|
|
663
|
-
assessedControls.push(control);
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
framework.controls = assessedControls;
|
|
667
|
-
framework.score = this.calculateFrameworkScore(assessedControls);
|
|
668
|
-
framework.status = this.determineFrameworkStatus(assessedControls);
|
|
669
|
-
framework.lastAssessment = new Date().toISOString();
|
|
670
|
-
framework.nextAssessment = new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString();
|
|
671
|
-
|
|
672
|
-
assessedFrameworks.push(framework);
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
return assessedFrameworks;
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
private async testControl(
|
|
679
|
-
control: ComplianceControl,
|
|
680
|
-
framework: ComplianceFramework
|
|
681
|
-
): Promise<TestResult> {
|
|
682
|
-
// Simulate control testing
|
|
683
|
-
const testResult: TestResult = {
|
|
684
|
-
id: `test_${Date.now()}_${Math.random().toString(36).substr(2, 6)}`,
|
|
685
|
-
testName: `Test for ${control.controlId}`,
|
|
686
|
-
executionTime: new Date().toISOString(),
|
|
687
|
-
status: 'passed',
|
|
688
|
-
details: 'Automated compliance check completed',
|
|
689
|
-
findings: [],
|
|
690
|
-
automated: control.automationLevel === 'full'
|
|
691
|
-
};
|
|
692
|
-
|
|
693
|
-
// Simulate some failures for demonstration
|
|
694
|
-
if (Math.random() < 0.2) { // 20% failure rate
|
|
695
|
-
testResult.status = 'failed';
|
|
696
|
-
testResult.findings.push({
|
|
697
|
-
severity: control.criticality as any,
|
|
698
|
-
description: `${control.title} compliance check failed`,
|
|
699
|
-
impact: 'Potential compliance violation',
|
|
700
|
-
recommendation: 'Review and update control implementation'
|
|
701
|
-
});
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
return testResult;
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
private calculateFrameworkScore(controls: ComplianceControl[]): number {
|
|
708
|
-
if (controls.length === 0) return 0;
|
|
709
|
-
|
|
710
|
-
const weights = { critical: 4, high: 3, medium: 2, low: 1 };
|
|
711
|
-
let totalWeight = 0;
|
|
712
|
-
let achievedWeight = 0;
|
|
713
|
-
|
|
714
|
-
for (const control of controls) {
|
|
715
|
-
const weight = weights[control.criticality];
|
|
716
|
-
totalWeight += weight;
|
|
717
|
-
|
|
718
|
-
if (control.status === 'passed') {
|
|
719
|
-
achievedWeight += weight;
|
|
720
|
-
} else if (control.status === 'partial') {
|
|
721
|
-
achievedWeight += weight * 0.5;
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
return Math.round((achievedWeight / totalWeight) * 100);
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
private determineFrameworkStatus(controls: ComplianceControl[]): 'compliant' | 'non-compliant' | 'partial' | 'unknown' {
|
|
729
|
-
const criticalFailed = controls.filter(c => c.criticality === 'critical' && c.status === 'failed').length;
|
|
730
|
-
const totalFailed = controls.filter(c => c.status === 'failed').length;
|
|
731
|
-
|
|
732
|
-
if (criticalFailed > 0) return 'non-compliant';
|
|
733
|
-
if (totalFailed === 0) return 'compliant';
|
|
734
|
-
if (totalFailed < controls.length * 0.2) return 'partial';
|
|
735
|
-
return 'non-compliant';
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
private async detectViolations(frameworks: ComplianceFramework[]): Promise<ComplianceViolation[]> {
|
|
739
|
-
const violations: ComplianceViolation[] = [];
|
|
740
|
-
|
|
741
|
-
for (const framework of frameworks) {
|
|
742
|
-
for (const control of framework.controls) {
|
|
743
|
-
if (control.status === 'failed') {
|
|
744
|
-
const latestTest = control.testResults[control.testResults.length - 1];
|
|
745
|
-
|
|
746
|
-
for (const finding of latestTest.findings) {
|
|
747
|
-
violations.push({
|
|
748
|
-
id: `viol_${Date.now()}_${Math.random().toString(36).substr(2, 6)}`,
|
|
749
|
-
frameworkId: framework.id,
|
|
750
|
-
controlId: control.controlId,
|
|
751
|
-
severity: finding.severity,
|
|
752
|
-
title: `${control.title} Violation`,
|
|
753
|
-
description: finding.description,
|
|
754
|
-
detectedAt: latestTest.executionTime,
|
|
755
|
-
status: 'open',
|
|
756
|
-
remediationDeadline: this.calculateRemediationDeadline(finding.severity),
|
|
757
|
-
correctiveActions: [],
|
|
758
|
-
businessImpact: {
|
|
759
|
-
financial: finding.severity === 'critical' ? 100000 : 10000,
|
|
760
|
-
operational: finding.severity === 'critical' ? 'severe' : 'moderate',
|
|
761
|
-
reputational: finding.severity === 'critical' ? 'significant' : 'moderate',
|
|
762
|
-
legal: finding.severity === 'critical' ? 'significant' : 'minimal',
|
|
763
|
-
dataPrivacy: framework.name === 'GDPR',
|
|
764
|
-
affectedSystems: ['ServiceNow'],
|
|
765
|
-
affectedUsers: finding.severity === 'critical' ? 1000 : 100
|
|
766
|
-
}
|
|
767
|
-
});
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
}
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
return violations;
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
private calculateRemediationDeadline(severity: string): string {
|
|
777
|
-
const daysToRemediate = {
|
|
778
|
-
critical: 7,
|
|
779
|
-
high: 14,
|
|
780
|
-
medium: 30,
|
|
781
|
-
low: 90
|
|
782
|
-
};
|
|
783
|
-
|
|
784
|
-
const days = daysToRemediate[severity as keyof typeof daysToRemediate] || 30;
|
|
785
|
-
return new Date(Date.now() + days * 24 * 60 * 60 * 1000).toISOString();
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
private async generateCorrectiveActions(violations: ComplianceViolation[]): Promise<CorrectiveAction[]> {
|
|
789
|
-
const actions: CorrectiveAction[] = [];
|
|
790
|
-
|
|
791
|
-
for (const violation of violations) {
|
|
792
|
-
const action: CorrectiveAction = {
|
|
793
|
-
id: `action_${Date.now()}_${Math.random().toString(36).substr(2, 6)}`,
|
|
794
|
-
violationId: violation.id,
|
|
795
|
-
type: violation.severity === 'critical' ? 'automated' : 'semi-automated',
|
|
796
|
-
title: `Remediate ${violation.title}`,
|
|
797
|
-
description: `Corrective action to address ${violation.description}`,
|
|
798
|
-
status: 'pending',
|
|
799
|
-
executionSteps: this.generateExecutionSteps(violation),
|
|
800
|
-
rollbackPlan: 'Restore from backup if remediation fails'
|
|
801
|
-
};
|
|
802
|
-
|
|
803
|
-
violation.correctiveActions.push(action.id);
|
|
804
|
-
actions.push(action);
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
return actions;
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
private generateExecutionSteps(violation: ComplianceViolation): ExecutionStep[] {
|
|
811
|
-
return [
|
|
812
|
-
{
|
|
813
|
-
order: 1,
|
|
814
|
-
action: 'Analyze root cause',
|
|
815
|
-
automated: true,
|
|
816
|
-
status: 'pending'
|
|
817
|
-
},
|
|
818
|
-
{
|
|
819
|
-
order: 2,
|
|
820
|
-
action: 'Apply security patch or configuration change',
|
|
821
|
-
automated: violation.severity !== 'critical',
|
|
822
|
-
status: 'pending'
|
|
823
|
-
},
|
|
824
|
-
{
|
|
825
|
-
order: 3,
|
|
826
|
-
action: 'Verify remediation',
|
|
827
|
-
automated: true,
|
|
828
|
-
status: 'pending'
|
|
829
|
-
},
|
|
830
|
-
{
|
|
831
|
-
order: 4,
|
|
832
|
-
action: 'Generate compliance evidence',
|
|
833
|
-
automated: true,
|
|
834
|
-
status: 'pending'
|
|
835
|
-
}
|
|
836
|
-
];
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
private async autoRemediate(actions: CorrectiveAction[]): Promise<number> {
|
|
840
|
-
let remediatedCount = 0;
|
|
841
|
-
|
|
842
|
-
for (const action of actions) {
|
|
843
|
-
if (action.type === 'automated') {
|
|
844
|
-
try {
|
|
845
|
-
const result = await this.executeActionSteps(action);
|
|
846
|
-
if (result.success) {
|
|
847
|
-
action.status = 'completed';
|
|
848
|
-
remediatedCount++;
|
|
849
|
-
}
|
|
850
|
-
} catch (error) {
|
|
851
|
-
this.logger.error(`Failed to auto-remediate action ${action.id}`, error);
|
|
852
|
-
}
|
|
853
|
-
}
|
|
854
|
-
}
|
|
855
|
-
|
|
856
|
-
return remediatedCount;
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
private async executeActionSteps(action: CorrectiveAction): Promise<ActionResult> {
|
|
860
|
-
const result: ActionResult = {
|
|
861
|
-
success: true,
|
|
862
|
-
message: 'Corrective action executed successfully',
|
|
863
|
-
evidenceGenerated: [],
|
|
864
|
-
systemsUpdated: [],
|
|
865
|
-
verificationRequired: false
|
|
866
|
-
};
|
|
867
|
-
|
|
868
|
-
for (const step of action.executionSteps) {
|
|
869
|
-
if (step.automated) {
|
|
870
|
-
// Simulate step execution
|
|
871
|
-
await new Promise(resolve => setTimeout(resolve, 500));
|
|
872
|
-
step.status = 'completed';
|
|
873
|
-
step.result = 'Step completed successfully';
|
|
874
|
-
} else {
|
|
875
|
-
step.status = 'skipped';
|
|
876
|
-
result.verificationRequired = true;
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
return result;
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
private async generateRiskMatrix(
|
|
884
|
-
violations: ComplianceViolation[],
|
|
885
|
-
frameworks: ComplianceFramework[]
|
|
886
|
-
): Promise<RiskMatrix> {
|
|
887
|
-
const categories: RiskCategory[] = [
|
|
888
|
-
{
|
|
889
|
-
name: 'Financial Reporting',
|
|
890
|
-
score: 85,
|
|
891
|
-
level: 'low',
|
|
892
|
-
violations: violations.filter(v => v.frameworkId === 'sox_framework').length,
|
|
893
|
-
controls: frameworks.find(f => f.name === 'SOX')?.controls.length || 0,
|
|
894
|
-
trend: 'stable'
|
|
895
|
-
},
|
|
896
|
-
{
|
|
897
|
-
name: 'Data Privacy',
|
|
898
|
-
score: 75,
|
|
899
|
-
level: 'medium',
|
|
900
|
-
violations: violations.filter(v => v.frameworkId === 'gdpr_framework').length,
|
|
901
|
-
controls: frameworks.find(f => f.name === 'GDPR')?.controls.length || 0,
|
|
902
|
-
trend: violations.length > 0 ? 'deteriorating' : 'improving'
|
|
903
|
-
},
|
|
904
|
-
{
|
|
905
|
-
name: 'Healthcare Compliance',
|
|
906
|
-
score: 90,
|
|
907
|
-
level: 'low',
|
|
908
|
-
violations: violations.filter(v => v.frameworkId === 'hipaa_framework').length,
|
|
909
|
-
controls: frameworks.find(f => f.name === 'HIPAA')?.controls.length || 0,
|
|
910
|
-
trend: 'stable'
|
|
911
|
-
}
|
|
912
|
-
];
|
|
913
|
-
|
|
914
|
-
const overallRisk = violations.some(v => v.severity === 'critical') ? 'high' :
|
|
915
|
-
violations.length > 5 ? 'medium' : 'low';
|
|
916
|
-
|
|
917
|
-
return {
|
|
918
|
-
overallRisk,
|
|
919
|
-
categories,
|
|
920
|
-
heatMap: this.generateHeatMap(violations, frameworks),
|
|
921
|
-
trends: this.generateRiskTrends(),
|
|
922
|
-
mitigations: this.generateMitigations(violations)
|
|
923
|
-
};
|
|
924
|
-
}
|
|
925
|
-
|
|
926
|
-
private generateHeatMap(violations: ComplianceViolation[], frameworks: ComplianceFramework[]): HeatMapCell[] {
|
|
927
|
-
// Simplified heat map generation
|
|
928
|
-
return [
|
|
929
|
-
{
|
|
930
|
-
likelihood: 3,
|
|
931
|
-
impact: 4,
|
|
932
|
-
riskScore: 12,
|
|
933
|
-
controls: ['SOX-404', 'GDPR-Art32'],
|
|
934
|
-
violations: violations.slice(0, 2).map(v => v.id)
|
|
935
|
-
}
|
|
936
|
-
];
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
private generateRiskTrends(): RiskTrend[] {
|
|
940
|
-
return [
|
|
941
|
-
{
|
|
942
|
-
date: new Date().toISOString(),
|
|
943
|
-
overallScore: 85,
|
|
944
|
-
byCategory: {
|
|
945
|
-
'Financial Reporting': 90,
|
|
946
|
-
'Data Privacy': 80,
|
|
947
|
-
'Healthcare Compliance': 85
|
|
948
|
-
},
|
|
949
|
-
significantEvents: ['GDPR assessment completed', 'SOX controls updated']
|
|
950
|
-
}
|
|
951
|
-
];
|
|
952
|
-
}
|
|
953
|
-
|
|
954
|
-
private generateMitigations(violations: ComplianceViolation[]): RiskMitigation[] {
|
|
955
|
-
return violations
|
|
956
|
-
.filter(v => v.severity === 'critical' || v.severity === 'high')
|
|
957
|
-
.map(v => ({
|
|
958
|
-
risk: v.title,
|
|
959
|
-
strategy: 'Implement automated controls',
|
|
960
|
-
implementation: 'Deploy corrective scripts and monitoring',
|
|
961
|
-
priority: v.severity === 'critical' ? 'immediate' : 'high',
|
|
962
|
-
owner: 'Compliance Team',
|
|
963
|
-
deadline: v.remediationDeadline,
|
|
964
|
-
status: 'planned'
|
|
965
|
-
}));
|
|
966
|
-
}
|
|
967
|
-
|
|
968
|
-
private async createAuditTrail(
|
|
969
|
-
frameworks: ComplianceFramework[],
|
|
970
|
-
violations: ComplianceViolation[],
|
|
971
|
-
actions: CorrectiveAction[]
|
|
972
|
-
): Promise<AuditEntry[]> {
|
|
973
|
-
const entries: AuditEntry[] = [];
|
|
974
|
-
|
|
975
|
-
// Framework assessment entries
|
|
976
|
-
for (const framework of frameworks) {
|
|
977
|
-
entries.push({
|
|
978
|
-
id: `audit_${Date.now()}_${Math.random().toString(36).substr(2, 6)}`,
|
|
979
|
-
timestamp: new Date().toISOString(),
|
|
980
|
-
action: 'COMPLIANCE_ASSESSMENT',
|
|
981
|
-
actor: 'System',
|
|
982
|
-
target: framework.name,
|
|
983
|
-
details: {
|
|
984
|
-
score: framework.score,
|
|
985
|
-
status: framework.status,
|
|
986
|
-
controls: framework.controls.length
|
|
987
|
-
},
|
|
988
|
-
result: 'success',
|
|
989
|
-
framework: framework.name
|
|
990
|
-
});
|
|
991
|
-
}
|
|
992
|
-
|
|
993
|
-
// Violation detection entries
|
|
994
|
-
for (const violation of violations) {
|
|
995
|
-
entries.push({
|
|
996
|
-
id: `audit_${Date.now()}_${Math.random().toString(36).substr(2, 6)}`,
|
|
997
|
-
timestamp: violation.detectedAt,
|
|
998
|
-
action: 'VIOLATION_DETECTED',
|
|
999
|
-
actor: 'System',
|
|
1000
|
-
target: violation.controlId,
|
|
1001
|
-
details: {
|
|
1002
|
-
severity: violation.severity,
|
|
1003
|
-
framework: violation.frameworkId
|
|
1004
|
-
},
|
|
1005
|
-
result: 'success',
|
|
1006
|
-
controlId: violation.controlId
|
|
1007
|
-
});
|
|
1008
|
-
}
|
|
1009
|
-
|
|
1010
|
-
this.auditTrail.push(...entries);
|
|
1011
|
-
return entries;
|
|
1012
|
-
}
|
|
1013
|
-
|
|
1014
|
-
private async generateRecommendations(
|
|
1015
|
-
frameworks: ComplianceFramework[],
|
|
1016
|
-
violations: ComplianceViolation[]
|
|
1017
|
-
): Promise<ComplianceRecommendation[]> {
|
|
1018
|
-
const recommendations: ComplianceRecommendation[] = [];
|
|
1019
|
-
|
|
1020
|
-
// Automation recommendations
|
|
1021
|
-
const manualControls = frameworks
|
|
1022
|
-
.flatMap(f => f.controls)
|
|
1023
|
-
.filter(c => c.automationLevel === 'manual');
|
|
1024
|
-
|
|
1025
|
-
if (manualControls.length > 0) {
|
|
1026
|
-
recommendations.push({
|
|
1027
|
-
id: `rec_${Date.now()}_1`,
|
|
1028
|
-
category: 'technical',
|
|
1029
|
-
priority: 'high',
|
|
1030
|
-
title: 'Automate Manual Controls',
|
|
1031
|
-
description: `${manualControls.length} controls can be automated to improve compliance efficiency`,
|
|
1032
|
-
benefit: 'Reduce compliance overhead by 60%',
|
|
1033
|
-
effort: 'moderate',
|
|
1034
|
-
automatable: true,
|
|
1035
|
-
relatedControls: manualControls.map(c => c.controlId),
|
|
1036
|
-
estimatedCompletion: 30
|
|
1037
|
-
});
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
|
-
// Continuous monitoring recommendation
|
|
1041
|
-
recommendations.push({
|
|
1042
|
-
id: `rec_${Date.now()}_2`,
|
|
1043
|
-
category: 'process',
|
|
1044
|
-
priority: 'medium',
|
|
1045
|
-
title: 'Enable Real-time Compliance Monitoring',
|
|
1046
|
-
description: 'Implement continuous compliance monitoring for critical controls',
|
|
1047
|
-
benefit: 'Detect violations 90% faster',
|
|
1048
|
-
effort: 'minimal',
|
|
1049
|
-
automatable: true,
|
|
1050
|
-
relatedControls: [],
|
|
1051
|
-
estimatedCompletion: 7
|
|
1052
|
-
});
|
|
1053
|
-
|
|
1054
|
-
return recommendations;
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
|
-
private calculateOverallScore(frameworks: ComplianceFramework[]): number {
|
|
1058
|
-
if (frameworks.length === 0) return 0;
|
|
1059
|
-
|
|
1060
|
-
const totalScore = frameworks.reduce((sum, f) => sum + f.score, 0);
|
|
1061
|
-
return Math.round(totalScore / frameworks.length);
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
private async getCertifications(): Promise<ComplianceCertification[]> {
|
|
1065
|
-
// Return mock certifications for demonstration
|
|
1066
|
-
return [
|
|
1067
|
-
{
|
|
1068
|
-
framework: 'ISO-27001',
|
|
1069
|
-
certificateId: 'ISO-2024-001',
|
|
1070
|
-
issuedDate: new Date(Date.now() - 180 * 24 * 60 * 60 * 1000).toISOString(),
|
|
1071
|
-
expiryDate: new Date(Date.now() + 185 * 24 * 60 * 60 * 1000).toISOString(),
|
|
1072
|
-
scope: ['Information Security Management'],
|
|
1073
|
-
auditor: 'External Auditor Inc.',
|
|
1074
|
-
status: 'active',
|
|
1075
|
-
documentUrl: '/certifications/iso-27001.pdf'
|
|
1076
|
-
}
|
|
1077
|
-
];
|
|
1078
|
-
}
|
|
1079
|
-
|
|
1080
|
-
private generateNextSteps(profile: ComplianceProfile): string[] {
|
|
1081
|
-
const steps: string[] = [];
|
|
1082
|
-
|
|
1083
|
-
if (profile.violations.filter(v => v.status === 'open').length > 0) {
|
|
1084
|
-
steps.push('Address open compliance violations');
|
|
1085
|
-
}
|
|
1086
|
-
|
|
1087
|
-
if (profile.overallScore < 80) {
|
|
1088
|
-
steps.push('Improve compliance score to meet target threshold');
|
|
1089
|
-
}
|
|
1090
|
-
|
|
1091
|
-
steps.push('Schedule next compliance assessment');
|
|
1092
|
-
steps.push('Review and implement recommendations');
|
|
1093
|
-
|
|
1094
|
-
return steps;
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
|
-
private generateWarnings(profile: ComplianceProfile): string[] {
|
|
1098
|
-
const warnings: string[] = [];
|
|
1099
|
-
|
|
1100
|
-
const criticalViolations = profile.violations.filter(v => v.severity === 'critical');
|
|
1101
|
-
if (criticalViolations.length > 0) {
|
|
1102
|
-
warnings.push(`${criticalViolations.length} critical violations require immediate attention`);
|
|
1103
|
-
}
|
|
1104
|
-
|
|
1105
|
-
const expiredCerts = profile.certifications.filter(c => c.status === 'expired');
|
|
1106
|
-
if (expiredCerts.length > 0) {
|
|
1107
|
-
warnings.push(`${expiredCerts.length} certifications have expired`);
|
|
1108
|
-
}
|
|
1109
|
-
|
|
1110
|
-
return warnings;
|
|
1111
|
-
}
|
|
1112
|
-
|
|
1113
|
-
private getLatestComplianceProfile(): ComplianceProfile | null {
|
|
1114
|
-
const profiles = Array.from(this.complianceProfiles.values());
|
|
1115
|
-
if (profiles.length === 0) return null;
|
|
1116
|
-
|
|
1117
|
-
return profiles.sort((a, b) =>
|
|
1118
|
-
new Date(b.assessmentDate).getTime() -
|
|
1119
|
-
new Date(a.assessmentDate).getTime()
|
|
1120
|
-
)[0];
|
|
1121
|
-
}
|
|
1122
|
-
|
|
1123
|
-
private async generateDashboard(profile: ComplianceProfile): Promise<any> {
|
|
1124
|
-
return {
|
|
1125
|
-
overallStatus: profile.overallScore >= 80 ? 'Compliant' : 'Non-Compliant',
|
|
1126
|
-
complianceScore: profile.overallScore,
|
|
1127
|
-
activeFrameworks: profile.frameworks,
|
|
1128
|
-
recentViolations: profile.violations.slice(0, 5),
|
|
1129
|
-
pendingActions: profile.correctives.filter(a => a.status === 'pending'),
|
|
1130
|
-
riskLevel: profile.riskMatrix.overallRisk,
|
|
1131
|
-
certifications: profile.certifications,
|
|
1132
|
-
upcomingAudits: [profile.metadata.nextScheduledAssessment]
|
|
1133
|
-
};
|
|
1134
|
-
}
|
|
1135
|
-
|
|
1136
|
-
private async handleCriticalViolations(violations: ComplianceViolation[]): Promise<void> {
|
|
1137
|
-
this.logger.error(`🚨 Critical compliance violations detected: ${violations.length}`);
|
|
1138
|
-
|
|
1139
|
-
// Implement emergency response
|
|
1140
|
-
for (const violation of violations) {
|
|
1141
|
-
// Create immediate corrective action
|
|
1142
|
-
const emergencyAction: CorrectiveAction = {
|
|
1143
|
-
id: `emergency_${Date.now()}`,
|
|
1144
|
-
violationId: violation.id,
|
|
1145
|
-
type: 'automated',
|
|
1146
|
-
title: `Emergency: ${violation.title}`,
|
|
1147
|
-
description: 'Emergency corrective action for critical violation',
|
|
1148
|
-
status: 'in-progress',
|
|
1149
|
-
executionSteps: [
|
|
1150
|
-
{
|
|
1151
|
-
order: 1,
|
|
1152
|
-
action: 'Isolate affected systems',
|
|
1153
|
-
automated: true,
|
|
1154
|
-
status: 'pending'
|
|
1155
|
-
},
|
|
1156
|
-
{
|
|
1157
|
-
order: 2,
|
|
1158
|
-
action: 'Apply emergency patch',
|
|
1159
|
-
automated: true,
|
|
1160
|
-
status: 'pending'
|
|
1161
|
-
}
|
|
1162
|
-
]
|
|
1163
|
-
};
|
|
1164
|
-
|
|
1165
|
-
await this.executeActionSteps(emergencyAction);
|
|
1166
|
-
}
|
|
1167
|
-
}
|
|
1168
|
-
|
|
1169
|
-
private async updateMonitoringStatus(monitoringId: string, result: ComplianceResult): Promise<void> {
|
|
1170
|
-
await this.memory.store(`monitoring_${monitoringId}`, {
|
|
1171
|
-
lastCheck: new Date().toISOString(),
|
|
1172
|
-
complianceScore: result.profile.overallScore,
|
|
1173
|
-
violationsFound: result.violationsFound,
|
|
1174
|
-
violationsRemediated: result.violationsRemediated
|
|
1175
|
-
}, 86400000); // 24 hours
|
|
1176
|
-
}
|
|
1177
|
-
|
|
1178
|
-
private async getCorrectiveAction(actionId: string): Promise<CorrectiveAction | null> {
|
|
1179
|
-
// Search through all profiles for the action
|
|
1180
|
-
for (const profile of this.complianceProfiles.values()) {
|
|
1181
|
-
const action = profile.correctives.find(a => a.id === actionId);
|
|
1182
|
-
if (action) return action;
|
|
1183
|
-
}
|
|
1184
|
-
return null;
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
private async verifyActionSafety(action: CorrectiveAction): Promise<{ safe: boolean; reason?: string }> {
|
|
1188
|
-
// Verify action is safe to execute
|
|
1189
|
-
if (action.type === 'manual') {
|
|
1190
|
-
return { safe: false, reason: 'Manual actions cannot be automated' };
|
|
1191
|
-
}
|
|
1192
|
-
|
|
1193
|
-
return { safe: true };
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
|
-
private async generateActionEvidence(action: CorrectiveAction, result: ActionResult): Promise<string[]> {
|
|
1197
|
-
const evidence: string[] = [];
|
|
1198
|
-
|
|
1199
|
-
// Generate execution log
|
|
1200
|
-
evidence.push(`execution_log_${action.id}.json`);
|
|
1201
|
-
|
|
1202
|
-
// Generate before/after snapshots
|
|
1203
|
-
evidence.push(`before_snapshot_${action.id}.json`);
|
|
1204
|
-
evidence.push(`after_snapshot_${action.id}.json`);
|
|
1205
|
-
|
|
1206
|
-
return evidence;
|
|
1207
|
-
}
|
|
1208
|
-
|
|
1209
|
-
private async auditAction(action: CorrectiveAction, result: ActionResult): Promise<void> {
|
|
1210
|
-
const auditEntry: AuditEntry = {
|
|
1211
|
-
id: `audit_${Date.now()}`,
|
|
1212
|
-
timestamp: new Date().toISOString(),
|
|
1213
|
-
action: 'CORRECTIVE_ACTION_EXECUTED',
|
|
1214
|
-
actor: 'System',
|
|
1215
|
-
target: action.id,
|
|
1216
|
-
details: {
|
|
1217
|
-
violationId: action.violationId,
|
|
1218
|
-
success: result.success,
|
|
1219
|
-
automated: action.type === 'automated'
|
|
1220
|
-
},
|
|
1221
|
-
result: result.success ? 'success' : 'failure'
|
|
1222
|
-
};
|
|
1223
|
-
|
|
1224
|
-
this.auditTrail.push(auditEntry);
|
|
1225
|
-
await this.memory.store(`audit_${auditEntry.id}`, auditEntry, 31536000000); // 1 year
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1228
|
-
private async renderComplianceReport(profile: ComplianceProfile, format: string): Promise<string> {
|
|
1229
|
-
let content = `# Compliance Report\n\n`;
|
|
1230
|
-
content += `**Organization**: ${profile.organizationName}\n`;
|
|
1231
|
-
content += `**Assessment Date**: ${new Date(profile.assessmentDate).toLocaleDateString()}\n`;
|
|
1232
|
-
content += `**Overall Score**: ${profile.overallScore}%\n\n`;
|
|
1233
|
-
|
|
1234
|
-
content += `## Executive Summary\n`;
|
|
1235
|
-
content += `Overall compliance status: ${profile.overallScore >= 80 ? 'COMPLIANT' : 'NON-COMPLIANT'}\n\n`;
|
|
1236
|
-
|
|
1237
|
-
content += `## Framework Compliance\n`;
|
|
1238
|
-
for (const framework of profile.frameworks) {
|
|
1239
|
-
content += `### ${framework.name} (${framework.score}%)\n`;
|
|
1240
|
-
content += `- Status: ${framework.status}\n`;
|
|
1241
|
-
content += `- Controls Tested: ${framework.controls.length}\n`;
|
|
1242
|
-
content += `- Passed: ${framework.controls.filter(c => c.status === 'passed').length}\n\n`;
|
|
1243
|
-
}
|
|
1244
|
-
|
|
1245
|
-
content += `## Violations\n`;
|
|
1246
|
-
content += `Total Violations: ${profile.violations.length}\n`;
|
|
1247
|
-
content += `- Critical: ${profile.violations.filter(v => v.severity === 'critical').length}\n`;
|
|
1248
|
-
content += `- High: ${profile.violations.filter(v => v.severity === 'high').length}\n\n`;
|
|
1249
|
-
|
|
1250
|
-
content += `## Risk Assessment\n`;
|
|
1251
|
-
content += `Overall Risk Level: ${profile.riskMatrix.overallRisk.toUpperCase()}\n\n`;
|
|
1252
|
-
|
|
1253
|
-
return content;
|
|
1254
|
-
}
|
|
1255
|
-
|
|
1256
|
-
private async saveReport(content: string, format: string, profileId: string): Promise<string> {
|
|
1257
|
-
const path = `./reports/compliance_${profileId}.${format}`;
|
|
1258
|
-
// Save report logic would go here
|
|
1259
|
-
return path;
|
|
1260
|
-
}
|
|
1261
|
-
|
|
1262
|
-
private startContinuousCompliance(): void {
|
|
1263
|
-
// Initialize continuous compliance monitoring
|
|
1264
|
-
this.logger.info('🔐 Continuous compliance monitoring initialized');
|
|
1265
|
-
}
|
|
1266
|
-
}
|
|
1267
|
-
|
|
1268
|
-
export default AdvancedComplianceSystem;
|