@contrast/contrast 2.0.1 → 2.0.2-beta.1

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 (49) hide show
  1. package/dist/audit/report/reportingFeature.js +7 -0
  2. package/dist/cliConstants.js +9 -8
  3. package/dist/commands/audit/processAudit.js +0 -2
  4. package/dist/commands/github/fingerprintConfig.js +2 -1
  5. package/dist/commands/github/processFingerprint.js +17 -7
  6. package/dist/commands/github/projectGroup.js +110 -30
  7. package/dist/commands/github/repoServices.js +42 -4
  8. package/dist/common/HTTPClient.js +37 -16
  9. package/dist/common/baseRequest.js +74 -0
  10. package/dist/constants/constants.js +1 -1
  11. package/dist/scaAnalysis/common/auditReport.js +8 -1
  12. package/dist/scaAnalysis/common/scaServicesUpload.js +3 -1
  13. package/dist/scaAnalysis/go/goReadDepFile.js +5 -1
  14. package/dist/scaAnalysis/java/analysis.js +1 -1
  15. package/dist/scaAnalysis/java/javaBuildDepsParser.js +11 -1
  16. package/dist/scaAnalysis/legacy/legacyFlow.js +0 -6
  17. package/dist/scaAnalysis/processServicesFlow.js +38 -17
  18. package/dist/scaAnalysis/repoMode/mavenParser.js +95 -53
  19. package/dist/scaAnalysis/scaAnalysis.js +4 -8
  20. package/dist/scan/autoDetection.js +12 -5
  21. package/dist/scan/fileUtils.js +33 -19
  22. package/dist/utils/paramsUtil/paramHandler.js +11 -2
  23. package/dist/utils/validationCheck.js +5 -1
  24. package/package.json +7 -3
  25. package/src/audit/report/reportingFeature.ts +7 -0
  26. package/src/cliConstants.js +9 -8
  27. package/src/commands/audit/processAudit.js +0 -2
  28. package/src/commands/github/fingerprintConfig.js +2 -2
  29. package/src/commands/github/processFingerprint.js +21 -11
  30. package/src/commands/github/projectGroup.js +131 -35
  31. package/src/commands/github/repoServices.js +46 -4
  32. package/src/common/HTTPClient.js +46 -17
  33. package/src/common/baseRequest.ts +83 -0
  34. package/src/constants/constants.js +1 -1
  35. package/src/scaAnalysis/common/auditReport.js +8 -1
  36. package/src/scaAnalysis/common/scaServicesUpload.js +5 -1
  37. package/src/scaAnalysis/go/goReadDepFile.js +5 -1
  38. package/src/scaAnalysis/java/analysis.js +1 -1
  39. package/src/scaAnalysis/java/javaBuildDepsParser.js +17 -1
  40. package/src/scaAnalysis/legacy/legacyFlow.js +0 -5
  41. package/src/scaAnalysis/processServicesFlow.js +82 -24
  42. package/src/scaAnalysis/repoMode/mavenParser.js +112 -62
  43. package/src/scaAnalysis/scaAnalysis.js +9 -8
  44. package/src/scan/autoDetection.js +12 -5
  45. package/src/scan/fileUtils.js +33 -19
  46. package/src/utils/paramsUtil/paramHandler.js +16 -2
  47. package/src/utils/validationCheck.js +6 -1
  48. package/dist/utils/settingsHelper.js +0 -14
  49. package/src/utils/settingsHelper.js +0 -16
