guardrail-compliance 1.0.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/dist/audit/emitter.d.ts +97 -0
- package/dist/audit/emitter.d.ts.map +1 -0
- package/dist/audit/emitter.js +197 -0
- package/dist/audit/events.d.ts +304 -0
- package/dist/audit/events.d.ts.map +1 -0
- package/dist/audit/events.js +267 -0
- package/dist/audit/index.d.ts +11 -0
- package/dist/audit/index.d.ts.map +1 -0
- package/dist/audit/index.js +51 -0
- package/dist/audit/storage.d.ts +93 -0
- package/dist/audit/storage.d.ts.map +1 -0
- package/dist/audit/storage.js +337 -0
- package/dist/automation/__tests__/compliance-scheduler.test.d.ts +2 -0
- package/dist/automation/__tests__/compliance-scheduler.test.d.ts.map +1 -0
- package/dist/automation/__tests__/compliance-scheduler.test.js +140 -0
- package/dist/automation/audit-logger.d.ts +129 -0
- package/dist/automation/audit-logger.d.ts.map +1 -0
- package/dist/automation/audit-logger.js +473 -0
- package/dist/automation/compliance-scheduler-fixed.d.ts +1 -0
- package/dist/automation/compliance-scheduler-fixed.d.ts.map +1 -0
- package/dist/automation/compliance-scheduler-fixed.js +1 -0
- package/dist/automation/compliance-scheduler.d.ts +83 -0
- package/dist/automation/compliance-scheduler.d.ts.map +1 -0
- package/dist/automation/compliance-scheduler.js +414 -0
- package/dist/automation/dashboard.d.ts +194 -0
- package/dist/automation/dashboard.d.ts.map +1 -0
- package/dist/automation/dashboard.js +768 -0
- package/dist/automation/email-service.d.ts +69 -0
- package/dist/automation/email-service.d.ts.map +1 -0
- package/dist/automation/email-service.js +218 -0
- package/dist/automation/evidence-collector.d.ts +140 -0
- package/dist/automation/evidence-collector.d.ts.map +1 -0
- package/dist/automation/evidence-collector.js +682 -0
- package/dist/automation/index.d.ts +8 -0
- package/dist/automation/index.d.ts.map +1 -0
- package/dist/automation/index.js +24 -0
- package/dist/automation/pdf-exporter.d.ts +90 -0
- package/dist/automation/pdf-exporter.d.ts.map +1 -0
- package/dist/automation/pdf-exporter.js +381 -0
- package/dist/automation/reporting-engine.d.ts +116 -0
- package/dist/automation/reporting-engine.d.ts.map +1 -0
- package/dist/automation/reporting-engine.js +329 -0
- package/dist/container/index.d.ts +4 -0
- package/dist/container/index.d.ts.map +1 -0
- package/dist/container/index.js +19 -0
- package/dist/container/kubernetes.d.ts +94 -0
- package/dist/container/kubernetes.d.ts.map +1 -0
- package/dist/container/kubernetes.js +268 -0
- package/dist/container/rules.d.ts +27 -0
- package/dist/container/rules.d.ts.map +1 -0
- package/dist/container/rules.js +216 -0
- package/dist/container/scanner.d.ts +50 -0
- package/dist/container/scanner.d.ts.map +1 -0
- package/dist/container/scanner.js +143 -0
- package/dist/frameworks/engine.d.ts +108 -0
- package/dist/frameworks/engine.d.ts.map +1 -0
- package/dist/frameworks/engine.js +206 -0
- package/dist/frameworks/gdpr.d.ts +6 -0
- package/dist/frameworks/gdpr.d.ts.map +1 -0
- package/dist/frameworks/gdpr.js +198 -0
- package/dist/frameworks/hipaa.d.ts +6 -0
- package/dist/frameworks/hipaa.d.ts.map +1 -0
- package/dist/frameworks/hipaa.js +183 -0
- package/dist/frameworks/index.d.ts +8 -0
- package/dist/frameworks/index.d.ts.map +1 -0
- package/dist/frameworks/index.js +30 -0
- package/dist/frameworks/iso27001.d.ts +63 -0
- package/dist/frameworks/iso27001.d.ts.map +1 -0
- package/dist/frameworks/iso27001.js +331 -0
- package/dist/frameworks/nist.d.ts +62 -0
- package/dist/frameworks/nist.d.ts.map +1 -0
- package/dist/frameworks/nist.js +424 -0
- package/dist/frameworks/pci.d.ts +6 -0
- package/dist/frameworks/pci.d.ts.map +1 -0
- package/dist/frameworks/pci.js +201 -0
- package/dist/frameworks/soc2.d.ts +7 -0
- package/dist/frameworks/soc2.d.ts.map +1 -0
- package/dist/frameworks/soc2.js +248 -0
- package/dist/iac/drift-detector.d.ts +64 -0
- package/dist/iac/drift-detector.d.ts.map +1 -0
- package/dist/iac/drift-detector.js +134 -0
- package/dist/iac/index.d.ts +4 -0
- package/dist/iac/index.d.ts.map +1 -0
- package/dist/iac/index.js +19 -0
- package/dist/iac/rules.d.ts +17 -0
- package/dist/iac/rules.d.ts.map +1 -0
- package/dist/iac/rules.js +385 -0
- package/dist/iac/scanner.d.ts +104 -0
- package/dist/iac/scanner.d.ts.map +1 -0
- package/dist/iac/scanner.js +343 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/pii/data-flow.d.ts +58 -0
- package/dist/pii/data-flow.d.ts.map +1 -0
- package/dist/pii/data-flow.js +154 -0
- package/dist/pii/detector.d.ts +60 -0
- package/dist/pii/detector.d.ts.map +1 -0
- package/dist/pii/detector.js +267 -0
- package/dist/pii/index.d.ts +4 -0
- package/dist/pii/index.d.ts.map +1 -0
- package/dist/pii/index.js +19 -0
- package/dist/pii/patterns.d.ts +36 -0
- package/dist/pii/patterns.d.ts.map +1 -0
- package/dist/pii/patterns.js +108 -0
- package/dist/policy/index.d.ts +5 -0
- package/dist/policy/index.d.ts.map +1 -0
- package/dist/policy/index.js +20 -0
- package/dist/policy/opa-engine.d.ts +121 -0
- package/dist/policy/opa-engine.d.ts.map +1 -0
- package/dist/policy/opa-engine.js +423 -0
- package/package.json +31 -0
- package/src/audit/emitter.ts +383 -0
- package/src/audit/events.ts +351 -0
- package/src/audit/index.ts +35 -0
- package/src/audit/storage.ts +394 -0
- package/src/automation/__tests__/compliance-scheduler.test.ts +183 -0
- package/src/automation/audit-logger.ts +629 -0
- package/src/automation/compliance-scheduler-fixed.ts +0 -0
- package/src/automation/compliance-scheduler.ts +516 -0
- package/src/automation/dashboard.ts +947 -0
- package/src/automation/email-service.ts +230 -0
- package/src/automation/evidence-collector.ts +866 -0
- package/src/automation/index.ts +8 -0
- package/src/automation/pdf-exporter.ts +434 -0
- package/src/automation/reporting-engine.ts +462 -0
- package/src/container/index.ts +3 -0
- package/src/container/kubernetes.ts +379 -0
- package/src/container/rules.ts +244 -0
- package/src/container/scanner.ts +202 -0
- package/src/frameworks/engine.ts +298 -0
- package/src/frameworks/gdpr.ts +204 -0
- package/src/frameworks/hipaa.ts +209 -0
- package/src/frameworks/index.ts +23 -0
- package/src/frameworks/iso27001.ts +398 -0
- package/src/frameworks/nist.ts +518 -0
- package/src/frameworks/pci.ts +226 -0
- package/src/frameworks/soc2.ts +281 -0
- package/src/iac/drift-detector.ts +197 -0
- package/src/iac/index.ts +3 -0
- package/src/iac/rules.ts +420 -0
- package/src/iac/scanner.ts +445 -0
- package/src/index.ts +17 -0
- package/src/pii/data-flow.ts +216 -0
- package/src/pii/detector.ts +327 -0
- package/src/pii/index.ts +3 -0
- package/src/pii/patterns.ts +128 -0
- package/src/policy/index.ts +5 -0
- package/src/policy/opa-engine.ts +504 -0
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Audit Trail Event Schema
|
|
4
|
+
*
|
|
5
|
+
* Comprehensive audit logging for Compliance+ tier.
|
|
6
|
+
* All events are hash-chained for tamper evidence.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.AuditActions = exports.AuditEventSchema = exports.AuditEventMetadataSchema = void 0;
|
|
10
|
+
exports.redactSensitive = redactSensitive;
|
|
11
|
+
exports.redactMetadataForTier = redactMetadataForTier;
|
|
12
|
+
exports.computeEventHash = computeEventHash;
|
|
13
|
+
exports.verifyEventHash = verifyEventHash;
|
|
14
|
+
exports.createAuditEvent = createAuditEvent;
|
|
15
|
+
const zod_1 = require("zod");
|
|
16
|
+
const crypto_1 = require("crypto");
|
|
17
|
+
// Zod schemas for validation
|
|
18
|
+
exports.AuditEventMetadataSchema = zod_1.z.object({
|
|
19
|
+
// Command/action specific data
|
|
20
|
+
command: zod_1.z.string().optional(),
|
|
21
|
+
args: zod_1.z.array(zod_1.z.string()).optional(),
|
|
22
|
+
flags: zod_1.z.record(zod_1.z.unknown()).optional(),
|
|
23
|
+
// Results
|
|
24
|
+
score: zod_1.z.number().optional(),
|
|
25
|
+
grade: zod_1.z.string().optional(),
|
|
26
|
+
issueCount: zod_1.z.number().optional(),
|
|
27
|
+
fixCount: zod_1.z.number().optional(),
|
|
28
|
+
// Context
|
|
29
|
+
projectPath: zod_1.z.string().optional(),
|
|
30
|
+
gitBranch: zod_1.z.string().optional(),
|
|
31
|
+
gitCommit: zod_1.z.string().optional(),
|
|
32
|
+
// Performance
|
|
33
|
+
durationMs: zod_1.z.number().optional(),
|
|
34
|
+
// Error info (if result is error)
|
|
35
|
+
errorCode: zod_1.z.string().optional(),
|
|
36
|
+
errorMessage: zod_1.z.string().optional(),
|
|
37
|
+
// Custom metadata
|
|
38
|
+
custom: zod_1.z.record(zod_1.z.unknown()).optional(),
|
|
39
|
+
}).passthrough();
|
|
40
|
+
exports.AuditEventSchema = zod_1.z.object({
|
|
41
|
+
// Core identity
|
|
42
|
+
id: zod_1.z.string().uuid(),
|
|
43
|
+
timestamp: zod_1.z.string().datetime(),
|
|
44
|
+
// Actor information
|
|
45
|
+
actor: zod_1.z.object({
|
|
46
|
+
id: zod_1.z.string(),
|
|
47
|
+
type: zod_1.z.enum(['user', 'system', 'ci', 'api']),
|
|
48
|
+
name: zod_1.z.string().optional(),
|
|
49
|
+
email: zod_1.z.string().email().optional(),
|
|
50
|
+
ip: zod_1.z.string().optional(),
|
|
51
|
+
}),
|
|
52
|
+
// Event classification
|
|
53
|
+
surface: zod_1.z.enum(['cli', 'vscode', 'mcp', 'web', 'api', 'ci']),
|
|
54
|
+
action: zod_1.z.string(),
|
|
55
|
+
category: zod_1.z.enum(['scan', 'ship', 'reality', 'autopilot', 'fix', 'gate', 'auth', 'config', 'export', 'ai', 'tool', 'system']),
|
|
56
|
+
// Target of the action
|
|
57
|
+
target: zod_1.z.object({
|
|
58
|
+
type: zod_1.z.string(),
|
|
59
|
+
id: zod_1.z.string().optional(),
|
|
60
|
+
path: zod_1.z.string().optional(),
|
|
61
|
+
name: zod_1.z.string().optional(),
|
|
62
|
+
}),
|
|
63
|
+
// Access control
|
|
64
|
+
tier: zod_1.z.enum(['free', 'starter', 'pro', 'compliance', 'enterprise', 'unlimited']),
|
|
65
|
+
// Outcome
|
|
66
|
+
result: zod_1.z.enum(['success', 'failure', 'partial', 'skipped', 'error']),
|
|
67
|
+
// Additional context (tier-gated)
|
|
68
|
+
metadata: exports.AuditEventMetadataSchema.optional(),
|
|
69
|
+
// Hash chain for tamper evidence
|
|
70
|
+
hash: zod_1.z.string(),
|
|
71
|
+
prevHash: zod_1.z.string(),
|
|
72
|
+
// Version for schema evolution
|
|
73
|
+
version: zod_1.z.literal(1),
|
|
74
|
+
});
|
|
75
|
+
// Redaction patterns for sensitive data
|
|
76
|
+
const REDACTION_PATTERNS = [
|
|
77
|
+
// API keys
|
|
78
|
+
/(?:api[_-]?key|apikey|token|secret|password|pwd|auth)[=:]\s*['"]?([a-zA-Z0-9_\-]{16,})['"]?/gi,
|
|
79
|
+
// JWT tokens
|
|
80
|
+
/eyJ[a-zA-Z0-9_-]+\.eyJ[a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]+/g,
|
|
81
|
+
// AWS keys
|
|
82
|
+
/(?:AKIA|ABIA|ACCA|ASIA)[A-Z0-9]{16}/g,
|
|
83
|
+
// Generic secrets
|
|
84
|
+
/(?:sk_live_|sk_test_|pk_live_|pk_test_)[a-zA-Z0-9]+/g,
|
|
85
|
+
// Email addresses (partial redaction)
|
|
86
|
+
/([a-zA-Z0-9._%+-]+)@([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})/g,
|
|
87
|
+
];
|
|
88
|
+
/**
|
|
89
|
+
* Redact sensitive information from a string
|
|
90
|
+
*/
|
|
91
|
+
function redactSensitive(input) {
|
|
92
|
+
let result = input;
|
|
93
|
+
for (const pattern of REDACTION_PATTERNS) {
|
|
94
|
+
result = result.replace(pattern, (match, ...groups) => {
|
|
95
|
+
// For email, keep domain
|
|
96
|
+
if (match.includes('@')) {
|
|
97
|
+
return `[REDACTED]@${groups[1]}`;
|
|
98
|
+
}
|
|
99
|
+
// For other patterns, show type hint
|
|
100
|
+
const typeHint = match.slice(0, 4).toLowerCase();
|
|
101
|
+
return `[REDACTED:${typeHint}...]`;
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Redact metadata based on tier
|
|
108
|
+
* - Compliance+: Full metadata
|
|
109
|
+
* - Pro: Limited metadata (no prompt bodies)
|
|
110
|
+
* - Free/Starter: Minimal (action + result only)
|
|
111
|
+
*/
|
|
112
|
+
function redactMetadataForTier(metadata, tier) {
|
|
113
|
+
if (!metadata)
|
|
114
|
+
return undefined;
|
|
115
|
+
// Compliance+ and Enterprise get full metadata (still redact secrets)
|
|
116
|
+
if (tier === 'compliance' || tier === 'enterprise' || tier === 'unlimited') {
|
|
117
|
+
return redactMetadataSecrets(metadata);
|
|
118
|
+
}
|
|
119
|
+
// Pro gets limited metadata
|
|
120
|
+
if (tier === 'pro') {
|
|
121
|
+
const limited = {
|
|
122
|
+
command: metadata.command,
|
|
123
|
+
score: metadata.score,
|
|
124
|
+
grade: metadata.grade,
|
|
125
|
+
issueCount: metadata.issueCount,
|
|
126
|
+
fixCount: metadata.fixCount,
|
|
127
|
+
durationMs: metadata.durationMs,
|
|
128
|
+
errorCode: metadata.errorCode,
|
|
129
|
+
};
|
|
130
|
+
return redactMetadataSecrets(limited);
|
|
131
|
+
}
|
|
132
|
+
// Free/Starter get minimal
|
|
133
|
+
return {
|
|
134
|
+
score: metadata.score,
|
|
135
|
+
grade: metadata.grade,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Recursively redact secrets from metadata
|
|
140
|
+
*/
|
|
141
|
+
function redactMetadataSecrets(metadata) {
|
|
142
|
+
const result = {};
|
|
143
|
+
for (const [key, value] of Object.entries(metadata)) {
|
|
144
|
+
if (value === undefined)
|
|
145
|
+
continue;
|
|
146
|
+
if (typeof value === 'string') {
|
|
147
|
+
result[key] = redactSensitive(value);
|
|
148
|
+
}
|
|
149
|
+
else if (Array.isArray(value)) {
|
|
150
|
+
result[key] = value.map(v => typeof v === 'string' ? redactSensitive(v) : v);
|
|
151
|
+
}
|
|
152
|
+
else if (typeof value === 'object' && value !== null) {
|
|
153
|
+
result[key] = redactMetadataSecrets(value);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
result[key] = value;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return result;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Compute SHA-256 hash of event for chain integrity
|
|
163
|
+
*/
|
|
164
|
+
function computeEventHash(event) {
|
|
165
|
+
const payload = JSON.stringify({
|
|
166
|
+
id: event.id,
|
|
167
|
+
timestamp: event.timestamp,
|
|
168
|
+
actor: event.actor,
|
|
169
|
+
surface: event.surface,
|
|
170
|
+
action: event.action,
|
|
171
|
+
category: event.category,
|
|
172
|
+
target: event.target,
|
|
173
|
+
tier: event.tier,
|
|
174
|
+
result: event.result,
|
|
175
|
+
metadata: event.metadata,
|
|
176
|
+
prevHash: event.prevHash,
|
|
177
|
+
version: event.version,
|
|
178
|
+
});
|
|
179
|
+
return (0, crypto_1.createHash)('sha256').update(payload).digest('hex');
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Verify hash chain integrity
|
|
183
|
+
*/
|
|
184
|
+
function verifyEventHash(event) {
|
|
185
|
+
const { hash, ...eventWithoutHash } = event;
|
|
186
|
+
const computedHash = computeEventHash(eventWithoutHash);
|
|
187
|
+
return computedHash === hash;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Create a new audit event with proper hash chaining
|
|
191
|
+
*/
|
|
192
|
+
function createAuditEvent(input, prevHash = '0'.repeat(64) // Genesis hash
|
|
193
|
+
) {
|
|
194
|
+
const id = crypto.randomUUID();
|
|
195
|
+
const timestamp = new Date().toISOString();
|
|
196
|
+
// Redact metadata based on tier
|
|
197
|
+
const redactedMetadata = redactMetadataForTier(input.metadata, input.tier);
|
|
198
|
+
const eventWithoutHash = {
|
|
199
|
+
id,
|
|
200
|
+
timestamp,
|
|
201
|
+
actor: input.actor,
|
|
202
|
+
surface: input.surface,
|
|
203
|
+
action: input.action,
|
|
204
|
+
category: input.category,
|
|
205
|
+
target: input.target,
|
|
206
|
+
tier: input.tier,
|
|
207
|
+
result: input.result,
|
|
208
|
+
metadata: redactedMetadata,
|
|
209
|
+
prevHash,
|
|
210
|
+
version: 1,
|
|
211
|
+
};
|
|
212
|
+
const hash = computeEventHash(eventWithoutHash);
|
|
213
|
+
return {
|
|
214
|
+
...eventWithoutHash,
|
|
215
|
+
hash,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
// Pre-defined action types for consistency
|
|
219
|
+
exports.AuditActions = {
|
|
220
|
+
// Scan actions
|
|
221
|
+
SCAN_START: 'scan.start',
|
|
222
|
+
SCAN_COMPLETE: 'scan.complete',
|
|
223
|
+
SCAN_ERROR: 'scan.error',
|
|
224
|
+
// Ship actions
|
|
225
|
+
SHIP_CHECK: 'ship.check',
|
|
226
|
+
SHIP_APPROVE: 'ship.approve',
|
|
227
|
+
SHIP_REJECT: 'ship.reject',
|
|
228
|
+
// Reality actions
|
|
229
|
+
REALITY_START: 'reality.start',
|
|
230
|
+
REALITY_COMPLETE: 'reality.complete',
|
|
231
|
+
REALITY_ERROR: 'reality.error',
|
|
232
|
+
// Autopilot actions
|
|
233
|
+
AUTOPILOT_ENABLE: 'autopilot.enable',
|
|
234
|
+
AUTOPILOT_DISABLE: 'autopilot.disable',
|
|
235
|
+
AUTOPILOT_RUN: 'autopilot.run',
|
|
236
|
+
AUTOPILOT_REPORT: 'autopilot.report',
|
|
237
|
+
// Fix actions
|
|
238
|
+
FIX_PLAN: 'fix.plan',
|
|
239
|
+
FIX_APPLY: 'fix.apply',
|
|
240
|
+
FIX_REVERT: 'fix.revert',
|
|
241
|
+
// Gate actions
|
|
242
|
+
GATE_CHECK: 'gate.check',
|
|
243
|
+
GATE_PASS: 'gate.pass',
|
|
244
|
+
GATE_FAIL: 'gate.fail',
|
|
245
|
+
// Auth actions
|
|
246
|
+
AUTH_LOGIN: 'auth.login',
|
|
247
|
+
AUTH_LOGOUT: 'auth.logout',
|
|
248
|
+
AUTH_TOKEN_REFRESH: 'auth.token_refresh',
|
|
249
|
+
// Config actions
|
|
250
|
+
CONFIG_UPDATE: 'config.update',
|
|
251
|
+
CONFIG_RESET: 'config.reset',
|
|
252
|
+
// Export actions
|
|
253
|
+
EXPORT_REPORT: 'export.report',
|
|
254
|
+
EXPORT_AUDIT: 'export.audit',
|
|
255
|
+
// AI actions
|
|
256
|
+
AI_VALIDATE: 'ai.validate',
|
|
257
|
+
AI_SUGGEST: 'ai.suggest',
|
|
258
|
+
AI_CHECKPOINT: 'ai.checkpoint',
|
|
259
|
+
// MCP Tool actions
|
|
260
|
+
TOOL_INVOKE: 'tool.invoke',
|
|
261
|
+
TOOL_COMPLETE: 'tool.complete',
|
|
262
|
+
TOOL_ERROR: 'tool.error',
|
|
263
|
+
// System actions
|
|
264
|
+
SYSTEM_INIT: 'system.init',
|
|
265
|
+
SYSTEM_UPGRADE: 'system.upgrade',
|
|
266
|
+
SYSTEM_ERROR: 'system.error',
|
|
267
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Audit Trail Module
|
|
3
|
+
*
|
|
4
|
+
* Comprehensive audit logging for Compliance+ tier.
|
|
5
|
+
* Exports all audit functionality.
|
|
6
|
+
*/
|
|
7
|
+
export * from './events';
|
|
8
|
+
export * from './storage';
|
|
9
|
+
export { audit, configureAudit, emit, emitAction, emitScanStart, emitScanComplete, emitShipCheck, emitRealityStart, emitRealityComplete, emitAutopilotAction, emitFixPlan, emitFixApply, emitGateCheck, emitToolInvoke, emitAuth, hasFullAuditAccess, } from './emitter';
|
|
10
|
+
export { default } from './emitter';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/audit/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,UAAU,CAAC;AAGzB,cAAc,WAAW,CAAC;AAG1B,OAAO,EACL,KAAK,EACL,cAAc,EACd,IAAI,EACJ,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,EACX,YAAY,EACZ,aAAa,EACb,cAAc,EACd,QAAQ,EACR,kBAAkB,GACnB,MAAM,WAAW,CAAC;AAGnB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Audit Trail Module
|
|
4
|
+
*
|
|
5
|
+
* Comprehensive audit logging for Compliance+ tier.
|
|
6
|
+
* Exports all audit functionality.
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.default = exports.hasFullAuditAccess = exports.emitAuth = exports.emitToolInvoke = exports.emitGateCheck = exports.emitFixApply = exports.emitFixPlan = exports.emitAutopilotAction = exports.emitRealityComplete = exports.emitRealityStart = exports.emitShipCheck = exports.emitScanComplete = exports.emitScanStart = exports.emitAction = exports.emit = exports.configureAudit = exports.audit = void 0;
|
|
27
|
+
// Event types and schemas
|
|
28
|
+
__exportStar(require("./events"), exports);
|
|
29
|
+
// Storage adapters
|
|
30
|
+
__exportStar(require("./storage"), exports);
|
|
31
|
+
// Emitter (main API)
|
|
32
|
+
var emitter_1 = require("./emitter");
|
|
33
|
+
Object.defineProperty(exports, "audit", { enumerable: true, get: function () { return emitter_1.audit; } });
|
|
34
|
+
Object.defineProperty(exports, "configureAudit", { enumerable: true, get: function () { return emitter_1.configureAudit; } });
|
|
35
|
+
Object.defineProperty(exports, "emit", { enumerable: true, get: function () { return emitter_1.emit; } });
|
|
36
|
+
Object.defineProperty(exports, "emitAction", { enumerable: true, get: function () { return emitter_1.emitAction; } });
|
|
37
|
+
Object.defineProperty(exports, "emitScanStart", { enumerable: true, get: function () { return emitter_1.emitScanStart; } });
|
|
38
|
+
Object.defineProperty(exports, "emitScanComplete", { enumerable: true, get: function () { return emitter_1.emitScanComplete; } });
|
|
39
|
+
Object.defineProperty(exports, "emitShipCheck", { enumerable: true, get: function () { return emitter_1.emitShipCheck; } });
|
|
40
|
+
Object.defineProperty(exports, "emitRealityStart", { enumerable: true, get: function () { return emitter_1.emitRealityStart; } });
|
|
41
|
+
Object.defineProperty(exports, "emitRealityComplete", { enumerable: true, get: function () { return emitter_1.emitRealityComplete; } });
|
|
42
|
+
Object.defineProperty(exports, "emitAutopilotAction", { enumerable: true, get: function () { return emitter_1.emitAutopilotAction; } });
|
|
43
|
+
Object.defineProperty(exports, "emitFixPlan", { enumerable: true, get: function () { return emitter_1.emitFixPlan; } });
|
|
44
|
+
Object.defineProperty(exports, "emitFixApply", { enumerable: true, get: function () { return emitter_1.emitFixApply; } });
|
|
45
|
+
Object.defineProperty(exports, "emitGateCheck", { enumerable: true, get: function () { return emitter_1.emitGateCheck; } });
|
|
46
|
+
Object.defineProperty(exports, "emitToolInvoke", { enumerable: true, get: function () { return emitter_1.emitToolInvoke; } });
|
|
47
|
+
Object.defineProperty(exports, "emitAuth", { enumerable: true, get: function () { return emitter_1.emitAuth; } });
|
|
48
|
+
Object.defineProperty(exports, "hasFullAuditAccess", { enumerable: true, get: function () { return emitter_1.hasFullAuditAccess; } });
|
|
49
|
+
// Default export
|
|
50
|
+
var emitter_2 = require("./emitter");
|
|
51
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(emitter_2).default; } });
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Audit Trail Storage
|
|
3
|
+
*
|
|
4
|
+
* Hash-chained JSONL storage with adapter interface for future extensibility.
|
|
5
|
+
* Default: Local file storage at .guardrail/audit/audit.log.jsonl
|
|
6
|
+
*/
|
|
7
|
+
import { AuditEvent } from './events';
|
|
8
|
+
export interface AuditStorageAdapter {
|
|
9
|
+
append(event: AuditEvent): Promise<void>;
|
|
10
|
+
getLastHash(): Promise<string>;
|
|
11
|
+
read(options?: AuditReadOptions): Promise<AuditEvent[]>;
|
|
12
|
+
tail(count: number): Promise<AuditEvent[]>;
|
|
13
|
+
validateChain(): Promise<AuditChainValidation>;
|
|
14
|
+
export(format: 'json' | 'csv', options?: AuditExportOptions): Promise<string>;
|
|
15
|
+
clear(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export interface AuditReadOptions {
|
|
18
|
+
limit?: number;
|
|
19
|
+
offset?: number;
|
|
20
|
+
startDate?: Date;
|
|
21
|
+
endDate?: Date;
|
|
22
|
+
surface?: string;
|
|
23
|
+
category?: string;
|
|
24
|
+
action?: string;
|
|
25
|
+
actorId?: string;
|
|
26
|
+
result?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface AuditExportOptions {
|
|
29
|
+
startDate?: Date;
|
|
30
|
+
endDate?: Date;
|
|
31
|
+
includeMetadata?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface AuditChainValidation {
|
|
34
|
+
valid: boolean;
|
|
35
|
+
totalEvents: number;
|
|
36
|
+
validEvents: number;
|
|
37
|
+
invalidEvents: number;
|
|
38
|
+
brokenLinks: Array<{
|
|
39
|
+
index: number;
|
|
40
|
+
eventId: string;
|
|
41
|
+
expectedPrevHash: string;
|
|
42
|
+
actualPrevHash: string;
|
|
43
|
+
}>;
|
|
44
|
+
tamperedEvents: Array<{
|
|
45
|
+
index: number;
|
|
46
|
+
eventId: string;
|
|
47
|
+
reason: string;
|
|
48
|
+
}>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Local JSONL file storage adapter
|
|
52
|
+
*/
|
|
53
|
+
export declare class LocalJSONLStorage implements AuditStorageAdapter {
|
|
54
|
+
private filePath;
|
|
55
|
+
private lastHash;
|
|
56
|
+
private initialized;
|
|
57
|
+
constructor(basePath?: string);
|
|
58
|
+
private ensureDir;
|
|
59
|
+
private initialize;
|
|
60
|
+
append(event: AuditEvent): Promise<void>;
|
|
61
|
+
getLastHash(): Promise<string>;
|
|
62
|
+
read(options?: AuditReadOptions): Promise<AuditEvent[]>;
|
|
63
|
+
tail(count: number): Promise<AuditEvent[]>;
|
|
64
|
+
validateChain(): Promise<AuditChainValidation>;
|
|
65
|
+
export(format: 'json' | 'csv', options?: AuditExportOptions): Promise<string>;
|
|
66
|
+
clear(): Promise<void>;
|
|
67
|
+
getFilePath(): string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Server storage adapter (placeholder for future implementation)
|
|
71
|
+
*/
|
|
72
|
+
export declare class ServerStorageAdapter implements AuditStorageAdapter {
|
|
73
|
+
private apiUrl;
|
|
74
|
+
private apiKey;
|
|
75
|
+
constructor(apiUrl: string, apiKey: string);
|
|
76
|
+
append(_event: AuditEvent): Promise<void>;
|
|
77
|
+
getLastHash(): Promise<string>;
|
|
78
|
+
read(_options?: AuditReadOptions): Promise<AuditEvent[]>;
|
|
79
|
+
tail(_count: number): Promise<AuditEvent[]>;
|
|
80
|
+
validateChain(): Promise<AuditChainValidation>;
|
|
81
|
+
export(_format: 'json' | 'csv', _options?: AuditExportOptions): Promise<string>;
|
|
82
|
+
clear(): Promise<void>;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Factory function to create storage adapter based on configuration
|
|
86
|
+
*/
|
|
87
|
+
export declare function createStorageAdapter(config?: {
|
|
88
|
+
type?: 'local' | 'server';
|
|
89
|
+
basePath?: string;
|
|
90
|
+
apiUrl?: string;
|
|
91
|
+
apiKey?: string;
|
|
92
|
+
}): AuditStorageAdapter;
|
|
93
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/audit/storage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EACL,UAAU,EAEX,MAAM,UAAU,CAAC;AAGlB,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/B,IAAI,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IACxD,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IAC3C,aAAa,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC/C,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,C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