i18ntk 1.10.1 → 2.0.2

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 (110) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +141 -1185
  3. package/main/i18ntk-analyze.js +149 -133
  4. package/main/i18ntk-backup-class.js +420 -0
  5. package/main/i18ntk-backup.js +4 -4
  6. package/main/i18ntk-complete.js +90 -65
  7. package/main/i18ntk-doctor.js +123 -103
  8. package/main/i18ntk-fixer.js +61 -725
  9. package/main/i18ntk-go.js +14 -15
  10. package/main/i18ntk-init.js +76 -25
  11. package/main/i18ntk-java.js +27 -32
  12. package/main/i18ntk-js.js +70 -68
  13. package/main/i18ntk-manage.js +128 -29
  14. package/main/i18ntk-php.js +75 -75
  15. package/main/i18ntk-py.js +55 -56
  16. package/main/i18ntk-scanner.js +59 -57
  17. package/main/i18ntk-setup.js +10 -396
  18. package/main/i18ntk-sizing.js +46 -40
  19. package/main/i18ntk-summary.js +21 -18
  20. package/main/i18ntk-ui.js +11 -10
  21. package/main/i18ntk-usage.js +55 -19
  22. package/main/i18ntk-validate.js +13 -13
  23. package/main/manage/commands/AnalyzeCommand.js +1124 -0
  24. package/main/manage/commands/BackupCommand.js +62 -0
  25. package/main/manage/commands/CommandRouter.js +295 -0
  26. package/main/manage/commands/CompleteCommand.js +61 -0
  27. package/main/manage/commands/DoctorCommand.js +60 -0
  28. package/main/manage/commands/FixerCommand.js +624 -0
  29. package/main/manage/commands/InitCommand.js +62 -0
  30. package/main/manage/commands/ScannerCommand.js +654 -0
  31. package/main/manage/commands/SizingCommand.js +60 -0
  32. package/main/manage/commands/SummaryCommand.js +61 -0
  33. package/main/manage/commands/UsageCommand.js +60 -0
  34. package/main/manage/commands/ValidateCommand.js +978 -0
  35. package/main/manage/index-fixed.js +1447 -0
  36. package/main/manage/index.js +1462 -0
  37. package/main/manage/managers/DebugMenu.js +140 -0
  38. package/main/manage/managers/InteractiveMenu.js +177 -0
  39. package/main/manage/managers/LanguageMenu.js +62 -0
  40. package/main/manage/managers/SettingsMenu.js +53 -0
  41. package/main/manage/services/AuthenticationService.js +263 -0
  42. package/main/manage/services/ConfigurationService-fixed.js +449 -0
  43. package/main/manage/services/ConfigurationService.js +449 -0
  44. package/main/manage/services/FileManagementService.js +368 -0
  45. package/main/manage/services/FrameworkDetectionService.js +458 -0
  46. package/main/manage/services/InitService.js +1051 -0
  47. package/main/manage/services/SetupService.js +462 -0
  48. package/main/manage/services/SummaryService.js +450 -0
  49. package/main/manage/services/UsageService.js +1502 -0
  50. package/package.json +32 -30
  51. package/runtime/enhanced.d.ts +221 -221
  52. package/runtime/index.d.ts +29 -29
  53. package/runtime/index.full.d.ts +331 -331
  54. package/runtime/index.js +7 -6
  55. package/scripts/build-lite.js +17 -17
  56. package/scripts/deprecate-versions.js +23 -6
  57. package/scripts/export-translations.js +5 -5
  58. package/scripts/fix-all-i18n.js +3 -3
  59. package/scripts/fix-and-purify-i18n.js +3 -2
  60. package/scripts/fix-locale-control-chars.js +110 -0
  61. package/scripts/lint-locales.js +80 -0
  62. package/scripts/locale-optimizer.js +8 -8
  63. package/scripts/prepublish.js +21 -21
  64. package/scripts/security-check.js +13 -5
  65. package/scripts/sync-translations.js +4 -4
  66. package/scripts/sync-ui-locales.js +9 -8
  67. package/scripts/validate-all-translations.js +8 -7
  68. package/scripts/verify-deprecations.js +23 -15
  69. package/scripts/verify-translations.js +6 -5
  70. package/settings/i18ntk-config.json +282 -282
  71. package/settings/language-config.json +5 -5
  72. package/settings/settings-cli.js +9 -9
  73. package/settings/settings-manager.js +23 -20
  74. package/ui-locales/de.json +2417 -2348
  75. package/ui-locales/en.json +2415 -2352
  76. package/ui-locales/es.json +2425 -2353
  77. package/ui-locales/fr.json +2418 -2348
  78. package/ui-locales/ja.json +2463 -2361
  79. package/ui-locales/ru.json +2463 -2359
  80. package/ui-locales/zh.json +2418 -2351
  81. package/utils/admin-auth.js +2 -2
  82. package/utils/admin-cli.js +297 -297
  83. package/utils/admin-pin.js +9 -9
  84. package/utils/cli-helper.js +9 -9
  85. package/utils/config-helper.js +152 -103
  86. package/utils/config-manager.js +204 -164
  87. package/utils/config.js +5 -4
  88. package/utils/env-manager.js +256 -0
  89. package/utils/framework-detector.js +27 -24
  90. package/utils/i18n-helper.js +85 -41
  91. package/utils/init-helper.js +152 -94
  92. package/utils/json-output.js +98 -98
  93. package/utils/logger.js +6 -2
  94. package/utils/mini-commander.js +179 -0
  95. package/utils/missing-key-validator.js +5 -5
  96. package/utils/plugin-loader.js +29 -11
  97. package/utils/prompt.js +14 -44
  98. package/utils/safe-json.js +40 -0
  99. package/utils/secure-errors.js +3 -3
  100. package/utils/security-check-improved.js +390 -0
  101. package/utils/security-config.js +5 -5
  102. package/utils/security-fixed.js +607 -0
  103. package/utils/security.js +462 -248
  104. package/utils/setup-enforcer.js +136 -44
  105. package/utils/setup-validator.js +33 -32
  106. package/utils/terminal-icons.js +1 -1
  107. package/utils/ultra-performance-optimizer.js +11 -9
  108. package/utils/watch-locales.js +2 -1
  109. package/utils/prompt-fixed.js +0 -55
  110. package/utils/security-check.js +0 -450
