@contrast/contrast 2.0.2-beta.0 → 2.0.2-beta.10
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 +2 -1
- package/dist/assess/assessConfig.js +9 -0
- package/dist/assess/assessConfig.js.map +1 -0
- package/dist/assess/help.js +37 -0
- package/dist/assess/help.js.map +1 -0
- package/dist/assess/http/index.js +39 -0
- package/dist/assess/http/index.js.map +1 -0
- package/dist/assess/index.js +69 -0
- package/dist/assess/index.js.map +1 -0
- package/dist/assess/metadata/findYamlFile.js +59 -0
- package/dist/assess/metadata/findYamlFile.js.map +1 -0
- package/dist/assess/metadata/index.js +37 -0
- package/dist/assess/metadata/index.js.map +1 -0
- package/dist/assess/metadata/utils.js +159 -0
- package/dist/assess/metadata/utils.js.map +1 -0
- package/dist/assess/printing/index.js +11 -0
- package/dist/assess/printing/index.js.map +1 -0
- package/dist/assess/printing/utils.js +119 -0
- package/dist/assess/printing/utils.js.map +1 -0
- package/dist/audit/auditConfig.js +9 -0
- package/dist/audit/auditConfig.js.map +1 -0
- package/dist/{commands/audit → audit}/auditController.js +9 -13
- package/dist/audit/auditController.js.map +1 -0
- package/dist/audit/auditRequests.js +193 -0
- package/dist/audit/auditRequests.js.map +1 -0
- package/dist/audit/auditRequestsLegacy.js +63 -0
- package/dist/audit/auditRequestsLegacy.js.map +1 -0
- package/dist/audit/catalogueApplication/catalogueApplication.js +16 -29
- package/dist/audit/catalogueApplication/catalogueApplication.js.map +1 -0
- package/dist/audit/help.js +68 -0
- package/dist/audit/help.js.map +1 -0
- package/dist/audit/languageAnalysisEngine/commonApi.js +12 -14
- package/dist/audit/languageAnalysisEngine/commonApi.js.map +1 -0
- package/dist/audit/languageAnalysisEngine/filterProjectPath.js +2 -1
- 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 +18 -30
- 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/processAudit.js +21 -0
- package/dist/audit/processAudit.js.map +1 -0
- package/dist/audit/report/commonReportingFunctions.js +33 -61
- 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/{commands/audit → audit}/saveFile.js +3 -6
- package/dist/audit/saveFile.js.map +1 -0
- package/dist/auth/auth.js +103 -0
- package/dist/auth/auth.js.map +1 -0
- package/dist/auth/authRequests.js +18 -0
- package/dist/auth/authRequests.js.map +1 -0
- package/dist/cliConstants.js +48 -18
- package/dist/cliConstants.js.map +1 -0
- package/dist/commands/config/config.js +12 -13
- package/dist/commands/config/config.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/common/HTTPClient.js +193 -94
- package/dist/common/HTTPClient.js.map +1 -0
- package/dist/{scan → common}/autoDetection.js +53 -36
- package/dist/common/autoDetection.js.map +1 -0
- package/dist/common/baseRequest.js +59 -23
- 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 +49 -63
- 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/stringManipulations.js +8 -0
- package/dist/common/stringManipulations.js.map +1 -0
- package/dist/common/versionChecker.js +16 -19
- package/dist/common/versionChecker.js.map +1 -0
- package/dist/constants/constants.js +46 -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 +14 -10
- package/dist/constants/locales.js.map +1 -0
- package/dist/github/fingerprintConfig.js +10 -0
- package/dist/github/fingerprintConfig.js.map +1 -0
- package/dist/github/processFingerprint.js +25 -0
- package/dist/github/processFingerprint.js.map +1 -0
- package/dist/github/projectGroup.js +225 -0
- package/dist/github/projectGroup.js.map +1 -0
- package/dist/github/repoServices.js +91 -0
- package/dist/github/repoServices.js.map +1 -0
- package/dist/index.js +42 -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 +59 -90
- package/dist/scaAnalysis/common/scaServicesUpload.js.map +1 -0
- package/dist/scaAnalysis/common/treeUpload.js +15 -25
- 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 +86 -32
- 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 +109 -73
- 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 +36 -40
- 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 +22 -60
- package/dist/scan/populateProjectIdAndProjectName.js.map +1 -0
- package/dist/scan/processScan.js +28 -0
- package/dist/scan/processScan.js.map +1 -0
- package/dist/scan/saveResults.js +3 -6
- package/dist/scan/saveResults.js.map +1 -0
- package/dist/scan/scan.js +33 -53
- 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 +19 -21
- package/dist/scan/scanController.js.map +1 -0
- package/dist/scan/scanRequests.js +86 -0
- package/dist/scan/scanRequests.js.map +1 -0
- package/dist/scan/scanResults.js +26 -72
- 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 +2 -1
- package/dist/utils/capabilities.js.map +1 -0
- package/dist/utils/commonApi.js +58 -50
- package/dist/utils/commonApi.js.map +1 -0
- package/dist/utils/filterProjectPath.js +2 -1
- package/dist/utils/filterProjectPath.js.map +1 -0
- package/dist/utils/generalAPI.js +11 -33
- package/dist/utils/generalAPI.js.map +1 -0
- package/dist/utils/getConfig.js +8 -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 +40 -48
- package/.prettierignore +0 -1
- package/bin/contrast.js +0 -2
- package/dist/audit/languageAnalysisEngine/util/requestUtils.js +0 -14
- package/dist/commands/audit/auditConfig.js +0 -12
- package/dist/commands/audit/help.js +0 -70
- package/dist/commands/audit/processAudit.js +0 -24
- package/dist/commands/auth/auth.js +0 -120
- package/dist/commands/github/fingerprintConfig.js +0 -13
- package/dist/commands/github/processFingerprint.js +0 -28
- package/dist/commands/github/projectGroup.js +0 -254
- package/dist/commands/github/repoServices.js +0 -108
- package/dist/commands/scan/processScan.js +0 -31
- 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 -522
- 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 -294
- 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/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 -155
- 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 -119
- 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 -112
- package/src/scaAnalysis/ruby/analysis.js +0 -413
- package/src/scaAnalysis/ruby/index.js +0 -16
- package/src/scaAnalysis/scaAnalysis.js +0 -171
- package/src/scan/autoDetection.js +0 -175
- package/src/scan/fileUtils.js +0 -206
- 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,154 +0,0 @@
|
|
|
1
|
-
import { getHttpClient } from '../utils/commonApi'
|
|
2
|
-
import * as crypto from 'crypto'
|
|
3
|
-
import { ContrastConf } from '../utils/getConfig'
|
|
4
|
-
|
|
5
|
-
export const TELEMETRY_CLI_COMMANDS_EVENT = 'CLI_COMMANDS'
|
|
6
|
-
export const TELEMETRY_CLI_TIME_TO_AUTH_EVENT = 'CLI_TIME_TO_AUTH'
|
|
7
|
-
|
|
8
|
-
export const sendTelemetryConfigAsConfObj = async (
|
|
9
|
-
config: ContrastConf,
|
|
10
|
-
command: string,
|
|
11
|
-
argv: string[],
|
|
12
|
-
result: string,
|
|
13
|
-
language: string
|
|
14
|
-
) => {
|
|
15
|
-
const hostParam = '--host'
|
|
16
|
-
const hostParamAlias = '-h'
|
|
17
|
-
const orgIdParam = '--organization-id'
|
|
18
|
-
const orgIdParamAlias = '-o'
|
|
19
|
-
const authParam = '--authorization'
|
|
20
|
-
const apiKeyParam = '--api-key'
|
|
21
|
-
|
|
22
|
-
let configToUse
|
|
23
|
-
|
|
24
|
-
if (
|
|
25
|
-
paramExists(argv, hostParam, hostParamAlias) &&
|
|
26
|
-
paramExists(argv, orgIdParam, orgIdParamAlias) &&
|
|
27
|
-
paramExists(argv, authParam, null) &&
|
|
28
|
-
paramExists(argv, apiKeyParam, null)
|
|
29
|
-
) {
|
|
30
|
-
//if the user has passed the values as params
|
|
31
|
-
configToUse = {
|
|
32
|
-
host: findParamValueFromArgs(argv, hostParam, hostParamAlias),
|
|
33
|
-
organizationId: findParamValueFromArgs(argv, orgIdParam, orgIdParamAlias),
|
|
34
|
-
authorization: findParamValueFromArgs(argv, authParam, null),
|
|
35
|
-
apiKey: findParamValueFromArgs(argv, apiKeyParam, null)
|
|
36
|
-
}
|
|
37
|
-
} else if (
|
|
38
|
-
config &&
|
|
39
|
-
config.get('host') &&
|
|
40
|
-
config.get('organizationId') &&
|
|
41
|
-
config.get('authorization') &&
|
|
42
|
-
config.get('apiKey')
|
|
43
|
-
) {
|
|
44
|
-
configToUse = {
|
|
45
|
-
host: config.get('host')?.slice(0, -1), //slice off extra / in url, will 404 on teamserver if we don't
|
|
46
|
-
organizationId: config.get('organizationId'),
|
|
47
|
-
authorization: config.get('authorization'),
|
|
48
|
-
apiKey: config.get('apiKey')
|
|
49
|
-
}
|
|
50
|
-
} else {
|
|
51
|
-
//return when unable to get config
|
|
52
|
-
return
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return await sendTelemetryConfigAsObject(
|
|
56
|
-
configToUse,
|
|
57
|
-
command,
|
|
58
|
-
argv,
|
|
59
|
-
result,
|
|
60
|
-
language
|
|
61
|
-
)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export const sendTelemetryConfigAsObject = async (
|
|
65
|
-
config: any,
|
|
66
|
-
command: string,
|
|
67
|
-
argv: string[],
|
|
68
|
-
result: string,
|
|
69
|
-
language: string
|
|
70
|
-
) => {
|
|
71
|
-
const obfuscatedParams = obfuscateParams(argv)
|
|
72
|
-
|
|
73
|
-
const requestBody = {
|
|
74
|
-
event: TELEMETRY_CLI_COMMANDS_EVENT,
|
|
75
|
-
details: {
|
|
76
|
-
ip_address: '',
|
|
77
|
-
account_name: '',
|
|
78
|
-
account_host: '',
|
|
79
|
-
company_domain: '',
|
|
80
|
-
command: `contrast ${command} ${obfuscatedParams}`,
|
|
81
|
-
app_id:
|
|
82
|
-
config && config.applicationId
|
|
83
|
-
? sha1Base64Value(config.applicationId)
|
|
84
|
-
: 'undefined',
|
|
85
|
-
project_id:
|
|
86
|
-
config && config.projectId
|
|
87
|
-
? sha1Base64Value(config.projectId)
|
|
88
|
-
: 'undefined',
|
|
89
|
-
language: language,
|
|
90
|
-
result: result,
|
|
91
|
-
additional_info: '',
|
|
92
|
-
timestamp: new Date().toUTCString()
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return await sendTelemetryRequest(config, requestBody)
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export const sendTelemetryRequest = async (config: any, requestBody: any) => {
|
|
100
|
-
const client = getHttpClient(config)
|
|
101
|
-
return client
|
|
102
|
-
.postTelemetry(config, requestBody)
|
|
103
|
-
.then((res: any) => {
|
|
104
|
-
if (res.statusCode !== 200 && config.debug === true) {
|
|
105
|
-
console.log('Telemetry failed to send with status', res.statusCode)
|
|
106
|
-
}
|
|
107
|
-
return { statusCode: res.statusCode, statusMessage: res.statusMessage }
|
|
108
|
-
})
|
|
109
|
-
.catch((err: any) => {
|
|
110
|
-
return
|
|
111
|
-
})
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export const obfuscateParams = (argv: string[]) => {
|
|
115
|
-
return argv
|
|
116
|
-
.join(' ')
|
|
117
|
-
.replace(/--(authorization [A-Z0-9]+)/gi, '--authorization *****')
|
|
118
|
-
.replace(/-(o [A-Z0-9-]+)/gi, '-o *****')
|
|
119
|
-
.replace(/--(organization-id [A-Z0-9-]+)/gi, '--organization-id *****')
|
|
120
|
-
.replace(/--(api-key [A-Z0-9]+)/gi, '--api-key *****')
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export const paramExists = (
|
|
124
|
-
argv: string[],
|
|
125
|
-
param: string,
|
|
126
|
-
paramAlias: string | null
|
|
127
|
-
) => {
|
|
128
|
-
return argv.find((arg: string) => arg === param || arg === paramAlias)
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export const findParamValueFromArgs = (
|
|
132
|
-
argv: string[],
|
|
133
|
-
param: string,
|
|
134
|
-
paramAlias: string | null
|
|
135
|
-
) => {
|
|
136
|
-
let paramAsValue
|
|
137
|
-
|
|
138
|
-
argv.forEach((arg: string, index: number) => {
|
|
139
|
-
if (
|
|
140
|
-
arg === param ||
|
|
141
|
-
(arg === paramAlias &&
|
|
142
|
-
argv[index + 1] !== undefined &&
|
|
143
|
-
argv[index + 1] !== null)
|
|
144
|
-
) {
|
|
145
|
-
paramAsValue = argv[index + 1]
|
|
146
|
-
}
|
|
147
|
-
})
|
|
148
|
-
|
|
149
|
-
return paramAsValue
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export const sha1Base64Value = (value: any) => {
|
|
153
|
-
return crypto.createHash('sha1').update(value).digest('base64')
|
|
154
|
-
}
|
package/src/utils/commonApi.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
const HttpClient = require('./../common/HTTPClient')
|
|
2
|
-
const {
|
|
3
|
-
badRequestError,
|
|
4
|
-
unauthenticatedError,
|
|
5
|
-
forbiddenError,
|
|
6
|
-
proxyError,
|
|
7
|
-
genericError,
|
|
8
|
-
maxAppError,
|
|
9
|
-
snapshotFailureError,
|
|
10
|
-
vulnerabilitiesFailureError,
|
|
11
|
-
reportFailureError,
|
|
12
|
-
parametersError,
|
|
13
|
-
invalidHostNameError
|
|
14
|
-
} = require('../common/errorHandling')
|
|
15
|
-
const { performance } = require('perf_hooks')
|
|
16
|
-
const requestUtils = require('./requestUtils')
|
|
17
|
-
const oraFunctions = require('./oraWrapper')
|
|
18
|
-
|
|
19
|
-
const getTimeout = config => {
|
|
20
|
-
if (config.timeout) {
|
|
21
|
-
return config.timeout
|
|
22
|
-
} else {
|
|
23
|
-
if (config.verbose) {
|
|
24
|
-
console.log('Timeout set to 5 minutes')
|
|
25
|
-
}
|
|
26
|
-
return 300
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const handleTimeout = (startTime, timeout, reportSpinner) => {
|
|
31
|
-
const endTime = performance.now() - startTime
|
|
32
|
-
if (requestUtils.millisToSeconds(endTime) > timeout) {
|
|
33
|
-
oraFunctions.failSpinner(
|
|
34
|
-
reportSpinner,
|
|
35
|
-
'Contrast audit timed out at the specified timeout of ' +
|
|
36
|
-
timeout +
|
|
37
|
-
' seconds.'
|
|
38
|
-
)
|
|
39
|
-
throw new Error('You can update the timeout using --timeout')
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
const handleResponseErrors = (res, api) => {
|
|
43
|
-
if (res.statusCode === 400) {
|
|
44
|
-
api === 'catalogue' ? badRequestError(true) : badRequestError(false)
|
|
45
|
-
} else if (res.statusCode === 401) {
|
|
46
|
-
unauthenticatedError()
|
|
47
|
-
} else if (res.statusCode === 403) {
|
|
48
|
-
forbiddenError()
|
|
49
|
-
} else if (res.statusCode === 407) {
|
|
50
|
-
proxyError()
|
|
51
|
-
} else if (res.statusCode === 412) {
|
|
52
|
-
maxAppError()
|
|
53
|
-
} else if (res.statusCode === 301) {
|
|
54
|
-
invalidHostNameError(res.statusCode)
|
|
55
|
-
} else if (res.statusCode === 302) {
|
|
56
|
-
parametersError(res.statusCode)
|
|
57
|
-
} else {
|
|
58
|
-
if (api === 'snapshot' || api === 'catalogue') {
|
|
59
|
-
snapshotFailureError()
|
|
60
|
-
}
|
|
61
|
-
if (api === 'vulnerabilities') {
|
|
62
|
-
vulnerabilitiesFailureError()
|
|
63
|
-
}
|
|
64
|
-
if (api === 'report') {
|
|
65
|
-
reportFailureError()
|
|
66
|
-
}
|
|
67
|
-
console.log(res.statusCode)
|
|
68
|
-
genericError(res)
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const getProtocol = host => {
|
|
73
|
-
const hasProtocol =
|
|
74
|
-
host.toLowerCase().includes('https://') ||
|
|
75
|
-
host.toLowerCase().includes('http://')
|
|
76
|
-
return hasProtocol ? host : 'https://' + host
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const getPath = host => {
|
|
80
|
-
const hasContrastPath = host.toLowerCase().endsWith('/contrast')
|
|
81
|
-
return hasContrastPath
|
|
82
|
-
? host.toLowerCase().substring(0, host.length - 9)
|
|
83
|
-
: host.replace(/\/*$/, '')
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const getValidHost = host => {
|
|
87
|
-
const correctProtocol = getProtocol(host)
|
|
88
|
-
return getPath(correctProtocol)
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const getHttpClient = config => {
|
|
92
|
-
return new HttpClient(config)
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
module.exports = {
|
|
96
|
-
getPath: getPath,
|
|
97
|
-
getValidHost: getValidHost,
|
|
98
|
-
getProtocol: getProtocol,
|
|
99
|
-
handleResponseErrors: handleResponseErrors,
|
|
100
|
-
getHttpClient: getHttpClient,
|
|
101
|
-
handleTimeout: handleTimeout,
|
|
102
|
-
getTimeout: getTimeout
|
|
103
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
const path = require('path')
|
|
2
|
-
const child_process = require('child_process')
|
|
3
|
-
|
|
4
|
-
function resolveFilePath(filepath) {
|
|
5
|
-
if (filepath[0] === '~') {
|
|
6
|
-
return path.join(process.env.HOME, filepath.slice(1))
|
|
7
|
-
}
|
|
8
|
-
return filepath
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const returnProjectPath = () => {
|
|
12
|
-
if (process.platform == 'win32') {
|
|
13
|
-
let winPath = child_process.execSync('cd').toString()
|
|
14
|
-
return winPath.replace(/\//g, '\\').trim()
|
|
15
|
-
} else if (process.env.PWD !== (undefined || null || 'undefined')) {
|
|
16
|
-
return process.env.PWD
|
|
17
|
-
} else {
|
|
18
|
-
return process.argv[process.argv.indexOf('--file') + 1]
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
module.exports = {
|
|
23
|
-
returnProjectPath: returnProjectPath,
|
|
24
|
-
resolveFilePath: resolveFilePath
|
|
25
|
-
}
|
package/src/utils/generalAPI.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
const { featuresTeamServer } = require('./capabilities')
|
|
2
|
-
const semver = require('semver')
|
|
3
|
-
const commonApi = require('./commonApi')
|
|
4
|
-
const { isNil } = require('lodash')
|
|
5
|
-
|
|
6
|
-
const getGlobalProperties = async config => {
|
|
7
|
-
const client = commonApi.getHttpClient(config)
|
|
8
|
-
return client
|
|
9
|
-
.getGlobalProperties(config.host)
|
|
10
|
-
.then(res => {
|
|
11
|
-
if (res.statusCode === 200) {
|
|
12
|
-
return res.body
|
|
13
|
-
} else {
|
|
14
|
-
commonApi.handleResponseErrors(res, 'globalProperties')
|
|
15
|
-
}
|
|
16
|
-
})
|
|
17
|
-
.catch(err => {
|
|
18
|
-
console.log(err)
|
|
19
|
-
})
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const getMode = async config => {
|
|
23
|
-
const features = await getGlobalProperties(config)
|
|
24
|
-
|
|
25
|
-
if (!isNil(features?.mode)) {
|
|
26
|
-
return features.mode
|
|
27
|
-
}
|
|
28
|
-
return ''
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const getFeatures = version => {
|
|
32
|
-
const featuresEnabled = []
|
|
33
|
-
|
|
34
|
-
featuresTeamServer.forEach(feature => {
|
|
35
|
-
const versionFrom = Object.values(feature)[0]
|
|
36
|
-
return semver.gte(version, versionFrom)
|
|
37
|
-
? featuresEnabled.push(Object.keys(feature)[0])
|
|
38
|
-
: null
|
|
39
|
-
})
|
|
40
|
-
return featuresEnabled
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const isFeatureEnabled = (features, featureName) => {
|
|
44
|
-
return features.includes(featureName)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
module.exports = {
|
|
48
|
-
getGlobalProperties,
|
|
49
|
-
getFeatures,
|
|
50
|
-
isFeatureEnabled,
|
|
51
|
-
getMode
|
|
52
|
-
}
|
package/src/utils/getConfig.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import Conf from 'conf'
|
|
2
|
-
import { CE_URL } from '../constants/constants'
|
|
3
|
-
|
|
4
|
-
type ContrastConfOptions = Partial<{
|
|
5
|
-
version: string
|
|
6
|
-
host: string
|
|
7
|
-
apiKey: string
|
|
8
|
-
orgId: string
|
|
9
|
-
authHeader: string
|
|
10
|
-
numOfRuns: number
|
|
11
|
-
}>
|
|
12
|
-
|
|
13
|
-
type ContrastConf = Conf<ContrastConfOptions>
|
|
14
|
-
|
|
15
|
-
const localConfig = (name: string, version: string) => {
|
|
16
|
-
const config: ContrastConf = new Conf<ContrastConfOptions>({
|
|
17
|
-
configName: name
|
|
18
|
-
})
|
|
19
|
-
config.set('version', version)
|
|
20
|
-
|
|
21
|
-
if (!config.has('host')) {
|
|
22
|
-
config.set('host', CE_URL)
|
|
23
|
-
}
|
|
24
|
-
return config
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const setConfigValues = (config: ContrastConf, values: ContrastConfOptions) => {
|
|
28
|
-
config.set('apiKey', values.apiKey)
|
|
29
|
-
config.set('organizationId', values.orgId)
|
|
30
|
-
config.set('authorization', values.authHeader)
|
|
31
|
-
values.host ? config.set('host', values.host) : config.set('host', CE_URL)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export { localConfig, setConfigValues, ContrastConf, ContrastConfOptions }
|
package/src/utils/oraWrapper.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
const ora = require('ora')
|
|
2
|
-
|
|
3
|
-
const returnOra = text => {
|
|
4
|
-
return ora(text)
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
const startSpinner = spinner => {
|
|
8
|
-
spinner.start()
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const stopSpinner = spinner => {
|
|
12
|
-
spinner.stop()
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const succeedSpinner = (spinner, text) => {
|
|
16
|
-
spinner.succeed(text)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const failSpinner = (spinner, text) => {
|
|
20
|
-
spinner.fail(text)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
module.exports = {
|
|
24
|
-
returnOra,
|
|
25
|
-
startSpinner,
|
|
26
|
-
succeedSpinner,
|
|
27
|
-
failSpinner,
|
|
28
|
-
stopSpinner
|
|
29
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const getAuth = (parsedCLIOptions = {}) => {
|
|
2
|
-
let params = {}
|
|
3
|
-
params.apiKey = parsedCLIOptions['apiKey']
|
|
4
|
-
params.authorization = parsedCLIOptions['authorization']
|
|
5
|
-
params.host = parsedCLIOptions['host']
|
|
6
|
-
params.organizationId = parsedCLIOptions['organizationId']
|
|
7
|
-
return params
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
module.exports = {
|
|
11
|
-
getAuth: getAuth
|
|
12
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const validationCheck = require('../validationCheck')
|
|
2
|
-
const commonApi = require('../commonApi')
|
|
3
|
-
const config = require('../getConfig')
|
|
4
|
-
const { APP_NAME, APP_VERSION } = require('../../constants/constants')
|
|
5
|
-
|
|
6
|
-
const getAuth = () => {
|
|
7
|
-
const ContrastConf = config.localConfig(APP_NAME, APP_VERSION)
|
|
8
|
-
let ContrastConfToUse = {}
|
|
9
|
-
if (validationCheck.checkConfigHasRequiredValues(ContrastConf)) {
|
|
10
|
-
ContrastConfToUse.apiKey = ContrastConf.get('apiKey')
|
|
11
|
-
ContrastConfToUse.organizationId = ContrastConf.get('organizationId')
|
|
12
|
-
ContrastConfToUse.host = commonApi.getValidHost(ContrastConf.get('host'))
|
|
13
|
-
ContrastConfToUse.authorization = ContrastConf.get('authorization')
|
|
14
|
-
ContrastConfToUse.version = ContrastConf.get('version')
|
|
15
|
-
}
|
|
16
|
-
return ContrastConfToUse
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
module.exports = { getAuth }
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
const getAuth = () => {
|
|
2
|
-
let params = {}
|
|
3
|
-
params.apiKey = process.env.CONTRAST__API__API_KEY
|
|
4
|
-
params.authorization = process.env.CONTRAST__API__AUTHORIZATION
|
|
5
|
-
params.host = process.env.CONTRAST__API__URL
|
|
6
|
-
params.organizationId = process.env.CONTRAST__API__ORGANIZATION_ID
|
|
7
|
-
return params
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
module.exports = { getAuth: getAuth }
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
const commandlineAuth = require('./commandlineParams')
|
|
2
|
-
const configStoreParams = require('./configStoreParams')
|
|
3
|
-
const envVariableParams = require('./envVariableParams')
|
|
4
|
-
const {
|
|
5
|
-
validateAuthParams,
|
|
6
|
-
validateFingerprintParams
|
|
7
|
-
} = require('../validationCheck')
|
|
8
|
-
const i18n = require('i18n')
|
|
9
|
-
|
|
10
|
-
const getAuth = params => {
|
|
11
|
-
let commandLineAuthParamsAuth = commandlineAuth.getAuth(params)
|
|
12
|
-
let envVariableParamsAuth = envVariableParams.getAuth()
|
|
13
|
-
let configStoreParamsAuth = configStoreParams.getAuth()
|
|
14
|
-
|
|
15
|
-
if (validateAuthParams(commandLineAuthParamsAuth)) {
|
|
16
|
-
return commandLineAuthParamsAuth
|
|
17
|
-
} else if (validateAuthParams(envVariableParamsAuth)) {
|
|
18
|
-
return envVariableParamsAuth
|
|
19
|
-
} else if (validateAuthParams(configStoreParamsAuth)) {
|
|
20
|
-
return configStoreParamsAuth
|
|
21
|
-
} else {
|
|
22
|
-
console.log(i18n.__('configNotFound'))
|
|
23
|
-
process.exit(1)
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const getFingerprint = params => {
|
|
28
|
-
if (validateFingerprintParams(params)) {
|
|
29
|
-
return params
|
|
30
|
-
} else {
|
|
31
|
-
console.log(
|
|
32
|
-
'missing fingerprint params please check repository-url and repository-name'
|
|
33
|
-
)
|
|
34
|
-
process.exit(1)
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
module.exports = { getAuth, getFingerprint }
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
const commandLineArgs = require('command-line-args')
|
|
2
|
-
const { sendTelemetryConfigAsConfObj } = require('../telemetry/telemetry')
|
|
3
|
-
|
|
4
|
-
const getCommandLineArgsCustom = async (
|
|
5
|
-
contrastConf,
|
|
6
|
-
command,
|
|
7
|
-
parameterList,
|
|
8
|
-
optionDefinitions
|
|
9
|
-
) => {
|
|
10
|
-
try {
|
|
11
|
-
return commandLineArgs(optionDefinitions, {
|
|
12
|
-
argv: parameterList,
|
|
13
|
-
partial: false,
|
|
14
|
-
camelCase: true,
|
|
15
|
-
caseInsensitive: true
|
|
16
|
-
})
|
|
17
|
-
} catch (e) {
|
|
18
|
-
await sendTelemetryConfigAsConfObj(
|
|
19
|
-
contrastConf,
|
|
20
|
-
command,
|
|
21
|
-
parameterList,
|
|
22
|
-
'FAILURE',
|
|
23
|
-
'undefined'
|
|
24
|
-
)
|
|
25
|
-
console.log(e.message.toString())
|
|
26
|
-
process.exit(1)
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
module.exports = {
|
|
31
|
-
getCommandLineArgsCustom
|
|
32
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
const request = require('request')
|
|
2
|
-
const Promise = require('bluebird')
|
|
3
|
-
|
|
4
|
-
Promise.promisifyAll(request)
|
|
5
|
-
|
|
6
|
-
function sendRequest({ options, method = 'put' }) {
|
|
7
|
-
return request[`${method}Async`](options.url, options)
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const millisToSeconds = millis => {
|
|
11
|
-
return (millis / 1000).toFixed(0)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const sleep = ms => {
|
|
15
|
-
return new Promise(resolve => setTimeout(resolve, ms))
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const timeOutError = (ms, reject) => {
|
|
19
|
-
return setTimeout(() => {
|
|
20
|
-
reject(new Error(`No input detected after 30s`))
|
|
21
|
-
}, ms)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
module.exports = {
|
|
25
|
-
sendRequest: sendRequest,
|
|
26
|
-
sleep: sleep,
|
|
27
|
-
millisToSeconds: millisToSeconds,
|
|
28
|
-
timeOutError: timeOutError
|
|
29
|
-
}
|
package/src/utils/saveFile.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const { SARIF_FILE } = require('../constants/constants')
|
|
2
|
-
const commonApi = require('./commonApi')
|
|
3
|
-
const saveResults = require('../scan/saveResults')
|
|
4
|
-
const i18n = require('i18n')
|
|
5
|
-
|
|
6
|
-
const saveScanFile = async (config, scanResults) => {
|
|
7
|
-
if (config.save === null || config.save.toUpperCase() === SARIF_FILE) {
|
|
8
|
-
const scanId = scanResults.scanDetail.id
|
|
9
|
-
const client = commonApi.getHttpClient(config)
|
|
10
|
-
const rawResults = await client.getSpecificScanResultSarif(config, scanId)
|
|
11
|
-
const name = await saveResults.writeResultsToFile(rawResults?.body)
|
|
12
|
-
console.log(`Scan Results saved to ${name}`)
|
|
13
|
-
} else {
|
|
14
|
-
console.log(i18n.__('scanNoFiletypeSpecifiedForSave'))
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
module.exports = {
|
|
19
|
-
saveScanFile: saveScanFile
|
|
20
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
const checkConfigHasRequiredValues = store => {
|
|
2
|
-
return (
|
|
3
|
-
store.has('apiKey') &&
|
|
4
|
-
store.has('organizationId') &&
|
|
5
|
-
store.has('host') &&
|
|
6
|
-
store.has('authorization') &&
|
|
7
|
-
store.has('version')
|
|
8
|
-
)
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const validateRequiredScanParams = params => {
|
|
12
|
-
return (
|
|
13
|
-
params.apiKey &&
|
|
14
|
-
params.organizationId &&
|
|
15
|
-
params.host &&
|
|
16
|
-
params.authorization &&
|
|
17
|
-
params.version
|
|
18
|
-
)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const validateAuthParams = params => {
|
|
22
|
-
return !!(
|
|
23
|
-
params.apiKey &&
|
|
24
|
-
params.organizationId &&
|
|
25
|
-
params.host &&
|
|
26
|
-
params.authorization
|
|
27
|
-
)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const validateFingerprintParams = params => {
|
|
31
|
-
return !!(params.repositoryUrl && params.repositoryName)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
module.exports = {
|
|
35
|
-
checkConfigHasRequiredValues: checkConfigHasRequiredValues,
|
|
36
|
-
validateAuthParams: validateAuthParams,
|
|
37
|
-
validateRequiredScanParams: validateRequiredScanParams,
|
|
38
|
-
validateFingerprintParams: validateFingerprintParams
|
|
39
|
-
}
|