@@ -412,6 +412,7 @@ const auditOptionDefinitions = [
412
412
  name: 'legacy',
413
413
  alias: 'l',
414
414
  type: Boolean,
415
+ defaultValue: false,
415
416
  description:
416
417
  '{bold ' +
417
418
  i18n.__('constantsOptional') +
@@ -428,7 +429,12 @@ const auditOptionDefinitions = [
428
429
  i18n.__('auditOptionsRepoSummary')
429
430
  },
430
431
  {
431
- name: 'repo-id',
432
+ name: 'repository-id',
433
+ type: String,
434
+ description: ''
435
+ },
436
+ {
437
+ name: 'project-group-id',
432
438
  type: String,
433
439
  description: ''
434
440
  }
@@ -443,7 +449,7 @@ const fingerprintOptionDefinitions = [
443
449
  '{bold ' + i18n.__('constantsOptional') + '}: ' + i18n.__('depthOption')
444
450
  },
445
451
  {
446
- name: 'repo-url',
452
+ name: 'repository-url',
447
453
  type: String,
448
454
  description: ''
449
455
  },
@@ -453,12 +459,7 @@ const fingerprintOptionDefinitions = [
453
459
  description: ''
454
460
  },
455
461
  {
456
- name: 'repo-name',
457
- type: String,
458
- description: ''
459
- },
460
- {
461
- name: 'language',
462
+ name: 'repository-name',
462
463
  type: String,
463
464
  description: ''
464
465
  }
@@ -3,7 +3,6 @@ const { auditUsageGuide } = require('./help')
3
3
  const scaController = require('../../scaAnalysis/scaAnalysis')
4
4
  const { sendTelemetryConfigAsObject } = require('../../telemetry/telemetry')
5
5
  const { postRunMessage } = require('../../common/commonHelp')
6
- const settingsHelper = require('../../utils/settingsHelper')
7
6
 
8
7
  const processAudit = async (contrastConf, argvMain) => {
9
8
  if (argvMain.indexOf('--help') !== -1) {
@@ -12,7 +11,6 @@ const processAudit = async (contrastConf, argvMain) => {
12
11
  }
13
12
 
14
13
  let config = await auditConfig.getAuditConfig(contrastConf, 'audit', argvMain)
15
- config = await settingsHelper.getSettings(config)
16
14
 
17
15
  await scaController.processSca(config)
18
16
  if (!config.fingerprint) {
@@ -3,14 +3,14 @@ const constants = require('../../cliConstants')
3
3
  const paramHandler = require('../../utils/paramsUtil/paramHandler')
4
4
 
5
5
  const getFingerprintConfig = async (contrastConf, command, argv) => {
6
- const fingerprintParameters = await parsedCLIOptions.getCommandLineArgsCustom(
6
+ let fingerprintParameters = await parsedCLIOptions.getCommandLineArgsCustom(
7
7
  contrastConf,
8
8
  command,
9
9
  argv,
10
10
  constants.commandLineDefinitions.fingerprintOptionDefinitions
11
11
  )
12
12
  const paramsAuth = paramHandler.getAuth(fingerprintParameters)
13
-
13
+ fingerprintParameters = paramHandler.getFingerprint(fingerprintParameters)
14
14
  return { ...paramsAuth, ...fingerprintParameters }
15
15
  }
16
16
 
@@ -1,27 +1,37 @@
1
1
  const fingerprintConfig = require('./fingerprintConfig')
2
2
  const repoServices = require('./repoServices')
3
- const settingsHelper = require('../../utils/settingsHelper')
4
3
  const autoDetection = require('../../scan/autoDetection')
5
4
  const saveResults = require('../../scan/saveResults')
5
+ const projectConfig = require('./projectGroup')
6
6
  const processFingerprint = async (contrastConf, argvMain) => {
7
7
  let config = await fingerprintConfig.getFingerprintConfig(
8
8
  contrastConf,
9
9
  'fingerprint',
10
10
  argvMain
11
11
  )
12
- config = await settingsHelper.getSettings(config)
13
12
  config.repositoryId = await repoServices.getRepoId(config)
14
- let fingerprint = await autoDetection.autoDetectFingerprintInfo(
15
- config.file,
16
- config.depth,
17
- config
18
- )
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
+ }
19
25
 
20
- let idArray = fingerprint.map(x => x.id)
21
- await saveResults.writeResultsToFile(fingerprint, 'fingerPrintInfo.json')
22
- return console.log(idArray)
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
+ }
23
33
  }
24
34
 
25
35
  module.exports = {
26
- processFingerprint
36
+ processFingerprint: processFingerprint
27
37
  }
@@ -17,25 +17,41 @@ const getProjectIdByOrg = async config => {
17
17
 
18
18
  const createNewProjectGroupBody = async config => {
19
19
  let body = {
20
- organizationId: config.organizationId,
21
- name: config.name ? config.name : config.file //has to be unique per project
20
+ organizationId: config.organizationId
22
21
  }
23
22
  if (config.repo || config?.repositoryId) {
24
23
  body.repositoryId = config.repositoryId
25
24
  body.type = 'REPOSITORY'
25
+ body.name = getProjectGroupNameRepo(config)
26
26
  } else {
27
27
  body.repositoryId = null
28
28
  body.type = 'CLI'
29
+ body.name = getProjectGroupNameCLI(config)
29
30
  }
30
31
  return body
31
32
  }
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
+
33
46
  const registerNewProjectGroup = async config => {
34
47
  let body = await createNewProjectGroupBody(config)
35
48
 
36
49
  const client = await commonApi.getHttpClient(config)
37
- body.projects = createProjects([config])
38
-
50
+ if (config.repositoryId) {
51
+ body.projects = []
52
+ } else {
53
+ body.projects = createProjectsArray([config])
54
+ }
39
55
  let projectGroupInfo = await client
40
56
  .registerProjectGroup(config, body)
41
57
  .then(res => {
@@ -53,7 +69,7 @@ const registerNewProjectGroup = async config => {
53
69
  }
54
70
 
55
71
  if (res.statusCode === 409) {
56
- return []
72
+ return ''
57
73
  }
58
74
  })
59
75
  .catch(err => {
@@ -64,30 +80,33 @@ const registerNewProjectGroup = async config => {
64
80
  return projectGroupInfo
65
81
  }
66
82
 
67
- const createProjects = params => {
83
+ const createProjectsArray = params => {
68
84
  let projectsArray = []
69
85
  let projects = {}
70
-
71
86
  params.forEach(param => {
72
- projects = {
73
- path: param.file,
74
- name: param.name ? param.name : param.file,
75
- source: 'SCA',
76
- language: param.language,
77
- packageManager: 'MAVEN',
78
- target: 'SCA',
79
- sourceId: '' // this is appID at the moment and scaID in future
80
- }
87
+ projects = createProject(param)
81
88
  projectsArray.push(projects)
82
89
  })
83
90
 
84
91
  return projectsArray
85
92
  }
86
93
 
94
+ const createProject = param => {
95
+ return {
96
+ path: param.fileName,
97
+ name: param.repo ? param.fileName : getProjectName(param),
98
+ source: 'SCA',
99
+ language: param.language,
100
+ packageManager: param.packageManager,
101
+ target: 'SCA',
102
+ sourceId: ''
103
+ }
104
+ }
105
+
87
106
  const getExistingGroupProjectId = (config, projectGroupsInfoEx) => {
88
107
  let existingGroupProjectId = ''
89
108
  projectGroupsInfoEx.forEach(i => {
90
- if (i.name === config.name) {
109
+ if (i.repositoryId === config.repositoryId) {
91
110
  existingGroupProjectId = i.projectGroupId
92
111
  }
93
112
  })
@@ -95,21 +114,46 @@ const getExistingGroupProjectId = (config, projectGroupsInfoEx) => {
95
114
  }
96
115
 
97
116
  const getProjectIdFromArray = (config, array) => {
98
- let projectId = ''
99
- array?.forEach(i => {
100
- if (i.name === config.name) {
101
- projectId = i.projectId
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
102
125
  }
103
- })
104
- return projectId
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
105
141
  }
106
142
 
107
- const registerProjectIdOnCliServices = async (config, projectId) => {
143
+ const registerProjectIdOnCliServices = async (
144
+ config,
145
+ projectId,
146
+ additionalData = undefined
147
+ ) => {
108
148
  const client = commonApi.getHttpClient(config)
109
149
 
110
150
  let cliServicesBody = {
111
151
  projectId: projectId,
112
- name: config.name
152
+ name: config.repo ? config.fileName : getProjectName(config)
153
+ }
154
+
155
+ if (additionalData) {
156
+ addAdditionalData(cliServicesBody, additionalData)
113
157
  }
114
158
 
115
159
  let result = await client
@@ -117,24 +161,48 @@ const registerProjectIdOnCliServices = async (config, projectId) => {
117
161
  .then(res => {
118
162
  if (config.debug || config.verbose) {
119
163
  console.log('\nregistration on cli services')
120
- console.log(res.statusCode)
164
+ console.log('request body', cliServicesBody)
165
+ console.log('response code', res.statusCode)
121
166
  }
122
167
  if (res.statusCode === 201 || res.statusCode === 200) {
123
168
  return res.body
124
169
  } else {
125
- return []
170
+ console.log('Failed to Register On Cli Services')
171
+ console.log(res.statusCode)
172
+ process.exit(1)
126
173
  }
127
174
  })
128
175
 
129
176
  return result
130
177
  }
131
178
 
179
+ const registerProjectWithGroupProjectId = async config => {
180
+ const client = commonApi.getHttpClient(config)
181
+ config.language = config.language === 'NODE' ? 'JAVASCRIPT' : config.language
182
+
183
+ let body = createProject(config)
184
+ let result = await client.registerProject(config, body).then(res => {
185
+ if (config.debug || config.verbose) {
186
+ console.log('\nregister Project With Group ProjectId')
187
+ console.log(res.statusCode)
188
+ console.log(res.body)
189
+ }
190
+ if (res.statusCode === 201 || res.statusCode === 200) {
191
+ return res.body
192
+ } else {
193
+ return []
194
+ }
195
+ })
196
+
197
+ return result
198
+ }
199
+
132
200
  const retrieveExistingProjectIdWithProjectGroupId = async (
133
201
  config,
134
202
  client,
135
203
  projectGroupId
136
204
  ) => {
137
- let groups = await client
205
+ return await client
138
206
  .retrieveExistingProjectIdByProjectGroupId(config, projectGroupId)
139
207
  .then(res => {
140
208
  if (config.debug || config.verbose) {
@@ -146,11 +214,9 @@ const retrieveExistingProjectIdWithProjectGroupId = async (
146
214
  if (res.statusCode === 200) {
147
215
  return res.body
148
216
  } else {
149
- return []
217
+ return ''
150
218
  }
151
219
  })
152
-
153
- return getProjectIdFromArray(config, groups)
154
220
  }
155
221
 
156
222
  const retrieveProjectByOrganization = async (config, client) => {
@@ -169,16 +235,41 @@ const retrieveProjectByOrganization = async (config, client) => {
169
235
  })
170
236
  }
171
237
 
172
- const retrieveExistingProjectGroups = async (config, client) => {
238
+ const retrieveExistingProjectGroups = async config => {
239
+ const client = commonApi.getHttpClient(config)
173
240
  return await client.retrieveExistingProjectGroupsByOrg(config).then(res => {
241
+ if (config.debug || config.verbose) {
242
+ console.log('retrieve Existing ProjectGroups By Org')
243
+ console.log(res.statusCode)
244
+ console.log(res.body)
245
+ }
174
246
  if (res.statusCode === 201 || res.statusCode === 200) {
175
- return res.body
247
+ let correctGroupID = res?.body?.filter(
248
+ i => i.repositoryId === config.repositoryId
249
+ )
250
+
251
+ if (correctGroupID.length > 0) {
252
+ return correctGroupID[0].projectGroupId
253
+ }
254
+ return ''
176
255
  } else {
177
- return []
256
+ return ''
178
257
  }
179
258
  })
180
259
  }
181
260
 
261
+ const getProjectGroupId = async config => {
262
+ let projectGroupId = ''
263
+ if (config.projectGroupId === '' || config.projectGroupId === undefined) {
264
+ projectGroupId = await retrieveExistingProjectGroups(config)
265
+ }
266
+
267
+ if (projectGroupId === '') {
268
+ projectGroupId = await registerNewProjectGroup(config)
269
+ }
270
+ return projectGroupId
271
+ }
272
+
182
273
  const dealWithNoName = async config => {
183
274
  try {
184
275
  config.name = getAppName(config.file)
@@ -194,5 +285,10 @@ module.exports = {
194
285
  registerProjectIdOnCliServices,
195
286
  dealWithNoName,
196
287
  registerNewProjectGroup,
197
- createNewProjectGroupBody
288
+ createNewProjectGroupBody,
289
+ registerProjectWithGroupProjectId,
290
+ getExistingGroupProjectId,
291
+ getProjectGroupId,
292
+ retrieveExistingProjectGroups,
293
+ createProject
198
294
  }
@@ -23,12 +23,16 @@ const retrieveRepoId = async config => {
23
23
 
24
24
  const registerNewRepo = async config => {
25
25
  let body = {
26
- externalScmUrl: config.repoUrl ? config.repoUrl : '',
27
- externalScmName: config.repoName,
28
- externalId: config.externalId ? config.externalId : '',
26
+ externalScmUrl: config.repositoryUrl,
27
+ externalScmName: config.repositoryName,
28
+ externalId: config.externalId,
29
29
  primaryLanguage: config.language,
30
30
  defaultBranch: 'develop'
31
31
  }
32
+ if (config.debug || config.verbose) {
33
+ console.log('registerNewRepo')
34
+ console.log(body)
35
+ }
32
36
 
33
37
  const client = await commonApi.getHttpClient(config)
34
38
 
@@ -51,10 +55,47 @@ const registerNewRepo = async config => {
51
55
  if (res.statusCode === 409) {
52
56
  return ''
53
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
+ }
54
66
  })
55
67
  .catch(err => {
56
68
  console.log('\nError Registering Repository')
57
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 = await 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)
58
99
  })
59
100
 
60
101
  return result
@@ -76,5 +117,6 @@ const getRepoId = async config => {
76
117
  module.exports = {
77
118
  retrieveRepoId,
78
119
  registerNewRepo,
79
- getRepoId
120
+ getRepoId,
121
+ retrieveProjectInfoViaRepoId
80
122
  }
@@ -225,12 +225,6 @@ HTTPClient.prototype.scaServiceIngest = function scaServiceIngest(
225
225
  options.url = url
226
226
  options.body = requestBody
227
227
 
228
- if (config.debug || config.verbose) {
229
- console.log('scaServiceIngest')
230
- console.log('url', options.url)
231
- console.log('body', options.body)
232
- }
233
-
234
228
  return requestUtils.sendRequest({ method: 'post', options })
235
229
  }
236
230
 
@@ -346,6 +340,17 @@ HTTPClient.prototype.registerRepo = function registerRepo(config, requestBody) {
346
340
  return requestUtils.sendRequest({ method: 'post', options })
347
341
  }
348
342
 
343
+ HTTPClient.prototype.retrieveProjectByRepoId = function retrieveProjectByRepoId(
344
+ config,
345
+ requestBody
346
+ ) {
347
+ const options = _.cloneDeep(this.requestOptions)
348
+ let url = createRepoProjectUrl(config)
349
+ options.url = url
350
+ options.body = requestBody
351
+ return requestUtils.sendRequest({ method: 'get', options })
352
+ }
353
+
349
354
  HTTPClient.prototype.registerProjectGroup = function (config, requestBody) {
350
355
  const options = _.cloneDeep(this.requestOptions)
351
356
  let url = registerProjectGroupUrl(config)
@@ -355,17 +360,18 @@ HTTPClient.prototype.registerProjectGroup = function (config, requestBody) {
355
360
  if (config.debug || config.verbose) {
356
361
  console.log('registerProjectGroup')
357
362
  console.log('url', options.url)
358
- console.log('body', options.body)
363
+ // console.log('body', options.body)
359
364
  }
360
365
 
361
366
  return requestUtils.sendRequest({ method: 'post', options })
362
367
  }
363
368
 
364
- HTTPClient.prototype.registerProject = function (config, projectGroupId) {
369
+ HTTPClient.prototype.registerProject = function (config, body) {
365
370
  const options = _.cloneDeep(this.requestOptions)
366
- let url = registerProjectUrl(config, projectGroupId)
371
+ let url = registerProjectUrl(config)
367
372
  options.url = url
368
- return requestUtils.sendRequest({ method: 'get', options })
373
+ options.body = body
374
+ return requestUtils.sendRequest({ method: 'post', options })
369
375
  }
370
376
  HTTPClient.prototype.retrieveSourcesViaRepositoryId = function (
371
377
  config,
@@ -405,6 +411,9 @@ HTTPClient.prototype.retrieveProjectByOrganizationId = function registerRepo(
405
411
  const options = _.cloneDeep(this.requestOptions)
406
412
  let url = retrieveProjectByOrganizationIdUrl(config)
407
413
  options.url = url
414
+ if (config.debug || config.verbose) {
415
+ console.log(url)
416
+ }
408
417
  return requestUtils.sendRequest({ method: 'get', options })
409
418
  }
410
419
 
@@ -412,8 +421,15 @@ HTTPClient.prototype.retrieveExistingProjectGroupsByOrg = function registerRepo(
412
421
  config
413
422
  ) {
414
423
  const options = _.cloneDeep(this.requestOptions)
415
- let url = retrieveExistingGroupProjectsByOrgUrl(config)
424
+ let url =
425
+ retrieveExistingGroupProjectsByOrgUrl(config) +
426
+ '?name=' +
427
+ config.repositoryName +
428
+ '&type=REPOSITORY'
416
429
  options.url = url
430
+ if (config.debug || config.verbose) {
431
+ console.log(options.url)
432
+ }
417
433
  return requestUtils.sendRequest({ method: 'get', options })
418
434
  }
419
435
 
@@ -622,7 +638,9 @@ function createScaServiceReportStatusURL(config, reportId) {
622
638
  function createScaServiceNoProjectIdURL(config) {
623
639
  return `${config.host}/Contrast/api/sca/organizations/${
624
640
  config.organizationId
625
- }/libraries/ingests/tree${config.repo ? '?incomplete=true' : ''}`
641
+ }/libraries/ingests/tree${
642
+ config.repo && config.language === 'JAVA?' ? 'incomplete=true' : ''
643
+ }`
626
644
  }
627
645
 
628
646
  // function createScaServiceIngestsURL(config) {
@@ -635,7 +653,9 @@ function createScaServiceHealthURL(config) {
635
653
 
636
654
  function createScaServiceIngestURL(config) {
637
655
  let optionalParams = []
638
- config.repo ? optionalParams.push('incomplete=true') : null
656
+ config.repo && config.language === 'JAVA'
657
+ ? optionalParams.push('incomplete=true')
658
+ : null
639
659
  config.track ? optionalParams.push('persist=true') : null
640
660
 
641
661
  let params = '?'
@@ -664,8 +684,8 @@ const registerProjectGroupUrl = config => {
664
684
  return `${config.host}/api/v4/organizations/${config.organizationId}/project-groups`
665
685
  }
666
686
 
667
- const registerProjectUrl = (config, projectGroupId) => {
668
- return `${config.host}/api/v4/organizations/${config.organizationId}/project-groups/${projectGroupId}/projects`
687
+ const registerProjectUrl = config => {
688
+ return `${config.host}/api/v4/organizations/${config.organizationId}/project-groups/${config.projectGroupId}/projects`
669
689
  }
670
690
 
671
691
  const retrieveRegisterOnCliServicesUrl = config => {
@@ -677,16 +697,21 @@ const retrieveSourcesUrl = (config, repositoryId) => {
677
697
  }
678
698
 
679
699
  const retrieveRepoByOrgAndGitURL = config => {
680
- return `${config.host}/api/v4/organizations/${config.organizationId}/repositories/external-url?externalRepoUrl=${config.repoUrl}`
700
+ return `${config.host}/api/v4/organizations/${config.organizationId}/repositories/external-url?externalRepoUrl=${config.repositoryUrl}`
681
701
  }
682
702
 
683
703
  const retrieveProjectByOrganizationIdUrl = config => {
684
704
  let baseUrl = `${config.host}/api/v4/organizations/${config.organizationId}/projects`
685
- baseUrl = config.name ? baseUrl.concat(`?name=${config.name}`) : baseUrl
705
+ baseUrl = config.name
706
+ ? baseUrl.concat(`?name=${config.name}`)
707
+ : baseUrl.concat(`?name=${config.fileName}`)
686
708
  baseUrl = config.language
687
709
  ? baseUrl.concat(`&language=${config.language}`)
688
710
  : baseUrl
689
711
  baseUrl = config.language ? baseUrl.concat(`&source=SCA`) : baseUrl
712
+ baseUrl = config.repo
713
+ ? baseUrl.concat(`&type=REPOSITORY`)
714
+ : baseUrl.concat(`&type=CLI`)
690
715
  return baseUrl
691
716
  }
692
717
 
@@ -705,6 +730,10 @@ function createRepositoryUrl(config) {
705
730
  return `${config.host}/api/v4/organizations/${config.organizationId}/repositories`
706
731
  }
707
732
 
733
+ function createRepoProjectUrl(config) {
734
+ return `${config.host}/api/v4/organizations/${config.organizationId}/repositories/${config.repositoryId}/projects`
735
+ }
736
+
708
737
  function createLibraryVulnerabilitiesUrl(config) {
709
738
  return `${config.host}/Contrast/api/ng/${config.organizationId}/libraries/artifactsByGroupNameVersion`
710
739
  }