@contrast/contrast 2.0.2-beta.3 → 2.0.2-beta.4
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 +51 -1
- package/dist/audit/catalogueApplication/catalogueApplication.js +6 -10
- package/dist/audit/catalogueApplication/catalogueApplication.js.map +1 -0
- package/dist/audit/languageAnalysisEngine/commonApi.js +3 -6
- package/dist/audit/languageAnalysisEngine/commonApi.js.map +1 -0
- package/dist/audit/languageAnalysisEngine/filterProjectPath.js +1 -0
- package/dist/audit/languageAnalysisEngine/filterProjectPath.js.map +1 -0
- package/dist/audit/languageAnalysisEngine/getProjectRootFilenames.js +9 -12
- package/dist/audit/languageAnalysisEngine/getProjectRootFilenames.js.map +1 -0
- package/dist/audit/languageAnalysisEngine/sendSnapshot.js +15 -19
- package/dist/audit/languageAnalysisEngine/sendSnapshot.js.map +1 -0
- package/dist/audit/nodeAnalysisEngine/parseYarn2LockFileContents.js +9 -9
- package/dist/audit/nodeAnalysisEngine/parseYarn2LockFileContents.js.map +1 -0
- package/dist/audit/report/commonReportingFunctions.js +33 -48
- package/dist/audit/report/commonReportingFunctions.js.map +1 -0
- package/dist/audit/report/models/reportGuidanceModel.js +2 -5
- package/dist/audit/report/models/reportGuidanceModel.js.map +1 -0
- package/dist/audit/report/models/reportLibraryModel.js +3 -7
- package/dist/audit/report/models/reportLibraryModel.js.map +1 -0
- package/dist/audit/report/models/reportListModel.js +4 -9
- package/dist/audit/report/models/reportListModel.js.map +1 -0
- package/dist/audit/report/models/reportOutputModel.js +4 -9
- package/dist/audit/report/models/reportOutputModel.js.map +1 -0
- package/dist/audit/report/models/reportSeverityModel.js +2 -5
- package/dist/audit/report/models/reportSeverityModel.js.map +1 -0
- package/dist/audit/report/models/severityCountModel.js +3 -5
- package/dist/audit/report/models/severityCountModel.js.map +1 -0
- package/dist/audit/report/reportingFeature.js +27 -55
- package/dist/audit/report/reportingFeature.js.map +1 -0
- package/dist/audit/report/utils/reportUtils.js +28 -59
- package/dist/audit/report/utils/reportUtils.js.map +1 -0
- package/dist/audit/save.js +14 -16
- package/dist/audit/save.js.map +1 -0
- package/dist/cliConstants.js +17 -18
- package/dist/cliConstants.js.map +1 -0
- package/dist/commands/audit/auditConfig.js +7 -10
- package/dist/commands/audit/auditConfig.js.map +1 -0
- package/dist/commands/audit/auditController.js +9 -13
- package/dist/commands/audit/auditController.js.map +1 -0
- package/dist/commands/audit/help.js +23 -25
- package/dist/commands/audit/help.js.map +1 -0
- package/dist/commands/audit/processAudit.js +9 -12
- package/dist/commands/audit/processAudit.js.map +1 -0
- package/dist/commands/audit/saveFile.js +3 -6
- package/dist/commands/audit/saveFile.js.map +1 -0
- package/dist/commands/auth/auth.js +25 -24
- package/dist/commands/auth/auth.js.map +1 -0
- package/dist/commands/config/config.js +12 -13
- package/dist/commands/config/config.js.map +1 -0
- package/dist/commands/github/fingerprintConfig.js +8 -11
- package/dist/commands/github/fingerprintConfig.js.map +1 -0
- package/dist/commands/github/processFingerprint.js +12 -15
- package/dist/commands/github/processFingerprint.js.map +1 -0
- package/dist/commands/github/projectGroup.js +25 -32
- package/dist/commands/github/projectGroup.js.map +1 -0
- package/dist/commands/github/repoServices.js +11 -21
- package/dist/commands/github/repoServices.js.map +1 -0
- package/dist/commands/learn/learn.js +3 -6
- package/dist/commands/learn/learn.js.map +1 -0
- package/dist/commands/learn/processLearn.js +3 -6
- package/dist/commands/learn/processLearn.js.map +1 -0
- package/dist/commands/scan/processScan.js +11 -14
- package/dist/commands/scan/processScan.js.map +1 -0
- package/dist/common/HTTPClient.js +123 -94
- package/dist/common/HTTPClient.js.map +1 -0
- package/dist/common/autoDetection.js +26 -33
- package/dist/common/autoDetection.js.map +1 -0
- package/dist/common/baseRequest.js +14 -18
- package/dist/common/baseRequest.js.map +1 -0
- package/dist/common/commonHelp.js +13 -13
- package/dist/common/commonHelp.js.map +1 -0
- package/dist/common/errorHandling.js +30 -39
- package/dist/common/errorHandling.js.map +1 -0
- package/dist/common/fail.js +6 -12
- package/dist/common/fail.js.map +1 -0
- package/dist/common/versionChecker.js +16 -19
- package/dist/common/versionChecker.js.map +1 -0
- package/dist/constants/constants.js +44 -65
- package/dist/constants/constants.js.map +1 -0
- package/dist/constants/lambda.js +8 -5
- package/dist/constants/lambda.js.map +1 -0
- package/dist/constants/locales.js +6 -9
- package/dist/constants/locales.js.map +1 -0
- package/dist/index.js +36 -39
- package/dist/index.js.map +1 -0
- package/dist/lambda/analytics.js +6 -9
- package/dist/lambda/analytics.js.map +1 -0
- package/dist/lambda/arn.js +6 -9
- package/dist/lambda/arn.js.map +1 -0
- package/dist/lambda/aws.js +29 -34
- package/dist/lambda/aws.js.map +1 -0
- package/dist/lambda/cliError.js +13 -41
- package/dist/lambda/cliError.js.map +1 -0
- package/dist/lambda/constants.js +3 -4
- package/dist/lambda/constants.js.map +1 -0
- package/dist/lambda/help.js +39 -44
- package/dist/lambda/help.js.map +1 -0
- package/dist/lambda/lambda.js +61 -65
- package/dist/lambda/lambda.js.map +1 -0
- package/dist/lambda/lambdaUtils.js +38 -32
- package/dist/lambda/lambdaUtils.js.map +1 -0
- package/dist/lambda/logUtils.js +21 -17
- package/dist/lambda/logUtils.js.map +1 -0
- package/dist/lambda/scanDetailCompletion.js +19 -25
- package/dist/lambda/scanDetailCompletion.js.map +1 -0
- package/dist/lambda/scanRequest.js +34 -41
- package/dist/lambda/scanRequest.js.map +1 -0
- package/dist/lambda/scanResults.js +8 -10
- package/dist/lambda/scanResults.js.map +1 -0
- package/dist/lambda/types.js +5 -7
- package/dist/lambda/types.js.map +1 -0
- package/dist/lambda/utils.js +33 -35
- package/dist/lambda/utils.js.map +1 -0
- package/dist/sbom/generateSbom.js +6 -10
- package/dist/sbom/generateSbom.js.map +1 -0
- package/dist/scaAnalysis/common/auditReport.js +8 -12
- package/dist/scaAnalysis/common/auditReport.js.map +1 -0
- package/dist/scaAnalysis/common/commonReportingFunctionsSca.js +26 -32
- package/dist/scaAnalysis/common/commonReportingFunctionsSca.js.map +1 -0
- package/dist/scaAnalysis/common/formatMessage.js +8 -17
- package/dist/scaAnalysis/common/formatMessage.js.map +1 -0
- package/dist/scaAnalysis/common/models/ScaReportModel.js +4 -9
- package/dist/scaAnalysis/common/models/ScaReportModel.js.map +1 -0
- package/dist/scaAnalysis/common/scaParserForGoAndJava.js +10 -9
- package/dist/scaAnalysis/common/scaParserForGoAndJava.js.map +1 -0
- package/dist/scaAnalysis/common/scaServicesUpload.js +21 -22
- package/dist/scaAnalysis/common/scaServicesUpload.js.map +1 -0
- package/dist/scaAnalysis/common/treeUpload.js +7 -10
- package/dist/scaAnalysis/common/treeUpload.js.map +1 -0
- package/dist/scaAnalysis/common/utils/reportUtilsSca.js +21 -29
- package/dist/scaAnalysis/common/utils/reportUtilsSca.js.map +1 -0
- package/dist/scaAnalysis/dotnet/analysis.js +12 -18
- package/dist/scaAnalysis/dotnet/analysis.js.map +1 -0
- package/dist/scaAnalysis/dotnet/index.js +4 -7
- package/dist/scaAnalysis/dotnet/index.js.map +1 -0
- package/dist/scaAnalysis/go/goAnalysis.js +8 -11
- package/dist/scaAnalysis/go/goAnalysis.js.map +1 -0
- package/dist/scaAnalysis/go/goParseDeps.js +9 -7
- package/dist/scaAnalysis/go/goParseDeps.js.map +1 -0
- package/dist/scaAnalysis/go/goReadDepFile.js +10 -8
- package/dist/scaAnalysis/go/goReadDepFile.js.map +1 -0
- package/dist/scaAnalysis/java/analysis.js +23 -20
- package/dist/scaAnalysis/java/analysis.js.map +1 -0
- package/dist/scaAnalysis/java/index.js +7 -10
- package/dist/scaAnalysis/java/index.js.map +1 -0
- package/dist/scaAnalysis/java/javaBuildDepsParser.js +43 -43
- package/dist/scaAnalysis/java/javaBuildDepsParser.js.map +1 -0
- package/dist/scaAnalysis/javascript/analysis.js +16 -20
- package/dist/scaAnalysis/javascript/analysis.js.map +1 -0
- package/dist/scaAnalysis/javascript/index.js +17 -19
- package/dist/scaAnalysis/javascript/index.js.map +1 -0
- package/dist/scaAnalysis/javascript/scaServiceParser.js +8 -15
- package/dist/scaAnalysis/javascript/scaServiceParser.js.map +1 -0
- package/dist/scaAnalysis/legacy/legacyFlow.js +13 -15
- package/dist/scaAnalysis/legacy/legacyFlow.js.map +1 -0
- package/dist/scaAnalysis/php/analysis.js +15 -16
- package/dist/scaAnalysis/php/analysis.js.map +1 -0
- package/dist/scaAnalysis/php/index.js +5 -8
- package/dist/scaAnalysis/php/index.js.map +1 -0
- package/dist/scaAnalysis/php/phpNewServicesMapper.js +9 -12
- package/dist/scaAnalysis/php/phpNewServicesMapper.js.map +1 -0
- package/dist/scaAnalysis/processServicesFlow.js +50 -25
- package/dist/scaAnalysis/processServicesFlow.js.map +1 -0
- package/dist/scaAnalysis/python/analysis.js +16 -23
- package/dist/scaAnalysis/python/analysis.js.map +1 -0
- package/dist/scaAnalysis/python/index.js +4 -7
- package/dist/scaAnalysis/python/index.js.map +1 -0
- package/dist/scaAnalysis/repoMode/gradleParser.js +7 -13
- package/dist/scaAnalysis/repoMode/gradleParser.js.map +1 -0
- package/dist/scaAnalysis/repoMode/index.js +9 -12
- package/dist/scaAnalysis/repoMode/index.js.map +1 -0
- package/dist/scaAnalysis/repoMode/mavenParser.js +12 -12
- package/dist/scaAnalysis/repoMode/mavenParser.js.map +1 -0
- package/dist/scaAnalysis/ruby/analysis.js +32 -46
- package/dist/scaAnalysis/ruby/analysis.js.map +1 -0
- package/dist/scaAnalysis/ruby/index.js +5 -8
- package/dist/scaAnalysis/ruby/index.js.map +1 -0
- package/dist/scaAnalysis/scaAnalysis.js +49 -51
- package/dist/scaAnalysis/scaAnalysis.js.map +1 -0
- package/dist/scan/fileUtils.js +27 -36
- package/dist/scan/fileUtils.js.map +1 -0
- package/dist/scan/formatScanOutput.js +47 -61
- package/dist/scan/formatScanOutput.js.map +1 -0
- package/dist/scan/help.js +8 -11
- package/dist/scan/help.js.map +1 -0
- package/dist/scan/models/groupedResultsModel.js +2 -5
- package/dist/scan/models/groupedResultsModel.js.map +1 -0
- package/dist/scan/models/resultContentModel.js +2 -2
- package/dist/scan/models/resultContentModel.js.map +1 -0
- package/dist/scan/models/scanResultsModel.js +2 -5
- package/dist/scan/models/scanResultsModel.js.map +1 -0
- package/dist/scan/populateProjectIdAndProjectName.js +9 -12
- package/dist/scan/populateProjectIdAndProjectName.js.map +1 -0
- package/dist/scan/saveResults.js +3 -6
- package/dist/scan/saveResults.js.map +1 -0
- package/dist/scan/scan.js +24 -31
- package/dist/scan/scan.js.map +1 -0
- package/dist/scan/scanConfig.js +14 -12
- package/dist/scan/scanConfig.js.map +1 -0
- package/dist/scan/scanController.js +17 -20
- package/dist/scan/scanController.js.map +1 -0
- package/dist/scan/scanResults.js +27 -34
- package/dist/scan/scanResults.js.map +1 -0
- package/dist/telemetry/telemetry.js +29 -59
- package/dist/telemetry/telemetry.js.map +1 -0
- package/dist/utils/capabilities.js +1 -0
- package/dist/utils/capabilities.js.map +1 -0
- package/dist/utils/commonApi.js +15 -24
- package/dist/utils/commonApi.js.map +1 -0
- package/dist/utils/filterProjectPath.js +1 -0
- package/dist/utils/filterProjectPath.js.map +1 -0
- package/dist/utils/generalAPI.js +11 -17
- package/dist/utils/generalAPI.js.map +1 -0
- package/dist/utils/getConfig.js +7 -13
- package/dist/utils/getConfig.js.map +1 -0
- package/dist/utils/oraWrapper.js +7 -14
- package/dist/utils/oraWrapper.js.map +1 -0
- package/dist/utils/paramsUtil/commandlineParams.js +2 -5
- package/dist/utils/paramsUtil/commandlineParams.js.map +1 -0
- package/dist/utils/paramsUtil/configStoreParams.js +9 -10
- package/dist/utils/paramsUtil/configStoreParams.js.map +1 -0
- package/dist/utils/paramsUtil/envVariableParams.js +2 -3
- package/dist/utils/paramsUtil/envVariableParams.js.map +1 -0
- package/dist/utils/paramsUtil/paramHandler.js +12 -13
- package/dist/utils/paramsUtil/paramHandler.js.map +1 -0
- package/dist/utils/parsedCLIOptions.js +4 -7
- package/dist/utils/parsedCLIOptions.js.map +1 -0
- package/dist/utils/requestUtils.js +7 -13
- package/dist/utils/requestUtils.js.map +1 -0
- package/dist/utils/saveFile.js +8 -11
- package/dist/utils/saveFile.js.map +1 -0
- package/dist/utils/validationCheck.js +5 -11
- package/dist/utils/validationCheck.js.map +1 -0
- package/package.json +32 -41
- package/.prettierignore +0 -1
- package/bin/contrast.js +0 -2
- package/dist/audit/languageAnalysisEngine/util/requestUtils.js +0 -14
- package/dist/lambda/__mocks__/aws.js +0 -21
- package/dist/lambda/__mocks__/lambdaConfig.json +0 -42
- package/src/audit/catalogueApplication/catalogueApplication.js +0 -51
- package/src/audit/languageAnalysisEngine/commonApi.js +0 -20
- package/src/audit/languageAnalysisEngine/filterProjectPath.js +0 -21
- package/src/audit/languageAnalysisEngine/getProjectRootFilenames.js +0 -36
- package/src/audit/languageAnalysisEngine/sendSnapshot.js +0 -57
- package/src/audit/languageAnalysisEngine/util/requestUtils.js +0 -17
- package/src/audit/nodeAnalysisEngine/parseYarn2LockFileContents.js +0 -63
- package/src/audit/report/commonReportingFunctions.js +0 -412
- package/src/audit/report/models/reportGuidanceModel.ts +0 -5
- package/src/audit/report/models/reportLibraryModel.ts +0 -30
- package/src/audit/report/models/reportListModel.ts +0 -49
- package/src/audit/report/models/reportOutputModel.ts +0 -29
- package/src/audit/report/models/reportSeverityModel.ts +0 -18
- package/src/audit/report/models/severityCountModel.ts +0 -22
- package/src/audit/report/reportingFeature.ts +0 -110
- package/src/audit/report/utils/reportUtils.ts +0 -165
- package/src/audit/save.js +0 -67
- package/src/cliConstants.js +0 -523
- package/src/commands/audit/auditConfig.js +0 -18
- package/src/commands/audit/auditController.js +0 -50
- package/src/commands/audit/help.js +0 -72
- package/src/commands/audit/processAudit.js +0 -34
- package/src/commands/audit/saveFile.js +0 -15
- package/src/commands/auth/auth.js +0 -146
- package/src/commands/config/config.js +0 -41
- package/src/commands/github/fingerprintConfig.js +0 -19
- package/src/commands/github/processFingerprint.js +0 -37
- package/src/commands/github/projectGroup.js +0 -298
- package/src/commands/github/repoServices.js +0 -122
- package/src/commands/learn/learn.js +0 -10
- package/src/commands/learn/processLearn.js +0 -13
- package/src/commands/scan/processScan.js +0 -42
- package/src/common/HTTPClient.js +0 -775
- package/src/common/autoDetection.js +0 -209
- package/src/common/baseRequest.ts +0 -83
- package/src/common/commonHelp.js +0 -53
- package/src/common/errorHandling.js +0 -157
- package/src/common/fail.js +0 -79
- package/src/common/versionChecker.js +0 -75
- package/src/constants/constants.js +0 -71
- package/src/constants/lambda.js +0 -85
- package/src/constants/locales.js +0 -365
- package/src/index.ts +0 -142
- package/src/lambda/__mocks__/aws.ts +0 -32
- package/src/lambda/__mocks__/lambdaConfig.json +0 -42
- package/src/lambda/analytics.ts +0 -9
- package/src/lambda/arn.ts +0 -33
- package/src/lambda/aws.ts +0 -248
- package/src/lambda/cliError.ts +0 -72
- package/src/lambda/constants.ts +0 -11
- package/src/lambda/help.ts +0 -92
- package/src/lambda/lambda.ts +0 -230
- package/src/lambda/lambdaUtils.ts +0 -111
- package/src/lambda/logUtils.ts +0 -64
- package/src/lambda/scanDetailCompletion.ts +0 -78
- package/src/lambda/scanRequest.ts +0 -169
- package/src/lambda/scanResults.ts +0 -29
- package/src/lambda/types.ts +0 -36
- package/src/lambda/utils.ts +0 -188
- package/src/sbom/generateSbom.ts +0 -45
- package/src/scaAnalysis/common/auditReport.js +0 -59
- package/src/scaAnalysis/common/commonReportingFunctionsSca.js +0 -276
- package/src/scaAnalysis/common/formatMessage.js +0 -67
- package/src/scaAnalysis/common/models/ScaReportModel.ts +0 -81
- package/src/scaAnalysis/common/scaParserForGoAndJava.js +0 -41
- package/src/scaAnalysis/common/scaServicesUpload.js +0 -159
- package/src/scaAnalysis/common/treeUpload.js +0 -51
- package/src/scaAnalysis/common/utils/reportUtilsSca.ts +0 -123
- package/src/scaAnalysis/dotnet/analysis.js +0 -72
- package/src/scaAnalysis/dotnet/index.js +0 -11
- package/src/scaAnalysis/go/goAnalysis.js +0 -26
- package/src/scaAnalysis/go/goParseDeps.js +0 -203
- package/src/scaAnalysis/go/goReadDepFile.js +0 -34
- package/src/scaAnalysis/java/analysis.js +0 -148
- package/src/scaAnalysis/java/index.js +0 -29
- package/src/scaAnalysis/java/javaBuildDepsParser.js +0 -439
- package/src/scaAnalysis/javascript/analysis.js +0 -111
- package/src/scaAnalysis/javascript/index.js +0 -104
- package/src/scaAnalysis/javascript/scaServiceParser.js +0 -151
- package/src/scaAnalysis/legacy/legacyFlow.js +0 -43
- package/src/scaAnalysis/php/analysis.js +0 -78
- package/src/scaAnalysis/php/index.js +0 -28
- package/src/scaAnalysis/php/phpNewServicesMapper.js +0 -77
- package/src/scaAnalysis/processServicesFlow.js +0 -126
- package/src/scaAnalysis/python/analysis.js +0 -93
- package/src/scaAnalysis/python/index.js +0 -16
- package/src/scaAnalysis/repoMode/gradleParser.js +0 -88
- package/src/scaAnalysis/repoMode/index.js +0 -21
- package/src/scaAnalysis/repoMode/mavenParser.js +0 -138
- package/src/scaAnalysis/ruby/analysis.js +0 -413
- package/src/scaAnalysis/ruby/index.js +0 -16
- package/src/scaAnalysis/scaAnalysis.js +0 -172
- package/src/scan/fileUtils.js +0 -218
- package/src/scan/formatScanOutput.ts +0 -225
- package/src/scan/help.js +0 -56
- package/src/scan/models/groupedResultsModel.ts +0 -20
- package/src/scan/models/resultContentModel.ts +0 -86
- package/src/scan/models/scanResultsModel.ts +0 -55
- package/src/scan/populateProjectIdAndProjectName.js +0 -73
- package/src/scan/saveResults.js +0 -14
- package/src/scan/scan.ts +0 -68
- package/src/scan/scanConfig.js +0 -58
- package/src/scan/scanController.js +0 -98
- package/src/scan/scanResults.js +0 -171
- package/src/telemetry/telemetry.ts +0 -154
- package/src/utils/capabilities.js +0 -12
- package/src/utils/commonApi.js +0 -103
- package/src/utils/filterProjectPath.js +0 -25
- package/src/utils/generalAPI.js +0 -52
- package/src/utils/getConfig.ts +0 -34
- package/src/utils/oraWrapper.js +0 -29
- package/src/utils/paramsUtil/commandlineParams.js +0 -12
- package/src/utils/paramsUtil/configStoreParams.js +0 -19
- package/src/utils/paramsUtil/envVariableParams.js +0 -10
- package/src/utils/paramsUtil/paramHandler.js +0 -38
- package/src/utils/parsedCLIOptions.js +0 -32
- package/src/utils/requestUtils.js +0 -29
- package/src/utils/saveFile.js +0 -20
- package/src/utils/validationCheck.js +0 -39
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
const i18n = require('i18n')
|
|
2
|
-
const fileFinder = require('../scan/fileUtils')
|
|
3
|
-
const {
|
|
4
|
-
supportedLanguages: { JAVA, GO, PYTHON, RUBY, JAVASCRIPT, DOTNET }
|
|
5
|
-
} = require('../constants/constants')
|
|
6
|
-
const { shortenFilePath } = require('../scan/fileUtils')
|
|
7
|
-
|
|
8
|
-
const autoDetectFingerprintInfo = async (filePath, depth, config) => {
|
|
9
|
-
let complexObj = await fileFinder.findAllFiles(filePath, depth)
|
|
10
|
-
let result = []
|
|
11
|
-
let count = 0
|
|
12
|
-
complexObj.forEach(i => {
|
|
13
|
-
count++
|
|
14
|
-
if (!i.includes('package.json')) {
|
|
15
|
-
result.push({
|
|
16
|
-
name: shortenFilePath(i),
|
|
17
|
-
filePath: i,
|
|
18
|
-
id: count.toString(),
|
|
19
|
-
repositoryId: config.repositoryId,
|
|
20
|
-
projectGroupId: config.projectGroupId
|
|
21
|
-
})
|
|
22
|
-
}
|
|
23
|
-
})
|
|
24
|
-
return result
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const detectPackageManager = async array => {
|
|
28
|
-
array.forEach(i => {
|
|
29
|
-
if (i.filePath.includes('pom.xml')) {
|
|
30
|
-
i['language'] = JAVA
|
|
31
|
-
i['packageManager'] = 'MAVEN'
|
|
32
|
-
}
|
|
33
|
-
if (i.filePath.includes('build.gradle.kts')) {
|
|
34
|
-
i['language'] = JAVA
|
|
35
|
-
i['packageManager'] = 'GRADLE'
|
|
36
|
-
}
|
|
37
|
-
if (i.filePath.includes('build.gradle')) {
|
|
38
|
-
i['language'] = JAVA
|
|
39
|
-
i['packageManager'] = 'GRADLE'
|
|
40
|
-
}
|
|
41
|
-
if (i.filePath.includes('package-lock.json')) {
|
|
42
|
-
i['language'] = JAVASCRIPT
|
|
43
|
-
i['packageManager'] = 'NPM'
|
|
44
|
-
}
|
|
45
|
-
if (i.filePath.includes('yarn.lock')) {
|
|
46
|
-
i['language'] = JAVASCRIPT
|
|
47
|
-
i['packageManager'] = 'YARN'
|
|
48
|
-
}
|
|
49
|
-
if (i.filePath.includes('Pipfile')) {
|
|
50
|
-
i['language'] = PYTHON
|
|
51
|
-
i['packageManager'] = 'PYPI'
|
|
52
|
-
}
|
|
53
|
-
if (i.filePath.includes('csproj')) {
|
|
54
|
-
i['language'] = DOTNET
|
|
55
|
-
i['packageManager'] = 'NUGET'
|
|
56
|
-
}
|
|
57
|
-
if (i.filePath.includes('Gemfile')) {
|
|
58
|
-
i['language'] = RUBY
|
|
59
|
-
i['packageManager'] = 'RUBYGEMS'
|
|
60
|
-
}
|
|
61
|
-
if (i.filePath.includes('go.mod')) {
|
|
62
|
-
i['language'] = GO
|
|
63
|
-
i['packageManager'] = 'PKG'
|
|
64
|
-
}
|
|
65
|
-
})
|
|
66
|
-
return array
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const autoDetectFileAndLanguage = async configToUse => {
|
|
70
|
-
const entries = await fileFinder.findFile()
|
|
71
|
-
|
|
72
|
-
if (entries.length === 1) {
|
|
73
|
-
console.log(i18n.__('foundScanFile', entries[0]))
|
|
74
|
-
|
|
75
|
-
if (hasWhiteSpace(entries[0])) {
|
|
76
|
-
console.log(i18n.__('fileHasWhiteSpacesError'))
|
|
77
|
-
process.exit(1)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (fileFinder.fileIsEmpty(entries[0])) {
|
|
81
|
-
console.log(i18n.__('scanFileIsEmpty'))
|
|
82
|
-
process.exit(1)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
configToUse.file = entries[0]
|
|
86
|
-
if (configToUse.name === undefined) {
|
|
87
|
-
configToUse.name = entries[0]
|
|
88
|
-
}
|
|
89
|
-
} else {
|
|
90
|
-
errorOnFileDetection(entries)
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const autoDetectAuditFilesAndLanguages = async filePath => {
|
|
95
|
-
let languagesFound = []
|
|
96
|
-
|
|
97
|
-
console.log(i18n.__('searchingAuditFileDirectory', filePath))
|
|
98
|
-
|
|
99
|
-
await fileFinder.findFilesJava(languagesFound, filePath)
|
|
100
|
-
await fileFinder.findFilesJavascript(languagesFound, filePath)
|
|
101
|
-
await fileFinder.findFilesPython(languagesFound, filePath)
|
|
102
|
-
await fileFinder.findFilesGo(languagesFound, filePath)
|
|
103
|
-
await fileFinder.findFilesPhp(languagesFound, filePath)
|
|
104
|
-
await fileFinder.findFilesRuby(languagesFound, filePath)
|
|
105
|
-
await fileFinder.findFilesDotNet(languagesFound, filePath)
|
|
106
|
-
|
|
107
|
-
if (languagesFound) {
|
|
108
|
-
return languagesFound
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return []
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const hasWhiteSpace = s => {
|
|
115
|
-
const filename = s.split('/').pop()
|
|
116
|
-
return filename.indexOf(' ') >= 0
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const dealWithMultiJava = (filesFound, config, isFile) => {
|
|
120
|
-
if (isFile && filesFound[0] && filesFound[0].language === 'JAVA') {
|
|
121
|
-
return multiJavaFilePathFullySpecified(filesFound, config)
|
|
122
|
-
} else {
|
|
123
|
-
return multiJavaNoFilePathFullySpecified(filesFound)
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const multiJavaNoFilePathFullySpecified = filesFound => {
|
|
128
|
-
const hasMultiJava =
|
|
129
|
-
filesFound.filter(
|
|
130
|
-
data =>
|
|
131
|
-
Object.keys(data)[0] === JAVA &&
|
|
132
|
-
Object.values(data)[0].includes('build.gradle') &&
|
|
133
|
-
Object.values(data)[0].includes('pom.xml')
|
|
134
|
-
).length > 0
|
|
135
|
-
|
|
136
|
-
if (hasMultiJava) {
|
|
137
|
-
console.log('Multiple Java language dependency files detected')
|
|
138
|
-
console.log(
|
|
139
|
-
'Please use --file to audit one only. \nExample: contrast audit --file pom.xml'
|
|
140
|
-
)
|
|
141
|
-
process.exit(1)
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
return filesFound
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
const multiJavaFilePathFullySpecified = (filesFound, config) => {
|
|
148
|
-
const filteredFiles = filesFound[0].JAVA.filter(fileTypes =>
|
|
149
|
-
config.fileName.endsWith(fileTypes)
|
|
150
|
-
)
|
|
151
|
-
filesFound[0].JAVA = filteredFiles
|
|
152
|
-
filesFound[0].filePath = filteredFiles[0]
|
|
153
|
-
|
|
154
|
-
if (filteredFiles[0] === 'pom.xml') {
|
|
155
|
-
filesFound[0].packageManager = 'MAVEN'
|
|
156
|
-
} else {
|
|
157
|
-
filesFound[0].packageManager = 'GRADLE'
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
if (config.debug || config.verbose) {
|
|
161
|
-
console.log('\nAuto detection - detected multiple Java files')
|
|
162
|
-
console.log(
|
|
163
|
-
`\nAuto detection - using ${filesFound[0].filePath} as based on full file path`
|
|
164
|
-
)
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
return filesFound
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
const errorOnFileDetection = entries => {
|
|
171
|
-
if (entries.length > 1) {
|
|
172
|
-
console.log(i18n.__('searchingDirectoryScan'))
|
|
173
|
-
for (let file in entries) {
|
|
174
|
-
console.log('-', entries[file])
|
|
175
|
-
}
|
|
176
|
-
console.log('')
|
|
177
|
-
console.log(i18n.__('specifyFileScanError'))
|
|
178
|
-
} else {
|
|
179
|
-
console.log(i18n.__('noFileFoundScan'))
|
|
180
|
-
console.log('')
|
|
181
|
-
console.log(i18n.__('specifyFileScanError'))
|
|
182
|
-
}
|
|
183
|
-
process.exit(1)
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
const errorOnAuditFileDetection = entries => {
|
|
187
|
-
if (entries.length > 1) {
|
|
188
|
-
console.log(i18n.__('searchingDirectoryScan'))
|
|
189
|
-
for (let file in entries) {
|
|
190
|
-
console.log('-', entries[file])
|
|
191
|
-
}
|
|
192
|
-
console.log('')
|
|
193
|
-
console.log(i18n.__('specifyFileAuditNotFound'))
|
|
194
|
-
} else {
|
|
195
|
-
console.log(i18n.__('noFileFoundScan'))
|
|
196
|
-
console.log('')
|
|
197
|
-
console.log(i18n.__('specifyFileAuditNotFound'))
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
module.exports = {
|
|
202
|
-
autoDetectFileAndLanguage,
|
|
203
|
-
errorOnFileDetection,
|
|
204
|
-
autoDetectAuditFilesAndLanguages,
|
|
205
|
-
errorOnAuditFileDetection,
|
|
206
|
-
autoDetectFingerprintInfo,
|
|
207
|
-
dealWithMultiJava,
|
|
208
|
-
detectPackageManager
|
|
209
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { HttpsProxyAgent } from 'hpagent'
|
|
2
|
-
import fs from 'fs'
|
|
3
|
-
import got, { Options } from 'got'
|
|
4
|
-
import { Agents, HTTPSOptions } from 'got/dist/source/core'
|
|
5
|
-
|
|
6
|
-
export function gotInstance(config: any) {
|
|
7
|
-
return got.extend({ retry: { limit: 0 }, ...buildBaseRequestOptions(config) })
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function buildBaseRequestOptions(config: any) {
|
|
11
|
-
const { apiKey, authorization } = config
|
|
12
|
-
const rejectUnauthorized = !config.certSelfSigned
|
|
13
|
-
|
|
14
|
-
const superApiKey = config.superApiKey
|
|
15
|
-
const superAuthToken = config.superAuthorization
|
|
16
|
-
|
|
17
|
-
const requestOptions = {
|
|
18
|
-
responseType: 'json',
|
|
19
|
-
forever: true,
|
|
20
|
-
uri: config.host,
|
|
21
|
-
followRedirect: false,
|
|
22
|
-
headers: {
|
|
23
|
-
'Content-Type': 'application/json; charset=utf-8',
|
|
24
|
-
Authorization: authorization,
|
|
25
|
-
'API-Key': apiKey,
|
|
26
|
-
SuperAuthorization: superAuthToken,
|
|
27
|
-
'Super-API-Key': superApiKey,
|
|
28
|
-
'User-Agent': 'contrast-cli-v2'
|
|
29
|
-
},
|
|
30
|
-
agent: getAgent(config)
|
|
31
|
-
} as Options
|
|
32
|
-
|
|
33
|
-
requestOptions.https = {
|
|
34
|
-
rejectUnauthorized: rejectUnauthorized
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
maybeAddCertsToRequest(config, requestOptions.https)
|
|
38
|
-
return requestOptions
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function getAgent(config: any) {
|
|
42
|
-
return config.proxy
|
|
43
|
-
? (new HttpsProxyAgent({ proxy: config.proxy }) as Agents)
|
|
44
|
-
: false
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function maybeAddCertsToRequest(config: any, https: HTTPSOptions) {
|
|
48
|
-
// cacert
|
|
49
|
-
const caCertFilePath = config.cacert
|
|
50
|
-
if (caCertFilePath) {
|
|
51
|
-
try {
|
|
52
|
-
https.certificateAuthority = fs.readFileSync(caCertFilePath)
|
|
53
|
-
} catch (error: any) {
|
|
54
|
-
throw new Error(
|
|
55
|
-
`Unable to read CA from ${caCertFilePath}, msg: ${error.message}`
|
|
56
|
-
)
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// cert
|
|
61
|
-
const certPath = config.cert
|
|
62
|
-
if (certPath) {
|
|
63
|
-
try {
|
|
64
|
-
https.certificate = fs.readFileSync(certPath)
|
|
65
|
-
} catch (error: any) {
|
|
66
|
-
throw new Error(
|
|
67
|
-
`Unable to read Certificate PEM file from config option contrast.api.certificate.cert_file='${certPath}', msg: ${error.message}`
|
|
68
|
-
)
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// key
|
|
73
|
-
const keyPath = config.key
|
|
74
|
-
if (keyPath) {
|
|
75
|
-
try {
|
|
76
|
-
https.key = fs.readFileSync(keyPath)
|
|
77
|
-
} catch (error: any) {
|
|
78
|
-
throw new Error(
|
|
79
|
-
`Unable to read Key PEM file from config option contrast.api.certificate.key_file='${keyPath}', msg: ${error.message}`
|
|
80
|
-
)
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
package/src/common/commonHelp.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
const i18n = require('i18n')
|
|
2
|
-
const chalk = require('chalk')
|
|
3
|
-
|
|
4
|
-
const commonHelpLinks = () => {
|
|
5
|
-
return [
|
|
6
|
-
{
|
|
7
|
-
header: i18n.__('commonHelpHeader'),
|
|
8
|
-
content: [
|
|
9
|
-
i18n.__('commonHelpCheckOutHeader') + i18n.__('commonHelpCheckOutText'),
|
|
10
|
-
i18n.__('commonHelpLearnMoreHeader') +
|
|
11
|
-
i18n.__('commonHelpLearnMoreText'),
|
|
12
|
-
i18n.__('commonHelpJoinDiscussionHeader') +
|
|
13
|
-
i18n.__('commonHelpJoinDiscussionText')
|
|
14
|
-
]
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
header: i18n.__('commonHelpEnterpriseHeader'),
|
|
18
|
-
content: [
|
|
19
|
-
i18n.__('commonHelpLearnMoreEnterpriseHeader') +
|
|
20
|
-
i18n.__('commonHelpLearnMoreEnterpriseText')
|
|
21
|
-
]
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
content: [
|
|
25
|
-
i18n.__('commonHelpLearnHeader') + i18n.__('commonHelpLearnText')
|
|
26
|
-
]
|
|
27
|
-
}
|
|
28
|
-
]
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const postRunMessage = commandName => {
|
|
32
|
-
console.log('\n' + chalk.underline.bold('Other Features:'))
|
|
33
|
-
if (commandName !== 'scan')
|
|
34
|
-
console.log(
|
|
35
|
-
"'contrast scan' to run Contrast's industry leading SAST scanner"
|
|
36
|
-
)
|
|
37
|
-
if (commandName !== 'audit')
|
|
38
|
-
console.log(
|
|
39
|
-
"'contrast audit' to find vulnerabilities in your open source dependencies"
|
|
40
|
-
)
|
|
41
|
-
if (commandName !== 'lambda')
|
|
42
|
-
console.log("'contrast lambda' to secure your AWS serverless functions")
|
|
43
|
-
|
|
44
|
-
if (commandName !== 'learn')
|
|
45
|
-
console.log(
|
|
46
|
-
"'contrast learn' launches Contrast's Secure Code Learning Hub."
|
|
47
|
-
)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
module.exports = {
|
|
51
|
-
commonHelpLinks,
|
|
52
|
-
postRunMessage
|
|
53
|
-
}
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
const i18n = require('i18n')
|
|
2
|
-
const chalk = require('chalk')
|
|
3
|
-
|
|
4
|
-
const libraryAnalysisError = () => {
|
|
5
|
-
console.log(i18n.__('libraryAnalysisError'))
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const snapshotFailureError = () => {
|
|
9
|
-
console.log(i18n.__('snapshotFailureMessage'))
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const vulnerabilitiesFailureError = () => {
|
|
13
|
-
console.log(i18n.__('vulnerabilitiesFailureMessage'))
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const reportFailureError = () => {
|
|
17
|
-
console.log(i18n.__('auditReportFailureMessage'))
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const genericError = () => {
|
|
21
|
-
console.error(i18n.__('genericErrorMessage'))
|
|
22
|
-
process.exit(1)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const unauthenticatedError = () => {
|
|
26
|
-
generalError('unauthenticatedErrorHeader', 'unauthenticatedErrorMessage')
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const badRequestError = catalogue => {
|
|
30
|
-
catalogue === true
|
|
31
|
-
? generalError('badRequestErrorHeader', 'badRequestCatalogueErrorMessage')
|
|
32
|
-
: generalError('badRequestErrorHeader', 'badRequestErrorMessage')
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const forbiddenError = () => {
|
|
36
|
-
generalError('forbiddenRequestErrorHeader', 'forbiddenRequestErrorMessage')
|
|
37
|
-
process.exit(1)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const proxyError = () => {
|
|
41
|
-
generalError('proxyErrorHeader', 'proxyErrorMessage')
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const maxAppError = () => {
|
|
45
|
-
generalError(
|
|
46
|
-
'No applications remaining',
|
|
47
|
-
'You have reached the maximum number of application you can create.'
|
|
48
|
-
)
|
|
49
|
-
process.exit(1)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const parametersError = () => {
|
|
53
|
-
generalError(
|
|
54
|
-
`Credentials not recognized`,
|
|
55
|
-
'Check your command & keys again for hidden characters / verify that the credentials are correct.\nFor more information use contrast help.'
|
|
56
|
-
)
|
|
57
|
-
process.exit(1)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const invalidHostNameError = () => {
|
|
61
|
-
generalError(
|
|
62
|
-
`Invalid host`,
|
|
63
|
-
'Check that the host parameter does not include a trailing "/".'
|
|
64
|
-
)
|
|
65
|
-
process.exit(1)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const failOptionError = () => {
|
|
69
|
-
console.log(
|
|
70
|
-
'\n ******************************** ' +
|
|
71
|
-
i18n.__('snapshotFailureHeader') +
|
|
72
|
-
' ********************************\n' +
|
|
73
|
-
i18n.__('failOptionErrorMessage')
|
|
74
|
-
)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* You don't have to pass `i18n` translation.
|
|
79
|
-
* String that didn't exists on translations will pass as regular string
|
|
80
|
-
* @param header title for the error
|
|
81
|
-
* @param message message for the error
|
|
82
|
-
* @returns error in general format
|
|
83
|
-
*/
|
|
84
|
-
const getErrorMessage = (header, message) => {
|
|
85
|
-
// prettier-ignore
|
|
86
|
-
const title = `******************************** ${i18n.__(header)} ********************************`
|
|
87
|
-
const multiLine = message?.includes('\n')
|
|
88
|
-
let finalMessage = ''
|
|
89
|
-
|
|
90
|
-
// i18n split the line if it includes '\n'
|
|
91
|
-
if (multiLine) {
|
|
92
|
-
finalMessage = `\n${message}`
|
|
93
|
-
} else if (message) {
|
|
94
|
-
finalMessage = `\n${i18n.__(message)}`
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return `${title}${finalMessage}`
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const generalError = (header, message) => {
|
|
101
|
-
const finalMessage = getErrorMessage(header, message)
|
|
102
|
-
console.log(finalMessage)
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const findCommandOnError = unknownOptions => {
|
|
106
|
-
const commandKeywords = {
|
|
107
|
-
auth: 'auth',
|
|
108
|
-
audit: 'audit',
|
|
109
|
-
scan: 'scan',
|
|
110
|
-
lambda: 'lambda',
|
|
111
|
-
config: 'config'
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const containsCommandKeyword = unknownOptions.some(
|
|
115
|
-
command => commandKeywords[command]
|
|
116
|
-
)
|
|
117
|
-
|
|
118
|
-
if (containsCommandKeyword) {
|
|
119
|
-
const foundCommands = unknownOptions.filter(
|
|
120
|
-
command => commandKeywords[command]
|
|
121
|
-
)
|
|
122
|
-
|
|
123
|
-
//return the first command found
|
|
124
|
-
return foundCommands[0]
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const commonMessageFormatter = (message, fail) => {
|
|
129
|
-
console.log(chalk.bold(i18n.__(message.title)))
|
|
130
|
-
console.log(i18n.__(message.body))
|
|
131
|
-
if (message.extra) {
|
|
132
|
-
console.log(i18n.__(message.extra))
|
|
133
|
-
}
|
|
134
|
-
if (fail) {
|
|
135
|
-
process.exit(1)
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
module.exports = {
|
|
140
|
-
genericError,
|
|
141
|
-
unauthenticatedError,
|
|
142
|
-
badRequestError,
|
|
143
|
-
forbiddenError,
|
|
144
|
-
proxyError,
|
|
145
|
-
failOptionError,
|
|
146
|
-
generalError,
|
|
147
|
-
getErrorMessage,
|
|
148
|
-
libraryAnalysisError,
|
|
149
|
-
findCommandOnError,
|
|
150
|
-
snapshotFailureError,
|
|
151
|
-
vulnerabilitiesFailureError,
|
|
152
|
-
reportFailureError,
|
|
153
|
-
maxAppError,
|
|
154
|
-
parametersError,
|
|
155
|
-
invalidHostNameError,
|
|
156
|
-
commonMessageFormatter
|
|
157
|
-
}
|
package/src/common/fail.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
const i18n = require('i18n')
|
|
2
|
-
|
|
3
|
-
const processFail = (config, reportResults) => {
|
|
4
|
-
if (config.severity !== undefined) {
|
|
5
|
-
if (
|
|
6
|
-
reportResults[config.severity] !== undefined &&
|
|
7
|
-
isSeverityViolation(config.severity, reportResults)
|
|
8
|
-
) {
|
|
9
|
-
failPipeline('failSeverityOptionErrorMessage')
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (config.severity === undefined && reportResults.total > 0) {
|
|
14
|
-
failPipeline('failThresholdOptionErrorMessage')
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const isSeverityViolation = (severity, reportResults) => {
|
|
19
|
-
let count = 0
|
|
20
|
-
switch (severity) {
|
|
21
|
-
case 'critical':
|
|
22
|
-
count += reportResults.critical
|
|
23
|
-
break
|
|
24
|
-
case 'high':
|
|
25
|
-
count += reportResults.high + reportResults.critical
|
|
26
|
-
break
|
|
27
|
-
case 'medium':
|
|
28
|
-
count +=
|
|
29
|
-
reportResults.medium + reportResults.high + reportResults.critical
|
|
30
|
-
break
|
|
31
|
-
case 'low':
|
|
32
|
-
count +=
|
|
33
|
-
reportResults.high +
|
|
34
|
-
reportResults.critical +
|
|
35
|
-
reportResults.medium +
|
|
36
|
-
reportResults.low
|
|
37
|
-
break
|
|
38
|
-
case 'note':
|
|
39
|
-
if (reportResults.note == reportResults.total) {
|
|
40
|
-
count = 0
|
|
41
|
-
} else {
|
|
42
|
-
count = reportResults.total
|
|
43
|
-
}
|
|
44
|
-
break
|
|
45
|
-
default:
|
|
46
|
-
count = 0
|
|
47
|
-
}
|
|
48
|
-
return count > 0
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const failPipeline = (message = '') => {
|
|
52
|
-
console.log(
|
|
53
|
-
'\n ******************************** ' +
|
|
54
|
-
i18n.__('snapshotFailureHeader') +
|
|
55
|
-
' *********************************\n' +
|
|
56
|
-
i18n.__(message)
|
|
57
|
-
)
|
|
58
|
-
process.exit(2)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const parseSeverity = severity => {
|
|
62
|
-
const severities = ['NOTE', 'LOW', 'MEDIUM', 'HIGH', 'CRITICAL']
|
|
63
|
-
if (severities.includes(severity.toUpperCase())) {
|
|
64
|
-
return severity.toLowerCase()
|
|
65
|
-
} else {
|
|
66
|
-
console.log(
|
|
67
|
-
severity +
|
|
68
|
-
' Not recognised as a severity type please use LOW, MEDIUM, HIGH, CRITICAL, NOTE'
|
|
69
|
-
)
|
|
70
|
-
return undefined
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
module.exports = {
|
|
75
|
-
failPipeline,
|
|
76
|
-
processFail,
|
|
77
|
-
isSeverityViolation,
|
|
78
|
-
parseSeverity
|
|
79
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
const { APP_VERSION } = require('../constants/constants')
|
|
2
|
-
const boxen = require('boxen')
|
|
3
|
-
const chalk = require('chalk')
|
|
4
|
-
const semver = require('semver')
|
|
5
|
-
const commonApi = require('../utils/commonApi')
|
|
6
|
-
const { constants } = require('http2')
|
|
7
|
-
|
|
8
|
-
const getLatestVersion = async config => {
|
|
9
|
-
const client = commonApi.getHttpClient(config)
|
|
10
|
-
try {
|
|
11
|
-
const res = await client.getLatestVersion()
|
|
12
|
-
if (res.statusCode === constants.HTTP_STATUS_OK) {
|
|
13
|
-
return res.body
|
|
14
|
-
}
|
|
15
|
-
} catch (e) {
|
|
16
|
-
return undefined
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const findLatestCLIVersion = async config => {
|
|
21
|
-
const isCI = process.env.CONTRAST_CODESEC_CI
|
|
22
|
-
? JSON.parse(process.env.CONTRAST_CODESEC_CI.toLowerCase())
|
|
23
|
-
: false
|
|
24
|
-
|
|
25
|
-
if (!isCI) {
|
|
26
|
-
let latestCLIVersion = await getLatestVersion(config)
|
|
27
|
-
|
|
28
|
-
if (latestCLIVersion === undefined) {
|
|
29
|
-
config.set('numOfRuns', 0)
|
|
30
|
-
console.log(
|
|
31
|
-
'Failed to retrieve latest version info. Continuing execution.'
|
|
32
|
-
)
|
|
33
|
-
return
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
//strip key and remove new lines
|
|
37
|
-
latestCLIVersion = latestCLIVersion.substring(8).replace('\n', '')
|
|
38
|
-
|
|
39
|
-
if (semver.lt(APP_VERSION, latestCLIVersion)) {
|
|
40
|
-
const updateAvailableMessage = `Update available ${chalk.yellow(
|
|
41
|
-
APP_VERSION
|
|
42
|
-
)} → ${chalk.green(latestCLIVersion)}`
|
|
43
|
-
|
|
44
|
-
const npmUpdateAvailableCommand = `Run ${chalk.cyan(
|
|
45
|
-
'npm i @contrast/contrast -g'
|
|
46
|
-
)} to update via npm`
|
|
47
|
-
|
|
48
|
-
const homebrewUpdateAvailableCommand = `Run ${chalk.cyan(
|
|
49
|
-
'brew install contrastsecurity/tap/contrast'
|
|
50
|
-
)} to update via brew`
|
|
51
|
-
|
|
52
|
-
console.log(
|
|
53
|
-
boxen(
|
|
54
|
-
`${updateAvailableMessage}\n${npmUpdateAvailableCommand}\n\n${homebrewUpdateAvailableCommand}`,
|
|
55
|
-
{
|
|
56
|
-
titleAlignment: 'center',
|
|
57
|
-
margin: 1,
|
|
58
|
-
padding: 1,
|
|
59
|
-
align: 'center'
|
|
60
|
-
}
|
|
61
|
-
)
|
|
62
|
-
)
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const isCorrectNodeVersion = async currentVersion => {
|
|
68
|
-
return semver.satisfies(currentVersion, '>=16')
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
module.exports = {
|
|
72
|
-
getLatestVersion,
|
|
73
|
-
findLatestCLIVersion,
|
|
74
|
-
isCorrectNodeVersion
|
|
75
|
-
}
|