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,230 @@
|
|
|
1
|
+
import * as nodemailer from "nodemailer";
|
|
2
|
+
|
|
3
|
+
export interface EmailConfig {
|
|
4
|
+
host: string;
|
|
5
|
+
port: number;
|
|
6
|
+
secure?: boolean;
|
|
7
|
+
auth: {
|
|
8
|
+
user: string;
|
|
9
|
+
pass: string;
|
|
10
|
+
};
|
|
11
|
+
from: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface EmailMessage {
|
|
15
|
+
to: string | string[];
|
|
16
|
+
subject: string;
|
|
17
|
+
text?: string;
|
|
18
|
+
html?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface EmailResult {
|
|
22
|
+
success: boolean;
|
|
23
|
+
messageId?: string;
|
|
24
|
+
error?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Email Service for Guardrail notifications
|
|
29
|
+
*
|
|
30
|
+
* Supports SMTP-based email delivery via nodemailer.
|
|
31
|
+
* Configure via environment variables:
|
|
32
|
+
* - EMAIL_FROM: sender email address
|
|
33
|
+
* - SMTP_HOST: SMTP server hostname
|
|
34
|
+
* - SMTP_PORT: SMTP server port (default: 587)
|
|
35
|
+
* - SMTP_USER: SMTP authentication username
|
|
36
|
+
* - SMTP_PASS: SMTP authentication password
|
|
37
|
+
* - SMTP_SECURE: Use TLS (default: false for port 587, true for port 465)
|
|
38
|
+
*/
|
|
39
|
+
export class EmailService {
|
|
40
|
+
private transporter: nodemailer.Transporter | null = null;
|
|
41
|
+
private config: EmailConfig | null = null;
|
|
42
|
+
|
|
43
|
+
constructor() {
|
|
44
|
+
this.initializeFromEnv();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Initialize email configuration from environment variables
|
|
49
|
+
*/
|
|
50
|
+
private initializeFromEnv(): void {
|
|
51
|
+
const host = process.env["SMTP_HOST"];
|
|
52
|
+
const port = parseInt(process.env["SMTP_PORT"] || "587", 10);
|
|
53
|
+
const user = process.env["SMTP_USER"];
|
|
54
|
+
const pass = process.env["SMTP_PASS"];
|
|
55
|
+
const from = process.env["EMAIL_FROM"];
|
|
56
|
+
|
|
57
|
+
if (host && user && pass && from) {
|
|
58
|
+
this.config = {
|
|
59
|
+
host,
|
|
60
|
+
port,
|
|
61
|
+
secure: process.env["SMTP_SECURE"] === "true" || port === 465,
|
|
62
|
+
auth: { user, pass },
|
|
63
|
+
from,
|
|
64
|
+
};
|
|
65
|
+
this.createTransporter();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Create nodemailer transporter with current config
|
|
71
|
+
*/
|
|
72
|
+
private createTransporter(): void {
|
|
73
|
+
if (!this.config) return;
|
|
74
|
+
|
|
75
|
+
this.transporter = nodemailer.createTransport({
|
|
76
|
+
host: this.config.host,
|
|
77
|
+
port: this.config.port,
|
|
78
|
+
secure: this.config.secure,
|
|
79
|
+
auth: this.config.auth,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Check if email service is configured and available
|
|
85
|
+
*/
|
|
86
|
+
isConfigured(): boolean {
|
|
87
|
+
return this.transporter !== null && this.config !== null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Verify SMTP connection
|
|
92
|
+
*/
|
|
93
|
+
async verifyConnection(): Promise<boolean> {
|
|
94
|
+
if (!this.transporter) return false;
|
|
95
|
+
|
|
96
|
+
try {
|
|
97
|
+
await this.transporter.verify();
|
|
98
|
+
return true;
|
|
99
|
+
} catch (error) {
|
|
100
|
+
console.error("Email service verification failed:", error);
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Send an email
|
|
107
|
+
*/
|
|
108
|
+
async send(message: EmailMessage): Promise<EmailResult> {
|
|
109
|
+
if (!this.transporter || !this.config) {
|
|
110
|
+
return {
|
|
111
|
+
success: false,
|
|
112
|
+
error: "Email service not configured. Set SMTP_HOST, SMTP_USER, SMTP_PASS, and EMAIL_FROM environment variables.",
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
try {
|
|
117
|
+
const recipients = Array.isArray(message.to)
|
|
118
|
+
? message.to.join(", ")
|
|
119
|
+
: message.to;
|
|
120
|
+
|
|
121
|
+
const result = await this.transporter.sendMail({
|
|
122
|
+
from: this.config.from,
|
|
123
|
+
to: recipients,
|
|
124
|
+
subject: message.subject,
|
|
125
|
+
text: message.text,
|
|
126
|
+
html: message.html,
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
return {
|
|
130
|
+
success: true,
|
|
131
|
+
messageId: result.messageId,
|
|
132
|
+
};
|
|
133
|
+
} catch (error) {
|
|
134
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
135
|
+
console.error("Failed to send email:", errorMessage);
|
|
136
|
+
return {
|
|
137
|
+
success: false,
|
|
138
|
+
error: errorMessage,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Send compliance check notification email
|
|
145
|
+
*/
|
|
146
|
+
async sendComplianceNotification(
|
|
147
|
+
recipients: string[],
|
|
148
|
+
projectId: string,
|
|
149
|
+
frameworkId: string,
|
|
150
|
+
result: {
|
|
151
|
+
status: "completed" | "failed";
|
|
152
|
+
score?: number;
|
|
153
|
+
summary?: string;
|
|
154
|
+
reportUrl?: string;
|
|
155
|
+
}
|
|
156
|
+
): Promise<EmailResult> {
|
|
157
|
+
const statusEmoji = result.status === "completed" ? "✅" : "❌";
|
|
158
|
+
const statusText = result.status === "completed" ? "Completed" : "Failed";
|
|
159
|
+
const scoreText = result.score !== undefined ? `${result.score}%` : "N/A";
|
|
160
|
+
|
|
161
|
+
const subject = `[Guardrail] Compliance Check ${statusText}: ${frameworkId}`;
|
|
162
|
+
|
|
163
|
+
const html = `
|
|
164
|
+
<!DOCTYPE html>
|
|
165
|
+
<html>
|
|
166
|
+
<head>
|
|
167
|
+
<style>
|
|
168
|
+
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; line-height: 1.6; color: #333; }
|
|
169
|
+
.container { max-width: 600px; margin: 0 auto; padding: 20px; }
|
|
170
|
+
.header { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 20px; border-radius: 8px 8px 0 0; }
|
|
171
|
+
.content { background: #f9fafb; padding: 20px; border: 1px solid #e5e7eb; border-top: none; border-radius: 0 0 8px 8px; }
|
|
172
|
+
.status { font-size: 24px; margin-bottom: 10px; }
|
|
173
|
+
.metric { background: white; padding: 15px; border-radius: 8px; margin: 10px 0; border: 1px solid #e5e7eb; }
|
|
174
|
+
.metric-label { color: #6b7280; font-size: 12px; text-transform: uppercase; }
|
|
175
|
+
.metric-value { font-size: 20px; font-weight: 600; color: #111827; }
|
|
176
|
+
.button { display: inline-block; background: #667eea; color: white; padding: 12px 24px; border-radius: 6px; text-decoration: none; margin-top: 15px; }
|
|
177
|
+
.footer { text-align: center; color: #6b7280; font-size: 12px; margin-top: 20px; }
|
|
178
|
+
</style>
|
|
179
|
+
</head>
|
|
180
|
+
<body>
|
|
181
|
+
<div class="container">
|
|
182
|
+
<div class="header">
|
|
183
|
+
<div class="status">${statusEmoji} Compliance Check ${statusText}</div>
|
|
184
|
+
<div>Project: ${projectId}</div>
|
|
185
|
+
</div>
|
|
186
|
+
<div class="content">
|
|
187
|
+
<div class="metric">
|
|
188
|
+
<div class="metric-label">Framework</div>
|
|
189
|
+
<div class="metric-value">${frameworkId}</div>
|
|
190
|
+
</div>
|
|
191
|
+
<div class="metric">
|
|
192
|
+
<div class="metric-label">Compliance Score</div>
|
|
193
|
+
<div class="metric-value">${scoreText}</div>
|
|
194
|
+
</div>
|
|
195
|
+
${result.summary ? `<p>${result.summary}</p>` : ""}
|
|
196
|
+
${result.reportUrl ? `<a href="${result.reportUrl}" class="button">View Full Report</a>` : ""}
|
|
197
|
+
</div>
|
|
198
|
+
<div class="footer">
|
|
199
|
+
<p>Sent by Guardrail Compliance Automation</p>
|
|
200
|
+
<p>Context Enhanced by Guardrail AI</p>
|
|
201
|
+
</div>
|
|
202
|
+
</div>
|
|
203
|
+
</body>
|
|
204
|
+
</html>
|
|
205
|
+
`.trim();
|
|
206
|
+
|
|
207
|
+
const text = `
|
|
208
|
+
Compliance Check ${statusText}
|
|
209
|
+
|
|
210
|
+
Project: ${projectId}
|
|
211
|
+
Framework: ${frameworkId}
|
|
212
|
+
Score: ${scoreText}
|
|
213
|
+
${result.summary ? `\nSummary: ${result.summary}` : ""}
|
|
214
|
+
${result.reportUrl ? `\nView Report: ${result.reportUrl}` : ""}
|
|
215
|
+
|
|
216
|
+
--
|
|
217
|
+
Sent by Guardrail Compliance Automation
|
|
218
|
+
`.trim();
|
|
219
|
+
|
|
220
|
+
return this.send({
|
|
221
|
+
to: recipients,
|
|
222
|
+
subject,
|
|
223
|
+
text,
|
|
224
|
+
html,
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// Singleton instance
|
|
230
|
+
export const emailService = new EmailService();
|