@tamyla/clodo-framework 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.
Files changed (130) hide show
  1. package/CHANGELOG.md +564 -0
  2. package/LICENSE +21 -0
  3. package/README.md +1393 -0
  4. package/bin/README.md +71 -0
  5. package/bin/clodo-service.js +416 -0
  6. package/bin/security/security-cli.js +96 -0
  7. package/bin/service-management/README.md +74 -0
  8. package/bin/service-management/create-service.js +129 -0
  9. package/bin/service-management/init-service.js +102 -0
  10. package/bin/service-management/init-service.js.backup +889 -0
  11. package/bin/shared/config/customer-cli.js +293 -0
  12. package/dist/config/ConfigurationManager.js +159 -0
  13. package/dist/config/CustomerConfigCLI.js +220 -0
  14. package/dist/config/FeatureManager.js +426 -0
  15. package/dist/config/customers.js +441 -0
  16. package/dist/config/domains.js +180 -0
  17. package/dist/config/features.js +225 -0
  18. package/dist/config/index.js +6 -0
  19. package/dist/database/database-orchestrator.js +730 -0
  20. package/dist/database/index.js +4 -0
  21. package/dist/deployment/auditor.js +971 -0
  22. package/dist/deployment/index.js +10 -0
  23. package/dist/deployment/rollback-manager.js +523 -0
  24. package/dist/deployment/testers/api-tester.js +80 -0
  25. package/dist/deployment/testers/auth-tester.js +129 -0
  26. package/dist/deployment/testers/core.js +217 -0
  27. package/dist/deployment/testers/database-tester.js +105 -0
  28. package/dist/deployment/testers/index.js +74 -0
  29. package/dist/deployment/testers/load-tester.js +120 -0
  30. package/dist/deployment/testers/performance-tester.js +105 -0
  31. package/dist/deployment/validator.js +558 -0
  32. package/dist/deployment/wrangler-deployer.js +574 -0
  33. package/dist/handlers/GenericRouteHandler.js +532 -0
  34. package/dist/index.js +39 -0
  35. package/dist/migration/MigrationAdapters.js +562 -0
  36. package/dist/modules/ModuleManager.js +668 -0
  37. package/dist/modules/security.js +98 -0
  38. package/dist/orchestration/cross-domain-coordinator.js +1083 -0
  39. package/dist/orchestration/index.js +5 -0
  40. package/dist/orchestration/modules/DeploymentCoordinator.js +258 -0
  41. package/dist/orchestration/modules/DomainResolver.js +196 -0
  42. package/dist/orchestration/modules/StateManager.js +332 -0
  43. package/dist/orchestration/multi-domain-orchestrator.js +255 -0
  44. package/dist/routing/EnhancedRouter.js +158 -0
  45. package/dist/schema/SchemaManager.js +778 -0
  46. package/dist/security/ConfigurationValidator.js +490 -0
  47. package/dist/security/DeploymentManager.js +208 -0
  48. package/dist/security/SecretGenerator.js +142 -0
  49. package/dist/security/SecurityCLI.js +228 -0
  50. package/dist/security/index.js +51 -0
  51. package/dist/security/patterns/environment-rules.js +66 -0
  52. package/dist/security/patterns/insecure-patterns.js +21 -0
  53. package/dist/service-management/ConfirmationEngine.js +411 -0
  54. package/dist/service-management/ErrorTracker.js +294 -0
  55. package/dist/service-management/GenerationEngine.js +3109 -0
  56. package/dist/service-management/InputCollector.js +237 -0
  57. package/dist/service-management/ServiceCreator.js +229 -0
  58. package/dist/service-management/ServiceInitializer.js +448 -0
  59. package/dist/service-management/ServiceOrchestrator.js +638 -0
  60. package/dist/service-management/handlers/ConfigMutator.js +130 -0
  61. package/dist/service-management/handlers/ConfirmationHandler.js +71 -0
  62. package/dist/service-management/handlers/GenerationHandler.js +80 -0
  63. package/dist/service-management/handlers/InputHandler.js +59 -0
  64. package/dist/service-management/handlers/ValidationHandler.js +203 -0
  65. package/dist/service-management/index.js +7 -0
  66. package/dist/services/GenericDataService.js +488 -0
  67. package/dist/shared/cloudflare/domain-discovery.js +562 -0
  68. package/dist/shared/cloudflare/domain-manager.js +912 -0
  69. package/dist/shared/cloudflare/index.js +8 -0
  70. package/dist/shared/cloudflare/ops.js +387 -0
  71. package/dist/shared/config/cache.js +1167 -0
  72. package/dist/shared/config/command-config-manager.js +174 -0
  73. package/dist/shared/config/customer-cli.js +258 -0
  74. package/dist/shared/config/index.js +9 -0
  75. package/dist/shared/config/manager.js +289 -0
  76. package/dist/shared/database/connection-manager.js +338 -0
  77. package/dist/shared/database/index.js +7 -0
  78. package/dist/shared/database/orchestrator.js +632 -0
  79. package/dist/shared/deployment/auditor.js +971 -0
  80. package/dist/shared/deployment/index.js +10 -0
  81. package/dist/shared/deployment/rollback-manager.js +523 -0
  82. package/dist/shared/deployment/validator.js +558 -0
  83. package/dist/shared/index.js +32 -0
  84. package/dist/shared/monitoring/health-checker.js +250 -0
  85. package/dist/shared/monitoring/index.js +8 -0
  86. package/dist/shared/monitoring/memory-manager.js +382 -0
  87. package/dist/shared/monitoring/production-monitor.js +390 -0
  88. package/dist/shared/production-tester/api-tester.js +80 -0
  89. package/dist/shared/production-tester/auth-tester.js +129 -0
  90. package/dist/shared/production-tester/core.js +217 -0
  91. package/dist/shared/production-tester/database-tester.js +105 -0
  92. package/dist/shared/production-tester/index.js +74 -0
  93. package/dist/shared/production-tester/load-tester.js +120 -0
  94. package/dist/shared/production-tester/performance-tester.js +105 -0
  95. package/dist/shared/security/api-token-manager.js +296 -0
  96. package/dist/shared/security/index.js +8 -0
  97. package/dist/shared/security/secret-generator.js +918 -0
  98. package/dist/shared/security/secure-token-manager.js +379 -0
  99. package/dist/shared/utils/error-recovery.js +240 -0
  100. package/dist/shared/utils/graceful-shutdown-manager.js +380 -0
  101. package/dist/shared/utils/index.js +9 -0
  102. package/dist/shared/utils/interactive-prompts.js +134 -0
  103. package/dist/shared/utils/rate-limiter.js +249 -0
  104. package/dist/utils/ErrorHandler.js +173 -0
  105. package/dist/utils/deployment/config-cache.js +1160 -0
  106. package/dist/utils/deployment/index.js +6 -0
  107. package/dist/utils/deployment/interactive-prompts.js +97 -0
  108. package/dist/utils/deployment/secret-generator.js +896 -0
  109. package/dist/utils/dirname-helper.js +35 -0
  110. package/dist/utils/domain-config.js +159 -0
  111. package/dist/utils/error-recovery.js +240 -0
  112. package/dist/utils/esm-helper.js +52 -0
  113. package/dist/utils/framework-config.js +481 -0
  114. package/dist/utils/graceful-shutdown-manager.js +379 -0
  115. package/dist/utils/health-checker.js +114 -0
  116. package/dist/utils/index.js +36 -0
  117. package/dist/utils/prompt-handler.js +98 -0
  118. package/dist/utils/usage-tracker.js +252 -0
  119. package/dist/utils/validation.js +112 -0
  120. package/dist/version/VersionDetector.js +723 -0
  121. package/dist/worker/index.js +4 -0
  122. package/dist/worker/integration.js +332 -0
  123. package/docs/FRAMEWORK-ARCHITECTURE-OVERVIEW.md +206 -0
  124. package/docs/INTEGRATION_GUIDE.md +2045 -0
  125. package/docs/README.md +82 -0
  126. package/docs/SECURITY.md +242 -0
  127. package/docs/deployment/deployment-guide.md +540 -0
  128. package/docs/overview.md +280 -0
  129. package/package.json +176 -0
  130. package/types/index.d.ts +575 -0