@@ -1,450 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Security Check Utility
5
- * Runs automated security checks and provides recommendations
6
- */
7
-
8
- const fs = require('fs');
9
- const path = require('path');
10
-
11
- class SecurityChecker {
12
- constructor() {
13
- this.checks = [];
14
- this.recommendations = [];
15
- this.isSilent = this.shouldBeSilent();
16
- }
17
-
18
- /**
19
- * Check if we should suppress output (e.g., during npm install)
20
- */
21
- shouldBeSilent() {
22
- // Determine silent mode based on environment variables
23
- return (
24
- process.env.npm_config_loglevel === 'silent' ||
25
- process.env.I18NTK_SILENT === 'true' ||
26
- process.env.CI === 'true'
27
- );
28
- }
29
-
30
- /**
31
- * Log message only if not silent
32
- */
33
- log(message) {
34
- if (!this.isSilent) {
35
- console.log(message);
36
- }
37
- }
38
-
39
- /**
40
- * Run all security checks
41
- */
42
- async runSecurityChecks() {
43
- this.log('šŸ” Running security checks...\n');
44
-
45
- this.checkSensitiveFiles();
46
- this.checkConfigurationFiles();
47
- this.checkDependencies();
48
- this.checkEncryptionConfig();
49
- this.checkAccessPermissions();
50
-
51
- this.generateReport();
52
- }
53
-
54
- /**
55
- * Check for sensitive files that shouldn't be committed
56
- */
57
- checkSensitiveFiles() {
58
- const sensitivePatterns = [
59
- '.env',
60
- '*.key',
61
- '*.pem',
62
- 'admin-pin.json',
63
- 'config.json',
64
- 'secrets.json'
65
- ];
66
-
67
- const gitignorePath = '.gitignore';
68
- let gitignoreContent = '';
69
-
70
- if (fs.existsSync(gitignorePath)) {
71
- gitignoreContent = fs.readFileSync(gitignorePath, 'utf8');
72
- }
73
-
74
- const issues = [];
75
- sensitivePatterns.forEach(pattern => {
76
- const files = this.findFiles(pattern);
77
- files.forEach(file => {
78
- if (!gitignoreContent.includes(file)) {
79
- issues.push(file);
80
- }
81
- });
82
- });
83
-
84
- this.checks.push({
85
- name: 'Sensitive Files Protection',
86
- status: issues.length === 0 ? 'PASS' : 'WARN',
87
- issues: issues,
88
- message: issues.length > 0 ? `${issues.length} sensitive files not in .gitignore` : 'All sensitive files protected'
89
- });
90
- }
91
-
92
- /**
93
- * Check configuration files
94
- */
95
- checkConfigurationFiles() {
96
- const configFiles = ['i18ntk-config.json', 'config.json'];
97
- const hasConfigFile = configFiles.some(file => fs.existsSync(file));
98
-
99
- this.checks.push({
100
- name: 'Configuration Files',
101
- status: hasConfigFile ? 'PASS' : 'WARN',
102
- message: hasConfigFile ? 'Configuration files configured' : 'Consider creating i18ntk-config.json'
103
- });
104
-
105
- // Check for default PINs in config
106
- const defaultPinFiles = ['i18ntk-config.json', 'config.json'];
107
- defaultPinFiles.forEach(file => {
108
- if (fs.existsSync(file)) {
109
- try {
110
- const config = JSON.parse(fs.readFileSync(file, 'utf8'));
111
- if (config.adminPin && ['1234', '0000', 'admin', 'password'].includes(config.adminPin)) {
112
- this.checks.push({
113
- name: 'Default PIN Check',
114
- status: 'FAIL',
115
- message: `Default PIN detected in ${file}: ${config.adminPin}`
116
- });
117
- }
118
- } catch (error) {
119
- // Ignore parse errors
120
- }
121
- }
122
- });
123
- }
124
-
125
- /**
126
- * Check dependencies for vulnerabilities
127
- */
128
- checkDependencies() {
129
- try {
130
- // Check if package-lock.json exists and analyze dependencies safely
131
- const packageLockPath = 'package-lock.json';
132
- const packagePath = 'package.json';
133
-
134
- let hasVulnerabilities = false;
135
- let criticalCount = 0;
136
- let highCount = 0;
137
- let moderateCount = 0;
138
-
139
- if (fs.existsSync(packageLockPath)) {
140
- try {
141
- const packageLock = JSON.parse(fs.readFileSync(packageLockPath, 'utf8'));
142
- const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
143
-
144
- // Check for outdated dependencies by comparing versions
145
- const dependencies = { ...packageJson.dependencies, ...packageJson.devDependencies };
146
-
147
- // Simple heuristic: check if any dependencies are significantly outdated
148
- // This is a safe alternative to npm audit
149
- const outdatedPackages = this.checkOutdatedPackages(dependencies, packageLock);
150
-
151
- // Set conservative counts based on outdated packages
152
- criticalCount = outdatedPackages.filter(p => p.severity === 'critical').length;
153
- highCount = outdatedPackages.filter(p => p.severity === 'high').length;
154
- moderateCount = outdatedPackages.filter(p => p.severity === 'moderate').length;
155
-
156
- } catch (parseError) {
157
- // Handle JSON parsing errors
158
- hasVulnerabilities = true;
159
- }
160
- } else {
161
- // No package-lock.json, suggest running npm install
162
- hasVulnerabilities = true;
163
- }
164
-
165
- let status = 'PASS';
166
- if (criticalCount > 0) status = 'FAIL';
167
- else if (highCount > 0) status = 'WARN';
168
- else if (moderateCount > 5) status = 'WARN';
169
-
170
- this.checks.push({
171
- name: 'Dependency Vulnerabilities',
172
- status: status,
173
- message: `Critical: ${criticalCount}, High: ${highCount}, Moderate: ${moderateCount}`,
174
- details: { critical: criticalCount, high: highCount, moderate: moderateCount }
175
- });
176
-
177
- } catch (error) {
178
- this.checks.push({
179
- name: 'Dependency Vulnerabilities',
180
- status: 'WARN',
181
- message: 'Unable to analyze dependencies - run npm audit manually'
182
- });
183
- }
184
- }
185
-
186
- /**
187
- * Check encryption configuration
188
- */
189
- checkEncryptionConfig() {
190
- const adminPinPath = 'admin-pin.json';
191
-
192
- if (fs.existsSync(adminPinPath)) {
193
- try {
194
- const pinData = JSON.parse(fs.readFileSync(adminPinPath, 'utf8'));
195
-
196
- // Check for old encryption methods
197
- if (pinData.hash && pinData.hash.length === 64) {
198
- // SHA256 hash - old method
199
- this.checks.push({
200
- name: 'Encryption Method',
201
- status: 'WARN',
202
- message: 'Old SHA256 hashing detected - consider upgrading to scrypt'
203
- });
204
- }
205
-
206
- // Check for secure algorithm
207
- if (pinData.algorithm && ['scrypt', 'pbkdf2'].includes(pinData.algorithm)) {
208
- this.checks.push({
209
- name: 'Hashing Algorithm',
210
- status: 'PASS',
211
- message: `Using secure hashing: ${pinData.algorithm}`
212
- });
213
- }
214
-
215
- } catch (error) {
216
- this.checks.push({
217
- name: 'Encryption Configuration',
218
- status: 'WARN',
219
- message: 'Unable to read PIN configuration'
220
- });
221
- }
222
- } else {
223
- this.checks.push({
224
- name: 'Encryption Configuration',
225
- status: 'INFO',
226
- message: 'No PIN configuration found - will be created on first admin setup'
227
- });
228
- }
229
- }
230
-
231
- /**
232
- * Check file permissions
233
- */
234
- checkAccessPermissions() {
235
- const sensitiveFiles = ['admin-pin.json', 'config.json', 'i18ntk-config.json'];
236
-
237
- sensitiveFiles.forEach(file => {
238
- if (fs.existsSync(file)) {
239
- try {
240
- const stats = fs.statSync(file);
241
- const mode = stats.mode & parseInt('777', 8);
242
-
243
- if (mode > parseInt('600', 8)) {
244
- this.checks.push({
245
- name: `File Permissions (${file})`,
246
- status: 'WARN',
247
- message: `File permissions are ${mode.toString(8)} - consider 600 or stricter`
248
- });
249
- } else {
250
- this.checks.push({
251
- name: `File Permissions (${file})`,
252
- status: 'PASS',
253
- message: 'File permissions are secure'
254
- });
255
- }
256
- } catch (error) {
257
- // Ignore permission errors
258
- }
259
- }
260
- });
261
- }
262
-
263
- /**
264
- * Find files matching pattern
265
- */
266
- findFiles(pattern) {
267
- try {
268
- return this.findFilesRecursively('.', pattern);
269
- } catch (error) {
270
- return [];
271
- }
272
- }
273
-
274
- /**
275
- * Recursively find files matching pattern (safe alternative to find command)
276
- */
277
- findFilesRecursively(dir, pattern) {
278
- const results = [];
279
-
280
- try {
281
- const items = fs.readdirSync(dir, { withFileTypes: true });
282
-
283
- items.forEach(item => {
284
- const fullPath = path.join(dir, item.name);
285
-
286
- if (item.isDirectory()) {
287
- // Skip node_modules and hidden directories
288
- if (item.name !== 'node_modules' && !item.name.startsWith('.')) {
289
- results.push(...this.findFilesRecursively(fullPath, pattern));
290
- }
291
- } else if (item.isFile()) {
292
- // Simple pattern matching
293
- const regex = new RegExp(pattern.replace(/\*/g, '.*').replace(/\?/g, '.'));
294
- if (regex.test(item.name)) {
295
- results.push(fullPath);
296
- }
297
- }
298
- });
299
- } catch (error) {
300
- // Ignore permission errors
301
- }
302
-
303
- return results;
304
- }
305
-
306
- /**
307
- * Check for outdated packages (safe alternative to npm audit)
308
- */
309
- checkOutdatedPackages(dependencies, packageLock) {
310
- const outdated = [];
311
-
312
- if (!packageLock.packages) return outdated;
313
-
314
- Object.keys(dependencies || {}).forEach(depName => {
315
- const requiredVersion = dependencies[depName];
316
- const installed = packageLock.packages[`node_modules/${depName}`];
317
-
318
- if (installed && installed.version) {
319
- // Simple heuristic: if version doesn't match exactly, flag as outdated
320
- if (!this.versionMatches(requiredVersion, installed.version)) {
321
- outdated.push({
322
- name: depName,
323
- required: requiredVersion,
324
- installed: installed.version,
325
- severity: this.determineSeverity(depName, installed.version)
326
- });
327
- }
328
- }
329
- });
330
-
331
- return outdated;
332
- }
333
-
334
- /**
335
- * Check if version matches requirement (simplified)
336
- */
337
- versionMatches(required, installed) {
338
- // Simplified version check - exact match for now
339
- return installed.startsWith(required.replace(/[^\d.]/g, ''));
340
- }
341
-
342
- /**
343
- * Determine severity based on package name (heuristic)
344
- */
345
- determineSeverity(packageName, version) {
346
- // High-risk packages that should be updated
347
- const highRisk = ['lodash', 'moment', 'request', 'axios', 'express', 'react'];
348
- if (highRisk.includes(packageName)) return 'high';
349
-
350
- // Critical packages with known vulnerabilities
351
- const criticalRisk = ['lodash', 'moment', 'handlebars', 'validator'];
352
- if (criticalRisk.includes(packageName) && version.startsWith('1.')) return 'critical';
353
-
354
- return 'moderate';
355
- }
356
-
357
- /**
358
- * Generate security report
359
- */
360
- generateReport() {
361
- if (this.isSilent) {
362
- // In silent mode, just exit without showing any output
363
- const summary = {
364
- PASS: 0,
365
- WARN: 0,
366
- FAIL: 0,
367
- INFO: 0
368
- };
369
-
370
- this.checks.forEach(check => {
371
- summary[check.status]++;
372
- });
373
-
374
- // Still exit with appropriate code for CI/CD
375
- if (summary.FAIL > 0) {
376
- process.exit(1);
377
- } else {
378
- process.exit(0);
379
- }
380
- return;
381
- }
382
-
383
- this.log('\nšŸ“Š Security Check Report\n');
384
-
385
- const summary = {
386
- PASS: 0,
387
- WARN: 0,
388
- FAIL: 0,
389
- INFO: 0
390
- };
391
-
392
- this.checks.forEach(check => {
393
- summary[check.status]++;
394
- const icon = {
395
- PASS: 'āœ…',
396
- WARN: 'āš ļø',
397
- FAIL: 'āŒ',
398
- INFO: 'ā„¹ļø'
399
- }[check.status];
400
-
401
- this.log(`${icon} ${check.name}: ${check.message}`);
402
- if (check.issues) {
403
- check.issues.forEach(issue => this.log(` - ${issue}`));
404
- }
405
- });
406
-
407
- this.log('\nšŸ“ˆ Summary:');
408
- this.log(`āœ… PASS: ${summary.PASS}`);
409
- this.log(`āš ļø WARN: ${summary.WARN}`);
410
- this.log(`āŒ FAIL: ${summary.FAIL}`);
411
- this.log(`ā„¹ļø INFO: ${summary.INFO}`);
412
-
413
- // Provide recommendations
414
- this.log('\nšŸ”§ Recommendations:');
415
-
416
- if (summary.FAIL > 0) {
417
- this.log('🚨 Critical issues found - address immediately:');
418
- this.log(' - Run: npm audit fix');
419
- this.log(' - Review and update default passwords');
420
- this.log(' - Check .gitignore for sensitive files');
421
- }
422
-
423
- if (summary.WARN > 0) {
424
- this.log('āš ļø Warnings to address:');
425
- this.log(' - Review file permissions');
426
- this.log(' - Update dependencies');
427
- this.log(' - Create .env.example if missing');
428
- }
429
-
430
- this.log('\nšŸ“š For more information, see:');
431
- this.log(' - SECURITY.md - Complete security guide');
432
- this.log(' - npm run security:config - Generate secure configuration');
433
- this.log(' - npm run security:audit - Run vulnerability scan');
434
-
435
- // Exit with appropriate code
436
- if (summary.FAIL > 0) {
437
- process.exit(1);
438
- } else if (summary.WARN > 0) {
439
- process.exit(0); // Warnings don't fail the build
440
- }
441
- }
442
- }
443
-
444
- // Run security checks if called directly
445
- if (require.main === module) {
446
- const checker = new SecurityChecker();
447
- checker.runSecurityChecks().catch(console.error);
448
- }
449
-
450
- module.exports = SecurityChecker;