secure-scan 1.2.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.
- package/README.md +564 -0
- package/dist/ai/aiAnalyzer.d.ts +99 -0
- package/dist/ai/aiAnalyzer.d.ts.map +1 -0
- package/dist/ai/aiAnalyzer.js +669 -0
- package/dist/ai/aiAnalyzer.js.map +1 -0
- package/dist/ai/index.d.ts +5 -0
- package/dist/ai/index.d.ts.map +1 -0
- package/dist/ai/index.js +21 -0
- package/dist/ai/index.js.map +1 -0
- package/dist/analyzers/base/baseAnalyzer.d.ts +44 -0
- package/dist/analyzers/base/baseAnalyzer.d.ts.map +1 -0
- package/dist/analyzers/base/baseAnalyzer.js +53 -0
- package/dist/analyzers/base/baseAnalyzer.js.map +1 -0
- package/dist/analyzers/base/index.d.ts +5 -0
- package/dist/analyzers/base/index.d.ts.map +1 -0
- package/dist/analyzers/base/index.js +21 -0
- package/dist/analyzers/base/index.js.map +1 -0
- package/dist/analyzers/c-cpp/cppAnalyzer.d.ts +60 -0
- package/dist/analyzers/c-cpp/cppAnalyzer.d.ts.map +1 -0
- package/dist/analyzers/c-cpp/cppAnalyzer.js +218 -0
- package/dist/analyzers/c-cpp/cppAnalyzer.js.map +1 -0
- package/dist/analyzers/c-cpp/index.d.ts +5 -0
- package/dist/analyzers/c-cpp/index.d.ts.map +1 -0
- package/dist/analyzers/c-cpp/index.js +21 -0
- package/dist/analyzers/c-cpp/index.js.map +1 -0
- package/dist/analyzers/core/engine/index.d.ts +5 -0
- package/dist/analyzers/core/engine/index.d.ts.map +1 -0
- package/dist/analyzers/core/engine/index.js +21 -0
- package/dist/analyzers/core/engine/index.js.map +1 -0
- package/dist/analyzers/core/engine/ruleEngine.d.ts +46 -0
- package/dist/analyzers/core/engine/ruleEngine.d.ts.map +1 -0
- package/dist/analyzers/core/engine/ruleEngine.js +173 -0
- package/dist/analyzers/core/engine/ruleEngine.js.map +1 -0
- package/dist/analyzers/core/index.d.ts +8 -0
- package/dist/analyzers/core/index.d.ts.map +1 -0
- package/dist/analyzers/core/index.js +24 -0
- package/dist/analyzers/core/index.js.map +1 -0
- package/dist/analyzers/core/scanner/fileScanner.d.ts +31 -0
- package/dist/analyzers/core/scanner/fileScanner.d.ts.map +1 -0
- package/dist/analyzers/core/scanner/fileScanner.js +199 -0
- package/dist/analyzers/core/scanner/fileScanner.js.map +1 -0
- package/dist/analyzers/core/scanner/index.d.ts +5 -0
- package/dist/analyzers/core/scanner/index.d.ts.map +1 -0
- package/dist/analyzers/core/scanner/index.js +21 -0
- package/dist/analyzers/core/scanner/index.js.map +1 -0
- package/dist/analyzers/core/scoring/index.d.ts +5 -0
- package/dist/analyzers/core/scoring/index.d.ts.map +1 -0
- package/dist/analyzers/core/scoring/index.js +21 -0
- package/dist/analyzers/core/scoring/index.js.map +1 -0
- package/dist/analyzers/core/scoring/riskScoring.d.ts +49 -0
- package/dist/analyzers/core/scoring/riskScoring.d.ts.map +1 -0
- package/dist/analyzers/core/scoring/riskScoring.js +180 -0
- package/dist/analyzers/core/scoring/riskScoring.js.map +1 -0
- package/dist/analyzers/core/securityScanner.d.ts +47 -0
- package/dist/analyzers/core/securityScanner.d.ts.map +1 -0
- package/dist/analyzers/core/securityScanner.js +298 -0
- package/dist/analyzers/core/securityScanner.js.map +1 -0
- package/dist/analyzers/csharp/csharpAnalyzer.d.ts +64 -0
- package/dist/analyzers/csharp/csharpAnalyzer.d.ts.map +1 -0
- package/dist/analyzers/csharp/csharpAnalyzer.js +232 -0
- package/dist/analyzers/csharp/csharpAnalyzer.js.map +1 -0
- package/dist/analyzers/csharp/index.d.ts +5 -0
- package/dist/analyzers/csharp/index.d.ts.map +1 -0
- package/dist/analyzers/csharp/index.js +21 -0
- package/dist/analyzers/csharp/index.js.map +1 -0
- package/dist/analyzers/iac/iacAnalyzer.d.ts +36 -0
- package/dist/analyzers/iac/iacAnalyzer.d.ts.map +1 -0
- package/dist/analyzers/iac/iacAnalyzer.js +182 -0
- package/dist/analyzers/iac/iacAnalyzer.js.map +1 -0
- package/dist/analyzers/iac/index.d.ts +5 -0
- package/dist/analyzers/iac/index.d.ts.map +1 -0
- package/dist/analyzers/iac/index.js +21 -0
- package/dist/analyzers/iac/index.js.map +1 -0
- package/dist/analyzers/index.d.ts +30 -0
- package/dist/analyzers/index.d.ts.map +1 -0
- package/dist/analyzers/index.js +80 -0
- package/dist/analyzers/index.js.map +1 -0
- package/dist/analyzers/java/index.d.ts +5 -0
- package/dist/analyzers/java/index.d.ts.map +1 -0
- package/dist/analyzers/java/index.js +21 -0
- package/dist/analyzers/java/index.js.map +1 -0
- package/dist/analyzers/java/javaAnalyzer.d.ts +64 -0
- package/dist/analyzers/java/javaAnalyzer.d.ts.map +1 -0
- package/dist/analyzers/java/javaAnalyzer.js +224 -0
- package/dist/analyzers/java/javaAnalyzer.js.map +1 -0
- package/dist/analyzers/javascript/astUtils.d.ts +170 -0
- package/dist/analyzers/javascript/astUtils.d.ts.map +1 -0
- package/dist/analyzers/javascript/astUtils.js +700 -0
- package/dist/analyzers/javascript/astUtils.js.map +1 -0
- package/dist/analyzers/javascript/index.d.ts +18 -0
- package/dist/analyzers/javascript/index.d.ts.map +1 -0
- package/dist/analyzers/javascript/index.js +50 -0
- package/dist/analyzers/javascript/index.js.map +1 -0
- package/dist/analyzers/javascript/javascriptAnalyzer.d.ts +111 -0
- package/dist/analyzers/javascript/javascriptAnalyzer.d.ts.map +1 -0
- package/dist/analyzers/javascript/javascriptAnalyzer.js +860 -0
- package/dist/analyzers/javascript/javascriptAnalyzer.js.map +1 -0
- package/dist/analyzers/javascript/malwareDetector.d.ts +102 -0
- package/dist/analyzers/javascript/malwareDetector.d.ts.map +1 -0
- package/dist/analyzers/javascript/malwareDetector.js +616 -0
- package/dist/analyzers/javascript/malwareDetector.js.map +1 -0
- package/dist/analyzers/javascript/packageJsonAnalyzer.d.ts +87 -0
- package/dist/analyzers/javascript/packageJsonAnalyzer.d.ts.map +1 -0
- package/dist/analyzers/javascript/packageJsonAnalyzer.js +553 -0
- package/dist/analyzers/javascript/packageJsonAnalyzer.js.map +1 -0
- package/dist/analyzers/javascript/taintAnalyzer.d.ts +120 -0
- package/dist/analyzers/javascript/taintAnalyzer.d.ts.map +1 -0
- package/dist/analyzers/javascript/taintAnalyzer.js +526 -0
- package/dist/analyzers/javascript/taintAnalyzer.js.map +1 -0
- package/dist/analyzers/php/index.d.ts +5 -0
- package/dist/analyzers/php/index.d.ts.map +1 -0
- package/dist/analyzers/php/index.js +21 -0
- package/dist/analyzers/php/index.js.map +1 -0
- package/dist/analyzers/php/phpAnalyzer.d.ts +56 -0
- package/dist/analyzers/php/phpAnalyzer.d.ts.map +1 -0
- package/dist/analyzers/php/phpAnalyzer.js +202 -0
- package/dist/analyzers/php/phpAnalyzer.js.map +1 -0
- package/dist/analyzers/python/index.d.ts +5 -0
- package/dist/analyzers/python/index.d.ts.map +1 -0
- package/dist/analyzers/python/index.js +21 -0
- package/dist/analyzers/python/index.js.map +1 -0
- package/dist/analyzers/python/pythonAnalyzer.d.ts +64 -0
- package/dist/analyzers/python/pythonAnalyzer.d.ts.map +1 -0
- package/dist/analyzers/python/pythonAnalyzer.js +226 -0
- package/dist/analyzers/python/pythonAnalyzer.js.map +1 -0
- package/dist/cli/index.d.ts +7 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +281 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/core/engine/index.d.ts +5 -0
- package/dist/core/engine/index.d.ts.map +1 -0
- package/dist/core/engine/index.js +21 -0
- package/dist/core/engine/index.js.map +1 -0
- package/dist/core/engine/ruleEngine.d.ts +46 -0
- package/dist/core/engine/ruleEngine.d.ts.map +1 -0
- package/dist/core/engine/ruleEngine.js +173 -0
- package/dist/core/engine/ruleEngine.js.map +1 -0
- package/dist/core/index.d.ts +8 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +24 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/scanner/fileScanner.d.ts +31 -0
- package/dist/core/scanner/fileScanner.d.ts.map +1 -0
- package/dist/core/scanner/fileScanner.js +199 -0
- package/dist/core/scanner/fileScanner.js.map +1 -0
- package/dist/core/scanner/index.d.ts +5 -0
- package/dist/core/scanner/index.d.ts.map +1 -0
- package/dist/core/scanner/index.js +21 -0
- package/dist/core/scanner/index.js.map +1 -0
- package/dist/core/scoring/index.d.ts +5 -0
- package/dist/core/scoring/index.d.ts.map +1 -0
- package/dist/core/scoring/index.js +21 -0
- package/dist/core/scoring/index.js.map +1 -0
- package/dist/core/scoring/riskScoring.d.ts +49 -0
- package/dist/core/scoring/riskScoring.d.ts.map +1 -0
- package/dist/core/scoring/riskScoring.js +180 -0
- package/dist/core/scoring/riskScoring.js.map +1 -0
- package/dist/core/securityScanner.d.ts +47 -0
- package/dist/core/securityScanner.d.ts.map +1 -0
- package/dist/core/securityScanner.js +298 -0
- package/dist/core/securityScanner.js.map +1 -0
- package/dist/dependencies/aiDependencyAnalyzer.d.ts +96 -0
- package/dist/dependencies/aiDependencyAnalyzer.d.ts.map +1 -0
- package/dist/dependencies/aiDependencyAnalyzer.js +435 -0
- package/dist/dependencies/aiDependencyAnalyzer.js.map +1 -0
- package/dist/dependencies/database/cveDatabase.d.ts +32 -0
- package/dist/dependencies/database/cveDatabase.d.ts.map +1 -0
- package/dist/dependencies/database/cveDatabase.js +393 -0
- package/dist/dependencies/database/cveDatabase.js.map +1 -0
- package/dist/dependencies/database/index.d.ts +6 -0
- package/dist/dependencies/database/index.d.ts.map +1 -0
- package/dist/dependencies/database/index.js +22 -0
- package/dist/dependencies/database/index.js.map +1 -0
- package/dist/dependencies/database/maliciousPackages.d.ts +43 -0
- package/dist/dependencies/database/maliciousPackages.d.ts.map +1 -0
- package/dist/dependencies/database/maliciousPackages.js +279 -0
- package/dist/dependencies/database/maliciousPackages.js.map +1 -0
- package/dist/dependencies/dependencyAnalyzer.d.ts +74 -0
- package/dist/dependencies/dependencyAnalyzer.d.ts.map +1 -0
- package/dist/dependencies/dependencyAnalyzer.js +349 -0
- package/dist/dependencies/dependencyAnalyzer.js.map +1 -0
- package/dist/dependencies/detectors/index.d.ts +7 -0
- package/dist/dependencies/detectors/index.d.ts.map +1 -0
- package/dist/dependencies/detectors/index.js +28 -0
- package/dist/dependencies/detectors/index.js.map +1 -0
- package/dist/dependencies/detectors/securityStandards.d.ts +15 -0
- package/dist/dependencies/detectors/securityStandards.d.ts.map +1 -0
- package/dist/dependencies/detectors/securityStandards.js +178 -0
- package/dist/dependencies/detectors/securityStandards.js.map +1 -0
- package/dist/dependencies/detectors/vulnerabilityDetector.d.ts +53 -0
- package/dist/dependencies/detectors/vulnerabilityDetector.d.ts.map +1 -0
- package/dist/dependencies/detectors/vulnerabilityDetector.js +289 -0
- package/dist/dependencies/detectors/vulnerabilityDetector.js.map +1 -0
- package/dist/dependencies/index.d.ts +14 -0
- package/dist/dependencies/index.d.ts.map +1 -0
- package/dist/dependencies/index.js +43 -0
- package/dist/dependencies/index.js.map +1 -0
- package/dist/dependencies/installed/index.d.ts +8 -0
- package/dist/dependencies/installed/index.d.ts.map +1 -0
- package/dist/dependencies/installed/index.js +24 -0
- package/dist/dependencies/installed/index.js.map +1 -0
- package/dist/dependencies/installed/installedScanner.d.ts +91 -0
- package/dist/dependencies/installed/installedScanner.d.ts.map +1 -0
- package/dist/dependencies/installed/installedScanner.js +766 -0
- package/dist/dependencies/installed/installedScanner.js.map +1 -0
- package/dist/dependencies/installed/malwarePatterns.d.ts +32 -0
- package/dist/dependencies/installed/malwarePatterns.d.ts.map +1 -0
- package/dist/dependencies/installed/malwarePatterns.js +480 -0
- package/dist/dependencies/installed/malwarePatterns.js.map +1 -0
- package/dist/dependencies/installed/types.d.ts +274 -0
- package/dist/dependencies/installed/types.d.ts.map +1 -0
- package/dist/dependencies/installed/types.js +7 -0
- package/dist/dependencies/installed/types.js.map +1 -0
- package/dist/dependencies/parsers/base/baseParser.d.ts +44 -0
- package/dist/dependencies/parsers/base/baseParser.d.ts.map +1 -0
- package/dist/dependencies/parsers/base/baseParser.js +80 -0
- package/dist/dependencies/parsers/base/baseParser.js.map +1 -0
- package/dist/dependencies/parsers/base/index.d.ts +6 -0
- package/dist/dependencies/parsers/base/index.d.ts.map +1 -0
- package/dist/dependencies/parsers/base/index.js +27 -0
- package/dist/dependencies/parsers/base/index.js.map +1 -0
- package/dist/dependencies/parsers/cpp/cppParser.d.ts +36 -0
- package/dist/dependencies/parsers/cpp/cppParser.d.ts.map +1 -0
- package/dist/dependencies/parsers/cpp/cppParser.js +196 -0
- package/dist/dependencies/parsers/cpp/cppParser.js.map +1 -0
- package/dist/dependencies/parsers/cpp/index.d.ts +6 -0
- package/dist/dependencies/parsers/cpp/index.d.ts.map +1 -0
- package/dist/dependencies/parsers/cpp/index.js +27 -0
- package/dist/dependencies/parsers/cpp/index.js.map +1 -0
- package/dist/dependencies/parsers/csharp/csharpParser.d.ts +32 -0
- package/dist/dependencies/parsers/csharp/csharpParser.d.ts.map +1 -0
- package/dist/dependencies/parsers/csharp/csharpParser.js +125 -0
- package/dist/dependencies/parsers/csharp/csharpParser.js.map +1 -0
- package/dist/dependencies/parsers/csharp/index.d.ts +6 -0
- package/dist/dependencies/parsers/csharp/index.d.ts.map +1 -0
- package/dist/dependencies/parsers/csharp/index.js +27 -0
- package/dist/dependencies/parsers/csharp/index.js.map +1 -0
- package/dist/dependencies/parsers/index.d.ts +24 -0
- package/dist/dependencies/parsers/index.d.ts.map +1 -0
- package/dist/dependencies/parsers/index.js +69 -0
- package/dist/dependencies/parsers/index.js.map +1 -0
- package/dist/dependencies/parsers/java/index.d.ts +6 -0
- package/dist/dependencies/parsers/java/index.d.ts.map +1 -0
- package/dist/dependencies/parsers/java/index.js +27 -0
- package/dist/dependencies/parsers/java/index.js.map +1 -0
- package/dist/dependencies/parsers/java/javaParser.d.ts +32 -0
- package/dist/dependencies/parsers/java/javaParser.d.ts.map +1 -0
- package/dist/dependencies/parsers/java/javaParser.js +168 -0
- package/dist/dependencies/parsers/java/javaParser.js.map +1 -0
- package/dist/dependencies/parsers/javascript/index.d.ts +6 -0
- package/dist/dependencies/parsers/javascript/index.d.ts.map +1 -0
- package/dist/dependencies/parsers/javascript/index.js +27 -0
- package/dist/dependencies/parsers/javascript/index.js.map +1 -0
- package/dist/dependencies/parsers/javascript/javascriptParser.d.ts +55 -0
- package/dist/dependencies/parsers/javascript/javascriptParser.d.ts.map +1 -0
- package/dist/dependencies/parsers/javascript/javascriptParser.js +266 -0
- package/dist/dependencies/parsers/javascript/javascriptParser.js.map +1 -0
- package/dist/dependencies/parsers/php/index.d.ts +6 -0
- package/dist/dependencies/parsers/php/index.d.ts.map +1 -0
- package/dist/dependencies/parsers/php/index.js +27 -0
- package/dist/dependencies/parsers/php/index.js.map +1 -0
- package/dist/dependencies/parsers/php/phpParser.d.ts +35 -0
- package/dist/dependencies/parsers/php/phpParser.d.ts.map +1 -0
- package/dist/dependencies/parsers/php/phpParser.js +162 -0
- package/dist/dependencies/parsers/php/phpParser.js.map +1 -0
- package/dist/dependencies/parsers/python/index.d.ts +6 -0
- package/dist/dependencies/parsers/python/index.d.ts.map +1 -0
- package/dist/dependencies/parsers/python/index.js +27 -0
- package/dist/dependencies/parsers/python/index.js.map +1 -0
- package/dist/dependencies/parsers/python/pythonParser.d.ts +60 -0
- package/dist/dependencies/parsers/python/pythonParser.d.ts.map +1 -0
- package/dist/dependencies/parsers/python/pythonParser.js +336 -0
- package/dist/dependencies/parsers/python/pythonParser.js.map +1 -0
- package/dist/dependencies/types.d.ts +280 -0
- package/dist/dependencies/types.d.ts.map +1 -0
- package/dist/dependencies/types.js +59 -0
- package/dist/dependencies/types.js.map +1 -0
- package/dist/i18n/index.d.ts +2 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +18 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/translations.d.ts +55 -0
- package/dist/i18n/translations.d.ts.map +1 -0
- package/dist/i18n/translations.js +119 -0
- package/dist/i18n/translations.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/reports/dependencyReportGenerator.d.ts +20 -0
- package/dist/reports/dependencyReportGenerator.d.ts.map +1 -0
- package/dist/reports/dependencyReportGenerator.js +690 -0
- package/dist/reports/dependencyReportGenerator.js.map +1 -0
- package/dist/reports/htmlReportGenerator.d.ts +43 -0
- package/dist/reports/htmlReportGenerator.d.ts.map +1 -0
- package/dist/reports/htmlReportGenerator.js +793 -0
- package/dist/reports/htmlReportGenerator.js.map +1 -0
- package/dist/reports/index.d.ts +7 -0
- package/dist/reports/index.d.ts.map +1 -0
- package/dist/reports/index.js +23 -0
- package/dist/reports/index.js.map +1 -0
- package/dist/reports/installedDepsReportGenerator.d.ts +14 -0
- package/dist/reports/installedDepsReportGenerator.d.ts.map +1 -0
- package/dist/reports/installedDepsReportGenerator.js +872 -0
- package/dist/reports/installedDepsReportGenerator.js.map +1 -0
- package/dist/rules/index.d.ts +31 -0
- package/dist/rules/index.d.ts.map +1 -0
- package/dist/rules/index.js +95 -0
- package/dist/rules/index.js.map +1 -0
- package/dist/rules/malware/categories/backdoors.d.ts +12 -0
- package/dist/rules/malware/categories/backdoors.d.ts.map +1 -0
- package/dist/rules/malware/categories/backdoors.js +163 -0
- package/dist/rules/malware/categories/backdoors.js.map +1 -0
- package/dist/rules/malware/categories/cryptominers.d.ts +13 -0
- package/dist/rules/malware/categories/cryptominers.d.ts.map +1 -0
- package/dist/rules/malware/categories/cryptominers.js +415 -0
- package/dist/rules/malware/categories/cryptominers.js.map +1 -0
- package/dist/rules/malware/categories/exfiltration.d.ts +20 -0
- package/dist/rules/malware/categories/exfiltration.d.ts.map +1 -0
- package/dist/rules/malware/categories/exfiltration.js +658 -0
- package/dist/rules/malware/categories/exfiltration.js.map +1 -0
- package/dist/rules/malware/categories/keyloggers.d.ts +19 -0
- package/dist/rules/malware/categories/keyloggers.d.ts.map +1 -0
- package/dist/rules/malware/categories/keyloggers.js +763 -0
- package/dist/rules/malware/categories/keyloggers.js.map +1 -0
- package/dist/rules/malware/categories/loaders.d.ts +20 -0
- package/dist/rules/malware/categories/loaders.d.ts.map +1 -0
- package/dist/rules/malware/categories/loaders.js +702 -0
- package/dist/rules/malware/categories/loaders.js.map +1 -0
- package/dist/rules/malware/categories/network.d.ts +19 -0
- package/dist/rules/malware/categories/network.d.ts.map +1 -0
- package/dist/rules/malware/categories/network.js +622 -0
- package/dist/rules/malware/categories/network.js.map +1 -0
- package/dist/rules/malware/categories/obfuscation.d.ts +22 -0
- package/dist/rules/malware/categories/obfuscation.d.ts.map +1 -0
- package/dist/rules/malware/categories/obfuscation.js +766 -0
- package/dist/rules/malware/categories/obfuscation.js.map +1 -0
- package/dist/rules/malware/constants/index.d.ts +281 -0
- package/dist/rules/malware/constants/index.d.ts.map +1 -0
- package/dist/rules/malware/constants/index.js +327 -0
- package/dist/rules/malware/constants/index.js.map +1 -0
- package/dist/rules/malware/engine/index.d.ts +178 -0
- package/dist/rules/malware/engine/index.d.ts.map +1 -0
- package/dist/rules/malware/engine/index.js +552 -0
- package/dist/rules/malware/engine/index.js.map +1 -0
- package/dist/rules/malware/index.d.ts +205 -0
- package/dist/rules/malware/index.d.ts.map +1 -0
- package/dist/rules/malware/index.js +837 -0
- package/dist/rules/malware/index.js.map +1 -0
- package/dist/rules/malware/scoring/index.d.ts +84 -0
- package/dist/rules/malware/scoring/index.d.ts.map +1 -0
- package/dist/rules/malware/scoring/index.js +441 -0
- package/dist/rules/malware/scoring/index.js.map +1 -0
- package/dist/rules/malware/types/index.d.ts +616 -0
- package/dist/rules/malware/types/index.d.ts.map +1 -0
- package/dist/rules/malware/types/index.js +155 -0
- package/dist/rules/malware/types/index.js.map +1 -0
- package/dist/rules/malware/utils/index.d.ts +117 -0
- package/dist/rules/malware/utils/index.d.ts.map +1 -0
- package/dist/rules/malware/utils/index.js +514 -0
- package/dist/rules/malware/utils/index.js.map +1 -0
- package/dist/rules/standards.d.ts +26 -0
- package/dist/rules/standards.d.ts.map +1 -0
- package/dist/rules/standards.js +352 -0
- package/dist/rules/standards.js.map +1 -0
- package/dist/rules/vulnerabilities/constants/index.d.ts +835 -0
- package/dist/rules/vulnerabilities/constants/index.d.ts.map +1 -0
- package/dist/rules/vulnerabilities/constants/index.js +544 -0
- package/dist/rules/vulnerabilities/constants/index.js.map +1 -0
- package/dist/rules/vulnerabilities/engine/index.d.ts +145 -0
- package/dist/rules/vulnerabilities/engine/index.d.ts.map +1 -0
- package/dist/rules/vulnerabilities/engine/index.js +581 -0
- package/dist/rules/vulnerabilities/engine/index.js.map +1 -0
- package/dist/rules/vulnerabilities/index.d.ts +148 -0
- package/dist/rules/vulnerabilities/index.d.ts.map +1 -0
- package/dist/rules/vulnerabilities/index.js +252 -0
- package/dist/rules/vulnerabilities/index.js.map +1 -0
- package/dist/rules/vulnerabilities/rules/authentication.d.ts +8 -0
- package/dist/rules/vulnerabilities/rules/authentication.d.ts.map +1 -0
- package/dist/rules/vulnerabilities/rules/authentication.js +419 -0
- package/dist/rules/vulnerabilities/rules/authentication.js.map +1 -0
- package/dist/rules/vulnerabilities/rules/commandInjection.d.ts +8 -0
- package/dist/rules/vulnerabilities/rules/commandInjection.d.ts.map +1 -0
- package/dist/rules/vulnerabilities/rules/commandInjection.js +300 -0
- package/dist/rules/vulnerabilities/rules/commandInjection.js.map +1 -0
- package/dist/rules/vulnerabilities/rules/csrf.d.ts +8 -0
- package/dist/rules/vulnerabilities/rules/csrf.d.ts.map +1 -0
- package/dist/rules/vulnerabilities/rules/csrf.js +261 -0
- package/dist/rules/vulnerabilities/rules/csrf.js.map +1 -0
- package/dist/rules/vulnerabilities/rules/deserialization.d.ts +8 -0
- package/dist/rules/vulnerabilities/rules/deserialization.d.ts.map +1 -0
- package/dist/rules/vulnerabilities/rules/deserialization.js +336 -0
- package/dist/rules/vulnerabilities/rules/deserialization.js.map +1 -0
- package/dist/rules/vulnerabilities/rules/fileUpload.d.ts +8 -0
- package/dist/rules/vulnerabilities/rules/fileUpload.d.ts.map +1 -0
- package/dist/rules/vulnerabilities/rules/fileUpload.js +325 -0
- package/dist/rules/vulnerabilities/rules/fileUpload.js.map +1 -0
- package/dist/rules/vulnerabilities/rules/hardcodedSecrets.d.ts +8 -0
- package/dist/rules/vulnerabilities/rules/hardcodedSecrets.d.ts.map +1 -0
- package/dist/rules/vulnerabilities/rules/hardcodedSecrets.js +446 -0
- package/dist/rules/vulnerabilities/rules/hardcodedSecrets.js.map +1 -0
- package/dist/rules/vulnerabilities/rules/index.d.ts +17 -0
- package/dist/rules/vulnerabilities/rules/index.d.ts.map +1 -0
- package/dist/rules/vulnerabilities/rules/index.js +47 -0
- package/dist/rules/vulnerabilities/rules/index.js.map +1 -0
- package/dist/rules/vulnerabilities/rules/pathTraversal.d.ts +8 -0
- package/dist/rules/vulnerabilities/rules/pathTraversal.d.ts.map +1 -0
- package/dist/rules/vulnerabilities/rules/pathTraversal.js +351 -0
- package/dist/rules/vulnerabilities/rules/pathTraversal.js.map +1 -0
- package/dist/rules/vulnerabilities/rules/prototypePollution.d.ts +8 -0
- package/dist/rules/vulnerabilities/rules/prototypePollution.d.ts.map +1 -0
- package/dist/rules/vulnerabilities/rules/prototypePollution.js +272 -0
- package/dist/rules/vulnerabilities/rules/prototypePollution.js.map +1 -0
- package/dist/rules/vulnerabilities/rules/securityMisconfiguration.d.ts +8 -0
- package/dist/rules/vulnerabilities/rules/securityMisconfiguration.d.ts.map +1 -0
- package/dist/rules/vulnerabilities/rules/securityMisconfiguration.js +438 -0
- package/dist/rules/vulnerabilities/rules/securityMisconfiguration.js.map +1 -0
- package/dist/rules/vulnerabilities/rules/sqlInjection.d.ts +12 -0
- package/dist/rules/vulnerabilities/rules/sqlInjection.d.ts.map +1 -0
- package/dist/rules/vulnerabilities/rules/sqlInjection.js +636 -0
- package/dist/rules/vulnerabilities/rules/sqlInjection.js.map +1 -0
- package/dist/rules/vulnerabilities/rules/ssrf.d.ts +8 -0
- package/dist/rules/vulnerabilities/rules/ssrf.d.ts.map +1 -0
- package/dist/rules/vulnerabilities/rules/ssrf.js +401 -0
- package/dist/rules/vulnerabilities/rules/ssrf.js.map +1 -0
- package/dist/rules/vulnerabilities/rules/xss.d.ts +11 -0
- package/dist/rules/vulnerabilities/rules/xss.d.ts.map +1 -0
- package/dist/rules/vulnerabilities/rules/xss.js +724 -0
- package/dist/rules/vulnerabilities/rules/xss.js.map +1 -0
- package/dist/rules/vulnerabilities/scoring/index.d.ts +80 -0
- package/dist/rules/vulnerabilities/scoring/index.d.ts.map +1 -0
- package/dist/rules/vulnerabilities/scoring/index.js +414 -0
- package/dist/rules/vulnerabilities/scoring/index.js.map +1 -0
- package/dist/rules/vulnerabilities/types/index.d.ts +830 -0
- package/dist/rules/vulnerabilities/types/index.d.ts.map +1 -0
- package/dist/rules/vulnerabilities/types/index.js +164 -0
- package/dist/rules/vulnerabilities/types/index.js.map +1 -0
- package/dist/rules/vulnerabilities/utils/index.d.ts +206 -0
- package/dist/rules/vulnerabilities/utils/index.d.ts.map +1 -0
- package/dist/rules/vulnerabilities/utils/index.js +615 -0
- package/dist/rules/vulnerabilities/utils/index.js.map +1 -0
- package/dist/types/index.d.ts +359 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +61 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/index.d.ts +82 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +326 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +40 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +139 -0
- package/dist/utils/logger.js.map +1 -0
- package/docs/ARCHITECTURE.md +320 -0
- package/docs/V1.2.1-IA_Performances.md +116 -0
- package/docs/images/WIN_Defender.png +0 -0
- package/package.json +68 -0
- package/secure-scan.config.json +134 -0
- package/secure-scan.sln +29 -0
- package/src/ai/aiAnalyzer.ts +714 -0
- package/src/ai/index.ts +5 -0
- package/src/analyzers/base/baseAnalyzer.ts +66 -0
- package/src/analyzers/base/index.ts +5 -0
- package/src/analyzers/c-cpp/cppAnalyzer.ts +308 -0
- package/src/analyzers/c-cpp/index.ts +5 -0
- package/src/analyzers/core/engine/index.ts +5 -0
- package/src/analyzers/core/engine/ruleEngine.ts +221 -0
- package/src/analyzers/core/index.ts +8 -0
- package/src/analyzers/core/scanner/fileScanner.ts +204 -0
- package/src/analyzers/core/scanner/index.ts +5 -0
- package/src/analyzers/core/scoring/index.ts +5 -0
- package/src/analyzers/core/scoring/riskScoring.ts +198 -0
- package/src/analyzers/core/securityScanner.ts +321 -0
- package/src/analyzers/csharp/csharpAnalyzer.ts +328 -0
- package/src/analyzers/csharp/index.ts +5 -0
- package/src/analyzers/iac/iacAnalyzer.ts +318 -0
- package/src/analyzers/iac/index.ts +5 -0
- package/src/analyzers/index.ts +67 -0
- package/src/analyzers/java/index.ts +5 -0
- package/src/analyzers/java/javaAnalyzer.ts +320 -0
- package/src/analyzers/javascript/PROMPT_JS_ANALYZER.md +267 -0
- package/src/analyzers/javascript/astUtils.ts +789 -0
- package/src/analyzers/javascript/index.ts +50 -0
- package/src/analyzers/javascript/javascriptAnalyzer.ts +984 -0
- package/src/analyzers/javascript/malwareDetector.ts +697 -0
- package/src/analyzers/javascript/packageJsonAnalyzer.ts +626 -0
- package/src/analyzers/javascript/taintAnalyzer.ts +630 -0
- package/src/analyzers/php/index.ts +5 -0
- package/src/analyzers/php/phpAnalyzer.ts +280 -0
- package/src/analyzers/python/index.ts +5 -0
- package/src/analyzers/python/pythonAnalyzer.ts +319 -0
- package/src/cli/index.ts +276 -0
- package/src/dependencies/aiDependencyAnalyzer.ts +496 -0
- package/src/dependencies/database/cveDatabase.ts +426 -0
- package/src/dependencies/database/index.ts +6 -0
- package/src/dependencies/database/maliciousPackages.ts +286 -0
- package/src/dependencies/dependencyAnalyzer.ts +394 -0
- package/src/dependencies/detectors/index.ts +7 -0
- package/src/dependencies/detectors/securityStandards.ts +200 -0
- package/src/dependencies/detectors/vulnerabilityDetector.ts +343 -0
- package/src/dependencies/index.ts +27 -0
- package/src/dependencies/installed/index.ts +8 -0
- package/src/dependencies/installed/installedScanner.ts +821 -0
- package/src/dependencies/installed/malwarePatterns.ts +492 -0
- package/src/dependencies/installed/types.ts +287 -0
- package/src/dependencies/parsers/base/baseParser.ts +108 -0
- package/src/dependencies/parsers/base/index.ts +6 -0
- package/src/dependencies/parsers/cpp/cppParser.ts +245 -0
- package/src/dependencies/parsers/cpp/index.ts +6 -0
- package/src/dependencies/parsers/csharp/csharpParser.ts +151 -0
- package/src/dependencies/parsers/csharp/index.ts +6 -0
- package/src/dependencies/parsers/index.ts +56 -0
- package/src/dependencies/parsers/java/index.ts +6 -0
- package/src/dependencies/parsers/java/javaParser.ts +203 -0
- package/src/dependencies/parsers/javascript/index.ts +6 -0
- package/src/dependencies/parsers/javascript/javascriptParser.ts +362 -0
- package/src/dependencies/parsers/php/index.ts +6 -0
- package/src/dependencies/parsers/php/phpParser.ts +208 -0
- package/src/dependencies/parsers/python/index.ts +6 -0
- package/src/dependencies/parsers/python/pythonParser.ts +437 -0
- package/src/dependencies/types.ts +330 -0
- package/src/i18n/index.ts +1 -0
- package/src/i18n/translations.ts +194 -0
- package/src/index.ts +16 -0
- package/src/reports/dependencyReportGenerator.ts +717 -0
- package/src/reports/htmlReportGenerator.ts +781 -0
- package/src/reports/index.ts +7 -0
- package/src/reports/installedDepsReportGenerator.ts +899 -0
- package/src/rules/index.ts +58 -0
- package/src/rules/malware/INFO.md +287 -0
- package/src/rules/malware/categories/backdoors.ts +174 -0
- package/src/rules/malware/categories/cryptominers.ts +434 -0
- package/src/rules/malware/categories/exfiltration.ts +677 -0
- package/src/rules/malware/categories/keyloggers.ts +780 -0
- package/src/rules/malware/categories/loaders.ts +721 -0
- package/src/rules/malware/categories/network.ts +639 -0
- package/src/rules/malware/categories/obfuscation.ts +788 -0
- package/src/rules/malware/constants/index.ts +358 -0
- package/src/rules/malware/engine/index.ts +758 -0
- package/src/rules/malware/index.ts +928 -0
- package/src/rules/malware/scoring/index.ts +549 -0
- package/src/rules/malware/types/index.ts +752 -0
- package/src/rules/malware/utils/index.ts +643 -0
- package/src/rules/standards.ts +372 -0
- package/src/rules/vulnerabilities/PROMPT_VULNERABILITIES.md +226 -0
- package/src/rules/vulnerabilities/constants/index.ts +625 -0
- package/src/rules/vulnerabilities/engine/index.ts +831 -0
- package/src/rules/vulnerabilities/index.ts +312 -0
- package/src/rules/vulnerabilities/rules/authentication.ts +426 -0
- package/src/rules/vulnerabilities/rules/commandInjection.ts +307 -0
- package/src/rules/vulnerabilities/rules/csrf.ts +268 -0
- package/src/rules/vulnerabilities/rules/deserialization.ts +343 -0
- package/src/rules/vulnerabilities/rules/fileUpload.ts +332 -0
- package/src/rules/vulnerabilities/rules/hardcodedSecrets.ts +453 -0
- package/src/rules/vulnerabilities/rules/index.ts +17 -0
- package/src/rules/vulnerabilities/rules/pathTraversal.ts +358 -0
- package/src/rules/vulnerabilities/rules/prototypePollution.ts +279 -0
- package/src/rules/vulnerabilities/rules/securityMisconfiguration.ts +445 -0
- package/src/rules/vulnerabilities/rules/sqlInjection.ts +669 -0
- package/src/rules/vulnerabilities/rules/ssrf.ts +408 -0
- package/src/rules/vulnerabilities/rules/xss.ts +753 -0
- package/src/rules/vulnerabilities/scoring/index.ts +543 -0
- package/src/rules/vulnerabilities/types/index.ts +1004 -0
- package/src/rules/vulnerabilities/utils/index.ts +709 -0
- package/src/types/index.ts +391 -0
- package/src/utils/index.ts +306 -0
- package/src/utils/logger.ts +150 -0
- package/test-installed-scanner.ts +136 -0
- package/tsconfig.json +30 -0
|
@@ -0,0 +1,984 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JavaScript/TypeScript Security Analyzer v2.0
|
|
3
|
+
* Advanced SAST analyzer with AST-based detection, taint analysis, and malware detection
|
|
4
|
+
*
|
|
5
|
+
* Features:
|
|
6
|
+
* - AST-based vulnerability detection (Babel Parser)
|
|
7
|
+
* - Taint analysis (source-to-sink tracking)
|
|
8
|
+
* - Malware detection (cryptominers, stealers, backdoors, etc.)
|
|
9
|
+
* - Package.json security analysis
|
|
10
|
+
* - OWASP/CWE compliance
|
|
11
|
+
*
|
|
12
|
+
* @version 2.0.0
|
|
13
|
+
* @author Secure-Scan Team
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { BaseAnalyzer } from '../base';
|
|
17
|
+
import {
|
|
18
|
+
ScannedFile,
|
|
19
|
+
Finding,
|
|
20
|
+
Rule,
|
|
21
|
+
SupportedLanguage,
|
|
22
|
+
Severity,
|
|
23
|
+
ThreatType,
|
|
24
|
+
FindingCategory,
|
|
25
|
+
SecurityStandard
|
|
26
|
+
} from '../../types';
|
|
27
|
+
import { generateId, extractCodeContext, looksObfuscated, calculateEntropy } from '../../utils';
|
|
28
|
+
import { getStandardsForThreat } from '../../rules/standards';
|
|
29
|
+
import { logger } from '../../utils/logger';
|
|
30
|
+
|
|
31
|
+
// Import specialized modules
|
|
32
|
+
import { TaintAnalyzer, TaintFlow, TAINT_SOURCES, TAINT_SINKS } from './taintAnalyzer';
|
|
33
|
+
import { ASTUtils, DangerousCall, DangerousPatternType } from './astUtils';
|
|
34
|
+
import { MalwareDetector, MalwareMatch, MalwareType } from './malwareDetector';
|
|
35
|
+
import { PackageJsonAnalyzer, PackageJsonFinding } from './packageJsonAnalyzer';
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Analysis options for the JavaScript Analyzer
|
|
39
|
+
*/
|
|
40
|
+
export interface JSAnalyzerOptions {
|
|
41
|
+
/** Enable AST-based analysis */
|
|
42
|
+
enableAST?: boolean;
|
|
43
|
+
/** Enable taint analysis */
|
|
44
|
+
enableTaintAnalysis?: boolean;
|
|
45
|
+
/** Enable malware detection */
|
|
46
|
+
enableMalwareDetection?: boolean;
|
|
47
|
+
/** Enable package.json analysis */
|
|
48
|
+
enablePackageAnalysis?: boolean;
|
|
49
|
+
/** Maximum file size to analyze (bytes) */
|
|
50
|
+
maxFileSize?: number;
|
|
51
|
+
/** Timeout per file (ms) */
|
|
52
|
+
fileTimeout?: number;
|
|
53
|
+
/** Minimum confidence to report (0-100) */
|
|
54
|
+
minConfidence?: number;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Default analyzer options
|
|
59
|
+
*/
|
|
60
|
+
const DEFAULT_OPTIONS: JSAnalyzerOptions = {
|
|
61
|
+
enableAST: true,
|
|
62
|
+
enableTaintAnalysis: true,
|
|
63
|
+
enableMalwareDetection: true,
|
|
64
|
+
enablePackageAnalysis: true,
|
|
65
|
+
maxFileSize: 5 * 1024 * 1024, // 5MB
|
|
66
|
+
fileTimeout: 30000, // 30 seconds
|
|
67
|
+
minConfidence: 50
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Vulnerability patterns for regex-based fallback detection
|
|
72
|
+
*/
|
|
73
|
+
interface VulnerabilityPattern {
|
|
74
|
+
id: string;
|
|
75
|
+
name: string;
|
|
76
|
+
pattern: RegExp;
|
|
77
|
+
severity: Severity;
|
|
78
|
+
threatType: ThreatType;
|
|
79
|
+
category: FindingCategory;
|
|
80
|
+
description: string;
|
|
81
|
+
remediation: string;
|
|
82
|
+
confidence: number;
|
|
83
|
+
tags: string[];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Vulnerability patterns database (regex fallback)
|
|
88
|
+
*/
|
|
89
|
+
const VULNERABILITY_PATTERNS: VulnerabilityPattern[] = [
|
|
90
|
+
// === CODE EXECUTION ===
|
|
91
|
+
{
|
|
92
|
+
id: 'JS-EXEC-001',
|
|
93
|
+
name: 'eval() Usage',
|
|
94
|
+
pattern: /\beval\s*\(\s*(?!['"`])/g,
|
|
95
|
+
severity: Severity.CRITICAL,
|
|
96
|
+
threatType: ThreatType.COMMAND_INJECTION,
|
|
97
|
+
category: FindingCategory.VULNERABILITY,
|
|
98
|
+
description: 'Use of eval() with dynamic content can lead to code injection.',
|
|
99
|
+
remediation: 'Avoid eval(). Use JSON.parse() for JSON data or safer alternatives.',
|
|
100
|
+
confidence: 85,
|
|
101
|
+
tags: ['injection', 'rce', 'owasp-a03']
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
id: 'JS-EXEC-002',
|
|
105
|
+
name: 'Function Constructor',
|
|
106
|
+
pattern: /\bnew\s+Function\s*\(/g,
|
|
107
|
+
severity: Severity.CRITICAL,
|
|
108
|
+
threatType: ThreatType.COMMAND_INJECTION,
|
|
109
|
+
category: FindingCategory.VULNERABILITY,
|
|
110
|
+
description: 'new Function() is equivalent to eval() and can execute arbitrary code.',
|
|
111
|
+
remediation: 'Use predefined functions instead of dynamically creating them.',
|
|
112
|
+
confidence: 85,
|
|
113
|
+
tags: ['injection', 'rce', 'owasp-a03']
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
id: 'JS-EXEC-003',
|
|
117
|
+
name: 'setTimeout/setInterval with String',
|
|
118
|
+
pattern: /\bset(?:Timeout|Interval)\s*\(\s*['"`][^'"`]+['"`]/g,
|
|
119
|
+
severity: Severity.HIGH,
|
|
120
|
+
threatType: ThreatType.COMMAND_INJECTION,
|
|
121
|
+
category: FindingCategory.VULNERABILITY,
|
|
122
|
+
description: 'setTimeout/setInterval with string argument acts like eval().',
|
|
123
|
+
remediation: 'Pass a function reference instead of a string.',
|
|
124
|
+
confidence: 80,
|
|
125
|
+
tags: ['injection', 'owasp-a03']
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
// === COMMAND INJECTION ===
|
|
129
|
+
{
|
|
130
|
+
id: 'JS-CMD-001',
|
|
131
|
+
name: 'child_process exec()',
|
|
132
|
+
pattern: /(?:child_process\.)?exec\s*\(\s*(?!['"`])/g,
|
|
133
|
+
severity: Severity.CRITICAL,
|
|
134
|
+
threatType: ThreatType.COMMAND_INJECTION,
|
|
135
|
+
category: FindingCategory.VULNERABILITY,
|
|
136
|
+
description: 'exec() with dynamic command string is vulnerable to command injection.',
|
|
137
|
+
remediation: 'Use execFile() with argument array instead of exec().',
|
|
138
|
+
confidence: 80,
|
|
139
|
+
tags: ['injection', 'rce', 'owasp-a03']
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
id: 'JS-CMD-002',
|
|
143
|
+
name: 'spawn with shell: true',
|
|
144
|
+
pattern: /spawn\s*\([^)]*shell\s*:\s*true/g,
|
|
145
|
+
severity: Severity.HIGH,
|
|
146
|
+
threatType: ThreatType.COMMAND_INJECTION,
|
|
147
|
+
category: FindingCategory.VULNERABILITY,
|
|
148
|
+
description: 'spawn() with shell option is vulnerable to command injection.',
|
|
149
|
+
remediation: 'Remove shell: true and pass arguments as an array.',
|
|
150
|
+
confidence: 85,
|
|
151
|
+
tags: ['injection', 'rce', 'owasp-a03']
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
// === XSS VULNERABILITIES ===
|
|
155
|
+
{
|
|
156
|
+
id: 'JS-XSS-001',
|
|
157
|
+
name: 'innerHTML Assignment',
|
|
158
|
+
pattern: /\.innerHTML\s*=\s*(?!['"`]<)/g,
|
|
159
|
+
severity: Severity.HIGH,
|
|
160
|
+
threatType: ThreatType.XSS,
|
|
161
|
+
category: FindingCategory.VULNERABILITY,
|
|
162
|
+
description: 'Direct innerHTML assignment with dynamic content enables XSS.',
|
|
163
|
+
remediation: 'Use textContent for text, or sanitize with DOMPurify.',
|
|
164
|
+
confidence: 75,
|
|
165
|
+
tags: ['xss', 'dom', 'owasp-a03']
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
id: 'JS-XSS-002',
|
|
169
|
+
name: 'document.write()',
|
|
170
|
+
pattern: /document\.write(?:ln)?\s*\(/g,
|
|
171
|
+
severity: Severity.HIGH,
|
|
172
|
+
threatType: ThreatType.XSS,
|
|
173
|
+
category: FindingCategory.VULNERABILITY,
|
|
174
|
+
description: 'document.write() with dynamic content is vulnerable to XSS.',
|
|
175
|
+
remediation: 'Use DOM manipulation methods like createElement() and textContent.',
|
|
176
|
+
confidence: 80,
|
|
177
|
+
tags: ['xss', 'dom', 'owasp-a03']
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
id: 'JS-XSS-003',
|
|
181
|
+
name: 'insertAdjacentHTML()',
|
|
182
|
+
pattern: /\.insertAdjacentHTML\s*\(/g,
|
|
183
|
+
severity: Severity.HIGH,
|
|
184
|
+
threatType: ThreatType.XSS,
|
|
185
|
+
category: FindingCategory.VULNERABILITY,
|
|
186
|
+
description: 'insertAdjacentHTML() with unsanitized content enables XSS.',
|
|
187
|
+
remediation: 'Sanitize HTML content with DOMPurify before insertion.',
|
|
188
|
+
confidence: 75,
|
|
189
|
+
tags: ['xss', 'dom', 'owasp-a03']
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
id: 'JS-XSS-004',
|
|
193
|
+
name: 'jQuery .html()',
|
|
194
|
+
pattern: /\$\([^)]+\)\.html\s*\(\s*(?!['"`]<)/g,
|
|
195
|
+
severity: Severity.HIGH,
|
|
196
|
+
threatType: ThreatType.XSS,
|
|
197
|
+
category: FindingCategory.VULNERABILITY,
|
|
198
|
+
description: 'jQuery .html() with dynamic content is vulnerable to XSS.',
|
|
199
|
+
remediation: 'Use .text() for text content or sanitize before .html().',
|
|
200
|
+
confidence: 70,
|
|
201
|
+
tags: ['xss', 'jquery', 'owasp-a03']
|
|
202
|
+
},
|
|
203
|
+
|
|
204
|
+
// === PROTOTYPE POLLUTION ===
|
|
205
|
+
{
|
|
206
|
+
id: 'JS-PP-001',
|
|
207
|
+
name: '__proto__ Access',
|
|
208
|
+
pattern: /\[['"`]?__proto__['"`]?\]|\.__proto__\b/g,
|
|
209
|
+
severity: Severity.HIGH,
|
|
210
|
+
threatType: ThreatType.DANGEROUS_FUNCTION,
|
|
211
|
+
category: FindingCategory.VULNERABILITY,
|
|
212
|
+
description: 'Direct __proto__ access can lead to prototype pollution.',
|
|
213
|
+
remediation: 'Use Object.create(null) for safe objects or validate keys.',
|
|
214
|
+
confidence: 85,
|
|
215
|
+
tags: ['prototype-pollution', 'owasp-a03']
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
id: 'JS-PP-002',
|
|
219
|
+
name: 'Object.prototype Modification',
|
|
220
|
+
pattern: /Object\.prototype\s*\.\s*\w+\s*=/g,
|
|
221
|
+
severity: Severity.HIGH,
|
|
222
|
+
threatType: ThreatType.DANGEROUS_FUNCTION,
|
|
223
|
+
category: FindingCategory.VULNERABILITY,
|
|
224
|
+
description: 'Modifying Object.prototype affects all objects.',
|
|
225
|
+
remediation: 'Avoid modifying built-in prototypes.',
|
|
226
|
+
confidence: 90,
|
|
227
|
+
tags: ['prototype-pollution', 'owasp-a03']
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
id: 'JS-PP-003',
|
|
231
|
+
name: 'constructor.prototype Access',
|
|
232
|
+
pattern: /constructor\s*\.\s*prototype/g,
|
|
233
|
+
severity: Severity.MEDIUM,
|
|
234
|
+
threatType: ThreatType.DANGEROUS_FUNCTION,
|
|
235
|
+
category: FindingCategory.VULNERABILITY,
|
|
236
|
+
description: 'Accessing constructor.prototype may indicate prototype pollution.',
|
|
237
|
+
remediation: 'Validate and sanitize any dynamic property access.',
|
|
238
|
+
confidence: 70,
|
|
239
|
+
tags: ['prototype-pollution', 'owasp-a03']
|
|
240
|
+
},
|
|
241
|
+
|
|
242
|
+
// === INSECURE RANDOMNESS ===
|
|
243
|
+
{
|
|
244
|
+
id: 'JS-RAND-001',
|
|
245
|
+
name: 'Math.random() for Security',
|
|
246
|
+
pattern: /(?:token|secret|key|password|salt|nonce|iv)\s*[=:]\s*[^;{]*Math\.random/gi,
|
|
247
|
+
severity: Severity.HIGH,
|
|
248
|
+
threatType: ThreatType.WEAK_RANDOM,
|
|
249
|
+
category: FindingCategory.VULNERABILITY,
|
|
250
|
+
description: 'Math.random() is not cryptographically secure.',
|
|
251
|
+
remediation: 'Use crypto.randomBytes() or crypto.getRandomValues().',
|
|
252
|
+
confidence: 80,
|
|
253
|
+
tags: ['crypto', 'random', 'owasp-a02']
|
|
254
|
+
},
|
|
255
|
+
|
|
256
|
+
// === HARDCODED CREDENTIALS ===
|
|
257
|
+
{
|
|
258
|
+
id: 'JS-CRED-001',
|
|
259
|
+
name: 'Hardcoded Password',
|
|
260
|
+
pattern: /(?:password|passwd|pwd)\s*[=:]\s*['"`][^'"`]{6,}['"`]/gi,
|
|
261
|
+
severity: Severity.HIGH,
|
|
262
|
+
threatType: ThreatType.HARDCODED_CREDENTIALS,
|
|
263
|
+
category: FindingCategory.VULNERABILITY,
|
|
264
|
+
description: 'Hardcoded password detected in source code.',
|
|
265
|
+
remediation: 'Use environment variables or a secrets manager.',
|
|
266
|
+
confidence: 75,
|
|
267
|
+
tags: ['credentials', 'secrets', 'owasp-a07']
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
id: 'JS-CRED-002',
|
|
271
|
+
name: 'Hardcoded API Key',
|
|
272
|
+
pattern: /(?:api[_-]?key|apikey)\s*[=:]\s*['"`][a-zA-Z0-9_-]{20,}['"`]/gi,
|
|
273
|
+
severity: Severity.HIGH,
|
|
274
|
+
threatType: ThreatType.HARDCODED_CREDENTIALS,
|
|
275
|
+
category: FindingCategory.VULNERABILITY,
|
|
276
|
+
description: 'Hardcoded API key detected in source code.',
|
|
277
|
+
remediation: 'Use environment variables or a secrets manager.',
|
|
278
|
+
confidence: 80,
|
|
279
|
+
tags: ['credentials', 'secrets', 'owasp-a07']
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
id: 'JS-CRED-003',
|
|
283
|
+
name: 'Hardcoded Secret/Token',
|
|
284
|
+
pattern: /(?:secret|token|auth)\s*[=:]\s*['"`][a-zA-Z0-9_-]{20,}['"`]/gi,
|
|
285
|
+
severity: Severity.HIGH,
|
|
286
|
+
threatType: ThreatType.HARDCODED_CREDENTIALS,
|
|
287
|
+
category: FindingCategory.VULNERABILITY,
|
|
288
|
+
description: 'Hardcoded secret or token detected in source code.',
|
|
289
|
+
remediation: 'Use environment variables or a secrets manager.',
|
|
290
|
+
confidence: 75,
|
|
291
|
+
tags: ['credentials', 'secrets', 'owasp-a07']
|
|
292
|
+
},
|
|
293
|
+
|
|
294
|
+
// === INSECURE CRYPTO ===
|
|
295
|
+
{
|
|
296
|
+
id: 'JS-CRYPTO-001',
|
|
297
|
+
name: 'MD5 Usage',
|
|
298
|
+
pattern: /(?:createHash|crypto)\s*\(\s*['"`]md5['"`]\s*\)/gi,
|
|
299
|
+
severity: Severity.MEDIUM,
|
|
300
|
+
threatType: ThreatType.INSECURE_CRYPTO,
|
|
301
|
+
category: FindingCategory.VULNERABILITY,
|
|
302
|
+
description: 'MD5 is cryptographically broken and should not be used.',
|
|
303
|
+
remediation: 'Use SHA-256 or stronger for hashing.',
|
|
304
|
+
confidence: 90,
|
|
305
|
+
tags: ['crypto', 'hash', 'owasp-a02']
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
id: 'JS-CRYPTO-002',
|
|
309
|
+
name: 'SHA1 Usage',
|
|
310
|
+
pattern: /(?:createHash|crypto)\s*\(\s*['"`]sha1['"`]\s*\)/gi,
|
|
311
|
+
severity: Severity.MEDIUM,
|
|
312
|
+
threatType: ThreatType.INSECURE_CRYPTO,
|
|
313
|
+
category: FindingCategory.VULNERABILITY,
|
|
314
|
+
description: 'SHA-1 is deprecated for cryptographic use.',
|
|
315
|
+
remediation: 'Use SHA-256 or stronger for hashing.',
|
|
316
|
+
confidence: 85,
|
|
317
|
+
tags: ['crypto', 'hash', 'owasp-a02']
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
id: 'JS-CRYPTO-003',
|
|
321
|
+
name: 'DES/3DES Usage',
|
|
322
|
+
pattern: /(?:createCipher|createDecipher)\s*\(\s*['"`](?:des|3des|des-ede3)['"`]/gi,
|
|
323
|
+
severity: Severity.HIGH,
|
|
324
|
+
threatType: ThreatType.INSECURE_CRYPTO,
|
|
325
|
+
category: FindingCategory.VULNERABILITY,
|
|
326
|
+
description: 'DES and 3DES are deprecated encryption algorithms.',
|
|
327
|
+
remediation: 'Use AES-256-GCM for encryption.',
|
|
328
|
+
confidence: 90,
|
|
329
|
+
tags: ['crypto', 'encryption', 'owasp-a02']
|
|
330
|
+
},
|
|
331
|
+
|
|
332
|
+
// === PATH TRAVERSAL ===
|
|
333
|
+
{
|
|
334
|
+
id: 'JS-PATH-001',
|
|
335
|
+
name: 'Path Traversal in File Read',
|
|
336
|
+
pattern: /(?:readFile|readFileSync|createReadStream)\s*\([^)]*(?:req\.(?:body|query|params)|process\.argv)/gi,
|
|
337
|
+
severity: Severity.HIGH,
|
|
338
|
+
threatType: ThreatType.PATH_TRAVERSAL,
|
|
339
|
+
category: FindingCategory.VULNERABILITY,
|
|
340
|
+
description: 'File read with user-controlled path enables path traversal.',
|
|
341
|
+
remediation: 'Validate paths with path.resolve() and check against base directory.',
|
|
342
|
+
confidence: 80,
|
|
343
|
+
tags: ['path-traversal', 'file', 'owasp-a01']
|
|
344
|
+
},
|
|
345
|
+
|
|
346
|
+
// === SQL INJECTION ===
|
|
347
|
+
{
|
|
348
|
+
id: 'JS-SQL-001',
|
|
349
|
+
name: 'SQL Query Concatenation',
|
|
350
|
+
pattern: /\.query\s*\(\s*['"`](?:SELECT|INSERT|UPDATE|DELETE)[^'"]*\+/gi,
|
|
351
|
+
severity: Severity.CRITICAL,
|
|
352
|
+
threatType: ThreatType.SQL_INJECTION,
|
|
353
|
+
category: FindingCategory.VULNERABILITY,
|
|
354
|
+
description: 'SQL query with string concatenation is vulnerable to injection.',
|
|
355
|
+
remediation: 'Use parameterized queries or prepared statements.',
|
|
356
|
+
confidence: 85,
|
|
357
|
+
tags: ['sqli', 'injection', 'owasp-a03']
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
id: 'JS-SQL-002',
|
|
361
|
+
name: 'SQL Template Literal',
|
|
362
|
+
pattern: /\.query\s*\(\s*`(?:SELECT|INSERT|UPDATE|DELETE)[^`]*\$\{/gi,
|
|
363
|
+
severity: Severity.CRITICAL,
|
|
364
|
+
threatType: ThreatType.SQL_INJECTION,
|
|
365
|
+
category: FindingCategory.VULNERABILITY,
|
|
366
|
+
description: 'SQL query with template literal interpolation is vulnerable.',
|
|
367
|
+
remediation: 'Use parameterized queries or prepared statements.',
|
|
368
|
+
confidence: 85,
|
|
369
|
+
tags: ['sqli', 'injection', 'owasp-a03']
|
|
370
|
+
},
|
|
371
|
+
|
|
372
|
+
// === SSRF ===
|
|
373
|
+
{
|
|
374
|
+
id: 'JS-SSRF-001',
|
|
375
|
+
name: 'SSRF in fetch()',
|
|
376
|
+
pattern: /fetch\s*\(\s*(?:req\.(?:body|query|params)|`[^`]*\$\{)/gi,
|
|
377
|
+
severity: Severity.HIGH,
|
|
378
|
+
threatType: ThreatType.SECURITY_MISCONFIGURATION,
|
|
379
|
+
category: FindingCategory.VULNERABILITY,
|
|
380
|
+
description: 'fetch() with user-controlled URL enables SSRF attacks.',
|
|
381
|
+
remediation: 'Validate and whitelist URLs before making requests.',
|
|
382
|
+
confidence: 75,
|
|
383
|
+
tags: ['ssrf', 'owasp-a10']
|
|
384
|
+
},
|
|
385
|
+
|
|
386
|
+
// === INSECURE CONFIGURATION ===
|
|
387
|
+
{
|
|
388
|
+
id: 'JS-CONFIG-001',
|
|
389
|
+
name: 'CORS Wildcard',
|
|
390
|
+
pattern: /(?:cors|Access-Control-Allow-Origin)\s*[=:]\s*['"*]/gi,
|
|
391
|
+
severity: Severity.MEDIUM,
|
|
392
|
+
threatType: ThreatType.SECURITY_MISCONFIGURATION,
|
|
393
|
+
category: FindingCategory.VULNERABILITY,
|
|
394
|
+
description: 'CORS with wildcard origin allows any domain to access the API.',
|
|
395
|
+
remediation: 'Specify allowed origins explicitly.',
|
|
396
|
+
confidence: 80,
|
|
397
|
+
tags: ['cors', 'config', 'owasp-a05']
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
id: 'JS-CONFIG-002',
|
|
401
|
+
name: 'Disabled CSRF Protection',
|
|
402
|
+
pattern: /csrf\s*:\s*false|csrfProtection\s*=\s*false/gi,
|
|
403
|
+
severity: Severity.HIGH,
|
|
404
|
+
threatType: ThreatType.CSRF,
|
|
405
|
+
category: FindingCategory.VULNERABILITY,
|
|
406
|
+
description: 'CSRF protection is explicitly disabled.',
|
|
407
|
+
remediation: 'Enable CSRF protection for state-changing operations.',
|
|
408
|
+
confidence: 90,
|
|
409
|
+
tags: ['csrf', 'config', 'owasp-a05']
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
id: 'JS-CONFIG-003',
|
|
413
|
+
name: 'Insecure Cookie Settings',
|
|
414
|
+
pattern: /(?:secure|httpOnly)\s*:\s*false/gi,
|
|
415
|
+
severity: Severity.MEDIUM,
|
|
416
|
+
threatType: ThreatType.SECURITY_MISCONFIGURATION,
|
|
417
|
+
category: FindingCategory.VULNERABILITY,
|
|
418
|
+
description: 'Cookie security flags are explicitly disabled.',
|
|
419
|
+
remediation: 'Set secure: true and httpOnly: true for session cookies.',
|
|
420
|
+
confidence: 85,
|
|
421
|
+
tags: ['cookie', 'config', 'owasp-a05']
|
|
422
|
+
},
|
|
423
|
+
|
|
424
|
+
// === POSTMESSAGE VULNERABILITIES ===
|
|
425
|
+
{
|
|
426
|
+
id: 'JS-PM-001',
|
|
427
|
+
name: 'postMessage Wildcard Origin',
|
|
428
|
+
pattern: /postMessage\s*\([^)]+,\s*['"]\*['"]\s*\)/g,
|
|
429
|
+
severity: Severity.MEDIUM,
|
|
430
|
+
threatType: ThreatType.SECURITY_MISCONFIGURATION,
|
|
431
|
+
category: FindingCategory.VULNERABILITY,
|
|
432
|
+
description: 'postMessage with "*" origin can leak data to any origin.',
|
|
433
|
+
remediation: 'Specify the target origin explicitly.',
|
|
434
|
+
confidence: 90,
|
|
435
|
+
tags: ['postmessage', 'origin', 'owasp-a05']
|
|
436
|
+
},
|
|
437
|
+
{
|
|
438
|
+
id: 'JS-PM-002',
|
|
439
|
+
name: 'Missing Origin Check',
|
|
440
|
+
pattern: /addEventListener\s*\(\s*['"`]message['"`][^}]*(?:eval|innerHTML|document\.write)/g,
|
|
441
|
+
severity: Severity.HIGH,
|
|
442
|
+
threatType: ThreatType.XSS,
|
|
443
|
+
category: FindingCategory.VULNERABILITY,
|
|
444
|
+
description: 'Message event handler without origin check enables XSS.',
|
|
445
|
+
remediation: 'Always validate event.origin before processing messages.',
|
|
446
|
+
confidence: 75,
|
|
447
|
+
tags: ['postmessage', 'xss', 'owasp-a03']
|
|
448
|
+
},
|
|
449
|
+
|
|
450
|
+
// === DANGEROUS PATTERNS ===
|
|
451
|
+
{
|
|
452
|
+
id: 'JS-DANGER-001',
|
|
453
|
+
name: 'debugger Statement',
|
|
454
|
+
pattern: /\bdebugger\s*;/g,
|
|
455
|
+
severity: Severity.LOW,
|
|
456
|
+
threatType: ThreatType.SECURITY_MISCONFIGURATION,
|
|
457
|
+
category: FindingCategory.CODE_SMELL,
|
|
458
|
+
description: 'debugger statement should be removed in production.',
|
|
459
|
+
remediation: 'Remove debugger statements before deployment.',
|
|
460
|
+
confidence: 100,
|
|
461
|
+
tags: ['debug', 'cleanup']
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
id: 'JS-DANGER-002',
|
|
465
|
+
name: 'console.log in Production',
|
|
466
|
+
pattern: /console\.(?:log|debug|trace)\s*\([^)]*(?:password|secret|token|key)/gi,
|
|
467
|
+
severity: Severity.MEDIUM,
|
|
468
|
+
threatType: ThreatType.INFORMATION_DISCLOSURE,
|
|
469
|
+
category: FindingCategory.VULNERABILITY,
|
|
470
|
+
description: 'Logging sensitive data may expose credentials.',
|
|
471
|
+
remediation: 'Remove or redact sensitive data from logs.',
|
|
472
|
+
confidence: 70,
|
|
473
|
+
tags: ['logging', 'secrets', 'owasp-a09']
|
|
474
|
+
}
|
|
475
|
+
];
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* JavaScript/TypeScript Analyzer Class v2.0
|
|
479
|
+
*/
|
|
480
|
+
export class JavaScriptAnalyzer extends BaseAnalyzer {
|
|
481
|
+
name = 'JavaScript Analyzer';
|
|
482
|
+
languages: SupportedLanguage[] = ['javascript', 'typescript'];
|
|
483
|
+
version = '2.0.0';
|
|
484
|
+
|
|
485
|
+
// Specialized analyzers
|
|
486
|
+
private taintAnalyzer: TaintAnalyzer;
|
|
487
|
+
private astUtils: ASTUtils;
|
|
488
|
+
private malwareDetector: MalwareDetector;
|
|
489
|
+
private packageJsonAnalyzer: PackageJsonAnalyzer;
|
|
490
|
+
|
|
491
|
+
// Configuration
|
|
492
|
+
private options: JSAnalyzerOptions;
|
|
493
|
+
|
|
494
|
+
constructor(options: JSAnalyzerOptions = {}) {
|
|
495
|
+
super();
|
|
496
|
+
this.options = { ...DEFAULT_OPTIONS, ...options };
|
|
497
|
+
|
|
498
|
+
// Initialize specialized analyzers
|
|
499
|
+
this.taintAnalyzer = new TaintAnalyzer();
|
|
500
|
+
this.astUtils = new ASTUtils();
|
|
501
|
+
this.malwareDetector = new MalwareDetector();
|
|
502
|
+
this.packageJsonAnalyzer = new PackageJsonAnalyzer();
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* Initialize the analyzer
|
|
507
|
+
*/
|
|
508
|
+
async initialize(): Promise<void> {
|
|
509
|
+
await super.initialize();
|
|
510
|
+
logger.debug('JavaScript Analyzer v2.0 initialized with AST, Taint, and Malware detection');
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* Main analysis entry point
|
|
515
|
+
*/
|
|
516
|
+
async analyze(file: ScannedFile, rules: Rule[]): Promise<Finding[]> {
|
|
517
|
+
const findings: Finding[] = [];
|
|
518
|
+
const startTime = Date.now();
|
|
519
|
+
|
|
520
|
+
try {
|
|
521
|
+
// Skip files that are too large
|
|
522
|
+
if (file.size > this.options.maxFileSize!) {
|
|
523
|
+
logger.warn(`Skipping ${file.relativePath}: file too large (${file.size} bytes)`);
|
|
524
|
+
return findings;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
// Filter rules for JS/TS
|
|
528
|
+
const jsRules = rules.filter(r =>
|
|
529
|
+
r.languages.includes('javascript') || r.languages.includes('typescript')
|
|
530
|
+
);
|
|
531
|
+
|
|
532
|
+
// Run rule engine (inherited from BaseAnalyzer)
|
|
533
|
+
const ruleFindings = await this.ruleEngine.analyzeFile(file, jsRules);
|
|
534
|
+
findings.push(...ruleFindings);
|
|
535
|
+
|
|
536
|
+
// Special handling for package.json
|
|
537
|
+
if (file.relativePath.endsWith('package.json')) {
|
|
538
|
+
const pkgFindings = await this.analyzePackageJson(file);
|
|
539
|
+
findings.push(...pkgFindings);
|
|
540
|
+
return this.filterByConfidence(findings);
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
// Run parallel analysis for code files
|
|
544
|
+
const analysisPromises: Promise<Finding[]>[] = [];
|
|
545
|
+
|
|
546
|
+
// 1. Pattern-based vulnerability detection (fast, always run)
|
|
547
|
+
analysisPromises.push(this.runPatternAnalysis(file));
|
|
548
|
+
|
|
549
|
+
// 2. AST-based analysis (accurate, optional)
|
|
550
|
+
if (this.options.enableAST) {
|
|
551
|
+
analysisPromises.push(this.runASTAnalysis(file));
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
// 3. Taint analysis (complex, optional)
|
|
555
|
+
if (this.options.enableTaintAnalysis) {
|
|
556
|
+
analysisPromises.push(this.runTaintAnalysis(file));
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
// 4. Malware detection (comprehensive, optional)
|
|
560
|
+
if (this.options.enableMalwareDetection) {
|
|
561
|
+
analysisPromises.push(this.runMalwareAnalysis(file));
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
// 5. Obfuscation detection
|
|
565
|
+
analysisPromises.push(this.checkObfuscation(file));
|
|
566
|
+
|
|
567
|
+
// Wait for all analyses with timeout
|
|
568
|
+
const results = await Promise.race([
|
|
569
|
+
Promise.all(analysisPromises),
|
|
570
|
+
this.timeout(this.options.fileTimeout!)
|
|
571
|
+
]) as Finding[][];
|
|
572
|
+
|
|
573
|
+
// Flatten results
|
|
574
|
+
for (const result of results) {
|
|
575
|
+
findings.push(...result);
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
// Deduplicate findings
|
|
579
|
+
const deduped = this.deduplicateFindings(findings);
|
|
580
|
+
|
|
581
|
+
// Filter by confidence
|
|
582
|
+
const filtered = this.filterByConfidence(deduped);
|
|
583
|
+
|
|
584
|
+
const elapsed = Date.now() - startTime;
|
|
585
|
+
logger.debug(`Analyzed ${file.relativePath} in ${elapsed}ms, found ${filtered.length} issues`);
|
|
586
|
+
|
|
587
|
+
return filtered;
|
|
588
|
+
|
|
589
|
+
} catch (error) {
|
|
590
|
+
logger.error(`Error analyzing ${file.relativePath}:`, error);
|
|
591
|
+
return findings;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* Run pattern-based vulnerability detection
|
|
597
|
+
*/
|
|
598
|
+
private async runPatternAnalysis(file: ScannedFile): Promise<Finding[]> {
|
|
599
|
+
const findings: Finding[] = [];
|
|
600
|
+
|
|
601
|
+
for (const vuln of VULNERABILITY_PATTERNS) {
|
|
602
|
+
// Reset regex state
|
|
603
|
+
vuln.pattern.lastIndex = 0;
|
|
604
|
+
|
|
605
|
+
let match;
|
|
606
|
+
while ((match = vuln.pattern.exec(file.content)) !== null) {
|
|
607
|
+
// Find line number
|
|
608
|
+
const beforeMatch = file.content.substring(0, match.index);
|
|
609
|
+
const lineNum = beforeMatch.split('\n').length;
|
|
610
|
+
|
|
611
|
+
const context = extractCodeContext(file.content, lineNum, 2);
|
|
612
|
+
|
|
613
|
+
findings.push({
|
|
614
|
+
id: generateId(),
|
|
615
|
+
title: vuln.name,
|
|
616
|
+
description: vuln.description,
|
|
617
|
+
severity: vuln.severity,
|
|
618
|
+
threatType: vuln.threatType,
|
|
619
|
+
category: vuln.category,
|
|
620
|
+
location: {
|
|
621
|
+
file: file.relativePath,
|
|
622
|
+
startLine: lineNum,
|
|
623
|
+
endLine: lineNum
|
|
624
|
+
},
|
|
625
|
+
snippet: {
|
|
626
|
+
code: context.code,
|
|
627
|
+
contextBefore: context.contextBefore,
|
|
628
|
+
contextAfter: context.contextAfter
|
|
629
|
+
},
|
|
630
|
+
standards: getStandardsForThreat(vuln.threatType),
|
|
631
|
+
remediation: vuln.remediation,
|
|
632
|
+
confidence: vuln.confidence,
|
|
633
|
+
analyzer: this.name,
|
|
634
|
+
timestamp: new Date(),
|
|
635
|
+
tags: vuln.tags
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
return findings;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
/**
|
|
644
|
+
* Run AST-based analysis
|
|
645
|
+
*/
|
|
646
|
+
private async runASTAnalysis(file: ScannedFile): Promise<Finding[]> {
|
|
647
|
+
const findings: Finding[] = [];
|
|
648
|
+
|
|
649
|
+
try {
|
|
650
|
+
// Parse the file
|
|
651
|
+
const ast = this.astUtils.safeParse(file.content, file.relativePath);
|
|
652
|
+
if (!ast) {
|
|
653
|
+
logger.debug(`Could not parse ${file.relativePath} for AST analysis`);
|
|
654
|
+
return findings;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
// Find dangerous calls
|
|
658
|
+
const dangerousCalls = this.astUtils.findDangerousCalls(file.relativePath);
|
|
659
|
+
for (const call of dangerousCalls) {
|
|
660
|
+
findings.push(this.dangerousCallToFinding(call, file));
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
// Find hardcoded secrets
|
|
664
|
+
const secrets = this.astUtils.findHardcodedSecrets();
|
|
665
|
+
for (const secret of secrets) {
|
|
666
|
+
findings.push(this.dangerousCallToFinding(secret, file));
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
// Find dangerous regex patterns
|
|
670
|
+
const regexIssues = this.astUtils.findDangerousRegex();
|
|
671
|
+
for (const regex of regexIssues) {
|
|
672
|
+
findings.push(this.dangerousCallToFinding(regex, file));
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
} catch (error) {
|
|
676
|
+
logger.debug(`AST analysis failed for ${file.relativePath}:`, error);
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
return findings;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Run taint analysis
|
|
684
|
+
*/
|
|
685
|
+
private async runTaintAnalysis(file: ScannedFile): Promise<Finding[]> {
|
|
686
|
+
const findings: Finding[] = [];
|
|
687
|
+
|
|
688
|
+
try {
|
|
689
|
+
const flows = this.taintAnalyzer.analyze(file.content, file.relativePath);
|
|
690
|
+
|
|
691
|
+
for (const flow of flows) {
|
|
692
|
+
findings.push(this.taintFlowToFinding(flow, file));
|
|
693
|
+
}
|
|
694
|
+
} catch (error) {
|
|
695
|
+
logger.debug(`Taint analysis failed for ${file.relativePath}:`, error);
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
return findings;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* Run malware detection
|
|
703
|
+
*/
|
|
704
|
+
private async runMalwareAnalysis(file: ScannedFile): Promise<Finding[]> {
|
|
705
|
+
const findings: Finding[] = [];
|
|
706
|
+
|
|
707
|
+
try {
|
|
708
|
+
const matches = this.malwareDetector.scan(file.content, file.relativePath);
|
|
709
|
+
|
|
710
|
+
for (const match of matches) {
|
|
711
|
+
findings.push(this.malwareMatchToFinding(match, file));
|
|
712
|
+
}
|
|
713
|
+
} catch (error) {
|
|
714
|
+
logger.debug(`Malware analysis failed for ${file.relativePath}:`, error);
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
return findings;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
/**
|
|
721
|
+
* Analyze package.json for security issues
|
|
722
|
+
*/
|
|
723
|
+
private async analyzePackageJson(file: ScannedFile): Promise<Finding[]> {
|
|
724
|
+
const findings: Finding[] = [];
|
|
725
|
+
|
|
726
|
+
if (!this.options.enablePackageAnalysis) {
|
|
727
|
+
return findings;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
try {
|
|
731
|
+
const pkgFindings = this.packageJsonAnalyzer.analyze(file.content, file.relativePath);
|
|
732
|
+
|
|
733
|
+
for (const finding of pkgFindings) {
|
|
734
|
+
findings.push(this.packageFindingToFinding(finding, file));
|
|
735
|
+
}
|
|
736
|
+
} catch (error) {
|
|
737
|
+
logger.debug(`Package.json analysis failed for ${file.relativePath}:`, error);
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
return findings;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
/**
|
|
744
|
+
* Check for obfuscated code
|
|
745
|
+
*/
|
|
746
|
+
private async checkObfuscation(file: ScannedFile): Promise<Finding[]> {
|
|
747
|
+
const findings: Finding[] = [];
|
|
748
|
+
|
|
749
|
+
if (looksObfuscated(file.content)) {
|
|
750
|
+
const entropy = calculateEntropy(file.content);
|
|
751
|
+
|
|
752
|
+
findings.push({
|
|
753
|
+
id: generateId(),
|
|
754
|
+
title: 'Heavily Obfuscated Code',
|
|
755
|
+
description: `This file contains heavily obfuscated code (entropy: ${entropy.toFixed(2)}). This is unusual for legitimate code and may hide malicious functionality.`,
|
|
756
|
+
severity: Severity.HIGH,
|
|
757
|
+
threatType: ThreatType.OBFUSCATED_CODE,
|
|
758
|
+
category: FindingCategory.MALWARE,
|
|
759
|
+
location: {
|
|
760
|
+
file: file.relativePath,
|
|
761
|
+
startLine: 1,
|
|
762
|
+
endLine: Math.min(10, file.lineCount)
|
|
763
|
+
},
|
|
764
|
+
snippet: {
|
|
765
|
+
code: file.content.substring(0, 200) + '...'
|
|
766
|
+
},
|
|
767
|
+
standards: getStandardsForThreat(ThreatType.OBFUSCATED_CODE),
|
|
768
|
+
remediation: 'Deobfuscate and review the code. If this is a third-party library, verify its source and integrity.',
|
|
769
|
+
confidence: 75,
|
|
770
|
+
analyzer: this.name,
|
|
771
|
+
timestamp: new Date(),
|
|
772
|
+
tags: ['obfuscation', 'suspicious']
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
return findings;
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
/**
|
|
780
|
+
* Convert DangerousCall to Finding
|
|
781
|
+
*/
|
|
782
|
+
private dangerousCallToFinding(call: DangerousCall, file: ScannedFile): Finding {
|
|
783
|
+
const threatTypeMap: Record<DangerousPatternType, ThreatType> = {
|
|
784
|
+
[DangerousPatternType.CODE_EXECUTION]: ThreatType.COMMAND_INJECTION,
|
|
785
|
+
[DangerousPatternType.COMMAND_INJECTION]: ThreatType.COMMAND_INJECTION,
|
|
786
|
+
[DangerousPatternType.PROTOTYPE_POLLUTION]: ThreatType.DANGEROUS_FUNCTION,
|
|
787
|
+
[DangerousPatternType.XSS_SINK]: ThreatType.XSS,
|
|
788
|
+
[DangerousPatternType.DYNAMIC_REQUIRE]: ThreatType.DANGEROUS_FUNCTION,
|
|
789
|
+
[DangerousPatternType.INSECURE_RANDOM]: ThreatType.WEAK_RANDOM,
|
|
790
|
+
[DangerousPatternType.HARDCODED_SECRET]: ThreatType.HARDCODED_CREDENTIALS,
|
|
791
|
+
[DangerousPatternType.DANGEROUS_REGEX]: ThreatType.DANGEROUS_FUNCTION,
|
|
792
|
+
[DangerousPatternType.UNSAFE_ASSIGNMENT]: ThreatType.DANGEROUS_FUNCTION,
|
|
793
|
+
[DangerousPatternType.NETWORK_REQUEST]: ThreatType.SUSPICIOUS_NETWORK,
|
|
794
|
+
[DangerousPatternType.FILE_OPERATION]: ThreatType.PATH_TRAVERSAL,
|
|
795
|
+
[DangerousPatternType.CRYPTO_WEAKNESS]: ThreatType.INSECURE_CRYPTO
|
|
796
|
+
};
|
|
797
|
+
|
|
798
|
+
const severityMap: Record<DangerousPatternType, Severity> = {
|
|
799
|
+
[DangerousPatternType.CODE_EXECUTION]: Severity.CRITICAL,
|
|
800
|
+
[DangerousPatternType.COMMAND_INJECTION]: Severity.CRITICAL,
|
|
801
|
+
[DangerousPatternType.PROTOTYPE_POLLUTION]: Severity.HIGH,
|
|
802
|
+
[DangerousPatternType.XSS_SINK]: Severity.HIGH,
|
|
803
|
+
[DangerousPatternType.DYNAMIC_REQUIRE]: Severity.MEDIUM,
|
|
804
|
+
[DangerousPatternType.INSECURE_RANDOM]: Severity.MEDIUM,
|
|
805
|
+
[DangerousPatternType.HARDCODED_SECRET]: Severity.HIGH,
|
|
806
|
+
[DangerousPatternType.DANGEROUS_REGEX]: Severity.MEDIUM,
|
|
807
|
+
[DangerousPatternType.UNSAFE_ASSIGNMENT]: Severity.MEDIUM,
|
|
808
|
+
[DangerousPatternType.NETWORK_REQUEST]: Severity.MEDIUM,
|
|
809
|
+
[DangerousPatternType.FILE_OPERATION]: Severity.MEDIUM,
|
|
810
|
+
[DangerousPatternType.CRYPTO_WEAKNESS]: Severity.MEDIUM
|
|
811
|
+
};
|
|
812
|
+
|
|
813
|
+
const context = extractCodeContext(file.content, call.location.startLine, 2);
|
|
814
|
+
|
|
815
|
+
return {
|
|
816
|
+
id: generateId(),
|
|
817
|
+
title: `AST: ${call.name}`,
|
|
818
|
+
description: call.context || `Dangerous ${call.patternType.replace(/_/g, ' ')} detected via AST analysis`,
|
|
819
|
+
severity: severityMap[call.patternType] || Severity.MEDIUM,
|
|
820
|
+
threatType: threatTypeMap[call.patternType] || ThreatType.DANGEROUS_FUNCTION,
|
|
821
|
+
category: FindingCategory.VULNERABILITY,
|
|
822
|
+
location: {
|
|
823
|
+
file: file.relativePath,
|
|
824
|
+
startLine: call.location.startLine,
|
|
825
|
+
endLine: call.location.endLine,
|
|
826
|
+
startColumn: call.location.startColumn,
|
|
827
|
+
endColumn: call.location.endColumn
|
|
828
|
+
},
|
|
829
|
+
snippet: {
|
|
830
|
+
code: call.code,
|
|
831
|
+
contextBefore: context.contextBefore,
|
|
832
|
+
contextAfter: context.contextAfter
|
|
833
|
+
},
|
|
834
|
+
standards: getStandardsForThreat(threatTypeMap[call.patternType] || ThreatType.DANGEROUS_FUNCTION),
|
|
835
|
+
remediation: 'Review and fix the identified security issue.',
|
|
836
|
+
confidence: 85,
|
|
837
|
+
analyzer: `${this.name} (AST)`,
|
|
838
|
+
timestamp: new Date(),
|
|
839
|
+
tags: ['ast', call.patternType]
|
|
840
|
+
};
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
/**
|
|
844
|
+
* Convert TaintFlow to Finding
|
|
845
|
+
*/
|
|
846
|
+
private taintFlowToFinding(flow: TaintFlow, file: ScannedFile): Finding {
|
|
847
|
+
const sourceDesc = TaintAnalyzer.getSourceDescription(flow.source.type);
|
|
848
|
+
const sinkInfo = TaintAnalyzer.getSinkInfo(flow.sink.type);
|
|
849
|
+
|
|
850
|
+
const context = extractCodeContext(file.content, flow.sink.line, 2);
|
|
851
|
+
|
|
852
|
+
// Build detailed description with flow path
|
|
853
|
+
let description = `Tainted data from ${sourceDesc} flows to ${flow.sink.type} sink.`;
|
|
854
|
+
if (flow.propagation.length > 0) {
|
|
855
|
+
description += ` The data passes through ${flow.propagation.length} intermediate assignments.`;
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
return {
|
|
859
|
+
id: generateId(),
|
|
860
|
+
title: `Taint Flow: ${flow.source.type} → ${flow.sink.type}`,
|
|
861
|
+
description,
|
|
862
|
+
severity: flow.sink.severity,
|
|
863
|
+
threatType: flow.sink.threatType,
|
|
864
|
+
category: FindingCategory.VULNERABILITY,
|
|
865
|
+
location: {
|
|
866
|
+
file: file.relativePath,
|
|
867
|
+
startLine: flow.sink.line,
|
|
868
|
+
endLine: flow.sink.line
|
|
869
|
+
},
|
|
870
|
+
snippet: {
|
|
871
|
+
code: flow.sink.code,
|
|
872
|
+
contextBefore: context.contextBefore,
|
|
873
|
+
contextAfter: context.contextAfter
|
|
874
|
+
},
|
|
875
|
+
standards: getStandardsForThreat(flow.sink.threatType),
|
|
876
|
+
remediation: sinkInfo?.remediation || 'Validate and sanitize all user input before use.',
|
|
877
|
+
confidence: flow.confidence,
|
|
878
|
+
analyzer: `${this.name} (Taint)`,
|
|
879
|
+
timestamp: new Date(),
|
|
880
|
+
tags: ['taint-analysis', flow.source.type, flow.sink.type]
|
|
881
|
+
};
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
/**
|
|
885
|
+
* Convert MalwareMatch to Finding
|
|
886
|
+
*/
|
|
887
|
+
private malwareMatchToFinding(match: MalwareMatch, file: ScannedFile): Finding {
|
|
888
|
+
const context = extractCodeContext(file.content, match.line, 2);
|
|
889
|
+
|
|
890
|
+
return {
|
|
891
|
+
id: generateId(),
|
|
892
|
+
title: `Malware: ${match.name}`,
|
|
893
|
+
description: match.description,
|
|
894
|
+
severity: match.severity,
|
|
895
|
+
threatType: MalwareDetector.getThreatType(match.type),
|
|
896
|
+
category: FindingCategory.MALWARE,
|
|
897
|
+
location: {
|
|
898
|
+
file: file.relativePath,
|
|
899
|
+
startLine: match.line,
|
|
900
|
+
endLine: match.line
|
|
901
|
+
},
|
|
902
|
+
snippet: {
|
|
903
|
+
code: match.code,
|
|
904
|
+
contextBefore: context.contextBefore,
|
|
905
|
+
contextAfter: context.contextAfter
|
|
906
|
+
},
|
|
907
|
+
standards: getStandardsForThreat(MalwareDetector.getThreatType(match.type)),
|
|
908
|
+
remediation: match.remediation,
|
|
909
|
+
confidence: match.confidence,
|
|
910
|
+
analyzer: `${this.name} (Malware)`,
|
|
911
|
+
timestamp: new Date(),
|
|
912
|
+
tags: ['malware', match.type, ...(match.mitreAttack || [])]
|
|
913
|
+
};
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
/**
|
|
917
|
+
* Convert PackageJsonFinding to Finding
|
|
918
|
+
*/
|
|
919
|
+
private packageFindingToFinding(pkgFinding: PackageJsonFinding, file: ScannedFile): Finding {
|
|
920
|
+
return {
|
|
921
|
+
id: generateId(),
|
|
922
|
+
title: pkgFinding.name,
|
|
923
|
+
description: pkgFinding.description,
|
|
924
|
+
severity: pkgFinding.severity,
|
|
925
|
+
threatType: pkgFinding.threatType,
|
|
926
|
+
category: pkgFinding.category,
|
|
927
|
+
location: {
|
|
928
|
+
file: file.relativePath,
|
|
929
|
+
startLine: 1,
|
|
930
|
+
endLine: 1
|
|
931
|
+
},
|
|
932
|
+
snippet: {
|
|
933
|
+
code: `"${pkgFinding.field}": "${pkgFinding.value.substring(0, 100)}"`
|
|
934
|
+
},
|
|
935
|
+
standards: getStandardsForThreat(pkgFinding.threatType),
|
|
936
|
+
remediation: pkgFinding.remediation,
|
|
937
|
+
confidence: pkgFinding.confidence,
|
|
938
|
+
analyzer: `${this.name} (Package)`,
|
|
939
|
+
timestamp: new Date(),
|
|
940
|
+
tags: ['package-json', pkgFinding.type]
|
|
941
|
+
};
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
/**
|
|
945
|
+
* Deduplicate findings based on location and type
|
|
946
|
+
*/
|
|
947
|
+
private deduplicateFindings(findings: Finding[]): Finding[] {
|
|
948
|
+
const seen = new Map<string, Finding>();
|
|
949
|
+
|
|
950
|
+
for (const finding of findings) {
|
|
951
|
+
const key = `${finding.location.file}:${finding.location.startLine}:${finding.threatType}`;
|
|
952
|
+
|
|
953
|
+
if (!seen.has(key)) {
|
|
954
|
+
seen.set(key, finding);
|
|
955
|
+
} else {
|
|
956
|
+
// Keep the one with higher confidence
|
|
957
|
+
const existing = seen.get(key)!;
|
|
958
|
+
if (finding.confidence > existing.confidence) {
|
|
959
|
+
seen.set(key, finding);
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
return Array.from(seen.values());
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
/**
|
|
968
|
+
* Filter findings by minimum confidence
|
|
969
|
+
*/
|
|
970
|
+
private filterByConfidence(findings: Finding[]): Finding[] {
|
|
971
|
+
return findings.filter(f => f.confidence >= this.options.minConfidence!);
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
/**
|
|
975
|
+
* Create a timeout promise
|
|
976
|
+
*/
|
|
977
|
+
private timeout(ms: number): Promise<Finding[][]> {
|
|
978
|
+
return new Promise((_, reject) => {
|
|
979
|
+
setTimeout(() => reject(new Error('Analysis timeout')), ms);
|
|
980
|
+
});
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
export default JavaScriptAnalyzer;
|