@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,412 +0,0 @@
|
|
|
1
|
-
const commonApi = require('../../utils/commonApi')
|
|
2
|
-
const {
|
|
3
|
-
ReportCompositeKey,
|
|
4
|
-
ReportList,
|
|
5
|
-
ReportModelStructure
|
|
6
|
-
} = require('./models/reportListModel')
|
|
7
|
-
const { orderBy } = require('lodash')
|
|
8
|
-
const chalk = require('chalk')
|
|
9
|
-
const {
|
|
10
|
-
countVulnerableLibrariesBySeverity,
|
|
11
|
-
orderByHighestPriority,
|
|
12
|
-
findHighestSeverityCVE,
|
|
13
|
-
findNameAndVersion,
|
|
14
|
-
severityCountAllCVEs,
|
|
15
|
-
findCVESeverity
|
|
16
|
-
} = require('./utils/reportUtils')
|
|
17
|
-
const { SeverityCountModel } = require('./models/severityCountModel')
|
|
18
|
-
const {
|
|
19
|
-
ReportOutputBodyModel,
|
|
20
|
-
ReportOutputHeaderModel,
|
|
21
|
-
ReportOutputModel
|
|
22
|
-
} = require('./models/reportOutputModel')
|
|
23
|
-
const {
|
|
24
|
-
CE_URL,
|
|
25
|
-
CRITICAL_COLOUR,
|
|
26
|
-
HIGH_COLOUR,
|
|
27
|
-
LOW_COLOUR,
|
|
28
|
-
MEDIUM_COLOUR,
|
|
29
|
-
NOTE_COLOUR
|
|
30
|
-
} = require('../../constants/constants')
|
|
31
|
-
const Table = require('cli-table3')
|
|
32
|
-
const { ReportGuidanceModel } = require('./models/reportGuidanceModel')
|
|
33
|
-
const i18n = require('i18n')
|
|
34
|
-
|
|
35
|
-
const createSummaryMessageTop = (numberOfVulnerableLibraries, numberOfCves) => {
|
|
36
|
-
numberOfVulnerableLibraries === 1
|
|
37
|
-
? console.log(`Found 1 vulnerable library containing ${numberOfCves} CVE`)
|
|
38
|
-
: console.log(
|
|
39
|
-
`Found ${numberOfVulnerableLibraries} vulnerable libraries containing ${numberOfCves} CVEs`
|
|
40
|
-
)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const createSummaryMessageBottom = numberOfVulnerableLibraries => {
|
|
44
|
-
numberOfVulnerableLibraries === 1
|
|
45
|
-
? console.log(`Found 1 vulnerability`)
|
|
46
|
-
: console.log(`Found ${numberOfVulnerableLibraries} vulnerabilities`)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const getReport = async (config, reportId) => {
|
|
50
|
-
const client = commonApi.getHttpClient(config)
|
|
51
|
-
return client
|
|
52
|
-
.getReportById(config, reportId)
|
|
53
|
-
.then(res => {
|
|
54
|
-
if (res.statusCode === 200) {
|
|
55
|
-
return res.body
|
|
56
|
-
} else {
|
|
57
|
-
console.log(JSON.stringify(res.statusCode))
|
|
58
|
-
commonApi.handleResponseErrors(res, 'report')
|
|
59
|
-
}
|
|
60
|
-
})
|
|
61
|
-
.catch(err => {
|
|
62
|
-
console.log(err)
|
|
63
|
-
})
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const printVulnerabilityResponse = (
|
|
67
|
-
config,
|
|
68
|
-
vulnerableLibraries,
|
|
69
|
-
numberOfVulnerableLibraries,
|
|
70
|
-
numberOfCves,
|
|
71
|
-
guidance
|
|
72
|
-
) => {
|
|
73
|
-
let hasSomeVulnerabilitiesReported = false
|
|
74
|
-
printFormattedOutput(
|
|
75
|
-
config,
|
|
76
|
-
vulnerableLibraries,
|
|
77
|
-
numberOfVulnerableLibraries,
|
|
78
|
-
numberOfCves,
|
|
79
|
-
guidance
|
|
80
|
-
)
|
|
81
|
-
if (Object.keys(vulnerableLibraries).length > 0) {
|
|
82
|
-
hasSomeVulnerabilitiesReported = true
|
|
83
|
-
}
|
|
84
|
-
return hasSomeVulnerabilitiesReported
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const printFormattedOutput = (
|
|
88
|
-
config,
|
|
89
|
-
libraries,
|
|
90
|
-
numberOfVulnerableLibraries,
|
|
91
|
-
numberOfCves,
|
|
92
|
-
guidance
|
|
93
|
-
) => {
|
|
94
|
-
createSummaryMessageTop(numberOfVulnerableLibraries, numberOfCves)
|
|
95
|
-
console.log()
|
|
96
|
-
const report = new ReportList()
|
|
97
|
-
|
|
98
|
-
for (const library of libraries) {
|
|
99
|
-
const { name, version } = findNameAndVersion(library, config)
|
|
100
|
-
|
|
101
|
-
const newOutputModel = new ReportModelStructure(
|
|
102
|
-
new ReportCompositeKey(
|
|
103
|
-
name,
|
|
104
|
-
version,
|
|
105
|
-
findHighestSeverityCVE(library.cveArray),
|
|
106
|
-
severityCountAllCVEs(
|
|
107
|
-
library.cveArray,
|
|
108
|
-
new SeverityCountModel()
|
|
109
|
-
).getTotal
|
|
110
|
-
),
|
|
111
|
-
library.cveArray,
|
|
112
|
-
null
|
|
113
|
-
)
|
|
114
|
-
report.reportOutputList.push(newOutputModel)
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const outputOrderedByLowestSeverityAndLowestNumOfCvesFirst = orderBy(
|
|
118
|
-
report.reportOutputList,
|
|
119
|
-
[
|
|
120
|
-
reportListItem => {
|
|
121
|
-
return reportListItem.compositeKey.highestSeverity.priority
|
|
122
|
-
},
|
|
123
|
-
reportListItem => {
|
|
124
|
-
return reportListItem.compositeKey.numberOfSeverities
|
|
125
|
-
}
|
|
126
|
-
],
|
|
127
|
-
['asc', 'desc']
|
|
128
|
-
)
|
|
129
|
-
|
|
130
|
-
let contrastHeaderNumCounter = 0
|
|
131
|
-
for (const reportModel of outputOrderedByLowestSeverityAndLowestNumOfCvesFirst) {
|
|
132
|
-
contrastHeaderNumCounter++
|
|
133
|
-
const { libraryName, libraryVersion, highestSeverity } =
|
|
134
|
-
reportModel.compositeKey
|
|
135
|
-
|
|
136
|
-
const numOfCVEs = reportModel.cveArray.length
|
|
137
|
-
|
|
138
|
-
const table = getReportTable()
|
|
139
|
-
|
|
140
|
-
const header = buildHeader(
|
|
141
|
-
highestSeverity,
|
|
142
|
-
contrastHeaderNumCounter,
|
|
143
|
-
libraryName,
|
|
144
|
-
libraryVersion,
|
|
145
|
-
numOfCVEs
|
|
146
|
-
)
|
|
147
|
-
|
|
148
|
-
const advice = gatherRemediationAdvice(
|
|
149
|
-
guidance,
|
|
150
|
-
libraryName,
|
|
151
|
-
libraryVersion
|
|
152
|
-
)
|
|
153
|
-
|
|
154
|
-
const body = buildBody(reportModel.cveArray, advice)
|
|
155
|
-
|
|
156
|
-
const reportOutputModel = new ReportOutputModel(header, body)
|
|
157
|
-
|
|
158
|
-
table.push(
|
|
159
|
-
reportOutputModel.body.issueMessage,
|
|
160
|
-
reportOutputModel.body.adviceMessage
|
|
161
|
-
)
|
|
162
|
-
|
|
163
|
-
console.log(
|
|
164
|
-
reportOutputModel.header.vulnMessage,
|
|
165
|
-
reportOutputModel.header.introducesMessage
|
|
166
|
-
)
|
|
167
|
-
console.log(table.toString() + '\n')
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
createSummaryMessageBottom(numberOfVulnerableLibraries)
|
|
171
|
-
const {
|
|
172
|
-
criticalMessage,
|
|
173
|
-
highMessage,
|
|
174
|
-
mediumMessage,
|
|
175
|
-
lowMessage,
|
|
176
|
-
noteMessage
|
|
177
|
-
} = buildFooter(outputOrderedByLowestSeverityAndLowestNumOfCvesFirst)
|
|
178
|
-
console.log(
|
|
179
|
-
`${criticalMessage} | ${highMessage} | ${mediumMessage} | ${lowMessage} | ${noteMessage}`
|
|
180
|
-
)
|
|
181
|
-
|
|
182
|
-
if (config.host !== CE_URL) {
|
|
183
|
-
console.log(
|
|
184
|
-
'\n' + chalk.bold('View your full dependency tree in Contrast:')
|
|
185
|
-
)
|
|
186
|
-
console.log(
|
|
187
|
-
`${config.host}/Contrast/static/ng/index.html#/${config.organizationId}/applications/${config.applicationId}/libs/dependency-tree`
|
|
188
|
-
)
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
function getReportTable() {
|
|
193
|
-
return new Table({
|
|
194
|
-
chars: {
|
|
195
|
-
top: '',
|
|
196
|
-
'top-mid': '',
|
|
197
|
-
'top-left': '',
|
|
198
|
-
'top-right': '',
|
|
199
|
-
bottom: '',
|
|
200
|
-
'bottom-mid': '',
|
|
201
|
-
'bottom-left': '',
|
|
202
|
-
'bottom-right': '',
|
|
203
|
-
left: '',
|
|
204
|
-
'left-mid': '',
|
|
205
|
-
mid: '',
|
|
206
|
-
'mid-mid': '',
|
|
207
|
-
right: '',
|
|
208
|
-
'right-mid': '',
|
|
209
|
-
middle: ' '
|
|
210
|
-
},
|
|
211
|
-
style: { 'padding-left': 0, 'padding-right': 0 },
|
|
212
|
-
colAligns: ['right'],
|
|
213
|
-
wordWrap: true,
|
|
214
|
-
colWidths: [12, 1, 100]
|
|
215
|
-
})
|
|
216
|
-
}
|
|
217
|
-
function buildHeader(
|
|
218
|
-
highestSeverity,
|
|
219
|
-
contrastHeaderNum,
|
|
220
|
-
libraryName,
|
|
221
|
-
version,
|
|
222
|
-
numOfCVEs
|
|
223
|
-
) {
|
|
224
|
-
const vulnerabilityPluralised =
|
|
225
|
-
numOfCVEs > 1 ? 'vulnerabilities' : 'vulnerability'
|
|
226
|
-
const formattedHeaderNum = buildFormattedHeaderNum(contrastHeaderNum)
|
|
227
|
-
|
|
228
|
-
const headerColour = chalk.hex(highestSeverity.colour)
|
|
229
|
-
const headerNumAndSeverity = headerColour(
|
|
230
|
-
`${formattedHeaderNum} - [${highestSeverity.severity}]`
|
|
231
|
-
)
|
|
232
|
-
const libraryNameAndVersion = headerColour.bold(`${libraryName}-${version}`)
|
|
233
|
-
const vulnMessage = `${headerNumAndSeverity} ${libraryNameAndVersion}`
|
|
234
|
-
|
|
235
|
-
const introducesMessage = `introduces ${numOfCVEs} ${vulnerabilityPluralised}`
|
|
236
|
-
|
|
237
|
-
return new ReportOutputHeaderModel(vulnMessage, introducesMessage)
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
function buildBody(cveArray, advice) {
|
|
241
|
-
const orderedCvesWithSeverityAssigned = orderByHighestPriority(
|
|
242
|
-
cveArray.map(cve => findCVESeverity(cve))
|
|
243
|
-
)
|
|
244
|
-
|
|
245
|
-
const issueMessage = getIssueRow(orderedCvesWithSeverityAssigned)
|
|
246
|
-
|
|
247
|
-
//todo different advice based on remediationGuidance being available or now
|
|
248
|
-
// console.log(advice)
|
|
249
|
-
|
|
250
|
-
const minOrMax = advice.minimum ? advice.minimum : advice.maximum
|
|
251
|
-
const displayAdvice = minOrMax
|
|
252
|
-
? `Change to version ${chalk.bold(minOrMax)}`
|
|
253
|
-
: 'No recommendation is available according to our data. Upgrade to the latest stable is the best advice we can give.'
|
|
254
|
-
|
|
255
|
-
const adviceMessage = [chalk.bold('Advice'), ':', displayAdvice]
|
|
256
|
-
|
|
257
|
-
return new ReportOutputBodyModel(issueMessage, adviceMessage)
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
function getIssueRow(cveArray) {
|
|
261
|
-
const cveMessagesList = getIssueCveMsgList(cveArray)
|
|
262
|
-
return [chalk.bold('Issue'), ':', `${cveMessagesList.join(', ')}`]
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
function gatherRemediationAdvice(guidance, libraryName, libraryVersion) {
|
|
266
|
-
const guidanceModel = new ReportGuidanceModel()
|
|
267
|
-
|
|
268
|
-
const data = guidance[libraryName + '@' + libraryVersion]
|
|
269
|
-
|
|
270
|
-
if (data) {
|
|
271
|
-
guidanceModel.minimum = data.minUpgradeVersion
|
|
272
|
-
guidanceModel.maximum = data.maxUpgradeVersion
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
return guidanceModel
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
function buildFormattedHeaderNum(contrastHeaderNum) {
|
|
279
|
-
return `CONTRAST-${contrastHeaderNum.toString().padStart(3, '0')}`
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
const buildFooter = reportModelStructure => {
|
|
283
|
-
const { critical, high, medium, low, note } =
|
|
284
|
-
countVulnerableLibrariesBySeverity(reportModelStructure)
|
|
285
|
-
|
|
286
|
-
const criticalMessage = chalk
|
|
287
|
-
.hex(CRITICAL_COLOUR)
|
|
288
|
-
.bold(`${critical} Critical`)
|
|
289
|
-
const highMessage = chalk.hex(HIGH_COLOUR).bold(`${high} High`)
|
|
290
|
-
const mediumMessage = chalk.hex(MEDIUM_COLOUR).bold(`${medium} Medium`)
|
|
291
|
-
const lowMessage = chalk.hex(LOW_COLOUR).bold(`${low} Low`)
|
|
292
|
-
const noteMessage = chalk.hex(NOTE_COLOUR).bold(`${note} Note`)
|
|
293
|
-
|
|
294
|
-
return {
|
|
295
|
-
criticalMessage,
|
|
296
|
-
highMessage,
|
|
297
|
-
mediumMessage,
|
|
298
|
-
lowMessage,
|
|
299
|
-
noteMessage
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
const getIssueCveMsgList = results => {
|
|
304
|
-
const cveMessages = []
|
|
305
|
-
|
|
306
|
-
results.forEach(reportSeverityModel => {
|
|
307
|
-
const { colour, severity, name } = reportSeverityModel
|
|
308
|
-
|
|
309
|
-
const severityShorthand = chalk
|
|
310
|
-
.hex(colour)
|
|
311
|
-
.bold(`[${severity.charAt(0).toUpperCase()}]`)
|
|
312
|
-
|
|
313
|
-
const builtMessage = severityShorthand + name
|
|
314
|
-
cveMessages.push(builtMessage)
|
|
315
|
-
})
|
|
316
|
-
return cveMessages
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
const getSeverityCounts = results => {
|
|
320
|
-
const acc = {
|
|
321
|
-
critical: 0,
|
|
322
|
-
high: 0,
|
|
323
|
-
medium: 0,
|
|
324
|
-
low: 0,
|
|
325
|
-
note: 0,
|
|
326
|
-
total: 0
|
|
327
|
-
}
|
|
328
|
-
if (results && results.length > 0) {
|
|
329
|
-
results.forEach(i => {
|
|
330
|
-
acc[i.severity.toLowerCase()] += 1
|
|
331
|
-
acc.total += 1
|
|
332
|
-
return acc
|
|
333
|
-
})
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
return acc
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
const printNoVulnFoundMsg = () => {
|
|
340
|
-
console.log(i18n.__('scanNoVulnerabilitiesFound'))
|
|
341
|
-
console.log(i18n.__('scanNoVulnerabilitiesFoundSecureCode'))
|
|
342
|
-
console.log(i18n.__('scanNoVulnerabilitiesFoundGoodWork'))
|
|
343
|
-
console.log(chalk.bold(`Found 0 vulnerabilities`))
|
|
344
|
-
console.log(
|
|
345
|
-
i18n.__(
|
|
346
|
-
'foundDetailedVulnerabilities',
|
|
347
|
-
String(0),
|
|
348
|
-
String(0),
|
|
349
|
-
String(0),
|
|
350
|
-
String(0),
|
|
351
|
-
String(0)
|
|
352
|
-
)
|
|
353
|
-
)
|
|
354
|
-
}
|
|
355
|
-
const printVulnInfo = projectOverview => {
|
|
356
|
-
const totalVulnerabilities = projectOverview.total
|
|
357
|
-
|
|
358
|
-
createSummaryMessageBottom(totalVulnerabilities)
|
|
359
|
-
const formattedValues = severityFormatted(projectOverview)
|
|
360
|
-
console.log(
|
|
361
|
-
i18n.__(
|
|
362
|
-
'foundDetailedVulnerabilities',
|
|
363
|
-
String(formattedValues.criticalFormatted),
|
|
364
|
-
String(formattedValues.highFormatted),
|
|
365
|
-
String(formattedValues.mediumFormatted),
|
|
366
|
-
String(formattedValues.lowFormatted),
|
|
367
|
-
String(formattedValues.noteFormatted)
|
|
368
|
-
)
|
|
369
|
-
)
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
const severityFormatted = projectOverview => {
|
|
373
|
-
const criticalFormatted = chalk
|
|
374
|
-
.hex(CRITICAL_COLOUR)
|
|
375
|
-
.bold(`${projectOverview.critical} Critical`)
|
|
376
|
-
const highFormatted = chalk
|
|
377
|
-
.hex(HIGH_COLOUR)
|
|
378
|
-
.bold(`${projectOverview.high} High`)
|
|
379
|
-
const mediumFormatted = chalk
|
|
380
|
-
.hex(MEDIUM_COLOUR)
|
|
381
|
-
.bold(`${projectOverview.medium} Medium`)
|
|
382
|
-
const lowFormatted = chalk.hex(LOW_COLOUR).bold(`${projectOverview.low} Low`)
|
|
383
|
-
const noteFormatted = chalk
|
|
384
|
-
.hex(NOTE_COLOUR)
|
|
385
|
-
.bold(`${projectOverview.note} Note`)
|
|
386
|
-
|
|
387
|
-
return {
|
|
388
|
-
criticalFormatted,
|
|
389
|
-
highFormatted,
|
|
390
|
-
mediumFormatted,
|
|
391
|
-
lowFormatted,
|
|
392
|
-
noteFormatted
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
module.exports = {
|
|
397
|
-
createSummaryMessageTop,
|
|
398
|
-
getReport,
|
|
399
|
-
createSummaryMessageBottom,
|
|
400
|
-
printVulnerabilityResponse,
|
|
401
|
-
printFormattedOutput,
|
|
402
|
-
getReportTable,
|
|
403
|
-
buildHeader,
|
|
404
|
-
buildBody,
|
|
405
|
-
getIssueRow,
|
|
406
|
-
gatherRemediationAdvice,
|
|
407
|
-
buildFormattedHeaderNum,
|
|
408
|
-
getIssueCveMsgList,
|
|
409
|
-
getSeverityCounts,
|
|
410
|
-
printNoVulnFoundMsg,
|
|
411
|
-
printVulnInfo
|
|
412
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export class ReportLibraryModel {
|
|
2
|
-
name: string
|
|
3
|
-
cveArray: ReportCVEModel[]
|
|
4
|
-
|
|
5
|
-
constructor(name: string, cveArray: ReportCVEModel[]) {
|
|
6
|
-
this.name = name
|
|
7
|
-
this.cveArray = cveArray
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export class ReportCVEModel {
|
|
12
|
-
name?: string
|
|
13
|
-
description?: string
|
|
14
|
-
authentication?: string
|
|
15
|
-
references?: []
|
|
16
|
-
severityCode?: string
|
|
17
|
-
cvss3SeverityCode?: string
|
|
18
|
-
|
|
19
|
-
constructor(
|
|
20
|
-
name: string,
|
|
21
|
-
description: string,
|
|
22
|
-
severityCode: string,
|
|
23
|
-
cvss3SeverityCode: string
|
|
24
|
-
) {
|
|
25
|
-
this.name = name
|
|
26
|
-
this.description = description
|
|
27
|
-
this.severityCode = severityCode
|
|
28
|
-
this.cvss3SeverityCode = cvss3SeverityCode
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { ReportSeverityModel } from './reportSeverityModel'
|
|
2
|
-
import { ReportCVEModel } from './reportLibraryModel'
|
|
3
|
-
import {
|
|
4
|
-
ScaReportRemediationAdviceModel,
|
|
5
|
-
ScaReportVulnerabilityModel
|
|
6
|
-
} from '../../../scaAnalysis/common/models/ScaReportModel'
|
|
7
|
-
|
|
8
|
-
export class ReportList {
|
|
9
|
-
reportOutputList: ReportModelStructure[]
|
|
10
|
-
|
|
11
|
-
constructor() {
|
|
12
|
-
this.reportOutputList = []
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export class ReportModelStructure {
|
|
17
|
-
compositeKey: ReportCompositeKey
|
|
18
|
-
cveArray: ReportCVEModel[] | ScaReportVulnerabilityModel[]
|
|
19
|
-
remediationAdvice: ScaReportRemediationAdviceModel | null
|
|
20
|
-
|
|
21
|
-
constructor(
|
|
22
|
-
compositeKey: ReportCompositeKey,
|
|
23
|
-
cveArray: ReportCVEModel[] | ScaReportVulnerabilityModel[],
|
|
24
|
-
remediationAdvice: ScaReportRemediationAdviceModel | null
|
|
25
|
-
) {
|
|
26
|
-
this.compositeKey = compositeKey
|
|
27
|
-
this.cveArray = cveArray
|
|
28
|
-
this.remediationAdvice = remediationAdvice
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export class ReportCompositeKey {
|
|
33
|
-
libraryName!: string
|
|
34
|
-
libraryVersion!: string
|
|
35
|
-
highestSeverity!: ReportSeverityModel
|
|
36
|
-
numberOfSeverities!: number
|
|
37
|
-
|
|
38
|
-
constructor(
|
|
39
|
-
libraryName: string,
|
|
40
|
-
libraryVersion: string,
|
|
41
|
-
highestSeverity: ReportSeverityModel,
|
|
42
|
-
numberOfSeverities: number
|
|
43
|
-
) {
|
|
44
|
-
this.libraryName = libraryName
|
|
45
|
-
this.libraryVersion = libraryVersion
|
|
46
|
-
this.highestSeverity = highestSeverity
|
|
47
|
-
this.numberOfSeverities = numberOfSeverities
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export class ReportOutputModel {
|
|
2
|
-
header: ReportOutputHeaderModel
|
|
3
|
-
body: ReportOutputBodyModel
|
|
4
|
-
|
|
5
|
-
constructor(header: ReportOutputHeaderModel, body: ReportOutputBodyModel) {
|
|
6
|
-
this.header = header
|
|
7
|
-
this.body = body
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export class ReportOutputHeaderModel {
|
|
12
|
-
vulnMessage: string
|
|
13
|
-
introducesMessage: string
|
|
14
|
-
|
|
15
|
-
constructor(vulnMessage: string, introducesMessage: string) {
|
|
16
|
-
this.vulnMessage = vulnMessage
|
|
17
|
-
this.introducesMessage = introducesMessage
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export class ReportOutputBodyModel {
|
|
22
|
-
issueMessage: string[]
|
|
23
|
-
adviceMessage: string[]
|
|
24
|
-
|
|
25
|
-
constructor(issueMessage: string[], adviceMessage: string[]) {
|
|
26
|
-
this.issueMessage = issueMessage
|
|
27
|
-
this.adviceMessage = adviceMessage
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export class ReportSeverityModel {
|
|
2
|
-
severity: string
|
|
3
|
-
priority: number
|
|
4
|
-
colour: string
|
|
5
|
-
name: string
|
|
6
|
-
|
|
7
|
-
constructor(
|
|
8
|
-
severity: string,
|
|
9
|
-
priority: number,
|
|
10
|
-
colour: string,
|
|
11
|
-
name: string
|
|
12
|
-
) {
|
|
13
|
-
this.severity = severity
|
|
14
|
-
this.priority = priority
|
|
15
|
-
this.colour = colour
|
|
16
|
-
this.name = name
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export class SeverityCountModel {
|
|
2
|
-
critical!: number
|
|
3
|
-
high!: number
|
|
4
|
-
medium!: number
|
|
5
|
-
low!: number
|
|
6
|
-
note!: number
|
|
7
|
-
total!: number
|
|
8
|
-
|
|
9
|
-
//needed as default to stop NaN when new object constructed
|
|
10
|
-
constructor() {
|
|
11
|
-
this.critical = 0
|
|
12
|
-
this.high = 0
|
|
13
|
-
this.medium = 0
|
|
14
|
-
this.low = 0
|
|
15
|
-
this.note = 0
|
|
16
|
-
this.total = 0
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
get getTotal(): number {
|
|
20
|
-
return this.critical + this.high + this.medium + this.low + this.note
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getReport,
|
|
3
|
-
printNoVulnFoundMsg,
|
|
4
|
-
printVulnerabilityResponse
|
|
5
|
-
} from './commonReportingFunctions'
|
|
6
|
-
import {
|
|
7
|
-
convertGenericToTypedLibraryVulns,
|
|
8
|
-
severityCountAllLibraries
|
|
9
|
-
} from './utils/reportUtils'
|
|
10
|
-
import i18n from 'i18n'
|
|
11
|
-
import chalk from 'chalk'
|
|
12
|
-
import * as constants from '../../constants/constants'
|
|
13
|
-
import { SeverityCountModel } from './models/severityCountModel'
|
|
14
|
-
import * as common from '../../common/fail'
|
|
15
|
-
import { auditSave } from '../save'
|
|
16
|
-
|
|
17
|
-
export function convertKeysToStandardFormat(config: any, guidance: any) {
|
|
18
|
-
let convertedGuidance = guidance
|
|
19
|
-
|
|
20
|
-
switch (config.language) {
|
|
21
|
-
case constants.supportedLanguages.JAVA:
|
|
22
|
-
case constants.supportedLanguages.GO:
|
|
23
|
-
case constants.supportedLanguages.PHP:
|
|
24
|
-
break
|
|
25
|
-
case constants.supportedLanguages.NODE:
|
|
26
|
-
case constants.supportedLanguages.DOTNET:
|
|
27
|
-
case constants.supportedLanguages.PYTHON:
|
|
28
|
-
case constants.supportedLanguages.RUBY:
|
|
29
|
-
convertedGuidance = convertJSDotNetPython(guidance)
|
|
30
|
-
break
|
|
31
|
-
}
|
|
32
|
-
return convertedGuidance
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function convertJSDotNetPython(guidance: any) {
|
|
36
|
-
const returnObject = {}
|
|
37
|
-
|
|
38
|
-
Object.entries(guidance).forEach(([key, value]) => {
|
|
39
|
-
const splitKey = key.split('/')
|
|
40
|
-
if (splitKey.length === 2) {
|
|
41
|
-
// @ts-ignore
|
|
42
|
-
returnObject[splitKey[1]] = value
|
|
43
|
-
}
|
|
44
|
-
})
|
|
45
|
-
return returnObject
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function formatVulnerabilityOutput(
|
|
49
|
-
libraryVulnerabilityResponse: any,
|
|
50
|
-
id: string,
|
|
51
|
-
config: any,
|
|
52
|
-
remediationGuidance: any
|
|
53
|
-
) {
|
|
54
|
-
const vulnerableLibraries = convertGenericToTypedLibraryVulns(
|
|
55
|
-
libraryVulnerabilityResponse
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
const guidance = convertKeysToStandardFormat(config, remediationGuidance)
|
|
59
|
-
|
|
60
|
-
const numberOfVulnerableLibraries = vulnerableLibraries.length
|
|
61
|
-
|
|
62
|
-
if (numberOfVulnerableLibraries === 0) {
|
|
63
|
-
printNoVulnFoundMsg()
|
|
64
|
-
return [false, 0, [new SeverityCountModel()]]
|
|
65
|
-
} else {
|
|
66
|
-
let numberOfCves = 0
|
|
67
|
-
vulnerableLibraries.forEach(lib => (numberOfCves += lib.cveArray.length))
|
|
68
|
-
|
|
69
|
-
const hasSomeVulnerabilitiesReported = printVulnerabilityResponse(
|
|
70
|
-
config,
|
|
71
|
-
vulnerableLibraries,
|
|
72
|
-
numberOfVulnerableLibraries,
|
|
73
|
-
numberOfCves,
|
|
74
|
-
guidance
|
|
75
|
-
)
|
|
76
|
-
let severityCount = new SeverityCountModel()
|
|
77
|
-
severityCount = severityCountAllLibraries(
|
|
78
|
-
vulnerableLibraries,
|
|
79
|
-
severityCount
|
|
80
|
-
)
|
|
81
|
-
severityCount.total = severityCount.getTotal
|
|
82
|
-
return [hasSomeVulnerabilitiesReported, numberOfCves, severityCount]
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export async function vulnerabilityReportV2(config: any, reportId: string) {
|
|
87
|
-
console.log()
|
|
88
|
-
const reportResponse = await getReport(config, reportId)
|
|
89
|
-
|
|
90
|
-
if (reportResponse !== undefined) {
|
|
91
|
-
const output = formatVulnerabilityOutput(
|
|
92
|
-
reportResponse.vulnerabilities,
|
|
93
|
-
config.applicationId,
|
|
94
|
-
config,
|
|
95
|
-
reportResponse.remediationGuidance
|
|
96
|
-
? reportResponse.remediationGuidance
|
|
97
|
-
: {}
|
|
98
|
-
)
|
|
99
|
-
|
|
100
|
-
if (config.save !== undefined) {
|
|
101
|
-
await auditSave(config)
|
|
102
|
-
} else {
|
|
103
|
-
console.log('\nUse contrast audit --save to generate an SBOM')
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (config.fail) {
|
|
107
|
-
common.processFail(config, output[2])
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|