@@ -0,0 +1,142 @@
1
+ import crypto from 'crypto';
2
+
3
+ /**
4
+ * Secret Generator for Secure Key Management
5
+ * Provides cryptographically secure key generation utilities
6
+ */
7
+ export class SecretGenerator {
8
+ /**
9
+ * Generate a cryptographically secure API key
10
+ * @param {number} length - Length of the key in bytes (default: 32)
11
+ * @param {string} prefix - Optional prefix for the key
12
+ * @returns {string} Secure API key
13
+ */
14
+ static generateSecureApiKey(length = 32, prefix = '') {
15
+ const bytes = crypto.randomBytes(length);
16
+ const key = bytes.toString('hex');
17
+ if (prefix) {
18
+ return `${prefix}_${key}`;
19
+ }
20
+ return key;
21
+ }
22
+
23
+ /**
24
+ * Generate a cryptographically secure JWT secret
25
+ * @param {number} length - Length of the secret in bytes (default: 64)
26
+ * @returns {string} Secure JWT secret
27
+ */
28
+ static generateSecureJwtSecret(length = 64) {
29
+ const bytes = crypto.randomBytes(length);
30
+ return bytes.toString('hex');
31
+ }
32
+
33
+ /**
34
+ * Generate a secure key with specific service prefix
35
+ * @param {string} serviceName - Name of the service
36
+ * @param {string} environment - Environment (prod, staging, dev)
37
+ * @param {number} length - Length of the key in bytes
38
+ * @returns {string} Service-specific secure key
39
+ */
40
+ static generateServiceKey(serviceName, environment = 'prod', length = 32) {
41
+ const prefix = `${serviceName}_${environment}`;
42
+ return this.generateSecureApiKey(length, prefix);
43
+ }
44
+
45
+ /**
46
+ * Generate multiple keys at once
47
+ * @param {Array} keySpecs - Array of key specifications
48
+ * @returns {Object} Object with generated keys
49
+ */
50
+ static generateMultipleKeys(keySpecs) {
51
+ const keys = {};
52
+ for (const spec of keySpecs) {
53
+ const {
54
+ name,
55
+ type = 'api',
56
+ length,
57
+ prefix
58
+ } = spec;
59
+ if (type === 'jwt') {
60
+ keys[name] = this.generateSecureJwtSecret(length);
61
+ } else {
62
+ keys[name] = this.generateSecureApiKey(length, prefix);
63
+ }
64
+ }
65
+ return keys;
66
+ }
67
+
68
+ /**
69
+ * Validate key strength
70
+ * @param {string} key - Key to validate
71
+ * @param {Object} requirements - Strength requirements
72
+ * @returns {Object} Validation result
73
+ */
74
+ static validateKeyStrength(key, requirements = {}) {
75
+ const {
76
+ minLength = 32,
77
+ requireHex = true,
78
+ minEntropy = 3.0
79
+ } = requirements;
80
+ const result = {
81
+ valid: true,
82
+ issues: []
83
+ };
84
+
85
+ // Check length
86
+ if (key.length < minLength) {
87
+ result.valid = false;
88
+ result.issues.push(`Key too short: ${key.length} < ${minLength}`);
89
+ }
90
+
91
+ // Check if hex format is required
92
+ if (requireHex && !/^[a-f0-9]+$/i.test(key)) {
93
+ result.valid = false;
94
+ result.issues.push('Key must be hexadecimal format');
95
+ }
96
+
97
+ // Check entropy
98
+ const entropy = this.calculateEntropy(key);
99
+ if (entropy < minEntropy) {
100
+ result.valid = false;
101
+ result.issues.push(`Low entropy: ${entropy.toFixed(2)} < ${minEntropy}`);
102
+ }
103
+ return result;
104
+ }
105
+
106
+ /**
107
+ * Calculate Shannon entropy of a string
108
+ * @param {string} str - String to analyze
109
+ * @returns {number} Entropy value
110
+ */
111
+ static calculateEntropy(str) {
112
+ const charCounts = {};
113
+ for (const char of str) {
114
+ charCounts[char] = (charCounts[char] || 0) + 1;
115
+ }
116
+ let entropy = 0;
117
+ const len = str.length;
118
+ for (const count of Object.values(charCounts)) {
119
+ const p = count / len;
120
+ entropy -= p * Math.log2(p);
121
+ }
122
+ return entropy;
123
+ }
124
+
125
+ /**
126
+ * Generate a key with timestamp for rotation tracking
127
+ * @param {string} prefix - Key prefix
128
+ * @param {number} length - Key length
129
+ * @returns {Object} Key with metadata
130
+ */
131
+ static generateKeyWithMetadata(prefix = '', length = 32) {
132
+ const key = this.generateSecureApiKey(length, prefix);
133
+ const timestamp = new Date().toISOString();
134
+ return {
135
+ key,
136
+ generatedAt: timestamp,
137
+ length,
138
+ entropy: this.calculateEntropy(key),
139
+ algorithm: 'crypto.randomBytes'
140
+ };
141
+ }
142
+ }
@@ -0,0 +1,228 @@
1
+ /**
2
+ * Clodo Framework - Security CLI
3
+ * Programmatic API for security operations
4
+ */
5
+
6
+ import { ConfigurationValidator } from '../security/ConfigurationValidator.js';
7
+ import { SecretGenerator } from '../security/SecretGenerator.js';
8
+ import { DeploymentManager } from '../security/DeploymentManager.js';
9
+ export class SecurityCLI {
10
+ constructor() {
11
+ // Initialize with default settings
12
+ }
13
+
14
+ /**
15
+ * Validate configuration security for a customer and environment
16
+ * @param {string} customer - Customer name
17
+ * @param {string} environment - Environment name
18
+ * @returns {Object} Validation result
19
+ */
20
+ async validateConfiguration(customer, environment) {
21
+ try {
22
+ if (!customer || !environment) {
23
+ throw new Error('Customer and environment are required');
24
+ }
25
+ const result = ConfigurationValidator.validateConfiguration(customer, environment);
26
+ return {
27
+ success: result.valid,
28
+ customer,
29
+ environment,
30
+ valid: result.valid,
31
+ securityIssues: result.securityIssues || [],
32
+ message: result.valid ? 'Security validation passed' : 'Security issues found'
33
+ };
34
+ } catch (error) {
35
+ return {
36
+ success: false,
37
+ customer,
38
+ environment,
39
+ error: error.message
40
+ };
41
+ }
42
+ }
43
+
44
+ /**
45
+ * Generate a secure key
46
+ * @param {string} type - Key type ('api', 'jwt', or custom prefix)
47
+ * @param {number} length - Key length (optional)
48
+ * @returns {Object} Key generation result
49
+ */
50
+ generateKey(type = 'api', length) {
51
+ try {
52
+ let key;
53
+ let keyType;
54
+ if (type === 'jwt') {
55
+ key = SecretGenerator.generateSecureJwtSecret(length);
56
+ keyType = 'JWT secret';
57
+ } else {
58
+ const prefix = type && type !== 'api' ? type : '';
59
+ key = SecretGenerator.generateSecureApiKey(length || 32, prefix);
60
+ keyType = 'API key';
61
+ }
62
+ return {
63
+ success: true,
64
+ type: keyType,
65
+ key,
66
+ length: key.length
67
+ };
68
+ } catch (error) {
69
+ return {
70
+ success: false,
71
+ type,
72
+ error: error.message
73
+ };
74
+ }
75
+ }
76
+
77
+ /**
78
+ * Deploy with security validation
79
+ * @param {string} customer - Customer name
80
+ * @param {string} environment - Environment name
81
+ * @param {Object} options - Deployment options
82
+ * @param {boolean} options.dryRun - Perform dry run (default: false)
83
+ * @returns {Object} Deployment result
84
+ */
85
+ async deployWithSecurity(customer, environment, options = {}) {
86
+ try {
87
+ if (!customer || !environment) {
88
+ throw new Error('Customer and environment are required');
89
+ }
90
+ const result = await DeploymentManager.deployWithSecurity({
91
+ customer,
92
+ environment,
93
+ dryRun: options.dryRun || false
94
+ });
95
+ return {
96
+ success: true,
97
+ customer,
98
+ environment,
99
+ dryRun: options.dryRun,
100
+ deployed: !options.dryRun,
101
+ result
102
+ };
103
+ } catch (error) {
104
+ return {
105
+ success: false,
106
+ customer,
107
+ environment,
108
+ error: error.message
109
+ };
110
+ }
111
+ }
112
+
113
+ /**
114
+ * Generate secure configuration
115
+ * @param {string} customer - Customer name
116
+ * @param {string} environment - Environment name
117
+ * @returns {Object} Configuration generation result
118
+ */
119
+ generateSecureConfig(customer, environment) {
120
+ try {
121
+ if (!customer || !environment) {
122
+ throw new Error('Customer and environment are required');
123
+ }
124
+ const config = DeploymentManager.generateSecureConfig(customer, environment);
125
+ return {
126
+ success: true,
127
+ customer,
128
+ environment,
129
+ config
130
+ };
131
+ } catch (error) {
132
+ return {
133
+ success: false,
134
+ customer,
135
+ environment,
136
+ error: error.message
137
+ };
138
+ }
139
+ }
140
+
141
+ /**
142
+ * Check deployment readiness
143
+ * @param {string} customer - Customer name
144
+ * @param {string} environment - Environment name
145
+ * @returns {Object} Readiness check result
146
+ */
147
+ checkDeploymentReadiness(customer, environment) {
148
+ try {
149
+ if (!customer || !environment) {
150
+ throw new Error('Customer and environment are required');
151
+ }
152
+ const result = DeploymentManager.validateDeploymentReadiness(customer, environment);
153
+ return {
154
+ success: true,
155
+ customer,
156
+ environment,
157
+ ready: result.ready,
158
+ issues: result.issues || []
159
+ };
160
+ } catch (error) {
161
+ return {
162
+ success: false,
163
+ customer,
164
+ environment,
165
+ ready: false,
166
+ error: error.message
167
+ };
168
+ }
169
+ }
170
+
171
+ /**
172
+ * Get available commands
173
+ * @returns {string[]} Array of available commands
174
+ */
175
+ getAvailableCommands() {
176
+ return ['validate', 'generate-key', 'deploy', 'generate-config', 'check-readiness'];
177
+ }
178
+
179
+ /**
180
+ * Get command help
181
+ * @param {string} command - Command name (optional)
182
+ * @returns {string} Help text
183
+ */
184
+ getHelp(command) {
185
+ const help = {
186
+ validate: 'validate <customer> <environment> - Validate configuration security',
187
+ 'generate-key': 'generate-key [type] [length] - Generate secure key (api/jwt)',
188
+ deploy: 'deploy <customer> <environment> - Deploy with security validation',
189
+ 'generate-config': 'generate-config <customer> <environment> - Generate secure configuration',
190
+ 'check-readiness': 'check-readiness <customer> <environment> - Check deployment readiness'
191
+ };
192
+ if (command && help[command]) {
193
+ return help[command];
194
+ }
195
+ return `Clodo Framework Security CLI
196
+
197
+ Commands:
198
+ ${Object.values(help).map(cmd => ` ${cmd}`).join('\n')}
199
+
200
+ Examples:
201
+ validate tamyla production
202
+ generate-key jwt 64
203
+ generate-key content-skimmer
204
+ deploy tamyla staging --dry-run`;
205
+ }
206
+ }
207
+
208
+ // Convenience functions for direct use
209
+ export async function validateSecurity(customer, environment) {
210
+ const cli = new SecurityCLI();
211
+ return await cli.validateConfiguration(customer, environment);
212
+ }
213
+ export function generateSecureKey(type = 'api', length) {
214
+ const cli = new SecurityCLI();
215
+ return cli.generateKey(type, length);
216
+ }
217
+ export async function deployWithSecurity(customer, environment, options = {}) {
218
+ const cli = new SecurityCLI();
219
+ return await cli.deployWithSecurity(customer, environment, options);
220
+ }
221
+ export function generateSecureConfig(customer, environment) {
222
+ const cli = new SecurityCLI();
223
+ return cli.generateSecureConfig(customer, environment);
224
+ }
225
+ export function checkDeploymentReadiness(customer, environment) {
226
+ const cli = new SecurityCLI();
227
+ return cli.checkDeploymentReadiness(customer, environment);
228
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Clodo Framework Security Module
3
+ * Comprehensive security validation and management for Clodo services
4
+ */
5
+
6
+ import { ConfigurationValidator } from './ConfigurationValidator.js';
7
+ import { DeploymentManager } from './DeploymentManager.js';
8
+ import { SecretGenerator } from './SecretGenerator.js';
9
+ import { ErrorHandler } from '../utils/ErrorHandler.js';
10
+ import { InteractiveDeploymentConfigurator } from '../config/ConfigurationManager.js';
11
+ export { ConfigurationValidator } from './ConfigurationValidator.js';
12
+ export { DeploymentManager } from './DeploymentManager.js';
13
+ export { SecretGenerator } from './SecretGenerator.js';
14
+ export { ErrorHandler } from '../utils/ErrorHandler.js';
15
+ export { InteractiveDeploymentConfigurator } from '../config/ConfigurationManager.js';
16
+
17
+ // Re-export patterns and rules for advanced usage
18
+ export { INSECURE_PATTERNS } from './patterns/insecure-patterns.js';
19
+ export { ENVIRONMENT_REQUIREMENTS, getEnvironmentRequirements } from './patterns/environment-rules.js';
20
+
21
+ // Main security validation function for easy access
22
+ export function validateSecurity(config, environment = 'production') {
23
+ return ConfigurationValidator.validate(config, environment);
24
+ }
25
+
26
+ // Main secure deployment function
27
+ export async function deployWithSecurity(options) {
28
+ return DeploymentManager.deployWithSecurity(options);
29
+ }
30
+
31
+ // Main key generation function
32
+ export function generateSecureKey(type = 'api', options = {}) {
33
+ const {
34
+ length = 32,
35
+ prefix = ''
36
+ } = options;
37
+ if (type === 'jwt') {
38
+ return SecretGenerator.generateSecureJwtSecret(length);
39
+ }
40
+ return SecretGenerator.generateSecureApiKey(length, prefix);
41
+ }
42
+
43
+ // Main error handling function
44
+ export function handleDeploymentError(error, context = {}) {
45
+ return ErrorHandler.handleDeploymentError(error, context);
46
+ }
47
+
48
+ // Main configuration function
49
+ export async function generateConfiguration(defaults = {}) {
50
+ return InteractiveDeploymentConfigurator.generateFromUserInput(defaults);
51
+ }
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Environment-Specific Security Rules
3
+ * Defines security requirements for different deployment environments
4
+ */
5
+
6
+ export const ENVIRONMENT_REQUIREMENTS = {
7
+ production: {
8
+ minSecretLength: 32,
9
+ requireHttps: true,
10
+ allowDummyKeys: false,
11
+ requireStrongJWT: true,
12
+ allowLocalhostUrls: false,
13
+ minKeyEntropy: 4.0,
14
+ // bits of entropy per character
15
+ requireComplexPasswords: true,
16
+ maxDummyKeyTolerance: 0
17
+ },
18
+ staging: {
19
+ minSecretLength: 24,
20
+ requireHttps: true,
21
+ allowDummyKeys: false,
22
+ requireStrongJWT: true,
23
+ allowLocalhostUrls: false,
24
+ minKeyEntropy: 3.5,
25
+ requireComplexPasswords: true,
26
+ maxDummyKeyTolerance: 0
27
+ },
28
+ development: {
29
+ minSecretLength: 16,
30
+ requireHttps: false,
31
+ allowDummyKeys: true,
32
+ requireStrongJWT: false,
33
+ allowLocalhostUrls: true,
34
+ minKeyEntropy: 2.0,
35
+ requireComplexPasswords: false,
36
+ maxDummyKeyTolerance: 5 // Allow some dummy keys for development
37
+ },
38
+ testing: {
39
+ minSecretLength: 8,
40
+ requireHttps: false,
41
+ allowDummyKeys: true,
42
+ requireStrongJWT: false,
43
+ allowLocalhostUrls: true,
44
+ minKeyEntropy: 1.0,
45
+ requireComplexPasswords: false,
46
+ maxDummyKeyTolerance: 10
47
+ }
48
+ };
49
+
50
+ /**
51
+ * Get environment requirements with fallback to production
52
+ * @param {string} environment - Environment name
53
+ * @returns {Object} Environment security requirements
54
+ */
55
+ export function getEnvironmentRequirements(environment) {
56
+ return ENVIRONMENT_REQUIREMENTS[environment] || ENVIRONMENT_REQUIREMENTS.production;
57
+ }
58
+
59
+ /**
60
+ * Validate environment name
61
+ * @param {string} environment - Environment to validate
62
+ * @returns {boolean} True if environment is valid
63
+ */
64
+ export function isValidEnvironment(environment) {
65
+ return Object.keys(ENVIRONMENT_REQUIREMENTS).includes(environment);
66
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Insecure Patterns Database
3
+ * Known patterns that indicate security vulnerabilities
4
+ */
5
+
6
+ export const INSECURE_PATTERNS = {
7
+ // Development/dummy API keys
8
+ DUMMY_API_KEYS: ['content-skimmer-dev-key', 'logger-service-dev-key', 'auth-service-dev-key', 'test-key', 'dev-key', 'dummy-key', 'placeholder-key', 'example-key', 'sample-key', 'demo-key', 'test-api-key-*', 'dummy-*-key', 'dev-*-secret', 'placeholder-*', 'example-*-token', 'fake-*-credential', 'mock-*-password'],
9
+ // Weak secrets (common insecure values)
10
+ WEAK_SECRETS: ['secret', 'password', '123456', 'admin', 'test', 'changeme', 'default', 'password123', 'admin123', 'root', 'guest'],
11
+ // Development URLs that shouldn't be in production
12
+ DEV_URLS: ['localhost', '127.0.0.1', '0.0.0.0', 'dev.', 'test.', 'staging.', 'local.'],
13
+ // Insecure JWT secrets (too short or common)
14
+ WEAK_JWT_PATTERNS: [/^.{1,31}$/,
15
+ // Less than 32 characters
16
+ /^(secret|jwt|token|key|password)/i, /^[a-zA-Z0-9]{1,20}$/,
17
+ // Simple alphanumeric short strings
18
+ /^(password|secret|token|key|jwt|auth)$/i],
19
+ // Common insecure password patterns
20
+ COMMON_PASSWORDS: ['password', 'password123', 'admin', 'admin123', 'root', 'root123', 'guest', 'user', 'test', 'demo', '123456', '123456789', 'qwerty', 'abc123', 'letmein', 'welcome', 'monkey', 'dragon', 'passw0rd', 'p@ssword']
21
+ };