@contrast/contrast 1.0.23 → 2.0.0
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 +21 -138
- package/dist/audit/languageAnalysisEngine/sendSnapshot.js +2 -19
- package/dist/audit/save.js +6 -1
- package/dist/cliConstants.js +29 -0
- package/dist/commands/audit/auditController.js +2 -1
- package/dist/commands/audit/help.js +3 -2
- package/dist/commands/audit/processAudit.js +2 -0
- package/dist/commands/audit/saveFile.js +5 -1
- package/dist/commands/github/projectGroup.js +164 -0
- package/dist/common/HTTPClient.js +165 -13
- package/dist/constants/constants.js +3 -5
- package/dist/constants/locales.js +7 -3
- package/dist/index.js +0 -4
- package/dist/lambda/lambda.js +3 -1
- package/dist/scaAnalysis/common/commonReportingFunctionsSca.js +3 -3
- package/dist/scaAnalysis/common/scaServicesUpload.js +77 -7
- package/dist/scaAnalysis/common/treeUpload.js +19 -5
- package/dist/scaAnalysis/go/goAnalysis.js +6 -1
- package/dist/scaAnalysis/java/index.js +6 -1
- package/dist/scaAnalysis/javascript/index.js +5 -2
- package/dist/scaAnalysis/legacy/legacyFlow.js +33 -0
- package/dist/scaAnalysis/php/index.js +8 -2
- package/dist/scaAnalysis/processServicesFlow.js +21 -0
- package/dist/scaAnalysis/python/analysis.js +10 -4
- package/dist/scaAnalysis/python/index.js +6 -1
- package/dist/scaAnalysis/repoMode/index.js +2 -2
- package/dist/scaAnalysis/ruby/analysis.js +10 -1
- package/dist/scaAnalysis/ruby/index.js +6 -1
- package/dist/scaAnalysis/scaAnalysis.js +47 -25
- package/dist/scan/autoDetection.js +41 -2
- package/dist/scan/fileUtils.js +5 -4
- package/dist/utils/commonApi.js +26 -1
- package/dist/utils/settingsHelper.js +14 -0
- package/package.json +8 -5
- package/src/audit/languageAnalysisEngine/sendSnapshot.js +3 -22
- package/src/audit/save.js +10 -1
- package/src/cliConstants.js +32 -0
- package/src/commands/audit/auditController.js +2 -1
- package/src/commands/audit/help.js +3 -2
- package/src/commands/audit/processAudit.js +2 -0
- package/src/commands/audit/saveFile.js +6 -1
- package/src/commands/github/projectGroup.js +187 -0
- package/src/common/HTTPClient.js +221 -13
- package/src/constants/constants.js +3 -5
- package/src/constants/locales.js +9 -3
- package/src/index.ts +0 -5
- package/src/lambda/lambda.ts +3 -1
- package/src/lambda/lambdaUtils.ts +1 -1
- package/src/scaAnalysis/common/commonReportingFunctionsSca.js +3 -3
- package/src/scaAnalysis/common/scaServicesUpload.js +92 -7
- package/src/scaAnalysis/common/treeUpload.js +20 -5
- package/src/scaAnalysis/go/goAnalysis.js +6 -1
- package/src/scaAnalysis/java/index.js +6 -1
- package/src/scaAnalysis/javascript/index.js +6 -4
- package/src/scaAnalysis/legacy/legacyFlow.js +48 -0
- package/src/scaAnalysis/php/index.js +8 -2
- package/src/scaAnalysis/processServicesFlow.js +29 -0
- package/src/scaAnalysis/python/analysis.js +10 -4
- package/src/scaAnalysis/python/index.js +6 -1
- package/src/scaAnalysis/repoMode/index.js +2 -2
- package/src/scaAnalysis/ruby/analysis.js +11 -1
- package/src/scaAnalysis/ruby/index.js +6 -1
- package/src/scaAnalysis/scaAnalysis.js +61 -37
- package/src/scan/autoDetection.js +44 -3
- package/src/scan/fileUtils.js +5 -4
- package/src/utils/commonApi.js +29 -1
- package/src/utils/settingsHelper.js +16 -0
- package/dist/commands/fingerprint/processFingerprint.js +0 -14
- package/src/commands/fingerprint/processFingerprint.js +0 -21
- /package/dist/commands/{fingerprint → github}/fingerprintConfig.js +0 -0
- /package/src/commands/{fingerprint → github}/fingerprintConfig.js +0 -0
|
@@ -0,0 +1,187 @@
|
|
|
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 registerNewProjectGroup = async config => {
|
|
19
|
+
let projectId = ''
|
|
20
|
+
let body = {
|
|
21
|
+
organizationId: config.organizationId,
|
|
22
|
+
name: config.name ? config.name : config.file, //has to be unique per project
|
|
23
|
+
repositoryId: null,
|
|
24
|
+
type: 'CLI'
|
|
25
|
+
}
|
|
26
|
+
const client = await commonApi.getHttpClient(config)
|
|
27
|
+
body.projects = createProjects([config])
|
|
28
|
+
|
|
29
|
+
let projectGroupInfo = await client
|
|
30
|
+
.registerProjectGroup(config, body)
|
|
31
|
+
.then(res => {
|
|
32
|
+
if (config.debug || config.verbose) {
|
|
33
|
+
console.log('\nRegister ProjectGroup')
|
|
34
|
+
console.log(res.statusCode)
|
|
35
|
+
console.log(res.body)
|
|
36
|
+
}
|
|
37
|
+
if (res.statusCode === 201 || res.statusCode === 200) {
|
|
38
|
+
if (config.debug || config.verbose) {
|
|
39
|
+
console.log('registerProjectGroup - response')
|
|
40
|
+
console.log('response', res.body)
|
|
41
|
+
}
|
|
42
|
+
return res?.body?.projectGroupId
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (res.statusCode === 409) {
|
|
46
|
+
return []
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
.catch(err => {
|
|
50
|
+
console.log('\nError Registering Project Group')
|
|
51
|
+
console.log(err.statusCode)
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
return projectGroupInfo
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const createProjects = params => {
|
|
58
|
+
let projectsArray = []
|
|
59
|
+
let projects = {}
|
|
60
|
+
|
|
61
|
+
params.forEach(param => {
|
|
62
|
+
projects = {
|
|
63
|
+
path: param.file,
|
|
64
|
+
name: param.name ? param.name : param.file,
|
|
65
|
+
source: 'SCA',
|
|
66
|
+
language: param.language,
|
|
67
|
+
packageManager: 'MAVEN',
|
|
68
|
+
target: 'SCA',
|
|
69
|
+
sourceId: '' // this is appID at the moment and scaID in future
|
|
70
|
+
}
|
|
71
|
+
projectsArray.push(projects)
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
return projectsArray
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const getExistingGroupProjectId = (config, projectGroupsInfoEx) => {
|
|
78
|
+
let existingGroupProjectId = ''
|
|
79
|
+
projectGroupsInfoEx.forEach(i => {
|
|
80
|
+
if (i.name === config.name) {
|
|
81
|
+
existingGroupProjectId = i.projectGroupId
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
return existingGroupProjectId
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const getProjectIdFromArray = (config, array) => {
|
|
88
|
+
let projectId = ''
|
|
89
|
+
array?.forEach(i => {
|
|
90
|
+
if (i.name === config.name) {
|
|
91
|
+
projectId = i.projectId
|
|
92
|
+
}
|
|
93
|
+
})
|
|
94
|
+
return projectId
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const registerProjectIdOnCliServices = async (config, projectId) => {
|
|
98
|
+
const client = commonApi.getHttpClient(config)
|
|
99
|
+
|
|
100
|
+
let cliServicesBody = {
|
|
101
|
+
projectId: projectId,
|
|
102
|
+
name: config.name
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
let result = await client
|
|
106
|
+
.registerOnCliServices(config, cliServicesBody)
|
|
107
|
+
.then(res => {
|
|
108
|
+
if (config.debug || config.verbose) {
|
|
109
|
+
console.log('\nregistration on cli services')
|
|
110
|
+
console.log(res.statusCode)
|
|
111
|
+
}
|
|
112
|
+
if (res.statusCode === 201 || res.statusCode === 200) {
|
|
113
|
+
return res.body
|
|
114
|
+
} else {
|
|
115
|
+
return []
|
|
116
|
+
}
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
return result
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const retrieveExistingProjectIdWithProjectGroupId = async (
|
|
123
|
+
config,
|
|
124
|
+
client,
|
|
125
|
+
projectGroupId
|
|
126
|
+
) => {
|
|
127
|
+
let groups = await client
|
|
128
|
+
.retrieveExistingProjectIdByProjectGroupId(config, projectGroupId)
|
|
129
|
+
.then(res => {
|
|
130
|
+
if (config.debug || config.verbose) {
|
|
131
|
+
console.log('\nRetrieve Existing ProjectId By ProjectGroupId')
|
|
132
|
+
console.log(res.statusCode)
|
|
133
|
+
console.log(res.body)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (res.statusCode === 200) {
|
|
137
|
+
return res.body
|
|
138
|
+
} else {
|
|
139
|
+
return []
|
|
140
|
+
}
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
return getProjectIdFromArray(config, groups)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const retrieveProjectByOrganization = async (config, client) => {
|
|
147
|
+
return await client.retrieveProjectByOrganizationId(config).then(res => {
|
|
148
|
+
if (config.debug || config.verbose) {
|
|
149
|
+
console.log('\nRetrieve Project By OrganizationId')
|
|
150
|
+
console.log(res.statusCode)
|
|
151
|
+
console.log(res.body)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (res.statusCode === 201 || res.statusCode === 200) {
|
|
155
|
+
return res.body
|
|
156
|
+
} else {
|
|
157
|
+
return []
|
|
158
|
+
}
|
|
159
|
+
})
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const retrieveExistingProjectGroups = async (config, client) => {
|
|
163
|
+
return await client.retrieveExistingProjectGroupsByOrg(config).then(res => {
|
|
164
|
+
if (res.statusCode === 201 || res.statusCode === 200) {
|
|
165
|
+
return res.body
|
|
166
|
+
} else {
|
|
167
|
+
return []
|
|
168
|
+
}
|
|
169
|
+
})
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const dealWithNoName = async config => {
|
|
173
|
+
try {
|
|
174
|
+
config.name = getAppName(config.file)
|
|
175
|
+
} catch (e) {
|
|
176
|
+
console.log(e.message.toString())
|
|
177
|
+
process.exit(1)
|
|
178
|
+
}
|
|
179
|
+
return config
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
module.exports = {
|
|
183
|
+
getProjectIdByOrg,
|
|
184
|
+
registerProjectIdOnCliServices,
|
|
185
|
+
dealWithNoName,
|
|
186
|
+
registerNewProjectGroup
|
|
187
|
+
}
|
package/src/common/HTTPClient.js
CHANGED
|
@@ -224,6 +224,24 @@ HTTPClient.prototype.scaServiceIngest = function scaServiceIngest(
|
|
|
224
224
|
let url = createScaServiceIngestURL(config)
|
|
225
225
|
options.url = url
|
|
226
226
|
options.body = requestBody
|
|
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
|
+
return requestUtils.sendRequest({ method: 'post', options })
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
HTTPClient.prototype.noProjectIdUpload = function scaServiceIngest(
|
|
238
|
+
requestBody,
|
|
239
|
+
config
|
|
240
|
+
) {
|
|
241
|
+
const options = _.cloneDeep(this.requestOptions)
|
|
242
|
+
let url = createScaServiceNoProjectIdURL(config)
|
|
243
|
+
options.url = url
|
|
244
|
+
options.body = requestBody
|
|
227
245
|
return requestUtils.sendRequest({ method: 'post', options })
|
|
228
246
|
}
|
|
229
247
|
|
|
@@ -237,23 +255,47 @@ HTTPClient.prototype.scaServiceReport = function scaServiceReport(
|
|
|
237
255
|
return requestUtils.sendRequest({ method: 'get', options })
|
|
238
256
|
}
|
|
239
257
|
|
|
240
|
-
HTTPClient.prototype.
|
|
258
|
+
HTTPClient.prototype.scaServiceReportNoProjectId = function scaServiceReport(
|
|
241
259
|
config,
|
|
242
260
|
reportId
|
|
243
261
|
) {
|
|
244
262
|
const options = _.cloneDeep(this.requestOptions)
|
|
245
|
-
|
|
246
|
-
|
|
263
|
+
options.url = createScaServiceReportNoProjectIdURL(config, reportId)
|
|
264
|
+
if (config.debug || config.verbose) {
|
|
265
|
+
console.log('createScaServiceReportNoProjectIdURL', options.url)
|
|
266
|
+
}
|
|
247
267
|
return requestUtils.sendRequest({ method: 'get', options })
|
|
248
268
|
}
|
|
249
269
|
|
|
250
|
-
HTTPClient.prototype.
|
|
270
|
+
HTTPClient.prototype.scaServiceReportStatus = function scaServiceReport(
|
|
271
|
+
config,
|
|
272
|
+
reportId
|
|
273
|
+
) {
|
|
251
274
|
const options = _.cloneDeep(this.requestOptions)
|
|
252
|
-
|
|
253
|
-
|
|
275
|
+
options.url = createScaServiceReportStatusURL(config, reportId)
|
|
276
|
+
if (config.debug || config.verbose) {
|
|
277
|
+
console.log('createScaServiceReportStatusURL', options.url)
|
|
278
|
+
}
|
|
254
279
|
return requestUtils.sendRequest({ method: 'get', options })
|
|
255
280
|
}
|
|
256
281
|
|
|
282
|
+
HTTPClient.prototype.scaServiceNoProjectIdReportStatus =
|
|
283
|
+
function scaServiceReport(config, reportId) {
|
|
284
|
+
const options = _.cloneDeep(this.requestOptions)
|
|
285
|
+
options.url = createScaServiceReportStatusURL(config, reportId)
|
|
286
|
+
if (config.debug || config.verbose) {
|
|
287
|
+
console.log('createScaServiceReportStatusURL', options.url)
|
|
288
|
+
}
|
|
289
|
+
return requestUtils.sendRequest({ method: 'get', options })
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// HTTPClient.prototype.scaServiceIngests = function scaServiceIngests(config) {
|
|
293
|
+
// const options = _.cloneDeep(this.requestOptions)
|
|
294
|
+
// let url = createScaServiceIngestsURL(config)
|
|
295
|
+
// options.url = url
|
|
296
|
+
// return requestUtils.sendRequest({ method: 'get', options })
|
|
297
|
+
// }
|
|
298
|
+
|
|
257
299
|
HTTPClient.prototype.scaServiceHealth = function scaServiceIngests(config) {
|
|
258
300
|
const options = _.cloneDeep(this.requestOptions)
|
|
259
301
|
let url = createScaServiceHealthURL(config)
|
|
@@ -296,6 +338,100 @@ HTTPClient.prototype.getAppId = function getAppId(config) {
|
|
|
296
338
|
return requestUtils.sendRequest({ method: 'get', options })
|
|
297
339
|
}
|
|
298
340
|
|
|
341
|
+
HTTPClient.prototype.registerRepo = function registerRepo(config, requestBody) {
|
|
342
|
+
const options = _.cloneDeep(this.requestOptions)
|
|
343
|
+
let url = createRepositoryUrl(config)
|
|
344
|
+
options.url = url
|
|
345
|
+
options.body = requestBody
|
|
346
|
+
return requestUtils.sendRequest({ method: 'post', options })
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
HTTPClient.prototype.registerProjectGroup = function (config, requestBody) {
|
|
350
|
+
const options = _.cloneDeep(this.requestOptions)
|
|
351
|
+
let url = registerProjectGroupUrl(config)
|
|
352
|
+
options.url = url
|
|
353
|
+
options.body = requestBody
|
|
354
|
+
|
|
355
|
+
if (config.debug || config.verbose) {
|
|
356
|
+
console.log('registerProjectGroup')
|
|
357
|
+
console.log('url', options.url)
|
|
358
|
+
console.log('body', options.body)
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
return requestUtils.sendRequest({ method: 'post', options })
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
HTTPClient.prototype.registerProject = function (config, projectGroupId) {
|
|
365
|
+
const options = _.cloneDeep(this.requestOptions)
|
|
366
|
+
let url = registerProjectUrl(config, projectGroupId)
|
|
367
|
+
options.url = url
|
|
368
|
+
return requestUtils.sendRequest({ method: 'get', options })
|
|
369
|
+
}
|
|
370
|
+
HTTPClient.prototype.retrieveSourcesViaRepositoryId = function (
|
|
371
|
+
config,
|
|
372
|
+
repositoryId
|
|
373
|
+
) {
|
|
374
|
+
const options = _.cloneDeep(this.requestOptions)
|
|
375
|
+
let url = retrieveSourcesUrl(config, repositoryId)
|
|
376
|
+
options.url = url
|
|
377
|
+
return requestUtils.sendRequest({ method: 'get', options })
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
HTTPClient.prototype.retrieveRepoByOrgAndGitURL = function (config) {
|
|
381
|
+
const options = _.cloneDeep(this.requestOptions)
|
|
382
|
+
let url = retrieveRepoByOrgAndGitURL(config)
|
|
383
|
+
options.url = url
|
|
384
|
+
return requestUtils.sendRequest({ method: 'get', options })
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
HTTPClient.prototype.registerOnCliServices = function (config, project) {
|
|
388
|
+
const options = _.cloneDeep(this.requestOptions)
|
|
389
|
+
let url = retrieveRegisterOnCliServicesUrl(config)
|
|
390
|
+
options.url = url
|
|
391
|
+
options.body = project
|
|
392
|
+
|
|
393
|
+
if (config.debug || config.verbose) {
|
|
394
|
+
console.log('registerOnCliServices')
|
|
395
|
+
console.log('url', options.url)
|
|
396
|
+
console.log('body', options.body)
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
return requestUtils.sendRequest({ method: 'post', options })
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
HTTPClient.prototype.retrieveProjectByOrganizationId = function registerRepo(
|
|
403
|
+
config
|
|
404
|
+
) {
|
|
405
|
+
const options = _.cloneDeep(this.requestOptions)
|
|
406
|
+
let url = retrieveProjectByOrganizationIdUrl(config)
|
|
407
|
+
options.url = url
|
|
408
|
+
return requestUtils.sendRequest({ method: 'get', options })
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
HTTPClient.prototype.retrieveExistingProjectGroupsByOrg = function registerRepo(
|
|
412
|
+
config
|
|
413
|
+
) {
|
|
414
|
+
const options = _.cloneDeep(this.requestOptions)
|
|
415
|
+
let url = retrieveExistingGroupProjectsByOrgUrl(config)
|
|
416
|
+
options.url = url
|
|
417
|
+
return requestUtils.sendRequest({ method: 'get', options })
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
HTTPClient.prototype.retrieveExistingProjectIdByProjectGroupId =
|
|
421
|
+
function registerRepo(config, projectGroupId) {
|
|
422
|
+
const options = _.cloneDeep(this.requestOptions)
|
|
423
|
+
let url = retrieveExistingGroupProjectsByGroupIdUrl(config, projectGroupId)
|
|
424
|
+
options.url = url
|
|
425
|
+
return requestUtils.sendRequest({ method: 'get', options })
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
HTTPClient.prototype.retrieveExistingRepo = function registerRepo(config) {
|
|
429
|
+
const options = _.cloneDeep(this.requestOptions)
|
|
430
|
+
let url = retrieveExistingRepoUrl(config)
|
|
431
|
+
options.url = url
|
|
432
|
+
return requestUtils.sendRequest({ method: 'get', options })
|
|
433
|
+
}
|
|
434
|
+
|
|
299
435
|
// HTTPClient.prototype.getDependencyTree = function getReport(
|
|
300
436
|
// orgUuid,
|
|
301
437
|
// appId,
|
|
@@ -468,26 +604,51 @@ function createSnapshotURL(config) {
|
|
|
468
604
|
}
|
|
469
605
|
|
|
470
606
|
function createScaServiceReportURL(config, reportId) {
|
|
471
|
-
let baseUrl = `${config.host}/Contrast/api/sca/organizations/${config.organizationId}/
|
|
607
|
+
let baseUrl = `${config.host}/Contrast/api/sca/organizations/${config.organizationId}/projects/${config.projectId}/libraries/reports/${reportId}`
|
|
608
|
+
baseUrl = config.ignoreDev ? baseUrl.concat('?nodesToInclude=PROD') : baseUrl
|
|
609
|
+
return baseUrl
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
function createScaServiceReportNoProjectIdURL(config, reportId) {
|
|
613
|
+
let baseUrl = `${config.host}/Contrast/api/sca/organizations/${config.organizationId}/libraries/reports/${reportId}`
|
|
472
614
|
baseUrl = config.ignoreDev ? baseUrl.concat('?nodesToInclude=PROD') : baseUrl
|
|
473
615
|
return baseUrl
|
|
474
616
|
}
|
|
475
617
|
|
|
476
618
|
function createScaServiceReportStatusURL(config, reportId) {
|
|
477
|
-
return `${config.host}/Contrast/api/sca/organizations/${config.organizationId}/
|
|
619
|
+
return `${config.host}/Contrast/api/sca/organizations/${config.organizationId}/libraries/ingests/${reportId}/status`
|
|
478
620
|
}
|
|
479
621
|
|
|
480
|
-
function
|
|
481
|
-
return `${config.host}/Contrast/api/sca/organizations/${
|
|
622
|
+
function createScaServiceNoProjectIdURL(config) {
|
|
623
|
+
return `${config.host}/Contrast/api/sca/organizations/${
|
|
624
|
+
config.organizationId
|
|
625
|
+
}/libraries/ingests/tree${config.repo ? '?incomplete=true' : ''}`
|
|
482
626
|
}
|
|
483
627
|
|
|
628
|
+
// function createScaServiceIngestsURL(config) {
|
|
629
|
+
// return `${config.host}/Contrast/api/sca/organizations/${config.organizationId}/applications/${config.applicationId}/libraries/ingests`
|
|
630
|
+
// }
|
|
631
|
+
|
|
484
632
|
function createScaServiceHealthURL(config) {
|
|
485
633
|
return `${config.host}/Contrast/api/sca/organizations/${config.organizationId}/health`
|
|
486
634
|
}
|
|
487
635
|
|
|
488
636
|
function createScaServiceIngestURL(config) {
|
|
489
|
-
let
|
|
490
|
-
|
|
637
|
+
let optionalParams = []
|
|
638
|
+
config.repo ? optionalParams.push('incomplete=true') : null
|
|
639
|
+
config.track ? optionalParams.push('persist=true') : null
|
|
640
|
+
|
|
641
|
+
let params = '?'
|
|
642
|
+
optionalParams.forEach(param => {
|
|
643
|
+
params = params.concat(param)
|
|
644
|
+
params = params.concat('&')
|
|
645
|
+
})
|
|
646
|
+
|
|
647
|
+
let baseUrl = `${config.host}/Contrast/api/sca/organizations/${config.organizationId}/projects/${config.projectId}/libraries/ingests/tree${params}`
|
|
648
|
+
|
|
649
|
+
if (config.debug) {
|
|
650
|
+
console.log('createScaServiceIngestURL', baseUrl)
|
|
651
|
+
}
|
|
491
652
|
return baseUrl
|
|
492
653
|
}
|
|
493
654
|
|
|
@@ -499,6 +660,51 @@ const createAppNameUrl = config => {
|
|
|
499
660
|
return `${config.host}/Contrast/api/ng/${config.organizationId}/applications/name?filterText=${config.applicationName}`
|
|
500
661
|
}
|
|
501
662
|
|
|
663
|
+
const registerProjectGroupUrl = config => {
|
|
664
|
+
return `${config.host}/api/v4/organizations/${config.organizationId}/project-groups`
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
const registerProjectUrl = (config, projectGroupId) => {
|
|
668
|
+
return `${config.host}/api/v4/organizations/${config.organizationId}/project-groups/${projectGroupId}/projects`
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
const retrieveRegisterOnCliServicesUrl = config => {
|
|
672
|
+
return `${config.host}/Contrast/api/sca/organizations/${config.organizationId}/projects`
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
const retrieveSourcesUrl = (config, repositoryId) => {
|
|
676
|
+
return `${config.host}/projects/v1/repositories/${repositoryId}/sources`
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
const retrieveRepoByOrgAndGitURL = config => {
|
|
680
|
+
return `${config.host}/api/v4/organizations/${config.organizationId}/repository`
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
const retrieveProjectByOrganizationIdUrl = config => {
|
|
684
|
+
let baseUrl = `${config.host}/api/v4/organizations/${config.organizationId}/projects`
|
|
685
|
+
baseUrl = config.name ? baseUrl.concat(`?name=${config.name}`) : baseUrl
|
|
686
|
+
baseUrl = config.language
|
|
687
|
+
? baseUrl.concat(`&language=${config.language}`)
|
|
688
|
+
: baseUrl
|
|
689
|
+
baseUrl = config.language ? baseUrl.concat(`&source=SCA`) : baseUrl
|
|
690
|
+
return baseUrl
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
const retrieveExistingGroupProjectsByOrgUrl = config => {
|
|
694
|
+
return `${config.host}/api/v4/organizations/${config.organizationId}/project-groups`
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
const retrieveExistingGroupProjectsByGroupIdUrl = (config, projectGroupId) => {
|
|
698
|
+
return `${config.host}/api/v4/organizations/${config.organizationId}/projects/${projectGroupId}/projects`
|
|
699
|
+
}
|
|
700
|
+
const retrieveExistingRepoUrl = config => {
|
|
701
|
+
return `${config.host}/projects/v4/organizations/${config.organizationId}/repositories`
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
function createRepositoryUrl(config) {
|
|
705
|
+
return `${config.host}/projects/v1/repositories`
|
|
706
|
+
}
|
|
707
|
+
|
|
502
708
|
function createLibraryVulnerabilitiesUrl(config) {
|
|
503
709
|
return `${config.host}/Contrast/api/ng/${config.organizationId}/libraries/artifactsByGroupNameVersion`
|
|
504
710
|
}
|
|
@@ -526,7 +732,9 @@ function createSbomUrl(config, type) {
|
|
|
526
732
|
}
|
|
527
733
|
|
|
528
734
|
function createSCASbomUrl(config, type, reportId) {
|
|
529
|
-
return
|
|
735
|
+
return config.projectId
|
|
736
|
+
? `${config.host}/Contrast/api/sca/organizations/${config.organizationId}/projects/${config.projectId}/libraries/sbom/${reportId}?toolType=${type}`
|
|
737
|
+
: `${config.host}/Contrast/api/sca/organizations/${config.organizationId}/libraries/sbom/${reportId}?toolType=${type}`
|
|
530
738
|
}
|
|
531
739
|
|
|
532
740
|
function createTelemetryEventUrl(config) {
|
|
@@ -14,7 +14,7 @@ const HIGH = 'HIGH'
|
|
|
14
14
|
const CRITICAL = 'CRITICAL'
|
|
15
15
|
// App
|
|
16
16
|
const APP_NAME = 'contrast'
|
|
17
|
-
const APP_VERSION = '
|
|
17
|
+
const APP_VERSION = '2.0.0'
|
|
18
18
|
const TIMEOUT = 120000
|
|
19
19
|
const HIGH_COLOUR = '#ff9900'
|
|
20
20
|
const CRITICAL_COLOUR = '#e35858'
|
|
@@ -30,14 +30,13 @@ const NOTE_PRIORITY = 5
|
|
|
30
30
|
const AUTH_UI_URL = 'https://cli-auth.contrastsecurity.com'
|
|
31
31
|
const AUTH_CALLBACK_URL = 'https://cli-auth-api.contrastsecurity.com'
|
|
32
32
|
const SARIF_FILE = 'SARIF'
|
|
33
|
-
const SBOM_CYCLONE_DX_FILE = '
|
|
34
|
-
const SBOM_SPDX_FILE = '
|
|
33
|
+
const SBOM_CYCLONE_DX_FILE = 'CYCLONEDX'
|
|
34
|
+
const SBOM_SPDX_FILE = 'SPDX'
|
|
35
35
|
const CE_URL = 'https://ce.contrastsecurity.com'
|
|
36
36
|
|
|
37
37
|
//configuration
|
|
38
38
|
const SAAS = 'SAAS'
|
|
39
39
|
const EOP = 'EOP'
|
|
40
|
-
const MODE_BUILD = 'BUILD'
|
|
41
40
|
const MODE_REPO = 'REPO'
|
|
42
41
|
|
|
43
42
|
module.exports = {
|
|
@@ -68,6 +67,5 @@ module.exports = {
|
|
|
68
67
|
SBOM_SPDX_FILE,
|
|
69
68
|
SAAS,
|
|
70
69
|
EOP,
|
|
71
|
-
MODE_BUILD,
|
|
72
70
|
MODE_REPO
|
|
73
71
|
}
|
package/src/constants/locales.js
CHANGED
|
@@ -76,7 +76,7 @@ const en_locales = () => {
|
|
|
76
76
|
constantsDoNotWaitForScan:
|
|
77
77
|
'Fire and forget. Do not wait for the result of the scan.',
|
|
78
78
|
constantsProjectName:
|
|
79
|
-
'Contrast project name. If not specified, Contrast uses
|
|
79
|
+
'Contrast project name. If not specified, Contrast uses the file / folder name to identify the project or creates a new project.',
|
|
80
80
|
constantsProjectId:
|
|
81
81
|
'The ID associated with a scan project. Replace <ProjectID> with the ID for the scan project. To find the ID, select a scan project in Contrast and locate the last number in the URL.',
|
|
82
82
|
failThresholdOptionErrorMessage: 'More than 0 vulnerabilities found',
|
|
@@ -190,9 +190,15 @@ const en_locales = () => {
|
|
|
190
190
|
scanOptionsFileNameSummary:
|
|
191
191
|
'Path of the file you want to scan. If no file is specified, Contrast searches for a .jar, .war, .exe or .zip file in the working directory.',
|
|
192
192
|
scanOptionsVerboseSummary: ' Returns extended information to the terminal.',
|
|
193
|
-
auditOptionsTrackSummary:
|
|
193
|
+
auditOptionsTrackSummary:
|
|
194
|
+
' Send your dependency audit to Contrast to see results in the UI and start automating security checks. For instance when running local SCA checks you may not need or want to track the results.',
|
|
194
195
|
auditOptionsBranchSummary:
|
|
195
196
|
' Set the branch name to associate the library results to.',
|
|
197
|
+
auditOptionsLegacySummary:
|
|
198
|
+
' Creates an application in Contrast (a legacy workflow) - displays a dependency tree for your piece of code, utilizes metatdata.' +
|
|
199
|
+
'\n' +
|
|
200
|
+
'.NET is only supported using --legacy\n',
|
|
201
|
+
auditOptionsRepoSummary: ' Run in repo mode.',
|
|
196
202
|
authSuccessMessage: 'Authentication successful',
|
|
197
203
|
runAuthSuccessMessage:
|
|
198
204
|
chalk.bold('CodeSec by Contrast') +
|
|
@@ -275,7 +281,7 @@ const en_locales = () => {
|
|
|
275
281
|
${chalk.bold(
|
|
276
282
|
'.NET framework and .NET core:'
|
|
277
283
|
)} MSBuild 15.0 or greater and a packages.lock.json file.
|
|
278
|
-
Note: If the packages.lock.json file is unavailable it can be generated by setting RestorePackagesWithLockFile to true within each *.csproj file and running dotnet build
|
|
284
|
+
Note: If the packages.lock.json file is unavailable it can be generated by setting RestorePackagesWithLockFile to true within each *.csproj file and running dotnet build. Only supported with the --legacy flag, an older workflow\n`,
|
|
279
285
|
constantsAuditPrerequisitesContentNodeMessage: `${chalk.bold(
|
|
280
286
|
'Node:'
|
|
281
287
|
)} package.json and a lock file (either .package-lock.json or .yarn.lock.)\n`,
|
package/src/index.ts
CHANGED
|
@@ -5,7 +5,6 @@ import { processAudit } from './commands/audit/processAudit'
|
|
|
5
5
|
import { processAuth } from './commands/auth/auth'
|
|
6
6
|
import { processConfig } from './commands/config/config'
|
|
7
7
|
import { processScan } from './commands/scan/processScan'
|
|
8
|
-
import { processFingerprint } from './commands/fingerprint/processFingerprint'
|
|
9
8
|
import constants from './cliConstants'
|
|
10
9
|
import { APP_NAME, APP_VERSION } from './constants/constants'
|
|
11
10
|
import { processLambda } from './lambda/lambda'
|
|
@@ -88,10 +87,6 @@ const start = async () => {
|
|
|
88
87
|
return processLearn()
|
|
89
88
|
}
|
|
90
89
|
|
|
91
|
-
if (command === 'fingerprint') {
|
|
92
|
-
return await processFingerprint(config, argvMain)
|
|
93
|
-
}
|
|
94
|
-
|
|
95
90
|
if (
|
|
96
91
|
command === 'help' ||
|
|
97
92
|
argvMain.includes('--help') ||
|
package/src/lambda/lambda.ts
CHANGED
|
@@ -126,7 +126,9 @@ const processLambda = async (argv: string[]) => {
|
|
|
126
126
|
|
|
127
127
|
const getAvailableFunctions = async (lambdaOptions: LambdaOptions) => {
|
|
128
128
|
const lambdas = await getAllLambdas(lambdaOptions)
|
|
129
|
-
printAvailableLambdas(lambdas, {
|
|
129
|
+
printAvailableLambdas(lambdas, {
|
|
130
|
+
runtimes: ['python', 'java', 'node', 'dotnet']
|
|
131
|
+
})
|
|
130
132
|
}
|
|
131
133
|
|
|
132
134
|
const actualProcessLambda = async (lambdaOptions: LambdaOptions) => {
|
|
@@ -11,7 +11,7 @@ import ora from '../utils/oraWrapper'
|
|
|
11
11
|
import { LambdaOptions } from './lambda'
|
|
12
12
|
import { log, getReadableFileSize } from './logUtils'
|
|
13
13
|
|
|
14
|
-
type RuntimeLanguage = 'java' | 'python' | 'node'
|
|
14
|
+
type RuntimeLanguage = 'java' | 'python' | 'node' | 'dotnet'
|
|
15
15
|
|
|
16
16
|
type FilterLambdas = {
|
|
17
17
|
runtimes: RuntimeLanguage[]
|
|
@@ -142,12 +142,12 @@ const printFormattedOutputSca = (
|
|
|
142
142
|
`${criticalMessage} | ${highMessage} | ${mediumMessage} | ${lowMessage} | ${noteMessage}`
|
|
143
143
|
)
|
|
144
144
|
|
|
145
|
-
if (config.host !== CE_URL) {
|
|
145
|
+
if (config.host !== CE_URL && config.projectId) {
|
|
146
146
|
console.log(
|
|
147
|
-
'\n' + chalk.bold(
|
|
147
|
+
'\n' + chalk.bold("Check out your project's results in Contrast")
|
|
148
148
|
)
|
|
149
149
|
console.log(
|
|
150
|
-
`${config.host}/Contrast/static/ng/index.html#/${config.organizationId}/
|
|
150
|
+
`${config.host}/Contrast/static/ng/index.html#/${config.organizationId}/libraries?view=static&projects=${config.name}`
|
|
151
151
|
)
|
|
152
152
|
}
|
|
153
153
|
}
|