@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
package/src/lambda/types.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
export enum StatusType {
|
|
2
|
-
FAILED = 'failed',
|
|
3
|
-
SUCCESS = 'success'
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export enum EventType {
|
|
7
|
-
START = 'start_command_session',
|
|
8
|
-
END = 'end_command_session'
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export type LambdaOptions = {
|
|
12
|
-
functionName?: string
|
|
13
|
-
listFunctions?: boolean
|
|
14
|
-
region?: string
|
|
15
|
-
endpointUrl?: string
|
|
16
|
-
profile?: string
|
|
17
|
-
help?: boolean
|
|
18
|
-
verbose?: boolean
|
|
19
|
-
jsonOutput?: boolean
|
|
20
|
-
_unknown?: string[]
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
type ScanFunctionData = {
|
|
24
|
-
functionArn: string
|
|
25
|
-
scanId: string
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export type AnalyticsOption = {
|
|
29
|
-
sessionId: string
|
|
30
|
-
eventType: EventType
|
|
31
|
-
packageVersion: string
|
|
32
|
-
arguments?: LambdaOptions
|
|
33
|
-
scanFunctionData?: ScanFunctionData
|
|
34
|
-
status?: StatusType
|
|
35
|
-
errorMsg?: string
|
|
36
|
-
}
|
package/src/lambda/utils.ts
DELETED
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
2
|
-
import { groupBy, sortBy, capitalize, minBy } from 'lodash'
|
|
3
|
-
import i18n from 'i18n'
|
|
4
|
-
import { log } from './logUtils'
|
|
5
|
-
|
|
6
|
-
// fix for using `plural`
|
|
7
|
-
// https://github.com/mashpie/i18n-node/issues/429
|
|
8
|
-
i18n.setLocale('en')
|
|
9
|
-
|
|
10
|
-
class PrintVulnerability {
|
|
11
|
-
index: number
|
|
12
|
-
vulnerability: any
|
|
13
|
-
group?: any[]
|
|
14
|
-
title: string
|
|
15
|
-
severity: string
|
|
16
|
-
remediation: string
|
|
17
|
-
description: string
|
|
18
|
-
recommendation: string
|
|
19
|
-
whatHappened: string
|
|
20
|
-
|
|
21
|
-
constructor(index: number, vulnerability: any, group?: any[]) {
|
|
22
|
-
const { severityText, title, description, remediation, categoryText } =
|
|
23
|
-
vulnerability
|
|
24
|
-
|
|
25
|
-
this.group = group
|
|
26
|
-
this.vulnerability = vulnerability
|
|
27
|
-
this.index = index
|
|
28
|
-
this.title = title
|
|
29
|
-
this.severity = capitalize(severityText)
|
|
30
|
-
this.description = underlineLinks(description)
|
|
31
|
-
this.remediation = remediation?.description
|
|
32
|
-
this.recommendation = ''
|
|
33
|
-
this.whatHappened = ''
|
|
34
|
-
|
|
35
|
-
if (categoryText === 'PERMISSIONS') {
|
|
36
|
-
this.formatPermissions()
|
|
37
|
-
} else if (categoryText === 'DEPENDENCIES') {
|
|
38
|
-
this.formatDependencies()
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
formatPermissions() {
|
|
43
|
-
const { leastPrivilege, comment } = this.vulnerability.evidence
|
|
44
|
-
const violatingPolicies = leastPrivilege?.violatingPolicies || []
|
|
45
|
-
|
|
46
|
-
const filteredPolicies = violatingPolicies
|
|
47
|
-
.filter((vp: any) => vp?.suggestedPolicy?.suggestedPolicyCode?.length)
|
|
48
|
-
.map((vp: any) => vp?.suggestedPolicy)
|
|
49
|
-
|
|
50
|
-
const shouldNumerate = filteredPolicies.length > 1
|
|
51
|
-
filteredPolicies.forEach((policies: any, i: number) => {
|
|
52
|
-
const { suggestedPolicyCode, description } = policies
|
|
53
|
-
|
|
54
|
-
suggestedPolicyCode.forEach((policy: any) => {
|
|
55
|
-
const { snippet, title } = policy
|
|
56
|
-
this.recommendation += shouldNumerate
|
|
57
|
-
? ` ${i + 1}. ${description}\n`
|
|
58
|
-
: `${description}\n`
|
|
59
|
-
|
|
60
|
-
if (title !== 'DELETE POLICY') {
|
|
61
|
-
this.recommendation += `${snippet}\n`
|
|
62
|
-
}
|
|
63
|
-
})
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
if (comment?.length) {
|
|
67
|
-
const splitComment = (comment: string) => {
|
|
68
|
-
const [policy, description] = comment.split(':').map(c => c.trim())
|
|
69
|
-
return { policy, description }
|
|
70
|
-
}
|
|
71
|
-
const groupByPolicy = groupBy(comment, c => splitComment(c).policy)
|
|
72
|
-
|
|
73
|
-
Object.entries(groupByPolicy).forEach(([policy, commentArr]) => {
|
|
74
|
-
const comments = commentArr
|
|
75
|
-
.map(splitComment)
|
|
76
|
-
.map(({ description }) => ` - ${description}`)
|
|
77
|
-
.join('\n')
|
|
78
|
-
this.whatHappened += i18n.__('whatHappenedItem', { policy, comments })
|
|
79
|
-
})
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
formatDependencies() {
|
|
84
|
-
if (!this.group?.length) {
|
|
85
|
-
this.recommendation = this.vulnerability?.remediation?.description
|
|
86
|
-
return
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const maxSeverity = minBy(this.group, 'severity')
|
|
90
|
-
this.title = i18n.__('vulnerableDependency')
|
|
91
|
-
this.severity = capitalize(maxSeverity.severityText)
|
|
92
|
-
this.recommendation = maxSeverity.remediation?.description
|
|
93
|
-
|
|
94
|
-
const library = groupByDependency({ title: this.vulnerability.title })
|
|
95
|
-
const [packageName, version] = library.split(':')
|
|
96
|
-
const allCves = this.group.map(groupByCVE)
|
|
97
|
-
|
|
98
|
-
this.description = i18n.__mf('vulnerableDependencyDescriptions', {
|
|
99
|
-
NUM: this.group.length,
|
|
100
|
-
packageName,
|
|
101
|
-
version,
|
|
102
|
-
cves: allCves.join(' | ')
|
|
103
|
-
})
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
print() {
|
|
107
|
-
log(`${this.index}.`)
|
|
108
|
-
// prettier-ignore
|
|
109
|
-
log(`${chalk.bold(this.severity)} | ${chalk.bold(this.title)} ${this.description}`)
|
|
110
|
-
|
|
111
|
-
if (this.whatHappened) {
|
|
112
|
-
log(`\n${chalk.bold(i18n.__('whatHappenedTitle'))}\n${this.whatHappened}`)
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (this.recommendation) {
|
|
116
|
-
log(`${chalk.bold(i18n.__('recommendation'))}\n${this.recommendation}`)
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
log('')
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const groupByCVE = ({ title }: any) =>
|
|
124
|
-
title.substring(0, title.indexOf('[') - 1)
|
|
125
|
-
|
|
126
|
-
const groupByDependency = ({ title }: any) =>
|
|
127
|
-
title.substring(title.indexOf('[') + 1, title.indexOf(']'))
|
|
128
|
-
|
|
129
|
-
const printResults = (results: any[]) => {
|
|
130
|
-
//filter out any vulnerabs which is not least privilege or dependencies- cli does not handle other vulnerabs yet
|
|
131
|
-
const vulnerabs = results.filter(r => r.category === 1 || r.category === 4)
|
|
132
|
-
const sortBySeverity = sortBy(vulnerabs, ['severity', 'title'])
|
|
133
|
-
const notDependencies = sortBySeverity.filter(r => r.category !== 1)
|
|
134
|
-
const dependencies = sortBySeverity.filter(r => r.category === 1)
|
|
135
|
-
const dependenciesByLibrary = groupBy(dependencies, groupByDependency)
|
|
136
|
-
|
|
137
|
-
log('')
|
|
138
|
-
|
|
139
|
-
notDependencies.forEach((vulnerability: any, index: number) => {
|
|
140
|
-
const printVulnerab = new PrintVulnerability(index + 1, vulnerability)
|
|
141
|
-
printVulnerab.print()
|
|
142
|
-
})
|
|
143
|
-
const prevIndex = notDependencies.length + 1
|
|
144
|
-
Object.entries(dependenciesByLibrary).forEach(([, group], i) => {
|
|
145
|
-
const printVulnerab = new PrintVulnerability(prevIndex + i, group[0], group)
|
|
146
|
-
printVulnerab.print()
|
|
147
|
-
})
|
|
148
|
-
|
|
149
|
-
const dependenciesCount = Object.keys(dependenciesByLibrary).length
|
|
150
|
-
const resultCount = notDependencies.length + dependenciesCount
|
|
151
|
-
log(i18n.__n('foundVulnerabilities', resultCount), { bold: true })
|
|
152
|
-
|
|
153
|
-
const counters = getNotDependenciesCounters(notDependencies)
|
|
154
|
-
if (dependenciesCount) {
|
|
155
|
-
counters.push(i18n.__n('dependenciesCount', dependenciesCount))
|
|
156
|
-
}
|
|
157
|
-
log(counters.join(' | '), { bold: true })
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
const getNotDependenciesCounters = (notDependencies: any[]) => {
|
|
161
|
-
const groupByType = groupBy(notDependencies, ['categoryText'])
|
|
162
|
-
return Object.values(groupByType).map(
|
|
163
|
-
group => `${group.length} ${capitalize(group[0].categoryText)}`
|
|
164
|
-
)
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
const underlineLinks = (text: string) => {
|
|
168
|
-
if (!text) {
|
|
169
|
-
return text
|
|
170
|
-
}
|
|
171
|
-
const urlRegex = /(https?:\/\/[^\s]+)/g
|
|
172
|
-
return text.replace(urlRegex, chalk.underline('$1'))
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function toLowerKeys(obj: Record<string, unknown>) {
|
|
176
|
-
return Object.keys(obj).reduce((accumulator, key) => {
|
|
177
|
-
const new_key = `${key[0].toLowerCase()}${key.slice(1)}`
|
|
178
|
-
accumulator[new_key] = obj[key]
|
|
179
|
-
return accumulator
|
|
180
|
-
}, {} as Record<string, unknown>)
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
export { toLowerKeys, printResults }
|
|
184
|
-
export const exportedForTesting = {
|
|
185
|
-
underlineLinks,
|
|
186
|
-
printResults,
|
|
187
|
-
PrintVulnerability
|
|
188
|
-
}
|
package/src/sbom/generateSbom.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { getHttpClient } from '../utils/commonApi'
|
|
2
|
-
|
|
3
|
-
export const generateSbom = (config: any, type: string) => {
|
|
4
|
-
const client = getHttpClient(config)
|
|
5
|
-
return client
|
|
6
|
-
.getSbom(config, type)
|
|
7
|
-
.then((res: { statusCode: number; body: any }) => {
|
|
8
|
-
if (res.statusCode === 200) {
|
|
9
|
-
return res.body
|
|
10
|
-
} else if (res.statusCode === 403) {
|
|
11
|
-
console.log('\nUnable to retrieve Software Bill of Materials (SBOM)')
|
|
12
|
-
console.log(
|
|
13
|
-
`Please ensure OSS is enabled for your organization - org-id ${config.organizationId} and app ${config.applicationId}`
|
|
14
|
-
)
|
|
15
|
-
return undefined
|
|
16
|
-
} else {
|
|
17
|
-
console.log('Unable to retrieve Software Bill of Materials (SBOM)')
|
|
18
|
-
return undefined
|
|
19
|
-
}
|
|
20
|
-
})
|
|
21
|
-
.catch((err: any) => {
|
|
22
|
-
console.log(err)
|
|
23
|
-
})
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export const generateSCASbom = (
|
|
27
|
-
config: any,
|
|
28
|
-
type: string,
|
|
29
|
-
reportId: string
|
|
30
|
-
) => {
|
|
31
|
-
const client = getHttpClient(config)
|
|
32
|
-
return client
|
|
33
|
-
.getSCASbom(config, type, reportId)
|
|
34
|
-
.then((res: { statusCode: number; body: any }) => {
|
|
35
|
-
if (res.statusCode === 200) {
|
|
36
|
-
return res.body
|
|
37
|
-
} else {
|
|
38
|
-
console.log('Unable to retrieve Software Bill of Materials (SBOM)')
|
|
39
|
-
return undefined
|
|
40
|
-
}
|
|
41
|
-
})
|
|
42
|
-
.catch((err: any) => {
|
|
43
|
-
console.log(err)
|
|
44
|
-
})
|
|
45
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
const {
|
|
2
|
-
getSeverityCounts,
|
|
3
|
-
printNoVulnFoundMsg
|
|
4
|
-
} = require('../../audit/report/commonReportingFunctions')
|
|
5
|
-
const common = require('../../common/fail')
|
|
6
|
-
const { printFormattedOutputSca } = require('./commonReportingFunctionsSca')
|
|
7
|
-
const { auditSave } = require('../../audit/save')
|
|
8
|
-
|
|
9
|
-
const processAuditReport = async (config, reportModelList, reportId) => {
|
|
10
|
-
let severityCounts = {}
|
|
11
|
-
if (reportModelList !== undefined) {
|
|
12
|
-
severityCounts = formatScaServicesReport(config, reportModelList)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (config.save !== undefined) {
|
|
16
|
-
await auditSave(config, reportId)
|
|
17
|
-
} else {
|
|
18
|
-
console.log('Use contrast audit --save to generate an SBOM')
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (config.fail) {
|
|
22
|
-
common.processFail(config, severityCounts)
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
const formatScaServicesReport = (config, reportModelList) => {
|
|
26
|
-
const projectOverviewCount = getSeverityCounts(reportModelList)
|
|
27
|
-
|
|
28
|
-
if (projectOverviewCount.total === 0) {
|
|
29
|
-
printNoVulnFoundMsg()
|
|
30
|
-
} else {
|
|
31
|
-
const numberOfVulnerableLibraries = reportModelList.map(library => {
|
|
32
|
-
let count = 0
|
|
33
|
-
|
|
34
|
-
if (library.vulnerabilities.length > 0) {
|
|
35
|
-
count++
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return count
|
|
39
|
-
}).length
|
|
40
|
-
|
|
41
|
-
let numberOfCves = reportModelList.reduce(
|
|
42
|
-
(count, current) => count + current.vulnerabilities.length,
|
|
43
|
-
0
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
printFormattedOutputSca(
|
|
47
|
-
config,
|
|
48
|
-
reportModelList,
|
|
49
|
-
numberOfVulnerableLibraries,
|
|
50
|
-
numberOfCves
|
|
51
|
-
)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return projectOverviewCount
|
|
55
|
-
}
|
|
56
|
-
module.exports = {
|
|
57
|
-
formatScaServicesReport,
|
|
58
|
-
processAuditReport
|
|
59
|
-
}
|
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
const {
|
|
2
|
-
ReportList,
|
|
3
|
-
ReportModelStructure,
|
|
4
|
-
ReportCompositeKey
|
|
5
|
-
} = require('../../audit/report/models/reportListModel')
|
|
6
|
-
const {
|
|
7
|
-
countVulnerableLibrariesBySeverity
|
|
8
|
-
} = require('../../audit/report/utils/reportUtils')
|
|
9
|
-
const {
|
|
10
|
-
SeverityCountModel
|
|
11
|
-
} = require('../../audit/report/models/severityCountModel')
|
|
12
|
-
const { orderBy } = require('lodash')
|
|
13
|
-
const {
|
|
14
|
-
ReportOutputModel,
|
|
15
|
-
ReportOutputHeaderModel,
|
|
16
|
-
ReportOutputBodyModel
|
|
17
|
-
} = require('../../audit/report/models/reportOutputModel')
|
|
18
|
-
const {
|
|
19
|
-
CE_URL,
|
|
20
|
-
CRITICAL_COLOUR,
|
|
21
|
-
HIGH_COLOUR,
|
|
22
|
-
MEDIUM_COLOUR,
|
|
23
|
-
LOW_COLOUR,
|
|
24
|
-
NOTE_COLOUR
|
|
25
|
-
} = require('../../constants/constants')
|
|
26
|
-
const chalk = require('chalk')
|
|
27
|
-
const Table = require('cli-table3')
|
|
28
|
-
const {
|
|
29
|
-
findHighestSeverityCVESca,
|
|
30
|
-
severityCountAllCVEsSca,
|
|
31
|
-
findCVESeveritySca,
|
|
32
|
-
orderByHighestPrioritySca
|
|
33
|
-
} = require('./utils/reportUtilsSca')
|
|
34
|
-
const {
|
|
35
|
-
buildFormattedHeaderNum
|
|
36
|
-
} = require('../../audit/report/commonReportingFunctions')
|
|
37
|
-
|
|
38
|
-
const createSummaryMessageTop = (numberOfVulnerableLibraries, numberOfCves) => {
|
|
39
|
-
numberOfVulnerableLibraries === 1
|
|
40
|
-
? console.log(
|
|
41
|
-
`\n\nFound 1 vulnerable library containing ${numberOfCves} CVE`
|
|
42
|
-
)
|
|
43
|
-
: console.log(
|
|
44
|
-
`\n\nFound ${numberOfVulnerableLibraries} vulnerable libraries containing ${numberOfCves} CVEs`
|
|
45
|
-
)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const createSummaryMessageBottom = numberOfVulnerableLibraries => {
|
|
49
|
-
numberOfVulnerableLibraries === 1
|
|
50
|
-
? console.log(`Found 1 vulnerability`)
|
|
51
|
-
: console.log(`Found ${numberOfVulnerableLibraries} vulnerabilities`)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const printFormattedOutputSca = (
|
|
55
|
-
config,
|
|
56
|
-
reportModelList,
|
|
57
|
-
numberOfVulnerableLibraries,
|
|
58
|
-
numberOfCves
|
|
59
|
-
) => {
|
|
60
|
-
createSummaryMessageTop(numberOfVulnerableLibraries, numberOfCves)
|
|
61
|
-
console.log()
|
|
62
|
-
const report = new ReportList()
|
|
63
|
-
|
|
64
|
-
for (const library of reportModelList) {
|
|
65
|
-
const { artifactName, version, vulnerabilities, remediationAdvice } =
|
|
66
|
-
library
|
|
67
|
-
|
|
68
|
-
const newOutputModel = new ReportModelStructure(
|
|
69
|
-
new ReportCompositeKey(
|
|
70
|
-
artifactName,
|
|
71
|
-
version,
|
|
72
|
-
findHighestSeverityCVESca(vulnerabilities),
|
|
73
|
-
severityCountAllCVEsSca(
|
|
74
|
-
vulnerabilities,
|
|
75
|
-
new SeverityCountModel()
|
|
76
|
-
).getTotal
|
|
77
|
-
),
|
|
78
|
-
vulnerabilities,
|
|
79
|
-
remediationAdvice
|
|
80
|
-
)
|
|
81
|
-
report.reportOutputList.push(newOutputModel)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const outputOrderedByLowestSeverityAndLowestNumOfCvesFirst = orderBy(
|
|
85
|
-
report.reportOutputList,
|
|
86
|
-
[
|
|
87
|
-
reportListItem => {
|
|
88
|
-
return reportListItem.compositeKey.highestSeverity.priority
|
|
89
|
-
},
|
|
90
|
-
reportListItem => {
|
|
91
|
-
return reportListItem.compositeKey.numberOfSeverities
|
|
92
|
-
}
|
|
93
|
-
],
|
|
94
|
-
['asc', 'desc']
|
|
95
|
-
)
|
|
96
|
-
|
|
97
|
-
let contrastHeaderNumCounter = 0
|
|
98
|
-
for (const reportModel of outputOrderedByLowestSeverityAndLowestNumOfCvesFirst) {
|
|
99
|
-
contrastHeaderNumCounter++
|
|
100
|
-
const { libraryName, libraryVersion, highestSeverity } =
|
|
101
|
-
reportModel.compositeKey
|
|
102
|
-
|
|
103
|
-
const { cveArray, remediationAdvice } = reportModel
|
|
104
|
-
|
|
105
|
-
const numOfCVEs = reportModel.cveArray.length
|
|
106
|
-
|
|
107
|
-
const table = getReportTable()
|
|
108
|
-
|
|
109
|
-
const header = buildHeader(
|
|
110
|
-
highestSeverity,
|
|
111
|
-
contrastHeaderNumCounter,
|
|
112
|
-
libraryName,
|
|
113
|
-
libraryVersion,
|
|
114
|
-
numOfCVEs
|
|
115
|
-
)
|
|
116
|
-
|
|
117
|
-
const body = buildBody(cveArray, remediationAdvice)
|
|
118
|
-
|
|
119
|
-
const reportOutputModel = new ReportOutputModel(header, body)
|
|
120
|
-
|
|
121
|
-
table.push(
|
|
122
|
-
reportOutputModel.body.issueMessage,
|
|
123
|
-
reportOutputModel.body.adviceMessage
|
|
124
|
-
)
|
|
125
|
-
|
|
126
|
-
console.log(
|
|
127
|
-
reportOutputModel.header.vulnMessage,
|
|
128
|
-
reportOutputModel.header.introducesMessage
|
|
129
|
-
)
|
|
130
|
-
console.log(table.toString() + '\n')
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
createSummaryMessageBottom(numberOfVulnerableLibraries)
|
|
134
|
-
const {
|
|
135
|
-
criticalMessage,
|
|
136
|
-
highMessage,
|
|
137
|
-
mediumMessage,
|
|
138
|
-
lowMessage,
|
|
139
|
-
noteMessage
|
|
140
|
-
} = buildFooter(outputOrderedByLowestSeverityAndLowestNumOfCvesFirst)
|
|
141
|
-
console.log(
|
|
142
|
-
`${criticalMessage} | ${highMessage} | ${mediumMessage} | ${lowMessage} | ${noteMessage}`
|
|
143
|
-
)
|
|
144
|
-
|
|
145
|
-
if (config.host !== CE_URL && config.projectId) {
|
|
146
|
-
console.log(
|
|
147
|
-
'\n' + chalk.bold("Check out your project's results in Contrast")
|
|
148
|
-
)
|
|
149
|
-
console.log(
|
|
150
|
-
`${config.host}/Contrast/static/ng/index.html#/${config.organizationId}/libraries?view=static&projects=${config.name}`
|
|
151
|
-
)
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
function getReportTable() {
|
|
156
|
-
return new Table({
|
|
157
|
-
chars: {
|
|
158
|
-
top: '',
|
|
159
|
-
'top-mid': '',
|
|
160
|
-
'top-left': '',
|
|
161
|
-
'top-right': '',
|
|
162
|
-
bottom: '',
|
|
163
|
-
'bottom-mid': '',
|
|
164
|
-
'bottom-left': '',
|
|
165
|
-
'bottom-right': '',
|
|
166
|
-
left: '',
|
|
167
|
-
'left-mid': '',
|
|
168
|
-
mid: '',
|
|
169
|
-
'mid-mid': '',
|
|
170
|
-
right: '',
|
|
171
|
-
'right-mid': '',
|
|
172
|
-
middle: ' '
|
|
173
|
-
},
|
|
174
|
-
style: { 'padding-left': 0, 'padding-right': 0 },
|
|
175
|
-
colAligns: ['right'],
|
|
176
|
-
wordWrap: true,
|
|
177
|
-
colWidths: [12, 1, 100]
|
|
178
|
-
})
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
function buildHeader(
|
|
182
|
-
highestSeverity,
|
|
183
|
-
contrastHeaderNum,
|
|
184
|
-
libraryName,
|
|
185
|
-
version,
|
|
186
|
-
numOfCVEs
|
|
187
|
-
) {
|
|
188
|
-
const vulnerabilityPluralised =
|
|
189
|
-
numOfCVEs > 1 ? 'vulnerabilities' : 'vulnerability'
|
|
190
|
-
const formattedHeaderNum = buildFormattedHeaderNum(contrastHeaderNum)
|
|
191
|
-
|
|
192
|
-
const headerColour = chalk.hex(highestSeverity.colour)
|
|
193
|
-
const headerNumAndSeverity = headerColour(
|
|
194
|
-
`${formattedHeaderNum} - [${highestSeverity.severity}]`
|
|
195
|
-
)
|
|
196
|
-
const libraryNameAndVersion = headerColour.bold(`${libraryName}-${version}`)
|
|
197
|
-
const vulnMessage = `${headerNumAndSeverity} ${libraryNameAndVersion}`
|
|
198
|
-
|
|
199
|
-
const introducesMessage = `introduces ${numOfCVEs} ${vulnerabilityPluralised}`
|
|
200
|
-
|
|
201
|
-
return new ReportOutputHeaderModel(vulnMessage, introducesMessage)
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
function buildBody(cveArray, advice) {
|
|
205
|
-
const orderedCvesWithSeverityAssigned = orderByHighestPrioritySca(
|
|
206
|
-
cveArray.map(cve => findCVESeveritySca(cve))
|
|
207
|
-
)
|
|
208
|
-
const issueMessage = getIssueRow(orderedCvesWithSeverityAssigned)
|
|
209
|
-
const adviceMessage = getAdviceRow(advice)
|
|
210
|
-
|
|
211
|
-
return new ReportOutputBodyModel(issueMessage, adviceMessage)
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
function getIssueRow(cveArray) {
|
|
215
|
-
const cveMessagesList = getIssueCveMsgList(cveArray)
|
|
216
|
-
return [chalk.bold('Issue'), ':', `${cveMessagesList.join(', ')}`]
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
function getAdviceRow(advice) {
|
|
220
|
-
const latestOrClosest = advice.closestStableVersion
|
|
221
|
-
? advice.closestStableVersion
|
|
222
|
-
: advice.latestStableVersion
|
|
223
|
-
const displayAdvice = latestOrClosest
|
|
224
|
-
? `Change to version ${chalk.bold(latestOrClosest)}`
|
|
225
|
-
: 'No recommendation is available according to our data. Upgrade to the latest stable is the best advice we can give.'
|
|
226
|
-
|
|
227
|
-
return [chalk.bold(`Advice`), chalk.bold(`:`), `${displayAdvice}`]
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
const buildFooter = reportModelStructure => {
|
|
231
|
-
const { critical, high, medium, low, note } =
|
|
232
|
-
countVulnerableLibrariesBySeverity(reportModelStructure)
|
|
233
|
-
|
|
234
|
-
const criticalMessage = chalk
|
|
235
|
-
.hex(CRITICAL_COLOUR)
|
|
236
|
-
.bold(`${critical} Critical`)
|
|
237
|
-
const highMessage = chalk.hex(HIGH_COLOUR).bold(`${high} High`)
|
|
238
|
-
const mediumMessage = chalk.hex(MEDIUM_COLOUR).bold(`${medium} Medium`)
|
|
239
|
-
const lowMessage = chalk.hex(LOW_COLOUR).bold(`${low} Low`)
|
|
240
|
-
const noteMessage = chalk.hex(NOTE_COLOUR).bold(`${note} Note`)
|
|
241
|
-
|
|
242
|
-
return {
|
|
243
|
-
criticalMessage,
|
|
244
|
-
highMessage,
|
|
245
|
-
mediumMessage,
|
|
246
|
-
lowMessage,
|
|
247
|
-
noteMessage
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
const getIssueCveMsgList = reportSeverityModels => {
|
|
252
|
-
const cveMessages = []
|
|
253
|
-
reportSeverityModels.forEach(reportSeverityModel => {
|
|
254
|
-
const { colour, severity, name } = reportSeverityModel
|
|
255
|
-
|
|
256
|
-
const severityShorthand = chalk
|
|
257
|
-
.hex(colour)
|
|
258
|
-
.bold(`[${severity.charAt(0).toUpperCase()}]`)
|
|
259
|
-
|
|
260
|
-
const builtMessage = severityShorthand + name
|
|
261
|
-
cveMessages.push(builtMessage)
|
|
262
|
-
})
|
|
263
|
-
return cveMessages
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
module.exports = {
|
|
267
|
-
createSummaryMessageTop,
|
|
268
|
-
createSummaryMessageBottom,
|
|
269
|
-
printFormattedOutputSca,
|
|
270
|
-
getReportTable,
|
|
271
|
-
buildHeader,
|
|
272
|
-
buildBody,
|
|
273
|
-
getIssueRow,
|
|
274
|
-
buildFormattedHeaderNum,
|
|
275
|
-
getIssueCveMsgList
|
|
276
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
const createJavaTSMessage = javaTree => {
|
|
2
|
-
return {
|
|
3
|
-
java: {
|
|
4
|
-
mavenDependencyTrees: javaTree
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const createJavaScriptTSMessage = js => {
|
|
10
|
-
let message = {
|
|
11
|
-
node: {
|
|
12
|
-
packageJSON: js.packageJSON
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
if (js.yarn !== undefined) {
|
|
16
|
-
message.node.yarnLockFile = js.yarn.yarnLockFile
|
|
17
|
-
message.node.yarnVersion = js.yarn.yarnVersion
|
|
18
|
-
} else {
|
|
19
|
-
message.node.npmLockFile = js.npmLockFile
|
|
20
|
-
}
|
|
21
|
-
return message
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const createGoTSMessage = goTree => {
|
|
25
|
-
return {
|
|
26
|
-
go: {
|
|
27
|
-
goDependencyTrees: goTree
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const createRubyTSMessage = rubyTree => {
|
|
33
|
-
return {
|
|
34
|
-
ruby: rubyTree
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const createPythonTSMessage = pythonTree => {
|
|
39
|
-
return {
|
|
40
|
-
python: pythonTree
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const createPhpTSMessage = phpTree => {
|
|
45
|
-
return {
|
|
46
|
-
php: {
|
|
47
|
-
composerJSON: phpTree.composerJSON,
|
|
48
|
-
lockFile: phpTree.lockFile
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const createDotNetTSMessage = dotnetTree => {
|
|
54
|
-
return {
|
|
55
|
-
dotnet: dotnetTree
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
module.exports = {
|
|
60
|
-
createJavaScriptTSMessage,
|
|
61
|
-
createJavaTSMessage,
|
|
62
|
-
createGoTSMessage,
|
|
63
|
-
createPhpTSMessage,
|
|
64
|
-
createRubyTSMessage,
|
|
65
|
-
createPythonTSMessage,
|
|
66
|
-
createDotNetTSMessage
|
|
67
|
-
}
|