@contrast/contrast 2.0.2-beta.2 → 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,86 +0,0 @@
|
|
|
1
|
-
type Importance = 'important' | 'essential'
|
|
2
|
-
|
|
3
|
-
interface ArtifactLocation {
|
|
4
|
-
uri: string
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
interface Region {
|
|
8
|
-
startLine: string
|
|
9
|
-
snippet: Snippet
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface Snippet {
|
|
13
|
-
text: string
|
|
14
|
-
rendered: Rendered
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
interface Rendered {
|
|
18
|
-
text: string
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
interface PhysicalLocation {
|
|
22
|
-
artifactLocation: ArtifactLocation
|
|
23
|
-
region: Region
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
interface LogicalLocation {
|
|
27
|
-
fullyQualifiedName: string
|
|
28
|
-
name: string
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface Location {
|
|
32
|
-
physicalLocation: PhysicalLocation
|
|
33
|
-
logicalLocations?: LogicalLocation[]
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface ThreadFlowLocation {
|
|
37
|
-
importance: Importance
|
|
38
|
-
location: Location
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
interface ThreadFlow {
|
|
42
|
-
locations: ThreadFlowLocation[]
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
interface Message {
|
|
46
|
-
text: string
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export interface CodeFlow {
|
|
50
|
-
message: Message
|
|
51
|
-
threadFlows: ThreadFlow[]
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export interface ResultContent {
|
|
55
|
-
message?: { text: string }
|
|
56
|
-
id: string
|
|
57
|
-
organizationId: string
|
|
58
|
-
projectId: string
|
|
59
|
-
firstCreatedTime: string
|
|
60
|
-
ruleId: string
|
|
61
|
-
codeFlows: CodeFlow[]
|
|
62
|
-
lastSeenTime: string
|
|
63
|
-
locations: Location[]
|
|
64
|
-
name: string
|
|
65
|
-
description: string
|
|
66
|
-
recommendation: string | null
|
|
67
|
-
risk: string | null
|
|
68
|
-
category: string
|
|
69
|
-
confidence: string
|
|
70
|
-
standards: { [key: string]: string[] }
|
|
71
|
-
cwe: string[]
|
|
72
|
-
owasp: string[]
|
|
73
|
-
reference: string[]
|
|
74
|
-
sink: string
|
|
75
|
-
detailsTrigger: string
|
|
76
|
-
type: RuleType
|
|
77
|
-
source: string
|
|
78
|
-
severity: Severity
|
|
79
|
-
advice: string
|
|
80
|
-
learn: string[]
|
|
81
|
-
issue: string
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export type Severity = 'critical' | 'high' | 'medium' | 'low' | 'note'
|
|
85
|
-
|
|
86
|
-
export type RuleType = 'DATA_FLOW' | 'CRYPTO' | 'CONFIG' | 'DEFAULT'
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { ResultContent } from './resultContentModel'
|
|
2
|
-
|
|
3
|
-
export class ScanResultsModel {
|
|
4
|
-
projectOverview: ProjectOverview
|
|
5
|
-
scanDetail: ScanDetail
|
|
6
|
-
scanResultsInstances: ScanResultsInstances
|
|
7
|
-
newProject: boolean
|
|
8
|
-
|
|
9
|
-
constructor(scan: any) {
|
|
10
|
-
this.projectOverview = scan.projectOverview as ProjectOverview
|
|
11
|
-
this.scanDetail = scan.scanDetail as ScanDetail
|
|
12
|
-
this.scanResultsInstances =
|
|
13
|
-
scan.scanResultsInstances as ScanResultsInstances
|
|
14
|
-
this.newProject = scan.newProject
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface ProjectOverview {
|
|
19
|
-
id: string
|
|
20
|
-
organizationId: string
|
|
21
|
-
name: string
|
|
22
|
-
archived: boolean
|
|
23
|
-
language: string
|
|
24
|
-
critical: number
|
|
25
|
-
high: number
|
|
26
|
-
medium: number
|
|
27
|
-
low: number
|
|
28
|
-
note: number
|
|
29
|
-
lastScanTime: string
|
|
30
|
-
completedScans: number
|
|
31
|
-
lastScanId: string
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface ScanDetail {
|
|
35
|
-
critical: number
|
|
36
|
-
high: number
|
|
37
|
-
medium: number
|
|
38
|
-
low: number
|
|
39
|
-
note: number
|
|
40
|
-
id: string
|
|
41
|
-
organizationId: string
|
|
42
|
-
projectId: string
|
|
43
|
-
codeArtifactId: string
|
|
44
|
-
status: string
|
|
45
|
-
createdTime: string
|
|
46
|
-
startedTime: string
|
|
47
|
-
completedTime: string
|
|
48
|
-
language: string
|
|
49
|
-
label: string
|
|
50
|
-
errorMessage: string
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export interface ScanResultsInstances {
|
|
54
|
-
content: ResultContent[]
|
|
55
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
const commonApi = require('../utils/commonApi.js')
|
|
2
|
-
const i18n = require('i18n')
|
|
3
|
-
|
|
4
|
-
const populateProjectId = async config => {
|
|
5
|
-
const client = commonApi.getHttpClient(config)
|
|
6
|
-
let proj = await createProjectId(config, client)
|
|
7
|
-
if (proj === undefined) {
|
|
8
|
-
proj = await getExistingProjectIdByName(config, client).then(res => {
|
|
9
|
-
return res
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
return { projectId: proj, isNewProject: false }
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return { projectId: proj, isNewProject: true }
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const createProjectId = async (config, client) => {
|
|
19
|
-
return client
|
|
20
|
-
.createProjectId(config)
|
|
21
|
-
.then(res => {
|
|
22
|
-
if (res.statusCode === 409) {
|
|
23
|
-
console.log(i18n.__('foundExistingProjectScan'))
|
|
24
|
-
return
|
|
25
|
-
}
|
|
26
|
-
if (res.statusCode === 403) {
|
|
27
|
-
console.log(i18n.__('permissionsError'))
|
|
28
|
-
process.exit(1)
|
|
29
|
-
return
|
|
30
|
-
}
|
|
31
|
-
if (res.statusCode === 429) {
|
|
32
|
-
console.log(i18n.__('exceededFreeTier'))
|
|
33
|
-
process.exit(1)
|
|
34
|
-
return
|
|
35
|
-
}
|
|
36
|
-
if (res.statusCode === 201) {
|
|
37
|
-
console.log(i18n.__('projectCreatedScan'))
|
|
38
|
-
if (config.verbose) {
|
|
39
|
-
console.log(i18n.__('populateProjectIdMessage', res.body.id))
|
|
40
|
-
}
|
|
41
|
-
return res.body.id
|
|
42
|
-
}
|
|
43
|
-
})
|
|
44
|
-
.catch(err => {
|
|
45
|
-
if (config.verbose) {
|
|
46
|
-
console.log(err)
|
|
47
|
-
}
|
|
48
|
-
console.log(i18n.__('connectionError'))
|
|
49
|
-
process.exit(0)
|
|
50
|
-
})
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const getExistingProjectIdByName = async (config, client) => {
|
|
54
|
-
return client
|
|
55
|
-
.getProjectIdByName(config)
|
|
56
|
-
.then(res => {
|
|
57
|
-
if (res.statusCode === 200) {
|
|
58
|
-
if (config.verbose) {
|
|
59
|
-
console.log(
|
|
60
|
-
i18n.__('populateProjectIdMessage', res.body.content[0].id)
|
|
61
|
-
)
|
|
62
|
-
}
|
|
63
|
-
return res.body.content[0].id
|
|
64
|
-
}
|
|
65
|
-
})
|
|
66
|
-
.catch(err => {
|
|
67
|
-
console.log(err)
|
|
68
|
-
})
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
module.exports = {
|
|
72
|
-
populateProjectId: populateProjectId
|
|
73
|
-
}
|
package/src/scan/saveResults.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const fs = require('fs')
|
|
2
|
-
|
|
3
|
-
const writeResultsToFile = async (responseBody, name = 'results.sarif') => {
|
|
4
|
-
try {
|
|
5
|
-
fs.writeFileSync(name, JSON.stringify(responseBody, null, 2))
|
|
6
|
-
return name
|
|
7
|
-
} catch (err) {
|
|
8
|
-
console.log('Error writing Scan Results to file')
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
module.exports = {
|
|
13
|
-
writeResultsToFile: writeResultsToFile
|
|
14
|
-
}
|
package/src/scan/scan.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import commonApi from '../utils/commonApi.js'
|
|
2
|
-
import fileUtils from '../scan/fileUtils'
|
|
3
|
-
import i18n from 'i18n'
|
|
4
|
-
import oraWrapper from '../utils/oraWrapper'
|
|
5
|
-
|
|
6
|
-
export const allowedFileTypes = ['.jar', '.war', '.js', '.zip', '.exe']
|
|
7
|
-
|
|
8
|
-
export const isFileAllowed = (scanOption: string) => {
|
|
9
|
-
let valid = false
|
|
10
|
-
allowedFileTypes.forEach(fileType => {
|
|
11
|
-
if (scanOption.endsWith(fileType)) {
|
|
12
|
-
valid = true
|
|
13
|
-
}
|
|
14
|
-
})
|
|
15
|
-
return valid
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const sendScan = async (config: any) => {
|
|
19
|
-
if (!isFileAllowed(config.file)) {
|
|
20
|
-
console.log(i18n.__('scanErrorFileMessage'))
|
|
21
|
-
process.exit(9)
|
|
22
|
-
} else {
|
|
23
|
-
fileUtils.checkFilePermissions(config.file)
|
|
24
|
-
const client = commonApi.getHttpClient(config)
|
|
25
|
-
|
|
26
|
-
const startUploadSpinner = oraWrapper.returnOra(i18n.__('uploadingScan'))
|
|
27
|
-
oraWrapper.startSpinner(startUploadSpinner)
|
|
28
|
-
|
|
29
|
-
return await client
|
|
30
|
-
.sendArtifact(config)
|
|
31
|
-
.then(res => {
|
|
32
|
-
if (res.statusCode === 201) {
|
|
33
|
-
oraWrapper.succeedSpinner(
|
|
34
|
-
startUploadSpinner,
|
|
35
|
-
i18n.__('uploadingScanSuccessful')
|
|
36
|
-
)
|
|
37
|
-
if (config.verbose) {
|
|
38
|
-
console.log(i18n.__('responseMessage', res.body))
|
|
39
|
-
}
|
|
40
|
-
return res.body.id
|
|
41
|
-
} else {
|
|
42
|
-
if (config.debug) {
|
|
43
|
-
console.log(config)
|
|
44
|
-
oraWrapper.failSpinner(
|
|
45
|
-
startUploadSpinner,
|
|
46
|
-
i18n.__('uploadingScanFail')
|
|
47
|
-
)
|
|
48
|
-
console.log(i18n.__('genericServiceError', res.statusCode))
|
|
49
|
-
}
|
|
50
|
-
if (res.statusCode === 429) {
|
|
51
|
-
console.log(i18n.__('exceededFreeTier'))
|
|
52
|
-
process.exit(1)
|
|
53
|
-
}
|
|
54
|
-
if (res.statusCode === 403) {
|
|
55
|
-
console.log(i18n.__('permissionsError'))
|
|
56
|
-
process.exit(1)
|
|
57
|
-
}
|
|
58
|
-
oraWrapper.stopSpinner(startUploadSpinner)
|
|
59
|
-
console.log('Contrast Scan Finished')
|
|
60
|
-
process.exit(1)
|
|
61
|
-
}
|
|
62
|
-
})
|
|
63
|
-
.catch(err => {
|
|
64
|
-
oraWrapper.stopSpinner(startUploadSpinner)
|
|
65
|
-
console.log(err)
|
|
66
|
-
})
|
|
67
|
-
}
|
|
68
|
-
}
|
package/src/scan/scanConfig.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
const paramHandler = require('../utils/paramsUtil/paramHandler')
|
|
2
|
-
const constants = require('../cliConstants.js')
|
|
3
|
-
const path = require('path')
|
|
4
|
-
const { supportedLanguagesScan } = require('../constants/constants')
|
|
5
|
-
const i18n = require('i18n')
|
|
6
|
-
const { scanUsageGuide } = require('./help')
|
|
7
|
-
const parsedCLIOptions = require('../utils/parsedCLIOptions')
|
|
8
|
-
|
|
9
|
-
const getScanConfig = async (contrastConf, command, argv) => {
|
|
10
|
-
let scanParams = await parsedCLIOptions.getCommandLineArgsCustom(
|
|
11
|
-
contrastConf,
|
|
12
|
-
command,
|
|
13
|
-
argv,
|
|
14
|
-
constants.commandLineDefinitions.scanOptionDefinitions
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
if (scanParams.help) {
|
|
18
|
-
printHelpMessage()
|
|
19
|
-
process.exit(0)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const paramsAuth = paramHandler.getAuth(scanParams)
|
|
23
|
-
|
|
24
|
-
if (scanParams.language) {
|
|
25
|
-
scanParams.language = scanParams.language.toUpperCase()
|
|
26
|
-
if (!Object.values(supportedLanguagesScan).includes(scanParams.language)) {
|
|
27
|
-
console.log(`Did not recognise --language ${scanParams.language}`)
|
|
28
|
-
console.log(i18n.__('constantsHowToRunDev3'))
|
|
29
|
-
process.exit(1)
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// if no name, take the full file path and use it as the project name
|
|
34
|
-
let projectNameSource
|
|
35
|
-
if (!scanParams.name && scanParams.file) {
|
|
36
|
-
scanParams.name = getFileName(scanParams.file)
|
|
37
|
-
projectNameSource = 'AUTO'
|
|
38
|
-
} else {
|
|
39
|
-
projectNameSource = 'USER'
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return { ...paramsAuth, ...scanParams, projectNameSource }
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const getFileName = file => {
|
|
46
|
-
// from '/Users/x/y/spring-async.war' to 'spring-async.war'
|
|
47
|
-
return file.split(path.sep).pop()
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const printHelpMessage = () => {
|
|
51
|
-
console.log(scanUsageGuide)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
module.exports = {
|
|
55
|
-
getScanConfig,
|
|
56
|
-
getFileName,
|
|
57
|
-
printHelpMessage
|
|
58
|
-
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
const i18n = require('i18n')
|
|
2
|
-
const {
|
|
3
|
-
returnOra,
|
|
4
|
-
startSpinner,
|
|
5
|
-
succeedSpinner,
|
|
6
|
-
stopSpinner
|
|
7
|
-
} = require('../utils/oraWrapper')
|
|
8
|
-
const populateProjectIdAndProjectName = require('./populateProjectIdAndProjectName')
|
|
9
|
-
const scan = require('./scan')
|
|
10
|
-
const scanResults = require('./scanResults')
|
|
11
|
-
const autoDetection = require('../common/autoDetection')
|
|
12
|
-
const fileFunctions = require('./fileUtils')
|
|
13
|
-
const { performance } = require('perf_hooks')
|
|
14
|
-
|
|
15
|
-
const getTimeout = config => {
|
|
16
|
-
if (config.timeout) {
|
|
17
|
-
return config.timeout
|
|
18
|
-
} else {
|
|
19
|
-
if (config.verbose) {
|
|
20
|
-
console.log('Timeout set to 5 minutes')
|
|
21
|
-
}
|
|
22
|
-
return 300
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const fileAndLanguageLogic = async configToUse => {
|
|
27
|
-
if (configToUse.file) {
|
|
28
|
-
if (!fileFunctions.fileExists(configToUse.file)) {
|
|
29
|
-
console.log(i18n.__('fileNotExist'))
|
|
30
|
-
process.exit(1)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (fileFunctions.fileIsEmpty(configToUse.file)) {
|
|
34
|
-
console.log(i18n.__('scanFileIsEmpty'))
|
|
35
|
-
process.exit(1)
|
|
36
|
-
}
|
|
37
|
-
return configToUse
|
|
38
|
-
} else {
|
|
39
|
-
if (configToUse.file === undefined || configToUse.file === null) {
|
|
40
|
-
await autoDetection.autoDetectFileAndLanguage(configToUse)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const startScan = async configToUse => {
|
|
46
|
-
const startTime = performance.now()
|
|
47
|
-
await fileAndLanguageLogic(configToUse)
|
|
48
|
-
|
|
49
|
-
let newProject
|
|
50
|
-
|
|
51
|
-
if (!configToUse.projectId) {
|
|
52
|
-
const { projectId, isNewProject } =
|
|
53
|
-
await populateProjectIdAndProjectName.populateProjectId(configToUse)
|
|
54
|
-
configToUse.projectId = projectId
|
|
55
|
-
newProject = isNewProject
|
|
56
|
-
} else {
|
|
57
|
-
newProject = false
|
|
58
|
-
}
|
|
59
|
-
const codeArtifactId = await scan.sendScan(configToUse)
|
|
60
|
-
|
|
61
|
-
if (!configToUse.ff) {
|
|
62
|
-
const startScanSpinner = returnOra('🚀 Contrast Scan started')
|
|
63
|
-
startSpinner(startScanSpinner)
|
|
64
|
-
const scanDetail = await scanResults.returnScanResults(
|
|
65
|
-
configToUse,
|
|
66
|
-
codeArtifactId,
|
|
67
|
-
newProject,
|
|
68
|
-
getTimeout(configToUse),
|
|
69
|
-
startScanSpinner
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
const scanResultsInstances = await scanResults.returnScanResultsInstances(
|
|
73
|
-
configToUse,
|
|
74
|
-
scanDetail.id
|
|
75
|
-
)
|
|
76
|
-
|
|
77
|
-
const endTime = performance.now()
|
|
78
|
-
const scanDurationMs = endTime - startTime
|
|
79
|
-
if (scanResultsInstances.statusCode !== 200) {
|
|
80
|
-
stopSpinner(startScanSpinner)
|
|
81
|
-
console.log('Result Service is unavailable, please try again later')
|
|
82
|
-
process.exit(1)
|
|
83
|
-
} else {
|
|
84
|
-
succeedSpinner(startScanSpinner, 'Contrast Scan complete')
|
|
85
|
-
console.log(
|
|
86
|
-
`----- Scan completed in ${(scanDurationMs / 1000).toFixed(2)}s -----`
|
|
87
|
-
)
|
|
88
|
-
return {
|
|
89
|
-
scanDetail,
|
|
90
|
-
scanResultsInstances: scanResultsInstances.body
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
module.exports = {
|
|
97
|
-
startScan: startScan
|
|
98
|
-
}
|
package/src/scan/scanResults.js
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
const commonApi = require('../utils/commonApi')
|
|
2
|
-
const requestUtils = require('../../src/utils/requestUtils')
|
|
3
|
-
const oraFunctions = require('../utils/oraWrapper')
|
|
4
|
-
const _ = require('lodash')
|
|
5
|
-
const i18n = require('i18n')
|
|
6
|
-
const oraWrapper = require('../utils/oraWrapper')
|
|
7
|
-
const readLine = require('readline')
|
|
8
|
-
|
|
9
|
-
const getScanId = async (config, codeArtifactId, client) => {
|
|
10
|
-
return client
|
|
11
|
-
.getScanId(config, codeArtifactId)
|
|
12
|
-
.then(res => {
|
|
13
|
-
if (res.statusCode == 429) {
|
|
14
|
-
throw new Error(i18n.__('exceededFreeTier'))
|
|
15
|
-
}
|
|
16
|
-
return res.body.id
|
|
17
|
-
})
|
|
18
|
-
.catch(err => {
|
|
19
|
-
console.log(err)
|
|
20
|
-
})
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const pollScanResults = async (config, scanId, client) => {
|
|
24
|
-
await requestUtils.sleep(5000)
|
|
25
|
-
return client
|
|
26
|
-
.getSpecificScanResult(config, scanId)
|
|
27
|
-
.then(res => {
|
|
28
|
-
return res
|
|
29
|
-
})
|
|
30
|
-
.catch(err => {
|
|
31
|
-
console.log(err)
|
|
32
|
-
})
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const returnScanResults = async (
|
|
36
|
-
config,
|
|
37
|
-
codeArtifactId,
|
|
38
|
-
newProject,
|
|
39
|
-
timeout,
|
|
40
|
-
startScanSpinner
|
|
41
|
-
) => {
|
|
42
|
-
const client = commonApi.getHttpClient(config)
|
|
43
|
-
let scanId = await getScanId(config, codeArtifactId, client)
|
|
44
|
-
|
|
45
|
-
// send metrics event to sast-event-collector
|
|
46
|
-
if (
|
|
47
|
-
process.env.CODESEC_INVOCATION_ENVIRONMENT &&
|
|
48
|
-
process.env.CODESEC_INVOCATION_ENVIRONMENT.toUpperCase() === 'GITHUB'
|
|
49
|
-
) {
|
|
50
|
-
await client.createNewEvent(config, scanId, newProject)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
let startTime = new Date()
|
|
54
|
-
let complete = false
|
|
55
|
-
if (!_.isNil(scanId)) {
|
|
56
|
-
while (!complete) {
|
|
57
|
-
let result = await pollScanResults(config, scanId, client)
|
|
58
|
-
if (JSON.stringify(result.statusCode) == 200) {
|
|
59
|
-
if (result.body.status === 'COMPLETED') {
|
|
60
|
-
complete = true
|
|
61
|
-
return result.body
|
|
62
|
-
}
|
|
63
|
-
if (result.body.status === 'FAILED') {
|
|
64
|
-
complete = true
|
|
65
|
-
if (config.debug) {
|
|
66
|
-
oraFunctions.failSpinner(
|
|
67
|
-
startScanSpinner,
|
|
68
|
-
i18n.__(
|
|
69
|
-
'scanNotCompleted',
|
|
70
|
-
'https://docs.contrastsecurity.com/en/binary-package-preparation.html'
|
|
71
|
-
)
|
|
72
|
-
)
|
|
73
|
-
}
|
|
74
|
-
if (
|
|
75
|
-
result?.body?.errorMessage ===
|
|
76
|
-
'Unable to determine language for code artifact'
|
|
77
|
-
) {
|
|
78
|
-
console.log(result.body.errorMessage)
|
|
79
|
-
console.log(
|
|
80
|
-
'Try scanning again using --language param. ',
|
|
81
|
-
i18n.__('scanOptionsLanguageSummary')
|
|
82
|
-
)
|
|
83
|
-
}
|
|
84
|
-
oraWrapper.stopSpinner(startScanSpinner)
|
|
85
|
-
console.log('Contrast Scan Finished')
|
|
86
|
-
process.exit(1)
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
let endTime = new Date() - startTime
|
|
90
|
-
if (requestUtils.millisToSeconds(endTime) > timeout) {
|
|
91
|
-
oraFunctions.failSpinner(
|
|
92
|
-
startScanSpinner,
|
|
93
|
-
'Contrast Scan timed out at the specified ' + timeout + ' seconds.'
|
|
94
|
-
)
|
|
95
|
-
|
|
96
|
-
const isCI = process.env.CONTRAST_CODESEC_CI
|
|
97
|
-
? JSON.parse(process.env.CONTRAST_CODESEC_CI.toLowerCase())
|
|
98
|
-
: false
|
|
99
|
-
if (!isCI) {
|
|
100
|
-
const retry = await retryScanPrompt()
|
|
101
|
-
timeout = retry.timeout
|
|
102
|
-
} else {
|
|
103
|
-
console.log('Please try again, allowing more time')
|
|
104
|
-
process.exit(1)
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const retryScanPrompt = async () => {
|
|
112
|
-
const rl = readLine.createInterface({
|
|
113
|
-
input: process.stdin,
|
|
114
|
-
output: process.stdout
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
return new Promise((resolve, reject) => {
|
|
118
|
-
requestUtils.timeOutError(30000, reject)
|
|
119
|
-
|
|
120
|
-
rl.question(
|
|
121
|
-
'🔁 Do you want to continue waiting on Scan? [Y/N]\n',
|
|
122
|
-
async input => {
|
|
123
|
-
if (input.toLowerCase() === 'yes' || input.toLowerCase() === 'y') {
|
|
124
|
-
console.log('Continuing wait for Scan')
|
|
125
|
-
rl.close()
|
|
126
|
-
resolve({ timeout: 300 })
|
|
127
|
-
} else if (
|
|
128
|
-
input.toLowerCase() === 'no' ||
|
|
129
|
-
input.toLowerCase() === 'n'
|
|
130
|
-
) {
|
|
131
|
-
rl.close()
|
|
132
|
-
console.log('Contrast Scan Retry Cancelled: Exiting')
|
|
133
|
-
resolve(process.exit(1))
|
|
134
|
-
} else {
|
|
135
|
-
rl.close()
|
|
136
|
-
console.log('Invalid Input: Exiting')
|
|
137
|
-
resolve(process.exit(1))
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
)
|
|
141
|
-
}).catch(e => {
|
|
142
|
-
throw e
|
|
143
|
-
})
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
const returnScanResultsInstances = async (config, scanId) => {
|
|
147
|
-
const client = commonApi.getHttpClient(config)
|
|
148
|
-
let result
|
|
149
|
-
try {
|
|
150
|
-
result = await client.getScanResultsInstances(config, scanId)
|
|
151
|
-
if (JSON.stringify(result.statusCode) == 200) {
|
|
152
|
-
return { body: result.body, statusCode: result.statusCode }
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
if (JSON.stringify(result.statusCode) == 503) {
|
|
156
|
-
return { statusCode: result.statusCode }
|
|
157
|
-
}
|
|
158
|
-
} catch (e) {
|
|
159
|
-
if (config.debug) {
|
|
160
|
-
console.log(e.message.toString())
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
module.exports = {
|
|
166
|
-
getScanId: getScanId,
|
|
167
|
-
returnScanResults: returnScanResults,
|
|
168
|
-
pollScanResults: pollScanResults,
|
|
169
|
-
returnScanResultsInstances: returnScanResultsInstances,
|
|
170
|
-
retryScanPrompt
|
|
171
|
-
}
|