@contrast/contrast 1.0.21 → 1.0.23

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.
Files changed (62) hide show
  1. package/dist/audit/report/commonReportingFunctions.js +1 -1
  2. package/dist/audit/save.js +10 -4
  3. package/dist/cliConstants.js +4 -3
  4. package/dist/commands/audit/help.js +3 -1
  5. package/dist/commands/audit/processAudit.js +1 -1
  6. package/dist/commands/auth/auth.js +5 -0
  7. package/dist/commands/learn/processLearn.js +1 -1
  8. package/dist/common/HTTPClient.js +9 -0
  9. package/dist/constants/constants.js +1 -1
  10. package/dist/constants/lambda.js +1 -0
  11. package/dist/constants/locales.js +15 -14
  12. package/dist/lambda/help.js +3 -0
  13. package/dist/lambda/scanRequest.js +12 -1
  14. package/dist/sbom/generateSbom.js +7 -0
  15. package/dist/scaAnalysis/common/commonReportingFunctionsSca.js +3 -3
  16. package/dist/scaAnalysis/common/treeUpload.js +8 -19
  17. package/dist/scaAnalysis/go/goAnalysis.js +1 -6
  18. package/dist/scaAnalysis/java/analysis.js +24 -32
  19. package/dist/scaAnalysis/java/index.js +1 -6
  20. package/dist/scaAnalysis/javascript/analysis.js +11 -33
  21. package/dist/scaAnalysis/javascript/index.js +14 -4
  22. package/dist/scaAnalysis/javascript/scaServiceParser.js +3 -3
  23. package/dist/scaAnalysis/php/index.js +2 -8
  24. package/dist/scaAnalysis/python/analysis.js +4 -10
  25. package/dist/scaAnalysis/python/index.js +1 -6
  26. package/dist/scaAnalysis/ruby/analysis.js +1 -10
  27. package/dist/scaAnalysis/ruby/index.js +1 -6
  28. package/dist/scaAnalysis/scaAnalysis.js +17 -59
  29. package/dist/scan/help.js +3 -0
  30. package/package.json +2 -5
  31. package/src/audit/report/commonReportingFunctions.js +1 -1
  32. package/src/audit/save.js +11 -9
  33. package/src/cliConstants.js +4 -3
  34. package/src/commands/audit/help.js +3 -1
  35. package/src/commands/audit/processAudit.js +2 -5
  36. package/src/commands/auth/auth.js +5 -0
  37. package/src/commands/learn/processLearn.js +1 -1
  38. package/src/common/HTTPClient.js +11 -0
  39. package/src/constants/constants.js +1 -1
  40. package/src/constants/lambda.js +1 -0
  41. package/src/constants/locales.js +15 -14
  42. package/src/index.ts +0 -1
  43. package/src/lambda/help.ts +3 -0
  44. package/src/lambda/scanRequest.ts +27 -2
  45. package/src/sbom/generateSbom.ts +8 -0
  46. package/src/scaAnalysis/common/commonReportingFunctionsSca.js +3 -3
  47. package/src/scaAnalysis/common/treeUpload.js +12 -20
  48. package/src/scaAnalysis/go/goAnalysis.js +1 -6
  49. package/src/scaAnalysis/java/analysis.js +29 -34
  50. package/src/scaAnalysis/java/index.js +1 -6
  51. package/src/scaAnalysis/javascript/analysis.js +19 -34
  52. package/src/scaAnalysis/javascript/index.js +27 -4
  53. package/src/scaAnalysis/javascript/scaServiceParser.js +3 -3
  54. package/src/scaAnalysis/php/index.js +2 -8
  55. package/src/scaAnalysis/python/analysis.js +4 -10
  56. package/src/scaAnalysis/python/index.js +1 -6
  57. package/src/scaAnalysis/ruby/analysis.js +1 -11
  58. package/src/scaAnalysis/ruby/index.js +1 -6
  59. package/src/scaAnalysis/scaAnalysis.js +25 -85
  60. package/src/scan/help.js +3 -0
  61. package/dist/utils/settingsHelper.js +0 -24
  62. package/src/utils/settingsHelper.js +0 -26
@@ -3,8 +3,6 @@ const spawn = require('cross-spawn')
3
3
  const path = require('path')
4
4
  const i18n = require('i18n')
5
5
  const fs = require('fs')
6
- const readLine = require('readline')
7
- const paramHandler = require('../../utils/paramsUtil/paramHandler')
8
6
 
