@contrast/contrast 2.0.0 → 2.0.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.
@@ -377,6 +377,11 @@ const auditOptionDefinitions = [
377
377
  i18n.__('constantsOptional') +
378
378
  '}:' +
379
379
  i18n.__('auditOptionsRepoSummary')
380
+ },
381
+ {
382
+ name: 'repo-id',
383
+ type: String,
384
+ description: ''
380
385
  }
381
386
  ];
382
387
  const fingerprintOptionDefinitions = [
@@ -387,7 +392,22 @@ const fingerprintOptionDefinitions = [
387
392
  description: '{bold ' + i18n.__('constantsOptional') + '}: ' + i18n.__('depthOption')
388
393
  },
389
394
  {
390
- name: 'repoUrl',
395
+ name: 'repo-url',
396
+ type: String,
397
+ description: ''
398
+ },
399
+ {
400
+ name: 'external-id',
401
+ type: String,
402
+ description: ''
403
+ },
404
+ {
405
+ name: 'repo-name',
406
+ type: String,
407
+ description: ''
408
+ },
409
+ {
410
+ name: 'language',
391
411
  type: String,
392
412
  description: ''
393
413
  }
@@ -53,10 +53,8 @@ const auditUsageGuide = commandLineUsage([
53
53
  'language',
54
54
  'app-groups',
55
55
  'metadata',
56
- 'fingerprint',
57
56
  'branch',
58
- 'repo',
59
- 'name'
57
+ 'repo'
60
58
  ]
61
59
  },
62
60
  {
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ const fingerprintConfig = require('./fingerprintConfig');
3
+ const repoServices = require('./repoServices');
4
+ const settingsHelper = require('../../utils/settingsHelper');
5
+ const autoDetection = require('../../scan/autoDetection');
6
+ const saveResults = require('../../scan/saveResults');
7
+ const processFingerprint = async (contrastConf, argvMain) => {
8
+ let config = await fingerprintConfig.getFingerprintConfig(contrastConf, 'fingerprint', argvMain);
9
+ config = await settingsHelper.getSettings(config);
10
+ config.repositoryId = await repoServices.getRepoId(config);
11
+ let fingerprint = await autoDetection.autoDetectFingerprintInfo(config.file, config.depth, config);
12
+ let idArray = fingerprint.map(x => x.id);
13
+ await saveResults.writeResultsToFile(fingerprint, 'fingerPrintInfo.json');
14
+ return console.log(idArray);
15
+ };
16
+ module.exports = {
17
+ processFingerprint
18
+ };
@@ -11,14 +11,23 @@ const getProjectIdByOrg = async (config) => {
11
11
  }
12
12
  return projectId;
13
13
  };
14
- const registerNewProjectGroup = async (config) => {
15
- let projectId = '';
14
+ const createNewProjectGroupBody = async (config) => {
16
15
  let body = {
17
16
  organizationId: config.organizationId,
18
- name: config.name ? config.name : config.file,
19
- repositoryId: null,
20
- type: 'CLI'
17
+ name: config.name ? config.name : config.file
21
18
  };
19
+ if (config.repo || config?.repositoryId) {
20
+ body.repositoryId = config.repositoryId;
21
+ body.type = 'REPOSITORY';
22
+ }
23
+ else {
24
+ body.repositoryId = null;
25
+ body.type = 'CLI';
26
+ }
27
+ return body;
28
+ };
29
+ const registerNewProjectGroup = async (config) => {
30
+ let body = await createNewProjectGroupBody(config);
22
31
  const client = await commonApi.getHttpClient(config);
23
32
  body.projects = createProjects([config]);
24
33
  let projectGroupInfo = await client
@@ -160,5 +169,6 @@ module.exports = {
160
169
  getProjectIdByOrg,
161
170
  registerProjectIdOnCliServices,
162
171
  dealWithNoName,
163
- registerNewProjectGroup
172
+ registerNewProjectGroup,
173
+ createNewProjectGroupBody
164
174
  };
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ const commonApi = require('../../utils/commonApi');
3
+ const retrieveRepoId = async (config) => {
4
+ const client = await commonApi.getHttpClient(config);
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
+ if (res.statusCode === 201 || res.statusCode === 200) {
14
+ return res.body.repositoryId;
15
+ }
16
+ else {
17
+ return '';
18
+ }
19
+ });
20
+ return repositoryId;
21
+ };
22
+ const registerNewRepo = async (config) => {
23
+ let body = {
24
+ externalScmUrl: config.repoUrl ? config.repoUrl : '',
25
+ externalScmName: config.repoName,
26
+ externalId: config.externalId ? config.externalId : '',
27
+ primaryLanguage: config.language,
28
+ defaultBranch: 'develop'
29
+ };
30
+ const client = await commonApi.getHttpClient(config);
31
+ let result = await client
32
+ .registerRepo(config, body)
33
+ .then(res => {
34
+ if (config.debug || config.verbose) {
35
+ console.log('\nRegister Repository');
36
+ console.log(res.statusCode);
37
+ console.log(res.body);
38
+ }
39
+ if (res.statusCode === 201 || res.statusCode === 200) {
40
+ if (config.debug || config.verbose) {
41
+ console.log('registerRepository - response');
42
+ console.log('response', res.body);
43
+ }
44
+ return res?.body?.repositoryId;
45
+ }
46
+ if (res.statusCode === 409) {
47
+ return '';
48
+ }
49
+ })
50
+ .catch(err => {
51
+ console.log('\nError Registering Repository');
52
+ console.log(err.statusCode);
53
+ });
54
+ return result;
55
+ };
56
+ const getRepoId = async (config) => {
57
+ let repoId = '';
58
+ if (config.repositoryId === '' || config.repositoryId === undefined) {
59
+ repoId = await retrieveRepoId(config);
60
+ }
61
+ if (repoId === '') {
62
+ repoId = await registerNewRepo(config);
63
+ }
64
+ return repoId;
65
+ };
66
+ module.exports = {
67
+ retrieveRepoId,
68
+ registerNewRepo,
69
+ getRepoId
70
+ };
@@ -489,7 +489,7 @@ const retrieveSourcesUrl = (config, repositoryId) => {
489
489
  return `${config.host}/projects/v1/repositories/${repositoryId}/sources`;
490
490
  };
491
491
  const retrieveRepoByOrgAndGitURL = config => {
492
- return `${config.host}/api/v4/organizations/${config.organizationId}/repository`;
492
+ return `${config.host}/api/v4/organizations/${config.organizationId}/repositories/external-url?externalRepoUrl=${config.repoUrl}`;
493
493
  };
494
494
  const retrieveProjectByOrganizationIdUrl = config => {
495
495
  let baseUrl = `${config.host}/api/v4/organizations/${config.organizationId}/projects`;
@@ -510,7 +510,7 @@ const retrieveExistingRepoUrl = config => {
510
510
  return `${config.host}/projects/v4/organizations/${config.organizationId}/repositories`;
511
511
  };
512
512
  function createRepositoryUrl(config) {
513
- return `${config.host}/projects/v1/repositories`;
513
+ return `${config.host}/api/v4/organizations/${config.organizationId}/repositories`;
514
514
  }
515
515
  function createLibraryVulnerabilitiesUrl(config) {
516
516
  return `${config.host}/Contrast/api/ng/${config.organizationId}/libraries/artifactsByGroupNameVersion`;
@@ -37,7 +37,7 @@ const maxAppError = () => {
37
37
  process.exit(1);
38
38
  };
39
39
  const parametersError = () => {
40
- generalError(`Values not recognised`, 'Check your command & keys again for hidden characters.\nFor more information use contrast help.');
40
+ generalError(`Credentials not recognized`, 'Check your command & keys again for hidden characters / verify that the credentials are correct.\nFor more information use contrast help.');
41
41
  process.exit(1);
42
42
  };
43
43
  const invalidHostNameError = () => {
@@ -12,7 +12,7 @@ const MEDIUM = 'MEDIUM';
12
12
  const HIGH = 'HIGH';
13
13
  const CRITICAL = 'CRITICAL';
14
14
  const APP_NAME = 'contrast';
15
- const APP_VERSION = '2.0.0';
15
+ const APP_VERSION = '2.0.1';
16
16
  const TIMEOUT = 120000;
17
17
  const HIGH_COLOUR = '#ff9900';
18
18
  const CRITICAL_COLOUR = '#e35858';
package/dist/index.js CHANGED
@@ -17,6 +17,7 @@ const versionChecker_1 = require("./common/versionChecker");
17
17
  const errorHandling_1 = require("./common/errorHandling");
18
18
  const telemetry_1 = require("./telemetry/telemetry");
19
19
  const processLearn_1 = require("./commands/learn/processLearn");
20
+ const processFingerprint_1 = require("./commands/github/processFingerprint");
20
21
  const { commandLineDefinitions: { mainUsageGuide, mainDefinition } } = cliConstants_1.default;
21
22
  const config = (0, getConfig_1.localConfig)(constants_1.APP_NAME, constants_1.APP_VERSION);
22
23
  const getMainOption = () => {
@@ -65,6 +66,9 @@ const start = async () => {
65
66
  if (command === 'audit') {
66
67
  return await (0, processAudit_1.processAudit)(config, argvMain);
67
68
  }
69
+ if (command === 'fingerprint') {
70
+ return await (0, processFingerprint_1.processFingerprint)(config, argvMain);
71
+ }
68
72
  if (command === 'learn') {
69
73
  return (0, processLearn_1.processLearn)();
70
74
  }
@@ -1,21 +1,39 @@
1
1
  "use strict";
2
2
  const projectConfig = require('../commands/github/projectGroup');
3
3
  const scaServicesUpload = require('../scaAnalysis/common/scaServicesUpload');
4
- const processUpload = async (analysis, config, reportSpinner) => {
4
+ const trackProcess = async (analysis, config, reportSpinner) => {
5
+ await projectConfig.registerNewProjectGroup(config);
5
6
  let projectId = await projectConfig.getProjectIdByOrg(config);
6
- if (projectId === '') {
7
- if (config.track === true) {
8
- await projectConfig.registerNewProjectGroup(config);
9
- projectId = await projectConfig.getProjectIdByOrg(config);
10
- }
11
- if (config.track === false || config.track === undefined) {
12
- return await scaServicesUpload.noProjectUpload(analysis, config, reportSpinner);
13
- }
14
- }
15
7
  await projectConfig.registerProjectIdOnCliServices(config, projectId);
16
8
  config.projectId = projectId;
17
9
  return await scaServicesUpload.scaTreeUpload(analysis, config, reportSpinner);
18
10
  };
11
+ const repoProcess = async (analysis, config, reportSpinner) => {
12
+ let repoInfo = repoService.retrieveRepoId(config);
13
+ if (repoInfo.repoId === '') {
14
+ repoInfo = repoService.registerRepo(config);
15
+ }
16
+ await projectConfig.registerProjectIdOnCliServices(config, repoInfo.projectId);
17
+ return repoInfo;
18
+ };
19
+ const dealWithNoProjectId = async (analysis, config, reportSpinner) => {
20
+ if (config.track) {
21
+ return trackProcess(analysis, config, reportSpinner);
22
+ }
23
+ if (!config.track) {
24
+ return await scaServicesUpload.noProjectUpload(analysis, config, reportSpinner);
25
+ }
26
+ };
27
+ const processUpload = async (analysis, config, reportSpinner) => {
28
+ let projectId = await projectConfig.getProjectIdByOrg(config);
29
+ if (projectId === '') {
30
+ return dealWithNoProjectId(analysis, config, reportSpinner);
31
+ }
32
+ if (projectId) {
33
+ config.projectId = projectId;
34
+ return await scaServicesUpload.scaTreeUpload(analysis, config, reportSpinner);
35
+ }
36
+ };
19
37
  module.exports = {
20
38
  processUpload
21
39
  };
@@ -2,13 +2,17 @@
2
2
  const i18n = require('i18n');
3
3
  const fileFinder = require('./fileUtils');
4
4
  const { supportedLanguages: { JAVA, GO, PYTHON, RUBY, JAVASCRIPT, NODE, PHP, DOTNET } } = require('../constants/constants');
5
- const autoDetectFingerprintInfo = async (filePath, depth) => {
5
+ const autoDetectFingerprintInfo = async (filePath, depth, config) => {
6
6
  let complexObj = await fileFinder.findAllFiles(filePath, depth);
7
7
  let result = [];
8
8
  let count = 0;
9
9
  complexObj.forEach(i => {
10
10
  count++;
11
- result.push({ filePath: i, id: count.toString() });
11
+ result.push({
12
+ filePath: i,
13
+ id: count.toString(),
14
+ repositoryId: config.repositoryId
15
+ });
12
16
  });
13
17
  return result;
14
18
  };
@@ -26,7 +30,7 @@ const detectPackageManager = async (array) => {
26
30
  i['language'] = JAVA;
27
31
  i['packageManager'] = 'GRADLE';
28
32
  }
29
- if (i.filePath.includes('package.json')) {
33
+ if (i.filePath.includes('package-lock.json')) {
30
34
  i['language'] = JAVASCRIPT;
31
35
  i['packageManager'] = 'NPM';
32
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/contrast",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Contrast Security's command line tool",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -426,6 +426,11 @@ const auditOptionDefinitions = [
426
426
  i18n.__('constantsOptional') +
427
427
  '}:' +
428
428
  i18n.__('auditOptionsRepoSummary')
429
+ },
430
+ {
431
+ name: 'repo-id',
432
+ type: String,
433
+ description: ''
429
434
  }
430
435
  ]
431
436
 
@@ -438,7 +443,22 @@ const fingerprintOptionDefinitions = [
438
443
  '{bold ' + i18n.__('constantsOptional') + '}: ' + i18n.__('depthOption')
439
444
  },
440
445
  {
441
- name: 'repoUrl',
446
+ name: 'repo-url',
447
+ type: String,
448
+ description: ''
449
+ },
450
+ {
451
+ name: 'external-id',
452
+ type: String,
453
+ description: ''
454
+ },
455
+ {
456
+ name: 'repo-name',
457
+ type: String,
458
+ description: ''
459
+ },
460
+ {
461
+ name: 'language',
442
462
  type: String,
443
463
  description: ''
444
464
  }
@@ -53,10 +53,8 @@ const auditUsageGuide = commandLineUsage([
53
53
  'language',
54
54
  'app-groups',
55
55
  'metadata',
56
- 'fingerprint',
57
56
  'branch',
58
- 'repo',
59
- 'name'
57
+ 'repo'
60
58
  ]
61
59
  },
62
60
  {
@@ -0,0 +1,27 @@
1
+ const fingerprintConfig = require('./fingerprintConfig')
2
+ const repoServices = require('./repoServices')
3
+ const settingsHelper = require('../../utils/settingsHelper')
4
+ const autoDetection = require('../../scan/autoDetection')
5
+ const saveResults = require('../../scan/saveResults')
6
+ const processFingerprint = async (contrastConf, argvMain) => {
7
+ let config = await fingerprintConfig.getFingerprintConfig(
8
+ contrastConf,
9
+ 'fingerprint',
10
+ argvMain
11
+ )
12
+ config = await settingsHelper.getSettings(config)
13
+ config.repositoryId = await repoServices.getRepoId(config)
14
+ let fingerprint = await autoDetection.autoDetectFingerprintInfo(
15
+ config.file,
16
+ config.depth,
17
+ config
18
+ )
19
+
20
+ let idArray = fingerprint.map(x => x.id)
21
+ await saveResults.writeResultsToFile(fingerprint, 'fingerPrintInfo.json')
22
+ return console.log(idArray)
23
+ }
24
+
25
+ module.exports = {
26
+ processFingerprint
27
+ }
@@ -15,14 +15,24 @@ const getProjectIdByOrg = async config => {
15
15
  return projectId
16
16
  }
17
17
 
18
- const registerNewProjectGroup = async config => {
19
- let projectId = ''
18
+ const createNewProjectGroupBody = async config => {
20
19
  let body = {
21
20
  organizationId: config.organizationId,
22
- name: config.name ? config.name : config.file, //has to be unique per project
23
- repositoryId: null,
24
- type: 'CLI'
21
+ name: config.name ? config.name : config.file //has to be unique per project
25
22
  }
23
+ if (config.repo || config?.repositoryId) {
24
+ body.repositoryId = config.repositoryId
25
+ body.type = 'REPOSITORY'
26
+ } else {
27
+ body.repositoryId = null
28
+ body.type = 'CLI'
29
+ }
30
+ return body
31
+ }
32
+
33
+ const registerNewProjectGroup = async config => {
34
+ let body = await createNewProjectGroupBody(config)
35
+
26
36
  const client = await commonApi.getHttpClient(config)
27
37
  body.projects = createProjects([config])
28
38
 
@@ -183,5 +193,6 @@ module.exports = {
183
193
  getProjectIdByOrg,
184
194
  registerProjectIdOnCliServices,
185
195
  dealWithNoName,
186
- registerNewProjectGroup
196
+ registerNewProjectGroup,
197
+ createNewProjectGroupBody
187
198
  }
@@ -0,0 +1,80 @@
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.repoUrl ? config.repoUrl : '',
27
+ externalScmName: config.repoName,
28
+ externalId: config.externalId ? config.externalId : '',
29
+ primaryLanguage: config.language,
30
+ defaultBranch: 'develop'
31
+ }
32
+
33
+ const client = await commonApi.getHttpClient(config)
34
+
35
+ let result = await client
36
+ .registerRepo(config, body)
37
+ .then(res => {
38
+ if (config.debug || config.verbose) {
39
+ console.log('\nRegister Repository')
40
+ console.log(res.statusCode)
41
+ console.log(res.body)
42
+ }
43
+ if (res.statusCode === 201 || res.statusCode === 200) {
44
+ if (config.debug || config.verbose) {
45
+ console.log('registerRepository - response')
46
+ console.log('response', res.body)
47
+ }
48
+ return res?.body?.repositoryId
49
+ }
50
+
51
+ if (res.statusCode === 409) {
52
+ return ''
53
+ }
54
+ })
55
+ .catch(err => {
56
+ console.log('\nError Registering Repository')
57
+ console.log(err.statusCode)
58
+ })
59
+
60
+ return result
61
+ }
62
+
63
+ const getRepoId = async config => {
64
+ let repoId = ''
65
+ if (config.repositoryId === '' || config.repositoryId === undefined) {
66
+ repoId = await retrieveRepoId(config)
67
+ }
68
+
69
+ if (repoId === '') {
70
+ repoId = await registerNewRepo(config)
71
+ }
72
+
73
+ return repoId
74
+ }
75
+
76
+ module.exports = {
77
+ retrieveRepoId,
78
+ registerNewRepo,
79
+ getRepoId
80
+ }
@@ -677,7 +677,7 @@ const retrieveSourcesUrl = (config, repositoryId) => {
677
677
  }
678
678
 
679
679
  const retrieveRepoByOrgAndGitURL = config => {
680
- return `${config.host}/api/v4/organizations/${config.organizationId}/repository`
680
+ return `${config.host}/api/v4/organizations/${config.organizationId}/repositories/external-url?externalRepoUrl=${config.repoUrl}`
681
681
  }
682
682
 
683
683
  const retrieveProjectByOrganizationIdUrl = config => {
@@ -702,7 +702,7 @@ const retrieveExistingRepoUrl = config => {
702
702
  }
703
703
 
704
704
  function createRepositoryUrl(config) {
705
- return `${config.host}/projects/v1/repositories`
705
+ return `${config.host}/api/v4/organizations/${config.organizationId}/repositories`
706
706
  }
707
707
 
708
708
  function createLibraryVulnerabilitiesUrl(config) {
@@ -51,8 +51,8 @@ const maxAppError = () => {
51
51
 
52
52
  const parametersError = () => {
53
53
  generalError(
54
- `Values not recognised`,
55
- 'Check your command & keys again for hidden characters.\nFor more information use contrast help.'
54
+ `Credentials not recognized`,
55
+ 'Check your command & keys again for hidden characters / verify that the credentials are correct.\nFor more information use contrast help.'
56
56
  )
57
57
  process.exit(1)
58
58
  }
@@ -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 = '2.0.0'
17
+ const APP_VERSION = '2.0.1'
18
18
  const TIMEOUT = 120000
19
19
  const HIGH_COLOUR = '#ff9900'
20
20
  const CRITICAL_COLOUR = '#e35858'
package/src/index.ts CHANGED
@@ -16,6 +16,7 @@ import {
16
16
  import { findCommandOnError } from './common/errorHandling'
17
17
  import { sendTelemetryConfigAsConfObj } from './telemetry/telemetry'
18
18
  import { processLearn } from './commands/learn/processLearn'
19
+ import { processFingerprint } from './commands/github/processFingerprint'
19
20
  const {
20
21
  commandLineDefinitions: { mainUsageGuide, mainDefinition }
21
22
  } = constants
@@ -83,6 +84,10 @@ const start = async () => {
83
84
  return await processAudit(config, argvMain)
84
85
  }
85
86
 
87
+ if (command === 'fingerprint') {
88
+ return await processFingerprint(config, argvMain)
89
+ }
90
+
86
91
  if (command === 'learn') {
87
92
  return processLearn()
88
93
  }
@@ -1,27 +1,59 @@
1
1
  const projectConfig = require('../commands/github/projectGroup')
2
2
  const scaServicesUpload = require('../scaAnalysis/common/scaServicesUpload')
3
+
4
+ const trackProcess = async (analysis, config, reportSpinner) => {
5
+ await projectConfig.registerNewProjectGroup(config)
6
+ let projectId = await projectConfig.getProjectIdByOrg(config)
7
+ await projectConfig.registerProjectIdOnCliServices(config, projectId)
8
+ config.projectId = projectId
9
+ return await scaServicesUpload.scaTreeUpload(analysis, config, reportSpinner)
10
+ }
11
+
12
+ const repoProcess = async (analysis, config, reportSpinner) => {
13
+ let repoInfo = repoService.retrieveRepoId(config)
14
+ if (repoInfo.repoId === '') {
15
+ repoInfo = repoService.registerRepo(config)
16
+ }
17
+ await projectConfig.registerProjectIdOnCliServices(config, repoInfo.projectId)
18
+ return repoInfo
19
+ }
20
+
21
+ const dealWithNoProjectId = async (analysis, config, reportSpinner) => {
22
+ // if (config.repo === '') {
23
+ // return repoProcess(analysis, config, reportSpinner)
24
+ // }
25
+ if (config.track) {
26
+ return trackProcess(analysis, config, reportSpinner)
27
+ }
28
+
29
+ if (!config.track) {
30
+ return await scaServicesUpload.noProjectUpload(
31
+ analysis,
32
+ config,
33
+ reportSpinner
34
+ )
35
+ }
36
+ }
37
+
3
38
  const processUpload = async (analysis, config, reportSpinner) => {
39
+ // if repo but no repoId -> RegisterRepo -> GroupProjectFlow THEN scaTreeUpload
40
+ // if cli tracked but no projectId -> registerNewProjectGroup THEN scaTreeUpload
41
+ // if cli not tracked and no projectID -> noProjectUpload
42
+ // if cli not tracked and projectID -> scaTreeUpload}
4
43
  let projectId = await projectConfig.getProjectIdByOrg(config)
5
44
 
6
45
  if (projectId === '') {
7
- if (config.track === true) {
8
- await projectConfig.registerNewProjectGroup(config)
9
- projectId = await projectConfig.getProjectIdByOrg(config)
10
- }
11
-
12
- if (config.track === false || config.track === undefined) {
13
- return await scaServicesUpload.noProjectUpload(
14
- analysis,
15
- config,
16
- reportSpinner
17
- )
18
- }
46
+ return dealWithNoProjectId(analysis, config, reportSpinner)
19
47
  }
20
48
 
21
- await projectConfig.registerProjectIdOnCliServices(config, projectId)
22
- config.projectId = projectId
23
-
24
- return await scaServicesUpload.scaTreeUpload(analysis, config, reportSpinner)
49
+ if (projectId) {
50
+ config.projectId = projectId
51
+ return await scaServicesUpload.scaTreeUpload(
52
+ analysis,
53
+ config,
54
+ reportSpinner
55
+ )
56
+ }
25
57
  }
26
58
 
27
59
  module.exports = {
@@ -3,13 +3,17 @@ const fileFinder = require('./fileUtils')
3
3
  const {
4
4
  supportedLanguages: { JAVA, GO, PYTHON, RUBY, JAVASCRIPT, NODE, PHP, DOTNET }
5
5
  } = require('../constants/constants')
6
- const autoDetectFingerprintInfo = async (filePath, depth) => {
6
+ const autoDetectFingerprintInfo = async (filePath, depth, config) => {
7
7
  let complexObj = await fileFinder.findAllFiles(filePath, depth)
8
8
  let result = []
9
9
  let count = 0
10
10
  complexObj.forEach(i => {
11
11
  count++
12
- result.push({ filePath: i, id: count.toString() })
12
+ result.push({
13
+ filePath: i,
14
+ id: count.toString(),
15
+ repositoryId: config.repositoryId
16
+ })
13
17
  })
14
18
 
15
19
  return result
@@ -29,7 +33,7 @@ const detectPackageManager = async array => {
29
33
  i['language'] = JAVA
30
34
  i['packageManager'] = 'GRADLE'
31
35
  }
32
- if (i.filePath.includes('package.json')) {
36
+ if (i.filePath.includes('package-lock.json')) {
33
37
  i['language'] = JAVASCRIPT
34
38
  i['packageManager'] = 'NPM'
35
39
  }