@contrast/contrast 2.0.2-beta.3 → 2.0.2-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -1
- package/dist/audit/catalogueApplication/catalogueApplication.js +6 -10
- package/dist/audit/catalogueApplication/catalogueApplication.js.map +1 -0
- package/dist/audit/languageAnalysisEngine/commonApi.js +3 -6
- package/dist/audit/languageAnalysisEngine/commonApi.js.map +1 -0
- package/dist/audit/languageAnalysisEngine/filterProjectPath.js +1 -0
- package/dist/audit/languageAnalysisEngine/filterProjectPath.js.map +1 -0
- package/dist/audit/languageAnalysisEngine/getProjectRootFilenames.js +9 -12
- package/dist/audit/languageAnalysisEngine/getProjectRootFilenames.js.map +1 -0
- package/dist/audit/languageAnalysisEngine/sendSnapshot.js +15 -19
- package/dist/audit/languageAnalysisEngine/sendSnapshot.js.map +1 -0
- package/dist/audit/nodeAnalysisEngine/parseYarn2LockFileContents.js +9 -9
- package/dist/audit/nodeAnalysisEngine/parseYarn2LockFileContents.js.map +1 -0
- package/dist/audit/report/commonReportingFunctions.js +33 -48
- package/dist/audit/report/commonReportingFunctions.js.map +1 -0
- package/dist/audit/report/models/reportGuidanceModel.js +2 -5
- package/dist/audit/report/models/reportGuidanceModel.js.map +1 -0
- package/dist/audit/report/models/reportLibraryModel.js +3 -7
- package/dist/audit/report/models/reportLibraryModel.js.map +1 -0
- package/dist/audit/report/models/reportListModel.js +4 -9
- package/dist/audit/report/models/reportListModel.js.map +1 -0
- package/dist/audit/report/models/reportOutputModel.js +4 -9
- package/dist/audit/report/models/reportOutputModel.js.map +1 -0
- package/dist/audit/report/models/reportSeverityModel.js +2 -5
- package/dist/audit/report/models/reportSeverityModel.js.map +1 -0
- package/dist/audit/report/models/severityCountModel.js +3 -5
- package/dist/audit/report/models/severityCountModel.js.map +1 -0
- package/dist/audit/report/reportingFeature.js +27 -55
- package/dist/audit/report/reportingFeature.js.map +1 -0
- package/dist/audit/report/utils/reportUtils.js +28 -59
- package/dist/audit/report/utils/reportUtils.js.map +1 -0
- package/dist/audit/save.js +14 -16
- package/dist/audit/save.js.map +1 -0
- package/dist/cliConstants.js +17 -18
- package/dist/cliConstants.js.map +1 -0
- package/dist/commands/audit/auditConfig.js +7 -10
- package/dist/commands/audit/auditConfig.js.map +1 -0
- package/dist/commands/audit/auditController.js +9 -13
- package/dist/commands/audit/auditController.js.map +1 -0
- package/dist/commands/audit/help.js +23 -25
- package/dist/commands/audit/help.js.map +1 -0
- package/dist/commands/audit/processAudit.js +9 -12
- package/dist/commands/audit/processAudit.js.map +1 -0
- package/dist/commands/audit/saveFile.js +3 -6
- package/dist/commands/audit/saveFile.js.map +1 -0
- package/dist/commands/auth/auth.js +25 -24
- package/dist/commands/auth/auth.js.map +1 -0
- package/dist/commands/config/config.js +12 -13
- package/dist/commands/config/config.js.map +1 -0
- package/dist/commands/github/fingerprintConfig.js +8 -11
- package/dist/commands/github/fingerprintConfig.js.map +1 -0
- package/dist/commands/github/processFingerprint.js +12 -15
- package/dist/commands/github/processFingerprint.js.map +1 -0
- package/dist/commands/github/projectGroup.js +25 -32
- package/dist/commands/github/projectGroup.js.map +1 -0
- package/dist/commands/github/repoServices.js +11 -21
- package/dist/commands/github/repoServices.js.map +1 -0
- package/dist/commands/learn/learn.js +3 -6
- package/dist/commands/learn/learn.js.map +1 -0
- package/dist/commands/learn/processLearn.js +3 -6
- package/dist/commands/learn/processLearn.js.map +1 -0
- package/dist/commands/scan/processScan.js +11 -14
- package/dist/commands/scan/processScan.js.map +1 -0
- package/dist/common/HTTPClient.js +123 -94
- package/dist/common/HTTPClient.js.map +1 -0
- package/dist/common/autoDetection.js +26 -33
- package/dist/common/autoDetection.js.map +1 -0
- package/dist/common/baseRequest.js +14 -18
- package/dist/common/baseRequest.js.map +1 -0
- package/dist/common/commonHelp.js +13 -13
- package/dist/common/commonHelp.js.map +1 -0
- package/dist/common/errorHandling.js +30 -39
- package/dist/common/errorHandling.js.map +1 -0
- package/dist/common/fail.js +6 -12
- package/dist/common/fail.js.map +1 -0
- package/dist/common/versionChecker.js +16 -19
- package/dist/common/versionChecker.js.map +1 -0
- package/dist/constants/constants.js +44 -65
- package/dist/constants/constants.js.map +1 -0
- package/dist/constants/lambda.js +8 -5
- package/dist/constants/lambda.js.map +1 -0
- package/dist/constants/locales.js +6 -9
- package/dist/constants/locales.js.map +1 -0
- package/dist/index.js +36 -39
- package/dist/index.js.map +1 -0
- package/dist/lambda/analytics.js +6 -9
- package/dist/lambda/analytics.js.map +1 -0
- package/dist/lambda/arn.js +6 -9
- package/dist/lambda/arn.js.map +1 -0
- package/dist/lambda/aws.js +29 -34
- package/dist/lambda/aws.js.map +1 -0
- package/dist/lambda/cliError.js +13 -41
- package/dist/lambda/cliError.js.map +1 -0
- package/dist/lambda/constants.js +3 -4
- package/dist/lambda/constants.js.map +1 -0
- package/dist/lambda/help.js +39 -44
- package/dist/lambda/help.js.map +1 -0
- package/dist/lambda/lambda.js +61 -65
- package/dist/lambda/lambda.js.map +1 -0
- package/dist/lambda/lambdaUtils.js +38 -32
- package/dist/lambda/lambdaUtils.js.map +1 -0
- package/dist/lambda/logUtils.js +21 -17
- package/dist/lambda/logUtils.js.map +1 -0
- package/dist/lambda/scanDetailCompletion.js +19 -25
- package/dist/lambda/scanDetailCompletion.js.map +1 -0
- package/dist/lambda/scanRequest.js +34 -41
- package/dist/lambda/scanRequest.js.map +1 -0
- package/dist/lambda/scanResults.js +8 -10
- package/dist/lambda/scanResults.js.map +1 -0
- package/dist/lambda/types.js +5 -7
- package/dist/lambda/types.js.map +1 -0
- package/dist/lambda/utils.js +33 -35
- package/dist/lambda/utils.js.map +1 -0
- package/dist/sbom/generateSbom.js +6 -10
- package/dist/sbom/generateSbom.js.map +1 -0
- package/dist/scaAnalysis/common/auditReport.js +8 -12
- package/dist/scaAnalysis/common/auditReport.js.map +1 -0
- package/dist/scaAnalysis/common/commonReportingFunctionsSca.js +26 -32
- package/dist/scaAnalysis/common/commonReportingFunctionsSca.js.map +1 -0
- package/dist/scaAnalysis/common/formatMessage.js +8 -17
- package/dist/scaAnalysis/common/formatMessage.js.map +1 -0
- package/dist/scaAnalysis/common/models/ScaReportModel.js +4 -9
- package/dist/scaAnalysis/common/models/ScaReportModel.js.map +1 -0
- package/dist/scaAnalysis/common/scaParserForGoAndJava.js +10 -9
- package/dist/scaAnalysis/common/scaParserForGoAndJava.js.map +1 -0
- package/dist/scaAnalysis/common/scaServicesUpload.js +21 -22
- package/dist/scaAnalysis/common/scaServicesUpload.js.map +1 -0
- package/dist/scaAnalysis/common/treeUpload.js +7 -10
- package/dist/scaAnalysis/common/treeUpload.js.map +1 -0
- package/dist/scaAnalysis/common/utils/reportUtilsSca.js +21 -29
- package/dist/scaAnalysis/common/utils/reportUtilsSca.js.map +1 -0
- package/dist/scaAnalysis/dotnet/analysis.js +12 -18
- package/dist/scaAnalysis/dotnet/analysis.js.map +1 -0
- package/dist/scaAnalysis/dotnet/index.js +4 -7
- package/dist/scaAnalysis/dotnet/index.js.map +1 -0
- package/dist/scaAnalysis/go/goAnalysis.js +8 -11
- package/dist/scaAnalysis/go/goAnalysis.js.map +1 -0
- package/dist/scaAnalysis/go/goParseDeps.js +9 -7
- package/dist/scaAnalysis/go/goParseDeps.js.map +1 -0
- package/dist/scaAnalysis/go/goReadDepFile.js +10 -8
- package/dist/scaAnalysis/go/goReadDepFile.js.map +1 -0
- package/dist/scaAnalysis/java/analysis.js +23 -20
- package/dist/scaAnalysis/java/analysis.js.map +1 -0
- package/dist/scaAnalysis/java/index.js +7 -10
- package/dist/scaAnalysis/java/index.js.map +1 -0
- package/dist/scaAnalysis/java/javaBuildDepsParser.js +43 -43
- package/dist/scaAnalysis/java/javaBuildDepsParser.js.map +1 -0
- package/dist/scaAnalysis/javascript/analysis.js +16 -20
- package/dist/scaAnalysis/javascript/analysis.js.map +1 -0
- package/dist/scaAnalysis/javascript/index.js +17 -19
- package/dist/scaAnalysis/javascript/index.js.map +1 -0
- package/dist/scaAnalysis/javascript/scaServiceParser.js +8 -15
- package/dist/scaAnalysis/javascript/scaServiceParser.js.map +1 -0
- package/dist/scaAnalysis/legacy/legacyFlow.js +13 -15
- package/dist/scaAnalysis/legacy/legacyFlow.js.map +1 -0
- package/dist/scaAnalysis/php/analysis.js +15 -16
- package/dist/scaAnalysis/php/analysis.js.map +1 -0
- package/dist/scaAnalysis/php/index.js +5 -8
- package/dist/scaAnalysis/php/index.js.map +1 -0
- package/dist/scaAnalysis/php/phpNewServicesMapper.js +9 -12
- package/dist/scaAnalysis/php/phpNewServicesMapper.js.map +1 -0
- package/dist/scaAnalysis/processServicesFlow.js +50 -25
- package/dist/scaAnalysis/processServicesFlow.js.map +1 -0
- package/dist/scaAnalysis/python/analysis.js +16 -23
- package/dist/scaAnalysis/python/analysis.js.map +1 -0
- package/dist/scaAnalysis/python/index.js +4 -7
- package/dist/scaAnalysis/python/index.js.map +1 -0
- package/dist/scaAnalysis/repoMode/gradleParser.js +7 -13
- package/dist/scaAnalysis/repoMode/gradleParser.js.map +1 -0
- package/dist/scaAnalysis/repoMode/index.js +9 -12
- package/dist/scaAnalysis/repoMode/index.js.map +1 -0
- package/dist/scaAnalysis/repoMode/mavenParser.js +12 -12
- package/dist/scaAnalysis/repoMode/mavenParser.js.map +1 -0
- package/dist/scaAnalysis/ruby/analysis.js +32 -46
- package/dist/scaAnalysis/ruby/analysis.js.map +1 -0
- package/dist/scaAnalysis/ruby/index.js +5 -8
- package/dist/scaAnalysis/ruby/index.js.map +1 -0
- package/dist/scaAnalysis/scaAnalysis.js +49 -51
- package/dist/scaAnalysis/scaAnalysis.js.map +1 -0
- package/dist/scan/fileUtils.js +27 -36
- package/dist/scan/fileUtils.js.map +1 -0
- package/dist/scan/formatScanOutput.js +47 -61
- package/dist/scan/formatScanOutput.js.map +1 -0
- package/dist/scan/help.js +8 -11
- package/dist/scan/help.js.map +1 -0
- package/dist/scan/models/groupedResultsModel.js +2 -5
- package/dist/scan/models/groupedResultsModel.js.map +1 -0
- package/dist/scan/models/resultContentModel.js +2 -2
- package/dist/scan/models/resultContentModel.js.map +1 -0
- package/dist/scan/models/scanResultsModel.js +2 -5
- package/dist/scan/models/scanResultsModel.js.map +1 -0
- package/dist/scan/populateProjectIdAndProjectName.js +9 -12
- package/dist/scan/populateProjectIdAndProjectName.js.map +1 -0
- package/dist/scan/saveResults.js +3 -6
- package/dist/scan/saveResults.js.map +1 -0
- package/dist/scan/scan.js +24 -31
- package/dist/scan/scan.js.map +1 -0
- package/dist/scan/scanConfig.js +14 -12
- package/dist/scan/scanConfig.js.map +1 -0
- package/dist/scan/scanController.js +17 -20
- package/dist/scan/scanController.js.map +1 -0
- package/dist/scan/scanResults.js +27 -34
- package/dist/scan/scanResults.js.map +1 -0
- package/dist/telemetry/telemetry.js +29 -59
- package/dist/telemetry/telemetry.js.map +1 -0
- package/dist/utils/capabilities.js +1 -0
- package/dist/utils/capabilities.js.map +1 -0
- package/dist/utils/commonApi.js +15 -24
- package/dist/utils/commonApi.js.map +1 -0
- package/dist/utils/filterProjectPath.js +1 -0
- package/dist/utils/filterProjectPath.js.map +1 -0
- package/dist/utils/generalAPI.js +11 -17
- package/dist/utils/generalAPI.js.map +1 -0
- package/dist/utils/getConfig.js +7 -13
- package/dist/utils/getConfig.js.map +1 -0
- package/dist/utils/oraWrapper.js +7 -14
- package/dist/utils/oraWrapper.js.map +1 -0
- package/dist/utils/paramsUtil/commandlineParams.js +2 -5
- package/dist/utils/paramsUtil/commandlineParams.js.map +1 -0
- package/dist/utils/paramsUtil/configStoreParams.js +9 -10
- package/dist/utils/paramsUtil/configStoreParams.js.map +1 -0
- package/dist/utils/paramsUtil/envVariableParams.js +2 -3
- package/dist/utils/paramsUtil/envVariableParams.js.map +1 -0
- package/dist/utils/paramsUtil/paramHandler.js +12 -13
- package/dist/utils/paramsUtil/paramHandler.js.map +1 -0
- package/dist/utils/parsedCLIOptions.js +4 -7
- package/dist/utils/parsedCLIOptions.js.map +1 -0
- package/dist/utils/requestUtils.js +7 -13
- package/dist/utils/requestUtils.js.map +1 -0
- package/dist/utils/saveFile.js +8 -11
- package/dist/utils/saveFile.js.map +1 -0
- package/dist/utils/validationCheck.js +5 -11
- package/dist/utils/validationCheck.js.map +1 -0
- package/package.json +32 -41
- package/.prettierignore +0 -1
- package/bin/contrast.js +0 -2
- package/dist/audit/languageAnalysisEngine/util/requestUtils.js +0 -14
- package/dist/lambda/__mocks__/aws.js +0 -21
- package/dist/lambda/__mocks__/lambdaConfig.json +0 -42
- package/src/audit/catalogueApplication/catalogueApplication.js +0 -51
- package/src/audit/languageAnalysisEngine/commonApi.js +0 -20
- package/src/audit/languageAnalysisEngine/filterProjectPath.js +0 -21
- package/src/audit/languageAnalysisEngine/getProjectRootFilenames.js +0 -36
- package/src/audit/languageAnalysisEngine/sendSnapshot.js +0 -57
- package/src/audit/languageAnalysisEngine/util/requestUtils.js +0 -17
- package/src/audit/nodeAnalysisEngine/parseYarn2LockFileContents.js +0 -63
- package/src/audit/report/commonReportingFunctions.js +0 -412
- package/src/audit/report/models/reportGuidanceModel.ts +0 -5
- package/src/audit/report/models/reportLibraryModel.ts +0 -30
- package/src/audit/report/models/reportListModel.ts +0 -49
- package/src/audit/report/models/reportOutputModel.ts +0 -29
- package/src/audit/report/models/reportSeverityModel.ts +0 -18
- package/src/audit/report/models/severityCountModel.ts +0 -22
- package/src/audit/report/reportingFeature.ts +0 -110
- package/src/audit/report/utils/reportUtils.ts +0 -165
- package/src/audit/save.js +0 -67
- package/src/cliConstants.js +0 -523
- package/src/commands/audit/auditConfig.js +0 -18
- package/src/commands/audit/auditController.js +0 -50
- package/src/commands/audit/help.js +0 -72
- package/src/commands/audit/processAudit.js +0 -34
- package/src/commands/audit/saveFile.js +0 -15
- package/src/commands/auth/auth.js +0 -146
- package/src/commands/config/config.js +0 -41
- package/src/commands/github/fingerprintConfig.js +0 -19
- package/src/commands/github/processFingerprint.js +0 -37
- package/src/commands/github/projectGroup.js +0 -298
- package/src/commands/github/repoServices.js +0 -122
- package/src/commands/learn/learn.js +0 -10
- package/src/commands/learn/processLearn.js +0 -13
- package/src/commands/scan/processScan.js +0 -42
- package/src/common/HTTPClient.js +0 -775
- package/src/common/autoDetection.js +0 -209
- package/src/common/baseRequest.ts +0 -83
- package/src/common/commonHelp.js +0 -53
- package/src/common/errorHandling.js +0 -157
- package/src/common/fail.js +0 -79
- package/src/common/versionChecker.js +0 -75
- package/src/constants/constants.js +0 -71
- package/src/constants/lambda.js +0 -85
- package/src/constants/locales.js +0 -365
- package/src/index.ts +0 -142
- package/src/lambda/__mocks__/aws.ts +0 -32
- package/src/lambda/__mocks__/lambdaConfig.json +0 -42
- package/src/lambda/analytics.ts +0 -9
- package/src/lambda/arn.ts +0 -33
- package/src/lambda/aws.ts +0 -248
- package/src/lambda/cliError.ts +0 -72
- package/src/lambda/constants.ts +0 -11
- package/src/lambda/help.ts +0 -92
- package/src/lambda/lambda.ts +0 -230
- package/src/lambda/lambdaUtils.ts +0 -111
- package/src/lambda/logUtils.ts +0 -64
- package/src/lambda/scanDetailCompletion.ts +0 -78
- package/src/lambda/scanRequest.ts +0 -169
- package/src/lambda/scanResults.ts +0 -29
- package/src/lambda/types.ts +0 -36
- package/src/lambda/utils.ts +0 -188
- package/src/sbom/generateSbom.ts +0 -45
- package/src/scaAnalysis/common/auditReport.js +0 -59
- package/src/scaAnalysis/common/commonReportingFunctionsSca.js +0 -276
- package/src/scaAnalysis/common/formatMessage.js +0 -67
- package/src/scaAnalysis/common/models/ScaReportModel.ts +0 -81
- package/src/scaAnalysis/common/scaParserForGoAndJava.js +0 -41
- package/src/scaAnalysis/common/scaServicesUpload.js +0 -159
- package/src/scaAnalysis/common/treeUpload.js +0 -51
- package/src/scaAnalysis/common/utils/reportUtilsSca.ts +0 -123
- package/src/scaAnalysis/dotnet/analysis.js +0 -72
- package/src/scaAnalysis/dotnet/index.js +0 -11
- package/src/scaAnalysis/go/goAnalysis.js +0 -26
- package/src/scaAnalysis/go/goParseDeps.js +0 -203
- package/src/scaAnalysis/go/goReadDepFile.js +0 -34
- package/src/scaAnalysis/java/analysis.js +0 -148
- package/src/scaAnalysis/java/index.js +0 -29
- package/src/scaAnalysis/java/javaBuildDepsParser.js +0 -439
- package/src/scaAnalysis/javascript/analysis.js +0 -111
- package/src/scaAnalysis/javascript/index.js +0 -104
- package/src/scaAnalysis/javascript/scaServiceParser.js +0 -151
- package/src/scaAnalysis/legacy/legacyFlow.js +0 -43
- package/src/scaAnalysis/php/analysis.js +0 -78
- package/src/scaAnalysis/php/index.js +0 -28
- package/src/scaAnalysis/php/phpNewServicesMapper.js +0 -77
- package/src/scaAnalysis/processServicesFlow.js +0 -126
- package/src/scaAnalysis/python/analysis.js +0 -93
- package/src/scaAnalysis/python/index.js +0 -16
- package/src/scaAnalysis/repoMode/gradleParser.js +0 -88
- package/src/scaAnalysis/repoMode/index.js +0 -21
- package/src/scaAnalysis/repoMode/mavenParser.js +0 -138
- package/src/scaAnalysis/ruby/analysis.js +0 -413
- package/src/scaAnalysis/ruby/index.js +0 -16
- package/src/scaAnalysis/scaAnalysis.js +0 -172
- package/src/scan/fileUtils.js +0 -218
- package/src/scan/formatScanOutput.ts +0 -225
- package/src/scan/help.js +0 -56
- package/src/scan/models/groupedResultsModel.ts +0 -20
- package/src/scan/models/resultContentModel.ts +0 -86
- package/src/scan/models/scanResultsModel.ts +0 -55
- package/src/scan/populateProjectIdAndProjectName.js +0 -73
- package/src/scan/saveResults.js +0 -14
- package/src/scan/scan.ts +0 -68
- package/src/scan/scanConfig.js +0 -58
- package/src/scan/scanController.js +0 -98
- package/src/scan/scanResults.js +0 -171
- package/src/telemetry/telemetry.ts +0 -154
- package/src/utils/capabilities.js +0 -12
- package/src/utils/commonApi.js +0 -103
- package/src/utils/filterProjectPath.js +0 -25
- package/src/utils/generalAPI.js +0 -52
- package/src/utils/getConfig.ts +0 -34
- package/src/utils/oraWrapper.js +0 -29
- package/src/utils/paramsUtil/commandlineParams.js +0 -12
- package/src/utils/paramsUtil/configStoreParams.js +0 -19
- package/src/utils/paramsUtil/envVariableParams.js +0 -10
- package/src/utils/paramsUtil/paramHandler.js +0 -38
- package/src/utils/parsedCLIOptions.js +0 -32
- package/src/utils/requestUtils.js +0 -29
- package/src/utils/saveFile.js +0 -20
- package/src/utils/validationCheck.js +0 -39
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
const { v4: uuidv4 } = require('uuid')
|
|
2
|
-
const configFunctions = require('../../utils/getConfig')
|
|
3
|
-
const commonApi = require('../../utils/commonApi')
|
|
4
|
-
const requestUtils = require('../../utils/requestUtils')
|
|
5
|
-
const i18n = require('i18n')
|
|
6
|
-
const {
|
|
7
|
-
returnOra,
|
|
8
|
-
startSpinner,
|
|
9
|
-
failSpinner,
|
|
10
|
-
succeedSpinner
|
|
11
|
-
} = require('../../utils/oraWrapper')
|
|
12
|
-
const { TIMEOUT, AUTH_UI_URL } = require('../../constants/constants')
|
|
13
|
-
const parsedCLIOptions = require('../../utils/parsedCLIOptions')
|
|
14
|
-
const constants = require('../../cliConstants')
|
|
15
|
-
const commandLineUsage = require('command-line-usage')
|
|
16
|
-
const { commonMessageFormatter } = require('../../common/errorHandling')
|
|
17
|
-
const open = require('open')
|
|
18
|
-
const messages = require('../../constants/locales').en_locales()
|
|
19
|
-
|
|
20
|
-
const processAuth = async (argv, config) => {
|
|
21
|
-
let authParams = await parsedCLIOptions.getCommandLineArgsCustom(
|
|
22
|
-
config,
|
|
23
|
-
'auth',
|
|
24
|
-
argv,
|
|
25
|
-
constants.commandLineDefinitions.authOptionDefinitions
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
if (authParams.help) {
|
|
29
|
-
console.log(authUsageGuide)
|
|
30
|
-
process.exit(0)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
//check if user has entered enterprise credentials
|
|
34
|
-
if (checkForCustomCredentials(authParams)) {
|
|
35
|
-
processCustomCredentials(authParams, config)
|
|
36
|
-
} else {
|
|
37
|
-
await startAuthProcess(config)
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const startAuthProcess = async config => {
|
|
42
|
-
const token = uuidv4()
|
|
43
|
-
const url = `${AUTH_UI_URL}/?token=${token}`
|
|
44
|
-
|
|
45
|
-
console.log(i18n.__('redirectAuth', url))
|
|
46
|
-
|
|
47
|
-
try {
|
|
48
|
-
//start a spinner / progress
|
|
49
|
-
await setTimeout(() => {
|
|
50
|
-
open(url)
|
|
51
|
-
}, 0)
|
|
52
|
-
|
|
53
|
-
const result = await isAuthComplete(token, TIMEOUT, config)
|
|
54
|
-
if (result) {
|
|
55
|
-
configFunctions.setConfigValues(config, result)
|
|
56
|
-
}
|
|
57
|
-
} finally {
|
|
58
|
-
//spinner stop
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const isAuthComplete = async (token, timeout, config) => {
|
|
63
|
-
const authSpinner = returnOra(i18n.__('authWaitingMessage'))
|
|
64
|
-
startSpinner(authSpinner)
|
|
65
|
-
const client = commonApi.getHttpClient(config)
|
|
66
|
-
let startTime = new Date()
|
|
67
|
-
let complete = false
|
|
68
|
-
while (!complete) {
|
|
69
|
-
let result = await pollAuthResult(token, client)
|
|
70
|
-
if (result.statusCode === 200) {
|
|
71
|
-
succeedSpinner(authSpinner, i18n.__('authSuccessMessage'))
|
|
72
|
-
console.log(i18n.__('runAuthSuccessMessage'))
|
|
73
|
-
return result.body
|
|
74
|
-
}
|
|
75
|
-
let endTime = new Date() - startTime
|
|
76
|
-
if (endTime > timeout) {
|
|
77
|
-
failSpinner(authSpinner, i18n.__('authTimedOutMessage'))
|
|
78
|
-
process.exit(1)
|
|
79
|
-
return
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const pollAuthResult = async (token, client) => {
|
|
85
|
-
await requestUtils.sleep(5000)
|
|
86
|
-
return client
|
|
87
|
-
.pollForAuth(token)
|
|
88
|
-
.then(res => {
|
|
89
|
-
return res
|
|
90
|
-
})
|
|
91
|
-
.catch(err => {
|
|
92
|
-
console.log(err)
|
|
93
|
-
})
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const authUsageGuide = commandLineUsage([
|
|
97
|
-
{
|
|
98
|
-
header: i18n.__('authHeader'),
|
|
99
|
-
content: [i18n.__('constantsAuthHeaderContents')]
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
header: i18n.__('constantsAuthUsageHeader'),
|
|
103
|
-
content: [i18n.__('constantsAuthUsageContents')]
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
header: i18n.__('constantsAdvancedOptions'),
|
|
107
|
-
optionList: constants.commandLineDefinitions.authOptionDefinitions,
|
|
108
|
-
hide: ['organization-id', 'api-key', 'authorization', 'host']
|
|
109
|
-
}
|
|
110
|
-
])
|
|
111
|
-
|
|
112
|
-
const checkForCustomCredentials = authParams => {
|
|
113
|
-
const hasSomeKeys =
|
|
114
|
-
authParams.apiKey ||
|
|
115
|
-
authParams.organizationId ||
|
|
116
|
-
authParams.host ||
|
|
117
|
-
authParams.authorization
|
|
118
|
-
const hasAllKeys =
|
|
119
|
-
authParams.apiKey &&
|
|
120
|
-
authParams.organizationId &&
|
|
121
|
-
authParams.host &&
|
|
122
|
-
authParams.authorization
|
|
123
|
-
|
|
124
|
-
if (hasAllKeys) {
|
|
125
|
-
return true
|
|
126
|
-
}
|
|
127
|
-
if (hasSomeKeys) {
|
|
128
|
-
commonMessageFormatter(messages.authCommand.credentialsMissing, true)
|
|
129
|
-
}
|
|
130
|
-
return false
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const processCustomCredentials = (authParams, config) => {
|
|
134
|
-
const valuesToSet = {
|
|
135
|
-
apiKey: authParams.apiKey,
|
|
136
|
-
orgId: authParams.organizationId,
|
|
137
|
-
authHeader: authParams.authorization,
|
|
138
|
-
host: authParams.host
|
|
139
|
-
}
|
|
140
|
-
configFunctions.setConfigValues(config, valuesToSet)
|
|
141
|
-
commonMessageFormatter(messages.authCommand.credentialsAccepted, false)
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
module.exports = {
|
|
145
|
-
processAuth
|
|
146
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
const parsedCLIOptions = require('../../utils/parsedCLIOptions')
|
|
2
|
-
const constants = require('../../cliConstants')
|
|
3
|
-
const commandLineUsage = require('command-line-usage')
|
|
4
|
-
const i18n = require('i18n')
|
|
5
|
-
|
|
6
|
-
const processConfig = async (argv, config) => {
|
|
7
|
-
try {
|
|
8
|
-
let configParams = await parsedCLIOptions.getCommandLineArgsCustom(
|
|
9
|
-
config,
|
|
10
|
-
'config',
|
|
11
|
-
argv,
|
|
12
|
-
constants.commandLineDefinitions.configOptionDefinitions
|
|
13
|
-
)
|
|
14
|
-
if (configParams.help) {
|
|
15
|
-
console.log(configUsageGuide)
|
|
16
|
-
process.exit(0)
|
|
17
|
-
}
|
|
18
|
-
if (configParams.clear) {
|
|
19
|
-
config.clear()
|
|
20
|
-
} else {
|
|
21
|
-
console.log(JSON.parse(JSON.stringify(config.store)))
|
|
22
|
-
}
|
|
23
|
-
} catch (e) {
|
|
24
|
-
//handle unknown command inputs
|
|
25
|
-
console.log(e.message.toString())
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const configUsageGuide = commandLineUsage([
|
|
30
|
-
{
|
|
31
|
-
header: i18n.__('configHeader')
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
content: [i18n.__('constantsConfigUsageContents')],
|
|
35
|
-
optionList: constants.commandLineDefinitions.configOptionDefinitions
|
|
36
|
-
}
|
|
37
|
-
])
|
|
38
|
-
|
|
39
|
-
module.exports = {
|
|
40
|
-
processConfig: processConfig
|
|
41
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const parsedCLIOptions = require('../../utils/parsedCLIOptions')
|
|
2
|
-
const constants = require('../../cliConstants')
|
|
3
|
-
const paramHandler = require('../../utils/paramsUtil/paramHandler')
|
|
4
|
-
|
|
5
|
-
const getFingerprintConfig = async (contrastConf, command, argv) => {
|
|
6
|
-
let fingerprintParameters = await parsedCLIOptions.getCommandLineArgsCustom(
|
|
7
|
-
contrastConf,
|
|
8
|
-
command,
|
|
9
|
-
argv,
|
|
10
|
-
constants.commandLineDefinitions.fingerprintOptionDefinitions
|
|
11
|
-
)
|
|
12
|
-
const paramsAuth = paramHandler.getAuth(fingerprintParameters)
|
|
13
|
-
fingerprintParameters = paramHandler.getFingerprint(fingerprintParameters)
|
|
14
|
-
return { ...paramsAuth, ...fingerprintParameters }
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
module.exports = {
|
|
18
|
-
getFingerprintConfig
|
|
19
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
const fingerprintConfig = require('./fingerprintConfig')
|
|
2
|
-
const repoServices = require('./repoServices')
|
|
3
|
-
const autoDetection = require('../../common/autoDetection')
|
|
4
|
-
const saveResults = require('../../scan/saveResults')
|
|
5
|
-
const projectConfig = require('./projectGroup')
|
|
6
|
-
const processFingerprint = async (contrastConf, argvMain) => {
|
|
7
|
-
let config = await fingerprintConfig.getFingerprintConfig(
|
|
8
|
-
contrastConf,
|
|
9
|
-
'fingerprint',
|
|
10
|
-
argvMain
|
|
11
|
-
)
|
|
12
|
-
config.repositoryId = await repoServices.getRepoId(config)
|
|
13
|
-
if (config.repositoryId !== '') {
|
|
14
|
-
config.projectGroupId = await projectConfig.getProjectGroupId(config)
|
|
15
|
-
let fingerprint = await autoDetection.autoDetectFingerprintInfo(
|
|
16
|
-
config.file,
|
|
17
|
-
config.depth,
|
|
18
|
-
config
|
|
19
|
-
)
|
|
20
|
-
|
|
21
|
-
if (fingerprint.length === 0) {
|
|
22
|
-
console.log('No supported manifests found')
|
|
23
|
-
process.exit(0)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
let idArray = fingerprint.map(x => x.id)
|
|
27
|
-
await saveResults.writeResultsToFile(fingerprint, 'fingerPrintInfo.json')
|
|
28
|
-
return console.log(idArray)
|
|
29
|
-
} else {
|
|
30
|
-
console.log('No repository Id found')
|
|
31
|
-
process.exit(1)
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
module.exports = {
|
|
36
|
-
processFingerprint: processFingerprint
|
|
37
|
-
}
|
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
const commonApi = require('../../utils/commonApi')
|
|
2
|
-
const { getAppName } = require('../audit/auditController')
|
|
3
|
-
|
|
4
|
-
const getProjectIdByOrg = async config => {
|
|
5
|
-
const client = await commonApi.getHttpClient(config)
|
|
6
|
-
config.language = config.language === 'NODE' ? 'JAVASCRIPT' : config.language
|
|
7
|
-
let projectId = ''
|
|
8
|
-
|
|
9
|
-
let projectByOrg = await retrieveProjectByOrganization(config, client)
|
|
10
|
-
|
|
11
|
-
if (projectByOrg?.length > 0) {
|
|
12
|
-
projectId = getProjectIdFromArray(config, projectByOrg)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return projectId
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const createNewProjectGroupBody = async config => {
|
|
19
|
-
let body = {
|
|
20
|
-
organizationId: config.organizationId
|
|
21
|
-
}
|
|
22
|
-
if (config.repo || config?.repositoryId) {
|
|
23
|
-
body.repositoryId = config.repositoryId
|
|
24
|
-
body.type = 'REPOSITORY'
|
|
25
|
-
body.name = getProjectGroupNameRepo(config)
|
|
26
|
-
} else {
|
|
27
|
-
body.repositoryId = null
|
|
28
|
-
body.type = 'CLI'
|
|
29
|
-
body.name = getProjectGroupNameCLI(config)
|
|
30
|
-
}
|
|
31
|
-
return body
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const getProjectGroupNameRepo = config => {
|
|
35
|
-
return config.repositoryName
|
|
36
|
-
}
|
|
37
|
-
const getProjectGroupNameCLI = config => {
|
|
38
|
-
// file here is actually folder name
|
|
39
|
-
return config.name ? config.name : config.file
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const getProjectName = config => {
|
|
43
|
-
return config.name ? config.name : config.fileName
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const registerNewProjectGroup = async config => {
|
|
47
|
-
let body = await createNewProjectGroupBody(config)
|
|
48
|
-
|
|
49
|
-
const client = await commonApi.getHttpClient(config)
|
|
50
|
-
if (config.repositoryId) {
|
|
51
|
-
body.projects = []
|
|
52
|
-
} else {
|
|
53
|
-
body.projects = createProjectsArray([config])
|
|
54
|
-
}
|
|
55
|
-
let projectGroupInfo = await client
|
|
56
|
-
.registerProjectGroup(config, body)
|
|
57
|
-
.then(res => {
|
|
58
|
-
if (config.debug || config.verbose) {
|
|
59
|
-
console.log('\nRegister ProjectGroup')
|
|
60
|
-
console.log(res.statusCode)
|
|
61
|
-
console.log(res.body)
|
|
62
|
-
}
|
|
63
|
-
if (res.statusCode === 201 || res.statusCode === 200) {
|
|
64
|
-
if (config.debug || config.verbose) {
|
|
65
|
-
console.log('registerProjectGroup - response')
|
|
66
|
-
console.log('response', res.body)
|
|
67
|
-
}
|
|
68
|
-
return res?.body?.projectGroupId
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (res.statusCode === 409) {
|
|
72
|
-
return ''
|
|
73
|
-
}
|
|
74
|
-
})
|
|
75
|
-
.catch(err => {
|
|
76
|
-
console.log('\nError Registering Project Group')
|
|
77
|
-
console.log(err.statusCode)
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
return projectGroupInfo
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const createProjectsArray = params => {
|
|
84
|
-
let projectsArray = []
|
|
85
|
-
let projects = {}
|
|
86
|
-
params.forEach(param => {
|
|
87
|
-
projects = createProject(param)
|
|
88
|
-
projectsArray.push(projects)
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
return projectsArray
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const createProject = (param, shortenedProjectName) => {
|
|
95
|
-
return {
|
|
96
|
-
path: param.fileName,
|
|
97
|
-
name: param.repo ? shortenedProjectName : getProjectName(param),
|
|
98
|
-
source: 'SCA',
|
|
99
|
-
language: param.language,
|
|
100
|
-
packageManager: param.packageManager,
|
|
101
|
-
target: 'SCA',
|
|
102
|
-
sourceId: ''
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const getExistingGroupProjectId = (config, projectGroupsInfoEx) => {
|
|
107
|
-
let existingGroupProjectId = ''
|
|
108
|
-
projectGroupsInfoEx.forEach(i => {
|
|
109
|
-
if (i.repositoryId === config.repositoryId) {
|
|
110
|
-
existingGroupProjectId = i.projectGroupId
|
|
111
|
-
}
|
|
112
|
-
})
|
|
113
|
-
return existingGroupProjectId
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const getProjectIdFromArray = (config, array) => {
|
|
117
|
-
if (array.length === 1) {
|
|
118
|
-
return array[0].projectId
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (config.name) {
|
|
122
|
-
for (const i of array) {
|
|
123
|
-
//match on name
|
|
124
|
-
if (i.name === config.name) return i.projectId
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
for (const i of array) {
|
|
129
|
-
//match on fileName
|
|
130
|
-
if (i.name === config.fileName) return i.projectId
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return ''
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const addAdditionalData = (body, data) => {
|
|
137
|
-
body.projectGroupId = data.projectGroupId ? data.projectGroupId : null
|
|
138
|
-
body.projectGroupName = data.projectGroupName ? data.projectGroupName : null
|
|
139
|
-
body.projectLanguage = data.projectLanguage ? data.projectLanguage : null
|
|
140
|
-
body.projectType = data.projectType ? data.projectType : null
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
const registerProjectIdOnCliServices = async (
|
|
144
|
-
config,
|
|
145
|
-
projectId,
|
|
146
|
-
shortenedProjectName,
|
|
147
|
-
additionalData = undefined
|
|
148
|
-
) => {
|
|
149
|
-
const client = commonApi.getHttpClient(config)
|
|
150
|
-
|
|
151
|
-
let cliServicesBody = {
|
|
152
|
-
projectId: projectId,
|
|
153
|
-
name: config.repo ? shortenedProjectName : getProjectName(config)
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
if (additionalData) {
|
|
157
|
-
addAdditionalData(cliServicesBody, additionalData)
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
let result = await client
|
|
161
|
-
.registerOnCliServices(config, cliServicesBody)
|
|
162
|
-
.then(res => {
|
|
163
|
-
if (config.debug || config.verbose) {
|
|
164
|
-
console.log('\nregistration on cli services')
|
|
165
|
-
console.log('request body', cliServicesBody)
|
|
166
|
-
console.log('response code', res.statusCode)
|
|
167
|
-
}
|
|
168
|
-
if (res.statusCode === 201 || res.statusCode === 200) {
|
|
169
|
-
return res.body
|
|
170
|
-
} else {
|
|
171
|
-
console.log('Failed to Register On Cli Services')
|
|
172
|
-
console.log(res.statusCode)
|
|
173
|
-
process.exit(1)
|
|
174
|
-
}
|
|
175
|
-
})
|
|
176
|
-
|
|
177
|
-
return result
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const registerProjectWithGroupProjectId = async (
|
|
181
|
-
config,
|
|
182
|
-
shortenedProjectName
|
|
183
|
-
) => {
|
|
184
|
-
const client = commonApi.getHttpClient(config)
|
|
185
|
-
config.language = config.language === 'NODE' ? 'JAVASCRIPT' : config.language
|
|
186
|
-
|
|
187
|
-
let body = createProject(config, shortenedProjectName)
|
|
188
|
-
let result = await client.registerProject(config, body).then(res => {
|
|
189
|
-
if (config.debug || config.verbose) {
|
|
190
|
-
console.log('\nregister Project With Group ProjectId')
|
|
191
|
-
console.log(res.statusCode)
|
|
192
|
-
console.log(res.body)
|
|
193
|
-
}
|
|
194
|
-
if (res.statusCode === 201 || res.statusCode === 200) {
|
|
195
|
-
return res.body
|
|
196
|
-
} else {
|
|
197
|
-
return []
|
|
198
|
-
}
|
|
199
|
-
})
|
|
200
|
-
|
|
201
|
-
return result
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
const retrieveExistingProjectIdWithProjectGroupId = async (
|
|
205
|
-
config,
|
|
206
|
-
client,
|
|
207
|
-
projectGroupId
|
|
208
|
-
) => {
|
|
209
|
-
return await client
|
|
210
|
-
.retrieveExistingProjectIdByProjectGroupId(config, projectGroupId)
|
|
211
|
-
.then(res => {
|
|
212
|
-
if (config.debug || config.verbose) {
|
|
213
|
-
console.log('\nRetrieve Existing ProjectId By ProjectGroupId')
|
|
214
|
-
console.log(res.statusCode)
|
|
215
|
-
console.log(res.body)
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
if (res.statusCode === 200) {
|
|
219
|
-
return res.body
|
|
220
|
-
} else {
|
|
221
|
-
return ''
|
|
222
|
-
}
|
|
223
|
-
})
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
const retrieveProjectByOrganization = async (config, client) => {
|
|
227
|
-
return await client.retrieveProjectByOrganizationId(config).then(res => {
|
|
228
|
-
if (config.debug || config.verbose) {
|
|
229
|
-
console.log('\nRetrieve Project By OrganizationId')
|
|
230
|
-
console.log(res.statusCode)
|
|
231
|
-
console.log(res.body)
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
if (res.statusCode === 201 || res.statusCode === 200) {
|
|
235
|
-
return res.body
|
|
236
|
-
} else {
|
|
237
|
-
return []
|
|
238
|
-
}
|
|
239
|
-
})
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
const retrieveExistingProjectGroups = async config => {
|
|
243
|
-
const client = commonApi.getHttpClient(config)
|
|
244
|
-
return await client.retrieveExistingProjectGroupsByOrg(config).then(res => {
|
|
245
|
-
if (config.debug || config.verbose) {
|
|
246
|
-
console.log('retrieve Existing ProjectGroups By Org')
|
|
247
|
-
console.log(res.statusCode)
|
|
248
|
-
console.log(res.body)
|
|
249
|
-
}
|
|
250
|
-
if (res.statusCode === 201 || res.statusCode === 200) {
|
|
251
|
-
let correctGroupID = res?.body?.filter(
|
|
252
|
-
i => i.repositoryId === config.repositoryId
|
|
253
|
-
)
|
|
254
|
-
|
|
255
|
-
if (correctGroupID.length > 0) {
|
|
256
|
-
return correctGroupID[0].projectGroupId
|
|
257
|
-
}
|
|
258
|
-
return ''
|
|
259
|
-
} else {
|
|
260
|
-
return ''
|
|
261
|
-
}
|
|
262
|
-
})
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
const getProjectGroupId = async config => {
|
|
266
|
-
let projectGroupId = ''
|
|
267
|
-
if (config.projectGroupId === '' || config.projectGroupId === undefined) {
|
|
268
|
-
projectGroupId = await retrieveExistingProjectGroups(config)
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
if (projectGroupId === '') {
|
|
272
|
-
projectGroupId = await registerNewProjectGroup(config)
|
|
273
|
-
}
|
|
274
|
-
return projectGroupId
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
const dealWithNoName = async config => {
|
|
278
|
-
try {
|
|
279
|
-
config.name = getAppName(config.file)
|
|
280
|
-
} catch (e) {
|
|
281
|
-
console.log(e.message.toString())
|
|
282
|
-
process.exit(1)
|
|
283
|
-
}
|
|
284
|
-
return config
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
module.exports = {
|
|
288
|
-
getProjectIdByOrg,
|
|
289
|
-
registerProjectIdOnCliServices,
|
|
290
|
-
dealWithNoName,
|
|
291
|
-
registerNewProjectGroup,
|
|
292
|
-
createNewProjectGroupBody,
|
|
293
|
-
registerProjectWithGroupProjectId,
|
|
294
|
-
getExistingGroupProjectId,
|
|
295
|
-
getProjectGroupId,
|
|
296
|
-
retrieveExistingProjectGroups,
|
|
297
|
-
createProject
|
|
298
|
-
}
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
const commonApi = require('../../utils/commonApi')
|
|
2
|
-
const retrieveRepoId = async config => {
|
|
3
|
-
const client = await commonApi.getHttpClient(config)
|
|
4
|
-
|
|
5
|
-
let repositoryId = await client
|
|
6
|
-
.retrieveRepoByOrgAndGitURL(config)
|
|
7
|
-
.then(res => {
|
|
8
|
-
if (config.debug || config.verbose) {
|
|
9
|
-
console.log('\nRetrieve RepoId By retrieveRepoByOrgAndGitURL')
|
|
10
|
-
console.log(res.statusCode)
|
|
11
|
-
console.log(res.body)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
if (res.statusCode === 201 || res.statusCode === 200) {
|
|
15
|
-
return res.body.repositoryId
|
|
16
|
-
} else {
|
|
17
|
-
return ''
|
|
18
|
-
}
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
return repositoryId
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const registerNewRepo = async config => {
|
|
25
|
-
let body = {
|
|
26
|
-
externalScmUrl: config.repositoryUrl,
|
|
27
|
-
externalScmName: config.repositoryName,
|
|
28
|
-
externalId: config.externalId,
|
|
29
|
-
primaryLanguage: config.language,
|
|
30
|
-
defaultBranch: 'develop'
|
|
31
|
-
}
|
|
32
|
-
if (config.debug || config.verbose) {
|
|
33
|
-
console.log('registerNewRepo')
|
|
34
|
-
console.log(body)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const client = await commonApi.getHttpClient(config)
|
|
38
|
-
|
|
39
|
-
let result = await client
|
|
40
|
-
.registerRepo(config, body)
|
|
41
|
-
.then(res => {
|
|
42
|
-
if (config.debug || config.verbose) {
|
|
43
|
-
console.log('\nRegister Repository')
|
|
44
|
-
console.log(res.statusCode)
|
|
45
|
-
console.log(res.body)
|
|
46
|
-
}
|
|
47
|
-
if (res.statusCode === 201 || res.statusCode === 200) {
|
|
48
|
-
if (config.debug || config.verbose) {
|
|
49
|
-
console.log('registerRepository - response')
|
|
50
|
-
console.log('response', res.body)
|
|
51
|
-
}
|
|
52
|
-
return res?.body?.repositoryId
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (res.statusCode === 409) {
|
|
56
|
-
return ''
|
|
57
|
-
}
|
|
58
|
-
if (res.statusCode === 400) {
|
|
59
|
-
if (config.debug || config.verbose) {
|
|
60
|
-
console.log('\nError Registering Repository - Bad request')
|
|
61
|
-
console.log(res.statusCode)
|
|
62
|
-
console.log(res.message)
|
|
63
|
-
}
|
|
64
|
-
process.exit(1)
|
|
65
|
-
}
|
|
66
|
-
})
|
|
67
|
-
.catch(err => {
|
|
68
|
-
console.log('\nError Registering Repository')
|
|
69
|
-
console.log(err.statusCode)
|
|
70
|
-
console.log(err.message)
|
|
71
|
-
process.exit(1)
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
return result
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const retrieveProjectInfoViaRepoId = async config => {
|
|
78
|
-
const client = commonApi.getHttpClient(config)
|
|
79
|
-
|
|
80
|
-
let result = await client
|
|
81
|
-
.retrieveProjectByRepoId(config)
|
|
82
|
-
.then(res => {
|
|
83
|
-
if (config.debug || config.verbose) {
|
|
84
|
-
console.log('\nRetrieve Project By RepoId')
|
|
85
|
-
console.log(res.statusCode)
|
|
86
|
-
console.log(res.body)
|
|
87
|
-
}
|
|
88
|
-
if (res.statusCode === 201 || res.statusCode === 200) {
|
|
89
|
-
return res?.body
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (res.statusCode === 409) {
|
|
93
|
-
return []
|
|
94
|
-
}
|
|
95
|
-
})
|
|
96
|
-
.catch(err => {
|
|
97
|
-
console.log('\nError Retrieve Project By RepoId')
|
|
98
|
-
console.log(err.statusCode)
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
return result
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const getRepoId = async config => {
|
|
105
|
-
let repoId = ''
|
|
106
|
-
if (config.repositoryId === '' || config.repositoryId === undefined) {
|
|
107
|
-
repoId = await retrieveRepoId(config)
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (repoId === '') {
|
|
111
|
-
repoId = await registerNewRepo(config)
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return repoId
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
module.exports = {
|
|
118
|
-
retrieveRepoId,
|
|
119
|
-
registerNewRepo,
|
|
120
|
-
getRepoId,
|
|
121
|
-
retrieveProjectInfoViaRepoId
|
|
122
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
const { openLearnPage } = require('./learn')
|
|
2
|
-
|
|
3
|
-
async function processLearn() {
|
|
4
|
-
console.log('Opening Contrast’s Secure Code Learning Hub...')
|
|
5
|
-
console.log(
|
|
6
|
-
'If the page does not open you can open it directly via https://www.contrastsecurity.com/developer/learn'
|
|
7
|
-
)
|
|
8
|
-
return openLearnPage()
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
module.exports = {
|
|
12
|
-
processLearn
|
|
13
|
-
}
|