9
7
  const MAVEN = 'maven'
10
8
  const GRADLE = 'gradle'
@@ -31,30 +29,31 @@ const determineProjectTypeAndCwd = (files, config) => {
31
29
  }
32
30
 
33
31
  const buildMaven = (config, projectData, timeout) => {
34
- let cmdStdout
35
- try {
36
- let command = 'mvn'
37
- let args = ['dependency:tree', '-B']
38
- if (config.mavenSettingsPath) {
39
- args.push('-s')
40
- args.push(config.mavenSettingsPath)
41
- }
42
- // Allow users to provide a custom location for their settings.xml
32
+ let command = 'mvn'
33
+ let args = ['dependency:tree', '-B']
34
+ if (config.mavenSettingsPath) {
35
+ args.push('-s')
36
+ args.push(config.mavenSettingsPath)
37
+ }
43
38
 
44
- cmdStdout = spawn
45
- .sync(command, args, {
46
- env: process.env,
47
- cwd: projectData.cwd,
48
- timeout
49
- })
50
- .stdout.toString()
39
+ // Allow users to provide a custom location for their settings.xml
40
+ const cmdDepTree = spawn.sync(command, args, {
41
+ env: process.env,
42
+ cwd: projectData.cwd,
43
+ timeout
44
+ })
51
45
 
52
- return cmdStdout.toString()
53
- } catch (err) {
54
- throw new Error(
55
- i18n.__('mavenDependencyTreeNonZero', projectData.cwd, `${err.message}`)
56
- )
46
+ if (cmdDepTree.status !== 0) {
47
+ //if maven not found
48
+ if (config.debug && cmdDepTree.error.code === 'ENOENT') {
49
+ console.log(`ERROR: mvn not found`)
50
+ console.log('Please make sure mvn is installed and accessible')
51
+ }
52
+
53
+ throw new Error(i18n.__('mavenDependencyTreeNonZero', projectData.cwd))
57
54
  }
55
+
56
+ return cmdDepTree.stdout.toString()
58
57
  }
59
58
 
60
59
  const buildGradle = (config, projectData, timeout) => {
@@ -133,18 +132,14 @@ const getJavaBuildDeps = (config, files) => {
133
132
  projectType: undefined
134
133
  }
135
134
 
136
- try {
137
- const projectData = determineProjectTypeAndCwd(files, config)
138
- if (projectData.projectType === MAVEN) {
139
- output.mvnDependancyTreeOutput = buildMaven(config, projectData, timeout)
140
- } else if (projectData.projectType === GRADLE) {
141
- output.mvnDependancyTreeOutput = buildGradle(config, projectData, timeout)
142
- }
143
- output.projectType = projectData.projectType
144
- return output
145
- } catch (err) {
146
- console.log(err.message.toString())
135
+ const projectData = determineProjectTypeAndCwd(files, config)
136
+ if (projectData.projectType === MAVEN) {
137
+ output.mvnDependancyTreeOutput = buildMaven(config, projectData, timeout)
138
+ } else if (projectData.projectType === GRADLE) {
139
+ output.mvnDependancyTreeOutput = buildGradle(config, projectData, timeout)
147
140
  }
141
+ output.projectType = projectData.projectType
142
+ return output
148
143
  }
149
144
 
150
145
  module.exports = {
@@ -11,12 +11,7 @@ const javaAnalysis = async (config, languageFiles) => {
11
11
  })
12
12
 
13
13
  const javaDeps = buildJavaTree(config, languageFiles.JAVA)
14
-
15
- if (config.experimental) {
16
- return parseDependenciesForSCAServices(javaDeps)
17
- } else {
18
- return createJavaTSMessage(javaDeps)
19
- }
14
+ return createJavaTSMessage(javaDeps)
20
15
  }
21
16
 
22
17
  const buildJavaTree = (config, files) => {
@@ -44,48 +44,33 @@ const readYarn = async (config, languageFiles, nameOfFile) => {
44
44
  }
45
45
  }
46
46
 
47
- const parseNpmLockFile = async js => {
47
+ const parseNpmLockFile = async npmLockFile => {
48
48
  try {
49
- js.npmLockFile = JSON.parse(js.rawLockFileContents)
50
- if (js.npmLockFile && js.npmLockFile.lockfileVersion > 1) {
51
- const listOfTopDep = Object.keys(js.npmLockFile.dependencies)
52
- Object.entries(js.npmLockFile.dependencies).forEach(([objKey, value]) => {
53
- if (value.requires) {
54
- const listOfRequiresDep = Object.keys(value.requires)
55
- listOfRequiresDep.forEach(dep => {
56
- if (!listOfTopDep.includes(dep)) {
57
- addDepToLockFile(js, value['requires'], dep)
58
- }
59
- })
60
- }
49
+ if (!npmLockFile.parsedPackages) {
50
+ npmLockFile.parsedPackages = {}
51
+ }
61
52
 
62
- if (value.dependencies) {
63
- Object.entries(value.dependencies).forEach(
64
- ([objChildKey, childValue]) => {
65
- if (childValue.requires) {
66
- const listOfRequiresDep = Object.keys(childValue.requires)
67
- listOfRequiresDep.forEach(dep => {
68
- if (!listOfTopDep.includes(dep)) {
69
- addDepToLockFile(js, childValue['requires'], dep)
70
- }
71
- })
72
- }
73
- }
74
- )
53
+ Object.entries(npmLockFile.packages).forEach(
54
+ ([packageKey, packageValue]) => {
55
+ if (packageKey.includes('node_modules/')) {
56
+ //remove object keys node modules prefixing
57
+ //e.g: node_modules/@aws-amplify/datastore/node_modules/uuid --> @aws-amplify/datastore/uuid
58
+ packageKey = packageKey.replace(/(node_modules\/)+/g, '')
75
59
  }
76
- })
77
- return js.npmLockFile
78
- } else {
79
- return js.npmLockFile
80
- }
60
+
61
+ npmLockFile.parsedPackages[packageKey] = packageValue
62
+ }
63
+ )
64
+
65
+ //remove base project package - unneeded
66
+ delete npmLockFile.parsedPackages['']
67
+
68
+ return npmLockFile
81
69
  } catch (err) {
82
70
  throw new Error(i18n.__('NodeParseNPM') + `${err.message}`)
83
71
  }
84
72
  }
85
73
 
86
- const addDepToLockFile = (js, depObj, key) => {
87
- return (js.npmLockFile.dependencies[key] = { version: depObj[key] })
88
- }
89
74
  const parseYarnLockFile = async js => {
90
75
  try {
91
76
  js.yarn.yarnLockFile = {}
@@ -14,9 +14,6 @@ const jsAnalysis = async (config, languageFiles) => {
14
14
  const buildNodeTree = async (config, files) => {
15
15
  let analysis = await readFiles(config, files)
16
16
  const rawNode = await parseFiles(config, files, analysis)
17
- if (config.experimental) {
18
- return scaServiceParser.parseJS(rawNode)
19
- }
20
17
  return formatMessage.createJavaScriptTSMessage(rawNode)
21
18
  }
22
19
 
@@ -44,8 +41,34 @@ const readFiles = async (config, files) => {
44
41
 
45
42
  const parseFiles = async (config, files, js) => {
46
43
  if (files.includes('package-lock.json')) {
47
- js.npmLockFile = await analysis.parseNpmLockFile(js)
44
+ const npmLockFile = JSON.parse(js.rawLockFileContents)
45
+
46
+ const currentLockFileVersion = npmLockFile.lockfileVersion
47
+ const generalRebuildMessage =
48
+ '\nPlease update to Node 16+ & NPM 8+ or 9+ and then rebuild your package files.' +
49
+ '\nMore info here: https://docs.npmjs.com/cli/v9/configuring-npm/package-lock-json'
50
+
51
+ if (currentLockFileVersion === 1) {
52
+ throw new Error(
53
+ `NPM lockfileVersion 1 is no longer supported. \n ${generalRebuildMessage}`
54
+ )
55
+ }
56
+
57
+ if (!currentLockFileVersion || !npmLockFile.packages) {
58
+ throw new Error(
59
+ `package-lock.json needs to be in the NPM v2 or v3 format. \n ${generalRebuildMessage}`
60
+ )
61
+ }
62
+
63
+ if (currentLockFileVersion === 3) {
64
+ throw new Error(
65
+ `NPM lockfileVersion 3 is only supported when using the '-e' flag.`
66
+ )
67
+ }
68
+
69
+ js.npmLockFile = await analysis.parseNpmLockFile(npmLockFile)
48
70
  }
71
+
49
72
  if (files.includes('yarn.lock')) {
50
73
  js = await analysis.parseYarnLockFile(js)
51
74
  }
@@ -77,7 +77,7 @@ const chooseLockFile = rawNode => {
77
77
  if (rawNode?.yarn?.yarnLockFile !== undefined) {
78
78
  return { lockFile: rawNode?.yarn?.yarnLockFile?.object, type: 'yarn' }
79
79
  } else if (rawNode.npmLockFile !== undefined) {
80
- return { lockFile: rawNode?.npmLockFile?.dependencies, type: 'npm' }
80
+ return { lockFile: rawNode?.npmLockFile?.parsedPackages, type: 'npm' }
81
81
  } else {
82
82
  return undefined
83
83
  }
@@ -105,9 +105,9 @@ const createChildDependencies = (lockFileDep, currentDep) => {
105
105
 
106
106
  const createNPMChildDependencies = (lockFileDep, currentDep) => {
107
107
  let depArray = []
108
- if (lockFileDep[currentDep]?.requires) {
108
+ if (lockFileDep[currentDep]?.dependencies) {
109
109
  for (const [key, value] of Object.entries(
110
- lockFileDep[currentDep]?.requires
110
+ lockFileDep[currentDep]?.dependencies
111
111
  )) {
112
112
  depArray.push(key)
113
113
  }
@@ -1,16 +1,10 @@
1
1
  const { readFile, parseProjectFiles } = require('./analysis')
2
2
  const { createPhpTSMessage } = require('../common/formatMessage')
3
- const { parsePHPLockFileForScaServices } = require('./phpNewServicesMapper')
4
3
 
5
4
  const phpAnalysis = config => {
6
5
  let analysis = readFiles(config)
7
-
8
- if (config.experimental) {
9
- return parsePHPLockFileForScaServices(analysis.rawLockFileContents)
10
- } else {
11
- const phpDep = parseProjectFiles(analysis)
12
- return createPhpTSMessage(phpDep)
13
- }
6
+ const phpDep = parseProjectFiles(analysis)
7
+ return createPhpTSMessage(phpDep)
14
8
  }
15
9
 
16
10
  const readFiles = config => {
@@ -60,16 +60,10 @@ const checkForCorrectFiles = languageFiles => {
60
60
 
61
61
  const getPythonDeps = (config, languageFiles) => {
62
62
  try {
63
- if (config.experimental) {
64
- let pythonLockFileContents = readLockFile(config.file)
65
- return scaPythonParser(pythonLockFileContents)
66
- } else {
67
- checkForCorrectFiles(languageFiles)
68
- const parseProject = readAndParseProjectFile(config.file)
69
- const parsePip = readAndParseLockFile(config.file)
70
-
71
- return { pipfileLock: parsePip, pipfilDependanceies: parseProject }
72
- }
63
+ checkForCorrectFiles(languageFiles)
64
+ const parseProject = readAndParseProjectFile(config.file)
65
+ const parsePip = readAndParseLockFile(config.file)
66
+ return { pipfileLock: parsePip, pipfilDependanceies: parseProject }
73
67
  } catch (err) {
74
68
  console.log(err.message.toString())
75
69
  process.exit(1)
@@ -3,12 +3,7 @@ const { getPythonDeps, secondaryParser } = require('./analysis')
3
3
 
4
4
  const pythonAnalysis = (config, languageFiles) => {
5
5
  const pythonDeps = getPythonDeps(config, languageFiles.PYTHON)
6
-
7
- if (config.experimental) {
8
- return pythonDeps
9
- } else {
10
- return createPythonTSMessage(pythonDeps)
11
- }
6
+ return createPythonTSMessage(pythonDeps)
12
7
  }
13
8
 
14
9
  module.exports = {
@@ -6,17 +6,7 @@ const getRubyDeps = (config, languageFiles) => {
6
6
  checkForCorrectFiles(languageFiles)
7
7
  const parsedGem = readAndParseGemfile(config.file)
8
8
  const parsedLock = readAndParseGemLockFile(config.file)
9
- if (config.experimental) {
10
- const rubyArray = removeRedundantAndPopulateDefinedElements(
11
- parsedLock.sources
12
- )
13
- let rubyTree = createRubyTree(rubyArray)
14
- findChildrenDependencies(rubyTree)
15
- processRootDependencies(parsedLock.dependencies, rubyTree)
16
- return rubyTree
17
- } else {
18
- return { gemfilesDependanceies: parsedGem, gemfileLock: parsedLock }
19
- }
9
+ return { gemfilesDependanceies: parsedGem, gemfileLock: parsedLock }
20
10
  } catch (err) {
21
11
  throw err
22
12
  }
@@ -3,12 +3,7 @@ const { createRubyTSMessage } = require('../common/formatMessage')
3
3
 
4
4
  const rubyAnalysis = (config, languageFiles) => {
5
5
  const rubyDeps = analysis.getRubyDeps(config, languageFiles.RUBY)
6
-
7
- if (config.experimental) {
8
- return rubyDeps
9
- } else {
10
- return createRubyTSMessage(rubyDeps)
11
- }
6
+ return createRubyTSMessage(rubyDeps)
12
7
  }
13
8
 
14
9
  module.exports = {
@@ -26,18 +26,10 @@ const { rubyAnalysis } = require('./ruby')
26
26
  const { pythonAnalysis } = require('./python')
27
27
  const javaAnalysis = require('./java')
28
28
  const jsAnalysis = require('./javascript')
29
- const auditReport = require('./common/auditReport')
30
- const scaUpload = require('./common/scaServicesUpload')
31
- const settingsHelper = require('../utils/settingsHelper')
32
29
  const chalk = require('chalk')
33
- const saveResults = require('../scan/saveResults')
34
- const {
35
- convertGenericToTypedReportModelSca
36
- } = require('./common/utils/reportUtilsSca')
37
30
 
38
31
  const processSca = async config => {
39
32
  //checks to see whether to use old TS / new SCA path
40
- config = await settingsHelper.getSettings(config)
41
33
 
42
34
  const startTime = performance.now()
43
35
  let filesFound
@@ -72,18 +64,7 @@ const processSca = async config => {
72
64
  switch (Object.keys(filesFound[0])[0]) {
73
65
  case JAVA:
74
66
  config.language = JAVA
75
-
76
- if (config.mode === 'repo') {
77
- try {
78
- return repoMode.buildRepo(config, filesFound[0])
79
- } catch (e) {
80
- throw new Error(
81
- 'Unable to build in repository mode. Check your project file'
82
- )
83
- }
84
- } else {
85
- messageToSend = await javaAnalysis.javaAnalysis(config, filesFound[0])
86
- }
67
+ messageToSend = await javaAnalysis.javaAnalysis(config, filesFound[0])
87
68
  break
88
69
  case JAVASCRIPT:
89
70
  messageToSend = await jsAnalysis.jsAnalysis(config, filesFound[0])
@@ -106,18 +87,9 @@ const processSca = async config => {
106
87
  config.language = GO
107
88
  break
108
89
  case DOTNET:
109
- if (config.experimental) {
110
- console.log(
111
- `${chalk.bold(
112
- '\n.NET project found\n'
113
- )} Language type is unsupported.`
114
- )
115
- return
116
- } else {
117
- messageToSend = dotNetAnalysis(config, filesFound[0])
118
- config.language = DOTNET
119
- break
120
- }
90
+ messageToSend = dotNetAnalysis(config, filesFound[0])
91
+ config.language = DOTNET
92
+ break
121
93
  default:
122
94
  //something is wrong
123
95
  console.log('No supported language detected in project path')
@@ -127,63 +99,31 @@ const processSca = async config => {
127
99
  if (!config.applicationId) {
128
100
  config.applicationId = await auditController.dealWithNoAppId(config)
129
101
  }
102
+ console.log('') //empty log for space before spinner
103
+ //send message to TS
104
+ const reportSpinner = returnOra(i18n.__('auditSCAAnalysisBegins'))
105
+ startSpinner(reportSpinner)
106
+ const snapshotResponse = await treeUpload.commonSendSnapShot(
107
+ messageToSend,
108
+ config
109
+ )
130
110
 
131
- if (config.experimental) {
132
- console.log('') //empty log for space before spinner
133
- const reportSpinner = returnOra(i18n.__('auditSCAAnalysisBegins'))
134
- startSpinner(reportSpinner)
135
- const { reportArray, reportId } = await scaUpload.scaTreeUpload(
136
- messageToSend,
137
- config
138
- )
139
-
140
- const reportModelLibraryList =
141
- convertGenericToTypedReportModelSca(reportArray)
142
- auditReport.processAuditReport(config, reportModelLibraryList)
143
- succeedSpinner(reportSpinner, i18n.__('auditSCAAnalysisComplete'))
144
-
145
- if (config.save !== undefined) {
146
- await auditSave.auditSave(config, reportId)
147
- } else {
148
- console.log('Use contrast audit --save to generate an SBOM')
149
- }
111
+ // poll for completion
112
+ await pollForSnapshotCompletion(config, snapshotResponse.id, reportSpinner)
113
+ succeedSpinner(reportSpinner, i18n.__('auditSCAAnalysisComplete'))
150
114
 
151
- const endTime = performance.now() - startTime
152
- const scanDurationMs = endTime - startTime
153
- console.log(
154
- `----- completed in ${(scanDurationMs / 1000).toFixed(2)}s -----`
155
- )
115
+ await vulnerabilityReportV2(config, snapshotResponse.id)
116
+ if (config.save !== undefined) {
117
+ await auditSave.auditSave(config)
156
118
  } else {
157
- console.log('') //empty log for space before spinner
158
- //send message to TS
159
- const reportSpinner = returnOra(i18n.__('auditSCAAnalysisBegins'))
160
- startSpinner(reportSpinner)
161
- const snapshotResponse = await treeUpload.commonSendSnapShot(
162
- messageToSend,
163
- config
164
- )
165
-
166
- // poll for completion
167
- await pollForSnapshotCompletion(
168
- config,
169
- snapshotResponse.id,
170
- reportSpinner
171
- )
172
- succeedSpinner(reportSpinner, i18n.__('auditSCAAnalysisComplete'))
173
-
174
- await vulnerabilityReportV2(config, snapshotResponse.id)
175
- if (config.save !== undefined) {
176
- await auditSave.auditSave(config)
177
- } else {
178
- console.log('\nUse contrast audit --save to generate an SBOM')
179
- }
180
- const endTime = performance.now() - startTime
181
- const scanDurationMs = endTime - startTime
182
-
183
- console.log(
184
- `----- completed in ${(scanDurationMs / 1000).toFixed(2)}s -----`
185
- )
119
+ console.log('\nUse contrast audit --save to generate an SBOM')
186
120
  }
121
+ const endTime = performance.now() - startTime
122
+ const scanDurationMs = endTime - startTime
123
+
124
+ console.log(
125
+ `----- completed in ${(scanDurationMs / 1000).toFixed(2)}s -----`
126
+ )
187
127
  } else {
188
128
  if (filesFound.length === 0) {
189
129
  console.log(i18n.__('languageAnalysisNoLanguage'))
package/src/scan/help.js CHANGED
@@ -4,6 +4,9 @@ const constants = require('../cliConstants')
4
4
  const { commonHelpLinks } = require('../common/commonHelp')
5
5
 
6
6
  const scanUsageGuide = commandLineUsage([
7
+ {
8
+ header: i18n.__('constantsHeader')
9
+ },
7
10
  {
8
11
  header: i18n.__('scanHeader')
9
12
  },
@@ -1,24 +0,0 @@
1
- "use strict";
2
- const commonApi = require('./commonApi');
3
- const { getMode } = require('./generalAPI');
4
- const { SAAS, MODE_BUILD } = require('../constants/constants');
5
- const getSettings = async (config) => {
6
- config.isEOP = (await getMode(config)).toUpperCase() === SAAS ? false : true;
7
- config.mode = MODE_BUILD;
8
- config.scaServices = await isSCAServicesAvailable(config);
9
- return config;
10
- };
11
- const isSCAServicesAvailable = async (config) => {
12
- const client = commonApi.getHttpClient(config);
13
- return client
14
- .scaServiceIngests(config)
15
- .then(res => {
16
- return res.statusCode !== 403;
17
- })
18
- .catch(err => {
19
- console.log(err);
20
- });
21
- };
22
- module.exports = {
23
- getSettings
24
- };
@@ -1,26 +0,0 @@
1
- const commonApi = require('./commonApi')
2
- const { getMode } = require('./generalAPI')
3
- const { SAAS, MODE_BUILD } = require('../constants/constants')
4
-
5
- const getSettings = async config => {
6
- config.isEOP = (await getMode(config)).toUpperCase() === SAAS ? false : true
7
- config.mode = MODE_BUILD
8
- config.scaServices = await isSCAServicesAvailable(config)
9
- return config
10
- }
11
-
12
- const isSCAServicesAvailable = async config => {
13
- const client = commonApi.getHttpClient(config)
14
- return client
15
- .scaServiceIngests(config)
16
- .then(res => {
17
- return res.statusCode !== 403
18
- })
19
- .catch(err => {
20
- console.log(err)
21
- })
22
- }
23
-
24
- module.exports = {
25
- getSettings
26
- }