stringray-ai 1.0.38 → 1.0.39
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/plugin/architectural-integrity.d.ts +21 -0
- package/dist/plugin/architectural-integrity.d.ts.map +1 -0
- package/dist/plugin/architectural-integrity.js +81 -0
- package/dist/plugin/architectural-integrity.js.map +1 -0
- package/dist/plugin/boot-orchestrator.d.ts +100 -0
- package/dist/plugin/boot-orchestrator.d.ts.map +1 -0
- package/dist/plugin/boot-orchestrator.js +606 -0
- package/dist/plugin/boot-orchestrator.js.map +1 -0
- package/dist/plugin/codex-injector.d.ts +72 -0
- package/dist/plugin/codex-injector.d.ts.map +1 -0
- package/dist/plugin/codex-injector.js +387 -0
- package/dist/plugin/codex-injector.js.map +1 -0
- package/dist/plugin/delegation/index.d.ts +16 -0
- package/dist/plugin/delegation/index.d.ts.map +1 -0
- package/dist/plugin/delegation/index.js +13 -0
- package/dist/plugin/delegation/index.js.map +1 -0
- package/dist/plugin/delegation/session-coordinator.d.ts +121 -0
- package/dist/plugin/delegation/session-coordinator.d.ts.map +1 -0
- package/dist/plugin/delegation/session-coordinator.js +346 -0
- package/dist/plugin/delegation/session-coordinator.js.map +1 -0
- package/dist/plugin/index.d.ts +3 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/index.js +3 -0
- package/dist/plugin/index.js.map +1 -0
- package/dist/plugin/monitoring/memory-monitor.d.ts +113 -0
- package/dist/plugin/monitoring/memory-monitor.d.ts.map +1 -0
- package/dist/plugin/monitoring/memory-monitor.js +283 -0
- package/dist/plugin/monitoring/memory-monitor.js.map +1 -0
- package/dist/plugin/postprocessor/PostProcessor.d.ts +90 -0
- package/dist/plugin/postprocessor/PostProcessor.d.ts.map +1 -0
- package/dist/plugin/postprocessor/PostProcessor.js +631 -0
- package/dist/plugin/postprocessor/PostProcessor.js.map +1 -0
- package/dist/plugin/postprocessor/analysis/FailureAnalysisEngine.d.ts +40 -0
- package/dist/plugin/postprocessor/analysis/FailureAnalysisEngine.d.ts.map +1 -0
- package/dist/plugin/postprocessor/analysis/FailureAnalysisEngine.js +244 -0
- package/dist/plugin/postprocessor/analysis/FailureAnalysisEngine.js.map +1 -0
- package/dist/plugin/postprocessor/autofix/AutoFixEngine.d.ts +50 -0
- package/dist/plugin/postprocessor/autofix/AutoFixEngine.d.ts.map +1 -0
- package/dist/plugin/postprocessor/autofix/AutoFixEngine.js +246 -0
- package/dist/plugin/postprocessor/autofix/AutoFixEngine.js.map +1 -0
- package/dist/plugin/postprocessor/autofix/FixValidator.d.ts +27 -0
- package/dist/plugin/postprocessor/autofix/FixValidator.d.ts.map +1 -0
- package/dist/plugin/postprocessor/autofix/FixValidator.js +158 -0
- package/dist/plugin/postprocessor/autofix/FixValidator.js.map +1 -0
- package/dist/plugin/postprocessor/config.d.ts +7 -0
- package/dist/plugin/postprocessor/config.d.ts.map +1 -0
- package/dist/plugin/postprocessor/config.js +66 -0
- package/dist/plugin/postprocessor/config.js.map +1 -0
- package/dist/plugin/postprocessor/escalation/EscalationEngine.d.ts +73 -0
- package/dist/plugin/postprocessor/escalation/EscalationEngine.d.ts.map +1 -0
- package/dist/plugin/postprocessor/escalation/EscalationEngine.js +249 -0
- package/dist/plugin/postprocessor/escalation/EscalationEngine.js.map +1 -0
- package/dist/plugin/postprocessor/monitoring/MonitoringEngine.d.ts +19 -0
- package/dist/plugin/postprocessor/monitoring/MonitoringEngine.d.ts.map +1 -0
- package/dist/plugin/postprocessor/monitoring/MonitoringEngine.js +120 -0
- package/dist/plugin/postprocessor/monitoring/MonitoringEngine.js.map +1 -0
- package/dist/plugin/postprocessor/redeploy/RedeployCoordinator.d.ts +92 -0
- package/dist/plugin/postprocessor/redeploy/RedeployCoordinator.d.ts.map +1 -0
- package/dist/plugin/postprocessor/redeploy/RedeployCoordinator.js +319 -0
- package/dist/plugin/postprocessor/redeploy/RedeployCoordinator.js.map +1 -0
- package/dist/plugin/postprocessor/success/SuccessHandler.d.ts +61 -0
- package/dist/plugin/postprocessor/success/SuccessHandler.d.ts.map +1 -0
- package/dist/plugin/postprocessor/success/SuccessHandler.js +148 -0
- package/dist/plugin/postprocessor/success/SuccessHandler.js.map +1 -0
- package/dist/plugin/postprocessor/triggers/APITrigger.d.ts +13 -0
- package/dist/plugin/postprocessor/triggers/APITrigger.d.ts.map +1 -0
- package/dist/plugin/postprocessor/triggers/APITrigger.js +20 -0
- package/dist/plugin/postprocessor/triggers/APITrigger.js.map +1 -0
- package/dist/plugin/postprocessor/triggers/GitHookTrigger.d.ts +17 -0
- package/dist/plugin/postprocessor/triggers/GitHookTrigger.d.ts.map +1 -0
- package/dist/plugin/postprocessor/triggers/GitHookTrigger.js +285 -0
- package/dist/plugin/postprocessor/triggers/GitHookTrigger.js.map +1 -0
- package/dist/plugin/postprocessor/triggers/WebhookTrigger.d.ts +13 -0
- package/dist/plugin/postprocessor/triggers/WebhookTrigger.d.ts.map +1 -0
- package/dist/plugin/postprocessor/triggers/WebhookTrigger.js +21 -0
- package/dist/plugin/postprocessor/triggers/WebhookTrigger.js.map +1 -0
- package/dist/plugin/postprocessor/types.d.ts +198 -0
- package/dist/plugin/postprocessor/types.d.ts.map +1 -0
- package/dist/plugin/postprocessor/types.js +5 -0
- package/dist/plugin/postprocessor/types.js.map +1 -0
- package/dist/plugin/security/security-auditor.d.ts +57 -0
- package/dist/plugin/security/security-auditor.d.ts.map +1 -0
- package/dist/plugin/security/security-auditor.js +583 -0
- package/dist/plugin/security/security-auditor.js.map +1 -0
- package/dist/plugin/security/security-hardener.d.ts +63 -0
- package/dist/plugin/security/security-hardener.d.ts.map +1 -0
- package/dist/plugin/security/security-hardener.js +181 -0
- package/dist/plugin/security/security-hardener.js.map +1 -0
- package/dist/plugin/security/security-headers.d.ts +52 -0
- package/dist/plugin/security/security-headers.d.ts.map +1 -0
- package/dist/plugin/security/security-headers.js +118 -0
- package/dist/plugin/security/security-headers.js.map +1 -0
- package/dist/plugin/session/session-cleanup-manager.d.ts +118 -0
- package/dist/plugin/session/session-cleanup-manager.d.ts.map +1 -0
- package/dist/plugin/session/session-cleanup-manager.js +324 -0
- package/dist/plugin/session/session-cleanup-manager.js.map +1 -0
- package/dist/plugin/session/session-monitor.d.ts +99 -0
- package/dist/plugin/session/session-monitor.d.ts.map +1 -0
- package/dist/plugin/session/session-monitor.js +363 -0
- package/dist/plugin/session/session-monitor.js.map +1 -0
- package/dist/plugin/session/session-state-manager.d.ts +142 -0
- package/dist/plugin/session/session-state-manager.d.ts.map +1 -0
- package/dist/plugin/session/session-state-manager.js +504 -0
- package/dist/plugin/session/session-state-manager.js.map +1 -0
- package/dist/plugin/strray-activation.d.ts +18 -0
- package/dist/plugin/strray-activation.d.ts.map +1 -0
- package/dist/plugin/strray-activation.js +114 -0
- package/dist/plugin/strray-activation.js.map +1 -0
- package/dist/plugin/validation/report-content-validator.d.ts +43 -0
- package/dist/plugin/validation/report-content-validator.d.ts.map +1 -0
- package/dist/plugin/validation/report-content-validator.js +219 -0
- package/dist/plugin/validation/report-content-validator.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StringRay Framework v1.0.0 - Security Hardening Module
|
|
3
|
+
*
|
|
4
|
+
* Implements additional security measures and hardening for the framework.
|
|
5
|
+
* Addresses vulnerabilities identified during security audit.
|
|
6
|
+
*
|
|
7
|
+
* @version 1.0.0
|
|
8
|
+
* @since 2026-01-07
|
|
9
|
+
*/
|
|
10
|
+
import { promises as fs } from "fs";
|
|
11
|
+
export class SecurityHardener {
|
|
12
|
+
config;
|
|
13
|
+
constructor(config = {}) {
|
|
14
|
+
this.config = {
|
|
15
|
+
enableInputValidation: true,
|
|
16
|
+
enableRateLimiting: true,
|
|
17
|
+
enableAuditLogging: true,
|
|
18
|
+
enableSecureHeaders: true,
|
|
19
|
+
maxRequestSizeBytes: 1024 * 1024, // 1MB
|
|
20
|
+
rateLimitWindowMs: 60000, // 1 minute
|
|
21
|
+
rateLimitMaxRequests: 100,
|
|
22
|
+
...config,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Apply security hardening based on audit results
|
|
27
|
+
*/
|
|
28
|
+
async hardenSecurity(auditResult) {
|
|
29
|
+
const appliedFixes = [];
|
|
30
|
+
const remainingIssues = [];
|
|
31
|
+
console.log("🔒 Security Hardener: Applying security fixes...");
|
|
32
|
+
for (const issue of auditResult.issues) {
|
|
33
|
+
const fix = await this.applyFixForIssue(issue);
|
|
34
|
+
if (fix.applied) {
|
|
35
|
+
appliedFixes.push(fix.description);
|
|
36
|
+
console.log(`✅ Applied fix: ${fix.description}`);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
remainingIssues.push(issue);
|
|
40
|
+
console.log(`⚠️ Could not apply fix for: ${issue.description}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return { appliedFixes, remainingIssues };
|
|
44
|
+
}
|
|
45
|
+
async applyFixForIssue(issue) {
|
|
46
|
+
switch (issue.category) {
|
|
47
|
+
case "hardcoded-secrets":
|
|
48
|
+
return await this.fixHardcodedSecrets(issue);
|
|
49
|
+
case "file-permissions":
|
|
50
|
+
return await this.fixFilePermissions(issue);
|
|
51
|
+
case "dependency-management":
|
|
52
|
+
return await this.fixDependencyManagement(issue);
|
|
53
|
+
case "input-validation":
|
|
54
|
+
return await this.addInputValidation(issue);
|
|
55
|
+
default:
|
|
56
|
+
return {
|
|
57
|
+
applied: false,
|
|
58
|
+
description: `No automated fix available for ${issue.category}`,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async fixHardcodedSecrets(issue) {
|
|
63
|
+
// This would require manual intervention, but we can suggest the fix
|
|
64
|
+
console.log(`🔧 Manual fix needed for hardcoded secrets in ${issue.file}`);
|
|
65
|
+
console.log(`💡 Recommendation: Move secrets to environment variables`);
|
|
66
|
+
return {
|
|
67
|
+
applied: false,
|
|
68
|
+
description: `Manual intervention required for hardcoded secrets in ${issue.file}`,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
async fixFilePermissions(issue) {
|
|
72
|
+
try {
|
|
73
|
+
// Remove world-writable permissions
|
|
74
|
+
await fs.chmod(issue.file, 0o644);
|
|
75
|
+
return {
|
|
76
|
+
applied: true,
|
|
77
|
+
description: `Fixed file permissions for ${issue.file}`,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
return {
|
|
82
|
+
applied: false,
|
|
83
|
+
description: `Failed to fix permissions for ${issue.file}: ${error}`,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async fixDependencyManagement(issue) {
|
|
88
|
+
// This requires manual intervention for dependency updates
|
|
89
|
+
console.log(`🔧 Manual fix needed for dependency management in ${issue.file}`);
|
|
90
|
+
console.log(`💡 Recommendation: Update dependencies to specific versions and use lockfiles`);
|
|
91
|
+
return {
|
|
92
|
+
applied: false,
|
|
93
|
+
description: `Manual intervention required for dependency management in ${issue.file}`,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
async addInputValidation(issue) {
|
|
97
|
+
// This would require code analysis and modification
|
|
98
|
+
console.log(`🔧 Code modification needed for input validation in ${issue.file}:${issue.line}`);
|
|
99
|
+
console.log(`💡 Recommendation: Add comprehensive input validation and sanitization`);
|
|
100
|
+
return {
|
|
101
|
+
applied: false,
|
|
102
|
+
description: `Code modification required for input validation in ${issue.file}`,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Add security headers to HTTP responses
|
|
107
|
+
*/
|
|
108
|
+
addSecurityHeaders(headers) {
|
|
109
|
+
if (!this.config.enableSecureHeaders)
|
|
110
|
+
return headers;
|
|
111
|
+
return {
|
|
112
|
+
...headers,
|
|
113
|
+
"X-Content-Type-Options": "nosniff",
|
|
114
|
+
"X-Frame-Options": "DENY",
|
|
115
|
+
"X-XSS-Protection": "1; mode=block",
|
|
116
|
+
"Strict-Transport-Security": "max-age=31536000; includeSubDomains",
|
|
117
|
+
"Content-Security-Policy": "default-src 'self'",
|
|
118
|
+
"Referrer-Policy": "strict-origin-when-cross-origin",
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Validate input data
|
|
123
|
+
*/
|
|
124
|
+
validateInput(input, schema) {
|
|
125
|
+
if (!this.config.enableInputValidation) {
|
|
126
|
+
return { valid: true, errors: [] };
|
|
127
|
+
}
|
|
128
|
+
const errors = [];
|
|
129
|
+
// Basic validation - in production, use a proper validation library
|
|
130
|
+
if (schema.type === "string" && typeof input !== "string") {
|
|
131
|
+
errors.push("Expected string");
|
|
132
|
+
}
|
|
133
|
+
if (schema.maxLength &&
|
|
134
|
+
typeof input === "string" &&
|
|
135
|
+
input.length > schema.maxLength) {
|
|
136
|
+
errors.push(`String too long (max ${schema.maxLength})`);
|
|
137
|
+
}
|
|
138
|
+
if (schema.pattern &&
|
|
139
|
+
typeof input === "string" &&
|
|
140
|
+
!new RegExp(schema.pattern).test(input)) {
|
|
141
|
+
errors.push("String does not match required pattern");
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
valid: errors.length === 0,
|
|
145
|
+
errors,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Check rate limiting
|
|
150
|
+
*/
|
|
151
|
+
checkRateLimit(identifier, requests) {
|
|
152
|
+
if (!this.config.enableRateLimiting)
|
|
153
|
+
return true;
|
|
154
|
+
const now = Date.now();
|
|
155
|
+
const windowStart = now - this.config.rateLimitWindowMs;
|
|
156
|
+
const userRequests = requests.get(identifier) || [];
|
|
157
|
+
const recentRequests = userRequests.filter((time) => time > windowStart);
|
|
158
|
+
if (recentRequests.length >= this.config.rateLimitMaxRequests) {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
recentRequests.push(now);
|
|
162
|
+
requests.set(identifier, recentRequests);
|
|
163
|
+
return true;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Log security events
|
|
167
|
+
*/
|
|
168
|
+
logSecurityEvent(event) {
|
|
169
|
+
if (!this.config.enableAuditLogging)
|
|
170
|
+
return;
|
|
171
|
+
const logEntry = {
|
|
172
|
+
timestamp: new Date().toISOString(),
|
|
173
|
+
...event,
|
|
174
|
+
};
|
|
175
|
+
console.log(`🔒 SECURITY EVENT [${event.severity.toUpperCase()}]:`, JSON.stringify(logEntry));
|
|
176
|
+
// In production, this would write to secure audit logs
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
// Export singleton instance
|
|
180
|
+
export const securityHardener = new SecurityHardener();
|
|
181
|
+
//# sourceMappingURL=security-hardener.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security-hardener.js","sourceRoot":"","sources":["../../../src/security/security-hardener.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAC;AAYpC,MAAM,OAAO,gBAAgB;IACnB,MAAM,CAA0B;IAExC,YAAY,SAA2C,EAAE;QACvD,IAAI,CAAC,MAAM,GAAG;YACZ,qBAAqB,EAAE,IAAI;YAC3B,kBAAkB,EAAE,IAAI;YACxB,kBAAkB,EAAE,IAAI;YACxB,mBAAmB,EAAE,IAAI;YACzB,mBAAmB,EAAE,IAAI,GAAG,IAAI,EAAE,MAAM;YACxC,iBAAiB,EAAE,KAAK,EAAE,WAAW;YACrC,oBAAoB,EAAE,GAAG;YACzB,GAAG,MAAM;SACV,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,cAAc,CAAC,WAAwC;QAI3D,MAAM,YAAY,GAAa,EAAE,CAAC;QAClC,MAAM,eAAe,GAAoB,EAAE,CAAC;QAE5C,OAAO,CAAC,GAAG,CAAC,kDAAkD,CAAC,CAAC;QAEhE,KAAK,MAAM,KAAK,IAAI,WAAW,CAAC,MAAM,EAAE,C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B;YAAE,OAAO,IAAI,CAAC;QAEjD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,MAAM,WAAW,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC;QAExD,MAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;QACpD,MAAM,cAAc,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,WAAW,CAAC,CAAC;QAEzE,IAAI,cAAc,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,oBAAoB,EAAE,CAAC;YAC9D,OAAO,KAAK,CAAC;QACf,CAAC;QAED,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACzB,QAAQ,CAAC,GAAG,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;QAEzC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,gBAAgB,CAAC,KAKhB;QACC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,kBAAkB;YAAE,OAAO;QAE5C,MAAM,QAAQ,GAAG;YACf,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,GAAG,KAAK;SACT,CAAC;QAEF,OAAO,CAAC,GAAG,CACT,sBAAsB,KAAK,CAAC,QAAQ,CAAC,WAAW,EAAE,IAAI,EACtD,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CACzB,CAAC;QAEF,uDAAuD;IACzD,CAAC;CACF;AAED,4BAA4B;AAC5B,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,gBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StringRay Framework v1.0.0 - Security Headers Middleware
|
|
3
|
+
*
|
|
4
|
+
* Comprehensive security headers implementation for HTTP responses.
|
|
5
|
+
* Integrates with boot orchestrator and API endpoints.
|
|
6
|
+
*
|
|
7
|
+
* @version 1.0.0
|
|
8
|
+
* @since 2026-01-07
|
|
9
|
+
*/
|
|
10
|
+
export interface SecurityHeadersConfig {
|
|
11
|
+
enableCSP: boolean;
|
|
12
|
+
enableHSTS: boolean;
|
|
13
|
+
enableFrameOptions: boolean;
|
|
14
|
+
enableXSSProtection: boolean;
|
|
15
|
+
enableContentTypeOptions: boolean;
|
|
16
|
+
enableReferrerPolicy: boolean;
|
|
17
|
+
enablePermissionsPolicy: boolean;
|
|
18
|
+
customCSP?: string;
|
|
19
|
+
hstsMaxAge?: number;
|
|
20
|
+
hstsIncludeSubdomains?: boolean;
|
|
21
|
+
hstsPreload?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare class SecurityHeadersMiddleware {
|
|
24
|
+
private config;
|
|
25
|
+
constructor(config?: Partial<SecurityHeadersConfig>);
|
|
26
|
+
/**
|
|
27
|
+
* Apply security headers to HTTP response
|
|
28
|
+
*/
|
|
29
|
+
applySecurityHeaders(response: any): void;
|
|
30
|
+
/**
|
|
31
|
+
* Express.js middleware function
|
|
32
|
+
*/
|
|
33
|
+
getExpressMiddleware(): (req: any, res: any, next: any) => void;
|
|
34
|
+
/**
|
|
35
|
+
* Fastify middleware function
|
|
36
|
+
*/
|
|
37
|
+
getFastifyMiddleware(): (request: any, reply: any, done: any) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Generic middleware for any HTTP framework
|
|
40
|
+
*/
|
|
41
|
+
getMiddleware(): (response: any) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Update configuration
|
|
44
|
+
*/
|
|
45
|
+
updateConfig(newConfig: Partial<SecurityHeadersConfig>): void;
|
|
46
|
+
/**
|
|
47
|
+
* Get current configuration
|
|
48
|
+
*/
|
|
49
|
+
getConfig(): SecurityHeadersConfig;
|
|
50
|
+
}
|
|
51
|
+
export declare const securityHeadersMiddleware: SecurityHeadersMiddleware;
|
|
52
|
+
//# sourceMappingURL=security-headers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security-headers.d.ts","sourceRoot":"","sources":["../../../src/security/security-headers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,wBAAwB,EAAE,OAAO,CAAC;IAClC,oBAAoB,EAAE,OAAO,CAAC;IAC9B,uBAAuB,EAAE,OAAO,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,qBAAa,yBAAyB;IACpC,OAAO,CAAC,MAAM,CAAwB;gBAE1B,MAAM,GAAE,OAAO,CAAC,qBAAqB,CAAM;IAgBvD;;OAEG;IACH,oBAAoB,CAAC,QAAQ,EAAE,GAAG,GAAG,IAAI;IA2DzC;;OAEG;IACH,oBAAoB,KACV,KAAK,GAAG,EAAE,KAAK,GAAG,EAAE,MAAM,GAAG;IAMvC;;OAEG;IACH,oBAAoB,KACV,SAAS,GAAG,EAAE,OAAO,GAAG,EAAE,MAAM,GAAG;IAM7C;;OAEG;IACH,aAAa,eAlFkB,GAAG,KAAG,IAAI;IAsFzC;;OAEG;IACH,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,qBAAqB,CAAC,GAAG,IAAI;IAI7D;;OAEG;IACH,SAAS,IAAI,qBAAqB;CAGnC;AAGD,eAAO,MAAM,yBAAyB,2BAAkC,CAAC"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StringRay Framework v1.0.0 - Security Headers Middleware
|
|
3
|
+
*
|
|
4
|
+
* Comprehensive security headers implementation for HTTP responses.
|
|
5
|
+
* Integrates with boot orchestrator and API endpoints.
|
|
6
|
+
*
|
|
7
|
+
* @version 1.0.0
|
|
8
|
+
* @since 2026-01-07
|
|
9
|
+
*/
|
|
10
|
+
export class SecurityHeadersMiddleware {
|
|
11
|
+
config;
|
|
12
|
+
constructor(config = {}) {
|
|
13
|
+
this.config = {
|
|
14
|
+
enableCSP: true,
|
|
15
|
+
enableHSTS: true,
|
|
16
|
+
enableFrameOptions: true,
|
|
17
|
+
enableXSSProtection: true,
|
|
18
|
+
enableContentTypeOptions: true,
|
|
19
|
+
enableReferrerPolicy: true,
|
|
20
|
+
enablePermissionsPolicy: true,
|
|
21
|
+
hstsMaxAge: 31536000, // 1 year
|
|
22
|
+
hstsIncludeSubdomains: true,
|
|
23
|
+
hstsPreload: false,
|
|
24
|
+
...config,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Apply security headers to HTTP response
|
|
29
|
+
*/
|
|
30
|
+
applySecurityHeaders(response) {
|
|
31
|
+
if (!response || typeof response.setHeader !== "function") {
|
|
32
|
+
console.warn("SecurityHeadersMiddleware: Invalid response object");
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const headers = {};
|
|
36
|
+
// Content Security Policy
|
|
37
|
+
if (this.config.enableCSP) {
|
|
38
|
+
headers["Content-Security-Policy"] =
|
|
39
|
+
this.config.customCSP ||
|
|
40
|
+
"default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self'";
|
|
41
|
+
}
|
|
42
|
+
// HTTP Strict Transport Security
|
|
43
|
+
if (this.config.enableHSTS) {
|
|
44
|
+
let hstsValue = `max-age=${this.config.hstsMaxAge}`;
|
|
45
|
+
if (this.config.hstsIncludeSubdomains) {
|
|
46
|
+
hstsValue += "; includeSubDomains";
|
|
47
|
+
}
|
|
48
|
+
if (this.config.hstsPreload) {
|
|
49
|
+
hstsValue += "; preload";
|
|
50
|
+
}
|
|
51
|
+
headers["Strict-Transport-Security"] = hstsValue;
|
|
52
|
+
}
|
|
53
|
+
// X-Frame-Options
|
|
54
|
+
if (this.config.enableFrameOptions) {
|
|
55
|
+
headers["X-Frame-Options"] = "DENY";
|
|
56
|
+
}
|
|
57
|
+
// X-XSS-Protection
|
|
58
|
+
if (this.config.enableXSSProtection) {
|
|
59
|
+
headers["X-XSS-Protection"] = "1; mode=block";
|
|
60
|
+
}
|
|
61
|
+
// X-Content-Type-Options
|
|
62
|
+
if (this.config.enableContentTypeOptions) {
|
|
63
|
+
headers["X-Content-Type-Options"] = "nosniff";
|
|
64
|
+
}
|
|
65
|
+
// Referrer-Policy
|
|
66
|
+
if (this.config.enableReferrerPolicy) {
|
|
67
|
+
headers["Referrer-Policy"] = "strict-origin-when-cross-origin";
|
|
68
|
+
}
|
|
69
|
+
// Permissions-Policy
|
|
70
|
+
if (this.config.enablePermissionsPolicy) {
|
|
71
|
+
headers["Permissions-Policy"] =
|
|
72
|
+
"geolocation=(), microphone=(), camera=()";
|
|
73
|
+
}
|
|
74
|
+
// Set headers on response
|
|
75
|
+
Object.entries(headers).forEach(([key, value]) => {
|
|
76
|
+
response.setHeader(key, value);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Express.js middleware function
|
|
81
|
+
*/
|
|
82
|
+
getExpressMiddleware() {
|
|
83
|
+
return (req, res, next) => {
|
|
84
|
+
this.applySecurityHeaders(res);
|
|
85
|
+
next();
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Fastify middleware function
|
|
90
|
+
*/
|
|
91
|
+
getFastifyMiddleware() {
|
|
92
|
+
return (request, reply, done) => {
|
|
93
|
+
this.applySecurityHeaders(reply);
|
|
94
|
+
done();
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Generic middleware for any HTTP framework
|
|
99
|
+
*/
|
|
100
|
+
getMiddleware() {
|
|
101
|
+
return this.applySecurityHeaders.bind(this);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Update configuration
|
|
105
|
+
*/
|
|
106
|
+
updateConfig(newConfig) {
|
|
107
|
+
this.config = { ...this.config, ...newConfig };
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Get current configuration
|
|
111
|
+
*/
|
|
112
|
+
getConfig() {
|
|
113
|
+
return { ...this.config };
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// Export singleton instance
|
|
117
|
+
export const securityHeadersMiddleware = new SecurityHeadersMiddleware();
|
|
118
|
+
//# sourceMappingURL=security-headers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security-headers.js","sourceRoot":"","sources":["../../../src/security/security-headers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAgBH,MAAM,OAAO,yBAAyB;IAC5B,MAAM,CAAwB;IAEtC,YAAY,SAAyC,EAAE;QACrD,IAAI,CAAC,MAAM,GAAG;YACZ,SAAS,EAAE,IAAI;YACf,UAAU,EAAE,IAAI;YAChB,kBAAkB,EAAE,IAAI;YACxB,mBAAmB,EAAE,IAAI;YACzB,wBAAwB,EAAE,IAAI;YAC9B,oBAAoB,EAAE,IAAI;YAC1B,uBAAuB,EAAE,IAAI;YAC7B,UAAU,EAAE,QAAQ,EAAE,SAAS;YAC/B,qBAAqB,EAAE,IAAI;YAC3B,WAAW,EAAE,KAAK;YAClB,GAAG,MAAM;SACV,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,oBAAoB,CAAC,QAAa;QAChC,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,CAAC,SAAS,KAAK,UAAU,EAAE,CAAC;YAC1D,OAAO,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAC;YACnE,OAAO;QACT,CAAC;QAED,MAAM,OAAO,GAA2B,EAAE,CAAC;QAE3C,0BAA0B;QAC1B,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,E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,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YAC/C,QAAQ,CAAC,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,oBAAoB;QAClB,OAAO,CAAC,GAAQ,EAAE,GAAQ,EAAE,IAAS,EAAE,EAAE;YACvC,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC;YAC/B,IAAI,EAAE,CAAC;QACT,CAAC,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,oBAAoB;QAClB,OAAO,CAAC,OAAY,EAAE,KAAU,EAAE,IAAS,EAAE,EAAE;YAC7C,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;YACjC,IAAI,EAAE,CAAC;QACT,CAAC,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,aAAa;QACX,OAAO,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,SAAyC;QACpD,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,SAAS,EAAE,CAAC;IACjD,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IAC5B,CAAC;CACF;AAED,4BAA4B;AAC5B,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,yBAAyB,EAAE,CAAC"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StringRay Framework v1.0.0 - Session Cleanup Manager
|
|
3
|
+
*
|
|
4
|
+
* Manages automatic cleanup of sessions with TTL-based expiration,
|
|
5
|
+
* idle session detection, and manual cleanup utilities.
|
|
6
|
+
*
|
|
7
|
+
* @version 1.0.0
|
|
8
|
+
* @since 2026-01-07
|
|
9
|
+
*/
|
|
10
|
+
import { StringRayStateManager } from "../state/state-manager";
|
|
11
|
+
import { SessionMonitor } from "./session-monitor";
|
|
12
|
+
export interface SessionMetadata {
|
|
13
|
+
sessionId: string;
|
|
14
|
+
createdAt: number;
|
|
15
|
+
lastActivity: number;
|
|
16
|
+
ttlMs: number;
|
|
17
|
+
isActive: boolean;
|
|
18
|
+
agentCount: number;
|
|
19
|
+
memoryUsage: number;
|
|
20
|
+
cleanupReason?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface CleanupConfig {
|
|
23
|
+
ttlMs: number;
|
|
24
|
+
idleTimeoutMs: number;
|
|
25
|
+
maxSessions: number;
|
|
26
|
+
cleanupIntervalMs: number;
|
|
27
|
+
enableAutoCleanup: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface CleanupResult {
|
|
30
|
+
sessionsCleaned: number;
|
|
31
|
+
sessionsExpired: number;
|
|
32
|
+
sessionsIdle: number;
|
|
33
|
+
errors: string[];
|
|
34
|
+
}
|
|
35
|
+
export declare class SessionCleanupManager {
|
|
36
|
+
private stateManager;
|
|
37
|
+
private config;
|
|
38
|
+
private cleanupInterval?;
|
|
39
|
+
private _sessionMetadata?;
|
|
40
|
+
private _metadataLoaded;
|
|
41
|
+
private sessionMonitor;
|
|
42
|
+
constructor(stateManager: StringRayStateManager, config?: Partial<CleanupConfig>, sessionMonitor?: SessionMonitor);
|
|
43
|
+
/**
|
|
44
|
+
* Lazy-loaded session metadata - loads from state manager on first access
|
|
45
|
+
*/
|
|
46
|
+
private get sessionMetadata();
|
|
47
|
+
private set sessionMetadata(value);
|
|
48
|
+
/**
|
|
49
|
+
* Initialize cleanup manager and start auto-cleanup if enabled
|
|
50
|
+
*/
|
|
51
|
+
private initialize;
|
|
52
|
+
/**
|
|
53
|
+
* Register a new session for cleanup tracking
|
|
54
|
+
*/
|
|
55
|
+
registerSession(sessionId: string, ttlMs?: number): void;
|
|
56
|
+
updateActivity(sessionId: string): void;
|
|
57
|
+
updateMetadata(sessionId: string, updates: Partial<SessionMetadata>): void;
|
|
58
|
+
/**
|
|
59
|
+
* Check if session should be cleaned up
|
|
60
|
+
*/
|
|
61
|
+
shouldCleanup(sessionId: string): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Perform cleanup of expired/idle sessions
|
|
64
|
+
*/
|
|
65
|
+
performCleanup(): Promise<CleanupResult>;
|
|
66
|
+
/**
|
|
67
|
+
* Manually cleanup a specific session
|
|
68
|
+
*/
|
|
69
|
+
manualCleanup(sessionId: string, reason?: string): Promise<boolean>;
|
|
70
|
+
/**
|
|
71
|
+
* Cleanup all sessions (emergency cleanup)
|
|
72
|
+
*/
|
|
73
|
+
emergencyCleanup(): Promise<CleanupResult>;
|
|
74
|
+
/**
|
|
75
|
+
* Get cleanup statistics
|
|
76
|
+
*/
|
|
77
|
+
getCleanupStats(): {
|
|
78
|
+
totalSessions: number;
|
|
79
|
+
activeSessions: number;
|
|
80
|
+
expiredSessions: number;
|
|
81
|
+
idleSessions: number;
|
|
82
|
+
nextCleanup: number;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Get session metadata
|
|
86
|
+
*/
|
|
87
|
+
getSessionMetadata(sessionId: string): SessionMetadata | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* List all sessions with metadata
|
|
90
|
+
*/
|
|
91
|
+
listSessions(): SessionMetadata[];
|
|
92
|
+
/**
|
|
93
|
+
* Start automatic cleanup interval
|
|
94
|
+
*/
|
|
95
|
+
private startAutoCleanup;
|
|
96
|
+
/**
|
|
97
|
+
* Stop automatic cleanup
|
|
98
|
+
*/
|
|
99
|
+
stopAutoCleanup(): void;
|
|
100
|
+
/**
|
|
101
|
+
* Load session metadata from state manager (lazy loading)
|
|
102
|
+
*/
|
|
103
|
+
private loadSessionMetadata;
|
|
104
|
+
/**
|
|
105
|
+
* Persist session metadata to state manager
|
|
106
|
+
*/
|
|
107
|
+
private persistSessionMetadata;
|
|
108
|
+
/**
|
|
109
|
+
* Cleanup a specific session
|
|
110
|
+
*/
|
|
111
|
+
private cleanupSession;
|
|
112
|
+
/**
|
|
113
|
+
* Shutdown cleanup manager
|
|
114
|
+
*/
|
|
115
|
+
shutdown(): void;
|
|
116
|
+
}
|
|
117
|
+
export declare const createSessionCleanupManager: (stateManager: StringRayStateManager, config?: Partial<CleanupConfig>, sessionMonitor?: SessionMonitor) => SessionCleanupManager;
|
|
118
|
+
//# sourceMappingURL=session-cleanup-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-cleanup-manager.d.ts","sourceRoot":"","sources":["../../../src/session/session-cleanup-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,aAAa;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,qBAAa,qBAAqB;IAChC,OAAO,CAAC,YAAY,CAAwB;IAC5C,OAAO,CAAC,MAAM,CAAgB;IA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