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,766 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Installed Dependencies Scanner
|
|
4
|
+
* Scans installed packages (node_modules, vendor, venv) for malware
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.InstalledDependenciesScanner = void 0;
|
|
41
|
+
exports.scanInstalledDependencies = scanInstalledDependencies;
|
|
42
|
+
const fs = __importStar(require("fs"));
|
|
43
|
+
const path = __importStar(require("path"));
|
|
44
|
+
const malwarePatterns_1 = require("./malwarePatterns");
|
|
45
|
+
const types_1 = require("../types");
|
|
46
|
+
const types_2 = require("../../types");
|
|
47
|
+
const logger_1 = require("../../utils/logger");
|
|
48
|
+
const utils_1 = require("../../utils");
|
|
49
|
+
/**
|
|
50
|
+
* Default configuration for installed dependencies scanner
|
|
51
|
+
*/
|
|
52
|
+
const DEFAULT_CONFIG = {
|
|
53
|
+
maxFileSizeBytes: 5 * 1024 * 1024, // 5MB
|
|
54
|
+
fileExtensions: ['.js', '.ts', '.mjs', '.cjs', '.py', '.php', '.rb', '.sh', '.ps1', '.cmd', '.bat'],
|
|
55
|
+
verifyIntegrity: true,
|
|
56
|
+
scanPostInstallScripts: true,
|
|
57
|
+
maxDepth: 10,
|
|
58
|
+
verbose: false,
|
|
59
|
+
parallelScans: 4
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Folder configurations for different ecosystems
|
|
63
|
+
*/
|
|
64
|
+
const DEPENDENCY_FOLDERS = {
|
|
65
|
+
npm: ['node_modules'],
|
|
66
|
+
pip: ['venv', '.venv', 'env', '.env', 'site-packages', 'lib/python*/site-packages'],
|
|
67
|
+
composer: ['vendor'],
|
|
68
|
+
maven: ['.m2/repository'],
|
|
69
|
+
gradle: ['.gradle/caches/modules-2/files-2.1'],
|
|
70
|
+
nuget: ['packages', '.nuget/packages']
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Installed Dependencies Scanner Class
|
|
74
|
+
*/
|
|
75
|
+
class InstalledDependenciesScanner {
|
|
76
|
+
config;
|
|
77
|
+
scannedFiles = new Set();
|
|
78
|
+
stats;
|
|
79
|
+
constructor(config) {
|
|
80
|
+
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
81
|
+
this.stats = this.initializeStats();
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Run the installed dependencies scan
|
|
85
|
+
*/
|
|
86
|
+
async scan() {
|
|
87
|
+
const startTime = Date.now();
|
|
88
|
+
logger_1.logger.info('🔍 Starting installed dependencies scan...');
|
|
89
|
+
const scannedFolders = [];
|
|
90
|
+
const installedPackages = [];
|
|
91
|
+
const malwareFindings = [];
|
|
92
|
+
const integrityIssues = [];
|
|
93
|
+
const suspiciousScripts = [];
|
|
94
|
+
// Find and scan dependency folders
|
|
95
|
+
const foldersToScan = this.config.foldersToScan || this.findDependencyFolders();
|
|
96
|
+
for (const folderPath of foldersToScan) {
|
|
97
|
+
if (!fs.existsSync(folderPath))
|
|
98
|
+
continue;
|
|
99
|
+
logger_1.logger.info(`📂 Scanning: ${folderPath}`);
|
|
100
|
+
const folderInfo = await this.scanDependencyFolder(folderPath);
|
|
101
|
+
scannedFolders.push(folderInfo.scannedFolder);
|
|
102
|
+
installedPackages.push(...folderInfo.packages);
|
|
103
|
+
malwareFindings.push(...folderInfo.malwareFindings);
|
|
104
|
+
suspiciousScripts.push(...folderInfo.suspiciousScripts);
|
|
105
|
+
}
|
|
106
|
+
// Verify integrity if enabled
|
|
107
|
+
if (this.config.verifyIntegrity) {
|
|
108
|
+
const integrity = await this.verifyPackageIntegrity(installedPackages);
|
|
109
|
+
integrityIssues.push(...integrity);
|
|
110
|
+
}
|
|
111
|
+
// Update statistics
|
|
112
|
+
const endTime = Date.now();
|
|
113
|
+
this.stats.duration = endTime - startTime;
|
|
114
|
+
this.stats.totalFoldersScanned = scannedFolders.length;
|
|
115
|
+
this.stats.totalPackagesFound = installedPackages.length;
|
|
116
|
+
this.stats.malwareFindingsCount = malwareFindings.length;
|
|
117
|
+
this.stats.integrityIssuesCount = integrityIssues.length;
|
|
118
|
+
this.stats.suspiciousScriptsCount = suspiciousScripts.length;
|
|
119
|
+
// Count findings by severity
|
|
120
|
+
for (const finding of malwareFindings) {
|
|
121
|
+
this.stats.findingsBySeverity[finding.severity] =
|
|
122
|
+
(this.stats.findingsBySeverity[finding.severity] || 0) + 1;
|
|
123
|
+
}
|
|
124
|
+
logger_1.logger.info(`✅ Scan complete: ${malwareFindings.length} malware findings, ${integrityIssues.length} integrity issues`);
|
|
125
|
+
return {
|
|
126
|
+
scannedFolders,
|
|
127
|
+
installedPackages,
|
|
128
|
+
malwareFindings,
|
|
129
|
+
integrityIssues,
|
|
130
|
+
suspiciousScripts,
|
|
131
|
+
stats: this.stats,
|
|
132
|
+
timestamp: new Date()
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Find dependency folders in the project
|
|
137
|
+
*/
|
|
138
|
+
findDependencyFolders() {
|
|
139
|
+
const folders = [];
|
|
140
|
+
const projectPath = this.config.projectPath;
|
|
141
|
+
// Check for node_modules
|
|
142
|
+
const nodeModules = path.join(projectPath, 'node_modules');
|
|
143
|
+
if (fs.existsSync(nodeModules)) {
|
|
144
|
+
folders.push(nodeModules);
|
|
145
|
+
}
|
|
146
|
+
// Check for vendor (PHP)
|
|
147
|
+
const vendor = path.join(projectPath, 'vendor');
|
|
148
|
+
if (fs.existsSync(vendor)) {
|
|
149
|
+
folders.push(vendor);
|
|
150
|
+
}
|
|
151
|
+
// Check for Python virtual environments
|
|
152
|
+
for (const venvName of ['venv', '.venv', 'env', '.env']) {
|
|
153
|
+
const venv = path.join(projectPath, venvName);
|
|
154
|
+
if (fs.existsSync(venv)) {
|
|
155
|
+
// Look for site-packages
|
|
156
|
+
const sitePackages = this.findSitePackages(venv);
|
|
157
|
+
if (sitePackages) {
|
|
158
|
+
folders.push(sitePackages);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return folders;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Find site-packages in a Python virtual environment
|
|
166
|
+
*/
|
|
167
|
+
findSitePackages(venvPath) {
|
|
168
|
+
// Windows: venv/Lib/site-packages
|
|
169
|
+
const windowsPath = path.join(venvPath, 'Lib', 'site-packages');
|
|
170
|
+
if (fs.existsSync(windowsPath)) {
|
|
171
|
+
return windowsPath;
|
|
172
|
+
}
|
|
173
|
+
// Unix: venv/lib/pythonX.X/site-packages
|
|
174
|
+
const libPath = path.join(venvPath, 'lib');
|
|
175
|
+
if (fs.existsSync(libPath)) {
|
|
176
|
+
try {
|
|
177
|
+
const entries = fs.readdirSync(libPath);
|
|
178
|
+
for (const entry of entries) {
|
|
179
|
+
if (entry.startsWith('python')) {
|
|
180
|
+
const sitePackages = path.join(libPath, entry, 'site-packages');
|
|
181
|
+
if (fs.existsSync(sitePackages)) {
|
|
182
|
+
return sitePackages;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
catch {
|
|
188
|
+
// Ignore errors
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Scan a dependency folder
|
|
195
|
+
*/
|
|
196
|
+
async scanDependencyFolder(folderPath) {
|
|
197
|
+
const packages = [];
|
|
198
|
+
const malwareFindings = [];
|
|
199
|
+
const suspiciousScripts = [];
|
|
200
|
+
const folderType = this.getFolderType(folderPath);
|
|
201
|
+
const ecosystem = this.getEcosystemFromFolder(folderPath);
|
|
202
|
+
let totalSize = 0;
|
|
203
|
+
let filesScanned = 0;
|
|
204
|
+
// Get all packages in the folder
|
|
205
|
+
const packageDirs = await this.getPackageDirectories(folderPath, ecosystem);
|
|
206
|
+
for (const packageDir of packageDirs) {
|
|
207
|
+
const pkg = await this.parseInstalledPackage(packageDir, ecosystem);
|
|
208
|
+
if (pkg) {
|
|
209
|
+
packages.push(pkg);
|
|
210
|
+
totalSize += pkg.sizeBytes;
|
|
211
|
+
// Scan package files for malware
|
|
212
|
+
const findings = await this.scanPackageForMalware(pkg, packageDir);
|
|
213
|
+
malwareFindings.push(...findings.malwareFindings);
|
|
214
|
+
filesScanned += findings.filesScanned;
|
|
215
|
+
// Check post-install scripts
|
|
216
|
+
if (this.config.scanPostInstallScripts && pkg.hasPostInstallScripts) {
|
|
217
|
+
const scriptFindings = this.analyzePostInstallScripts(pkg);
|
|
218
|
+
suspiciousScripts.push(...scriptFindings);
|
|
219
|
+
}
|
|
220
|
+
// Update ecosystem stats
|
|
221
|
+
this.stats.packagesByEcosystem[ecosystem] =
|
|
222
|
+
(this.stats.packagesByEcosystem[ecosystem] || 0) + 1;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
this.stats.totalFilesScanned += filesScanned;
|
|
226
|
+
this.stats.totalBytesScanned += totalSize;
|
|
227
|
+
return {
|
|
228
|
+
scannedFolder: {
|
|
229
|
+
path: folderPath,
|
|
230
|
+
type: folderType,
|
|
231
|
+
ecosystem,
|
|
232
|
+
packageCount: packages.length,
|
|
233
|
+
totalSizeBytes: totalSize,
|
|
234
|
+
filesScanned
|
|
235
|
+
},
|
|
236
|
+
packages,
|
|
237
|
+
malwareFindings,
|
|
238
|
+
suspiciousScripts
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Get folder type from path
|
|
243
|
+
*/
|
|
244
|
+
getFolderType(folderPath) {
|
|
245
|
+
const folderName = path.basename(folderPath);
|
|
246
|
+
if (folderName === 'node_modules')
|
|
247
|
+
return 'node_modules';
|
|
248
|
+
if (folderName === 'vendor')
|
|
249
|
+
return 'vendor';
|
|
250
|
+
if (folderName === 'site-packages')
|
|
251
|
+
return 'site-packages';
|
|
252
|
+
if (['venv', '.venv', 'env', '.env'].includes(folderName))
|
|
253
|
+
return 'venv';
|
|
254
|
+
if (folderName === 'packages')
|
|
255
|
+
return 'packages';
|
|
256
|
+
return 'other';
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Get ecosystem from folder path
|
|
260
|
+
*/
|
|
261
|
+
getEcosystemFromFolder(folderPath) {
|
|
262
|
+
if (folderPath.includes('node_modules'))
|
|
263
|
+
return 'npm';
|
|
264
|
+
if (folderPath.includes('vendor'))
|
|
265
|
+
return 'composer';
|
|
266
|
+
if (folderPath.includes('site-packages') || folderPath.includes('venv'))
|
|
267
|
+
return 'pip';
|
|
268
|
+
if (folderPath.includes('.nuget') || folderPath.includes('packages'))
|
|
269
|
+
return 'nuget';
|
|
270
|
+
return 'npm'; // Default
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Get package directories in a dependency folder
|
|
274
|
+
*/
|
|
275
|
+
async getPackageDirectories(folderPath, ecosystem) {
|
|
276
|
+
const packageDirs = [];
|
|
277
|
+
try {
|
|
278
|
+
const entries = fs.readdirSync(folderPath, { withFileTypes: true });
|
|
279
|
+
for (const entry of entries) {
|
|
280
|
+
if (!entry.isDirectory())
|
|
281
|
+
continue;
|
|
282
|
+
const fullPath = path.join(folderPath, entry.name);
|
|
283
|
+
// Handle scoped packages for npm (@scope/package)
|
|
284
|
+
if (ecosystem === 'npm' && entry.name.startsWith('@')) {
|
|
285
|
+
const scopedEntries = fs.readdirSync(fullPath, { withFileTypes: true });
|
|
286
|
+
for (const scopedEntry of scopedEntries) {
|
|
287
|
+
if (scopedEntry.isDirectory()) {
|
|
288
|
+
packageDirs.push(path.join(fullPath, scopedEntry.name));
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
else if (!entry.name.startsWith('.')) {
|
|
293
|
+
packageDirs.push(fullPath);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
catch (error) {
|
|
298
|
+
logger_1.logger.debug(`Error reading directory ${folderPath}: ${error}`);
|
|
299
|
+
}
|
|
300
|
+
return packageDirs;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Parse an installed package directory
|
|
304
|
+
*/
|
|
305
|
+
async parseInstalledPackage(packageDir, ecosystem) {
|
|
306
|
+
try {
|
|
307
|
+
let name = path.basename(packageDir);
|
|
308
|
+
let version = 'unknown';
|
|
309
|
+
let metadata = {};
|
|
310
|
+
let hasPostInstallScripts = false;
|
|
311
|
+
let postInstallScripts = [];
|
|
312
|
+
// Handle scoped packages
|
|
313
|
+
const parentDir = path.basename(path.dirname(packageDir));
|
|
314
|
+
if (parentDir.startsWith('@')) {
|
|
315
|
+
name = `${parentDir}/${name}`;
|
|
316
|
+
}
|
|
317
|
+
// Parse package.json for npm
|
|
318
|
+
if (ecosystem === 'npm') {
|
|
319
|
+
const packageJsonPath = path.join(packageDir, 'package.json');
|
|
320
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
321
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
322
|
+
name = packageJson.name || name;
|
|
323
|
+
version = packageJson.version || version;
|
|
324
|
+
metadata = {
|
|
325
|
+
author: typeof packageJson.author === 'string' ? packageJson.author : packageJson.author?.name,
|
|
326
|
+
license: packageJson.license,
|
|
327
|
+
homepage: packageJson.homepage,
|
|
328
|
+
repository: typeof packageJson.repository === 'string' ? packageJson.repository : packageJson.repository?.url,
|
|
329
|
+
description: packageJson.description,
|
|
330
|
+
main: packageJson.main,
|
|
331
|
+
binaries: packageJson.bin ? Object.keys(packageJson.bin) : undefined
|
|
332
|
+
};
|
|
333
|
+
// Check for post-install scripts
|
|
334
|
+
const scripts = packageJson.scripts || {};
|
|
335
|
+
for (const scriptType of ['preinstall', 'install', 'postinstall', 'preuninstall', 'postuninstall']) {
|
|
336
|
+
if (scripts[scriptType]) {
|
|
337
|
+
hasPostInstallScripts = true;
|
|
338
|
+
const scriptInfo = this.analyzeScript(scriptType, scripts[scriptType], packageDir);
|
|
339
|
+
postInstallScripts.push(scriptInfo);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
// Parse for pip/Python
|
|
345
|
+
if (ecosystem === 'pip') {
|
|
346
|
+
// Try to find PKG-INFO or METADATA
|
|
347
|
+
const metadataPath = path.join(packageDir, 'PKG-INFO');
|
|
348
|
+
const distInfoDir = this.findDistInfoDir(packageDir);
|
|
349
|
+
if (distInfoDir) {
|
|
350
|
+
const metaPath = path.join(distInfoDir, 'METADATA');
|
|
351
|
+
if (fs.existsSync(metaPath)) {
|
|
352
|
+
const content = fs.readFileSync(metaPath, 'utf-8');
|
|
353
|
+
const parsed = this.parsePythonMetadata(content);
|
|
354
|
+
name = parsed.name || name;
|
|
355
|
+
version = parsed.version || version;
|
|
356
|
+
metadata = {
|
|
357
|
+
author: parsed.author,
|
|
358
|
+
license: parsed.license,
|
|
359
|
+
homepage: parsed.homepage,
|
|
360
|
+
description: parsed.summary
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
// Calculate size and file count
|
|
366
|
+
const sizeInfo = this.calculateDirectorySize(packageDir);
|
|
367
|
+
return {
|
|
368
|
+
name,
|
|
369
|
+
version,
|
|
370
|
+
ecosystem,
|
|
371
|
+
installPath: packageDir,
|
|
372
|
+
sizeBytes: sizeInfo.size,
|
|
373
|
+
fileCount: sizeInfo.fileCount,
|
|
374
|
+
hasPostInstallScripts,
|
|
375
|
+
postInstallScripts: postInstallScripts.length > 0 ? postInstallScripts : undefined,
|
|
376
|
+
metadata
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
catch (error) {
|
|
380
|
+
logger_1.logger.debug(`Error parsing package at ${packageDir}: ${error}`);
|
|
381
|
+
return null;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Find .dist-info directory for Python packages
|
|
386
|
+
*/
|
|
387
|
+
findDistInfoDir(packageDir) {
|
|
388
|
+
const parentDir = path.dirname(packageDir);
|
|
389
|
+
const packageName = path.basename(packageDir);
|
|
390
|
+
try {
|
|
391
|
+
const entries = fs.readdirSync(parentDir);
|
|
392
|
+
for (const entry of entries) {
|
|
393
|
+
if (entry.startsWith(packageName.replace(/-/g, '_')) && entry.endsWith('.dist-info')) {
|
|
394
|
+
return path.join(parentDir, entry);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
catch {
|
|
399
|
+
// Ignore
|
|
400
|
+
}
|
|
401
|
+
return null;
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Parse Python package metadata
|
|
405
|
+
*/
|
|
406
|
+
parsePythonMetadata(content) {
|
|
407
|
+
const result = {};
|
|
408
|
+
const lines = content.split('\n');
|
|
409
|
+
for (const line of lines) {
|
|
410
|
+
const match = line.match(/^([A-Za-z-]+):\s*(.+)$/);
|
|
411
|
+
if (match) {
|
|
412
|
+
const key = match[1].toLowerCase().replace(/-/g, '_');
|
|
413
|
+
result[key] = match[2].trim();
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
return {
|
|
417
|
+
name: result.name,
|
|
418
|
+
version: result.version,
|
|
419
|
+
author: result.author,
|
|
420
|
+
license: result.license,
|
|
421
|
+
homepage: result.home_page,
|
|
422
|
+
summary: result.summary
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Analyze a post-install script
|
|
427
|
+
*/
|
|
428
|
+
analyzeScript(type, command, packageDir) {
|
|
429
|
+
const riskIndicators = [];
|
|
430
|
+
let riskLevel = types_2.Severity.INFO;
|
|
431
|
+
let scriptContent;
|
|
432
|
+
let scriptPath;
|
|
433
|
+
// Check for file reference
|
|
434
|
+
const fileMatch = command.match(/node\s+([^\s]+)/);
|
|
435
|
+
if (fileMatch) {
|
|
436
|
+
const possiblePath = path.join(packageDir, fileMatch[1]);
|
|
437
|
+
if (fs.existsSync(possiblePath)) {
|
|
438
|
+
scriptPath = possiblePath;
|
|
439
|
+
try {
|
|
440
|
+
scriptContent = fs.readFileSync(possiblePath, 'utf-8');
|
|
441
|
+
}
|
|
442
|
+
catch {
|
|
443
|
+
// Ignore read errors
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
// Analyze command and content for suspicious patterns
|
|
448
|
+
const contentToAnalyze = scriptContent || command;
|
|
449
|
+
for (const pattern of malwarePatterns_1.SUSPICIOUS_SCRIPT_PATTERNS) {
|
|
450
|
+
if (pattern.test(contentToAnalyze)) {
|
|
451
|
+
riskIndicators.push(pattern.source);
|
|
452
|
+
if (riskLevel === types_2.Severity.INFO)
|
|
453
|
+
riskLevel = types_2.Severity.LOW;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
// Check for high-risk patterns
|
|
457
|
+
if (/curl.*\|.*sh|wget.*\|.*bash|rm\s+-rf/.test(contentToAnalyze)) {
|
|
458
|
+
riskLevel = types_2.Severity.CRITICAL;
|
|
459
|
+
}
|
|
460
|
+
else if (/eval|exec|subprocess|child_process/.test(contentToAnalyze)) {
|
|
461
|
+
riskLevel = types_2.Severity.HIGH;
|
|
462
|
+
}
|
|
463
|
+
else if (/http|fetch|request/.test(contentToAnalyze)) {
|
|
464
|
+
riskLevel = types_2.Severity.MEDIUM;
|
|
465
|
+
}
|
|
466
|
+
return {
|
|
467
|
+
type,
|
|
468
|
+
command,
|
|
469
|
+
scriptPath,
|
|
470
|
+
content: scriptContent,
|
|
471
|
+
riskLevel,
|
|
472
|
+
riskIndicators
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Analyze post-install scripts for a package
|
|
477
|
+
*/
|
|
478
|
+
analyzePostInstallScripts(pkg) {
|
|
479
|
+
const findings = [];
|
|
480
|
+
if (!pkg.postInstallScripts)
|
|
481
|
+
return findings;
|
|
482
|
+
for (const script of pkg.postInstallScripts) {
|
|
483
|
+
if (script.riskLevel !== 'info' && script.riskIndicators.length > 0) {
|
|
484
|
+
findings.push({
|
|
485
|
+
packageName: pkg.name,
|
|
486
|
+
script,
|
|
487
|
+
severity: script.riskLevel,
|
|
488
|
+
description: `Suspicious ${script.type} script detected in package ${pkg.name}`,
|
|
489
|
+
riskIndicators: script.riskIndicators
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
return findings;
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* Calculate directory size
|
|
497
|
+
*/
|
|
498
|
+
calculateDirectorySize(dirPath) {
|
|
499
|
+
let size = 0;
|
|
500
|
+
let fileCount = 0;
|
|
501
|
+
const calculate = (dir, depth = 0) => {
|
|
502
|
+
if (depth > 5)
|
|
503
|
+
return; // Limit recursion depth
|
|
504
|
+
try {
|
|
505
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
506
|
+
for (const entry of entries) {
|
|
507
|
+
const fullPath = path.join(dir, entry.name);
|
|
508
|
+
if (entry.isDirectory()) {
|
|
509
|
+
calculate(fullPath, depth + 1);
|
|
510
|
+
}
|
|
511
|
+
else if (entry.isFile()) {
|
|
512
|
+
const stats = fs.statSync(fullPath);
|
|
513
|
+
size += stats.size;
|
|
514
|
+
fileCount++;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
catch {
|
|
519
|
+
// Ignore permission errors
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
calculate(dirPath);
|
|
523
|
+
return { size, fileCount };
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Scan a package for malware
|
|
527
|
+
*/
|
|
528
|
+
async scanPackageForMalware(pkg, packageDir) {
|
|
529
|
+
const malwareFindings = [];
|
|
530
|
+
let filesScanned = 0;
|
|
531
|
+
const scanFile = (filePath) => {
|
|
532
|
+
if (this.scannedFiles.has(filePath))
|
|
533
|
+
return;
|
|
534
|
+
this.scannedFiles.add(filePath);
|
|
535
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
536
|
+
if (!this.config.fileExtensions?.includes(ext))
|
|
537
|
+
return;
|
|
538
|
+
try {
|
|
539
|
+
const stats = fs.statSync(filePath);
|
|
540
|
+
if (stats.size > (this.config.maxFileSizeBytes ?? 5 * 1024 * 1024))
|
|
541
|
+
return;
|
|
542
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
543
|
+
filesScanned++;
|
|
544
|
+
// Get patterns applicable to this file type
|
|
545
|
+
const patterns = (0, malwarePatterns_1.getPatternsForFile)(filePath);
|
|
546
|
+
for (const pattern of patterns) {
|
|
547
|
+
for (const regex of pattern.patterns) {
|
|
548
|
+
// Reset regex state
|
|
549
|
+
regex.lastIndex = 0;
|
|
550
|
+
const match = regex.exec(content);
|
|
551
|
+
if (match) {
|
|
552
|
+
// Find line number
|
|
553
|
+
const beforeMatch = content.substring(0, match.index);
|
|
554
|
+
const lineNumber = beforeMatch.split('\n').length;
|
|
555
|
+
// Extract code snippet
|
|
556
|
+
const lines = content.split('\n');
|
|
557
|
+
const startLine = Math.max(0, lineNumber - 2);
|
|
558
|
+
const endLine = Math.min(lines.length, lineNumber + 2);
|
|
559
|
+
const codeSnippet = lines.slice(startLine, endLine).join('\n');
|
|
560
|
+
malwareFindings.push({
|
|
561
|
+
id: (0, utils_1.generateId)(),
|
|
562
|
+
package: pkg,
|
|
563
|
+
filePath,
|
|
564
|
+
lineNumber,
|
|
565
|
+
indicators: [pattern.indicator],
|
|
566
|
+
severity: pattern.severity,
|
|
567
|
+
title: pattern.name,
|
|
568
|
+
description: pattern.description,
|
|
569
|
+
matchedPattern: pattern.id,
|
|
570
|
+
codeSnippet,
|
|
571
|
+
standards: pattern.standards,
|
|
572
|
+
recommendation: this.getRecommendation(pattern.indicator),
|
|
573
|
+
confidence: pattern.confidence,
|
|
574
|
+
timestamp: new Date()
|
|
575
|
+
});
|
|
576
|
+
// Only report first match per pattern per file
|
|
577
|
+
break;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
catch (error) {
|
|
583
|
+
// Ignore file read errors (binary files, etc.)
|
|
584
|
+
}
|
|
585
|
+
};
|
|
586
|
+
const scanDirectory = (dir, depth = 0) => {
|
|
587
|
+
if (depth > (this.config.maxDepth ?? 10))
|
|
588
|
+
return;
|
|
589
|
+
try {
|
|
590
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
591
|
+
for (const entry of entries) {
|
|
592
|
+
const fullPath = path.join(dir, entry.name);
|
|
593
|
+
if (entry.isDirectory()) {
|
|
594
|
+
// Skip nested node_modules
|
|
595
|
+
if (entry.name === 'node_modules' && depth > 0)
|
|
596
|
+
continue;
|
|
597
|
+
scanDirectory(fullPath, depth + 1);
|
|
598
|
+
}
|
|
599
|
+
else if (entry.isFile()) {
|
|
600
|
+
scanFile(fullPath);
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
catch {
|
|
605
|
+
// Ignore permission errors
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
scanDirectory(packageDir);
|
|
609
|
+
return { malwareFindings, filesScanned };
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* Get recommendation for malware indicator
|
|
613
|
+
*/
|
|
614
|
+
getRecommendation(indicator) {
|
|
615
|
+
const recommendations = {
|
|
616
|
+
[types_1.MalwareIndicator.BACKDOOR]: 'Remove this package immediately. It contains backdoor code that allows remote access.',
|
|
617
|
+
[types_1.MalwareIndicator.CRYPTOMINER]: 'Remove this package. It contains cryptocurrency mining code that steals computational resources.',
|
|
618
|
+
[types_1.MalwareIndicator.STEALER]: 'Remove this package immediately. It attempts to steal credentials or sensitive data.',
|
|
619
|
+
[types_1.MalwareIndicator.LOADER]: 'Remove this package. It downloads and executes code from external sources.',
|
|
620
|
+
[types_1.MalwareIndicator.OBFUSCATED]: 'Review this package carefully. Heavily obfuscated code may hide malicious functionality.',
|
|
621
|
+
[types_1.MalwareIndicator.DATA_EXFILTRATION]: 'Remove this package. It attempts to send sensitive data to external servers.',
|
|
622
|
+
[types_1.MalwareIndicator.KNOWN_MALWARE]: 'Remove this package immediately. It has been identified as known malware.'
|
|
623
|
+
};
|
|
624
|
+
return recommendations[indicator] || 'Review this package and consider removing it.';
|
|
625
|
+
}
|
|
626
|
+
/**
|
|
627
|
+
* Verify package integrity
|
|
628
|
+
*/
|
|
629
|
+
async verifyPackageIntegrity(packages) {
|
|
630
|
+
const issues = [];
|
|
631
|
+
// Try to load lock file
|
|
632
|
+
const lockFileData = await this.loadLockFile();
|
|
633
|
+
if (!lockFileData) {
|
|
634
|
+
logger_1.logger.debug('No lock file found for integrity verification');
|
|
635
|
+
return issues;
|
|
636
|
+
}
|
|
637
|
+
for (const pkg of packages) {
|
|
638
|
+
const expectedVersion = lockFileData.packages[pkg.name];
|
|
639
|
+
if (!expectedVersion) {
|
|
640
|
+
// Package not in lock file
|
|
641
|
+
issues.push({
|
|
642
|
+
packageName: pkg.name,
|
|
643
|
+
issueType: 'unexpected_package',
|
|
644
|
+
severity: types_2.Severity.MEDIUM,
|
|
645
|
+
description: `Package ${pkg.name} is installed but not in lock file`,
|
|
646
|
+
actual: pkg.version
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
else if (expectedVersion !== pkg.version) {
|
|
650
|
+
// Version mismatch
|
|
651
|
+
issues.push({
|
|
652
|
+
packageName: pkg.name,
|
|
653
|
+
issueType: 'version_mismatch',
|
|
654
|
+
severity: types_2.Severity.HIGH,
|
|
655
|
+
description: `Package ${pkg.name} version mismatch - possible tampering`,
|
|
656
|
+
expected: expectedVersion,
|
|
657
|
+
actual: pkg.version
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
// Update package integrity status
|
|
661
|
+
pkg.integrityStatus = {
|
|
662
|
+
status: expectedVersion === pkg.version ? 'verified' :
|
|
663
|
+
expectedVersion ? 'mismatch' : 'unknown',
|
|
664
|
+
expectedVersion,
|
|
665
|
+
installedVersion: pkg.version
|
|
666
|
+
};
|
|
667
|
+
}
|
|
668
|
+
// Check for missing packages
|
|
669
|
+
for (const [pkgName, version] of Object.entries(lockFileData.packages)) {
|
|
670
|
+
const installed = packages.find(p => p.name === pkgName);
|
|
671
|
+
if (!installed) {
|
|
672
|
+
issues.push({
|
|
673
|
+
packageName: pkgName,
|
|
674
|
+
issueType: 'missing_package',
|
|
675
|
+
severity: types_2.Severity.LOW,
|
|
676
|
+
description: `Package ${pkgName} is in lock file but not installed`,
|
|
677
|
+
expected: version
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
return issues;
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* Load lock file data
|
|
685
|
+
*/
|
|
686
|
+
async loadLockFile() {
|
|
687
|
+
const projectPath = this.config.projectPath;
|
|
688
|
+
const packages = {};
|
|
689
|
+
// Try package-lock.json
|
|
690
|
+
const packageLockPath = path.join(projectPath, 'package-lock.json');
|
|
691
|
+
if (fs.existsSync(packageLockPath)) {
|
|
692
|
+
try {
|
|
693
|
+
const lockFile = JSON.parse(fs.readFileSync(packageLockPath, 'utf-8'));
|
|
694
|
+
// Handle npm v3 format
|
|
695
|
+
if (lockFile.packages) {
|
|
696
|
+
for (const [key, value] of Object.entries(lockFile.packages)) {
|
|
697
|
+
if (key && key !== '') {
|
|
698
|
+
const name = key.replace(/^node_modules\//, '');
|
|
699
|
+
packages[name] = value.version;
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
// Handle npm v1/v2 format
|
|
704
|
+
if (lockFile.dependencies) {
|
|
705
|
+
for (const [name, value] of Object.entries(lockFile.dependencies)) {
|
|
706
|
+
packages[name] = value.version;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
return { packages };
|
|
710
|
+
}
|
|
711
|
+
catch {
|
|
712
|
+
logger_1.logger.debug('Error parsing package-lock.json');
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
// Try yarn.lock (simplified parsing)
|
|
716
|
+
const yarnLockPath = path.join(projectPath, 'yarn.lock');
|
|
717
|
+
if (fs.existsSync(yarnLockPath)) {
|
|
718
|
+
try {
|
|
719
|
+
const content = fs.readFileSync(yarnLockPath, 'utf-8');
|
|
720
|
+
const lines = content.split('\n');
|
|
721
|
+
let currentPackage = '';
|
|
722
|
+
for (const line of lines) {
|
|
723
|
+
const pkgMatch = line.match(/^"?(@?[^@\s]+)@/);
|
|
724
|
+
if (pkgMatch) {
|
|
725
|
+
currentPackage = pkgMatch[1];
|
|
726
|
+
}
|
|
727
|
+
const versionMatch = line.match(/^\s+version:?\s+"?([^"\s]+)"?/);
|
|
728
|
+
if (versionMatch && currentPackage) {
|
|
729
|
+
packages[currentPackage] = versionMatch[1];
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
return { packages };
|
|
733
|
+
}
|
|
734
|
+
catch {
|
|
735
|
+
logger_1.logger.debug('Error parsing yarn.lock');
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
return null;
|
|
739
|
+
}
|
|
740
|
+
/**
|
|
741
|
+
* Initialize statistics
|
|
742
|
+
*/
|
|
743
|
+
initializeStats() {
|
|
744
|
+
return {
|
|
745
|
+
totalFoldersScanned: 0,
|
|
746
|
+
totalPackagesFound: 0,
|
|
747
|
+
totalFilesScanned: 0,
|
|
748
|
+
totalBytesScanned: 0,
|
|
749
|
+
malwareFindingsCount: 0,
|
|
750
|
+
integrityIssuesCount: 0,
|
|
751
|
+
suspiciousScriptsCount: 0,
|
|
752
|
+
packagesByEcosystem: {},
|
|
753
|
+
findingsBySeverity: {},
|
|
754
|
+
duration: 0
|
|
755
|
+
};
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
exports.InstalledDependenciesScanner = InstalledDependenciesScanner;
|
|
759
|
+
/**
|
|
760
|
+
* Quick scan function
|
|
761
|
+
*/
|
|
762
|
+
async function scanInstalledDependencies(projectPath) {
|
|
763
|
+
const scanner = new InstalledDependenciesScanner({ projectPath });
|
|
764
|
+
return scanner.scan();
|
|
765
|
+
}
|
|
766
|
+
//# sourceMappingURL=installedScanner.js.map
|