@contrast/contrast 2.0.1 → 2.0.2-beta.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.
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 +19 -1
  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 +6 -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 +24 -1
  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
@@ -11,8 +11,10 @@ const scaTreeUpload = async (analysis, config, reportSpinner) => {
11
11
  config.language = config.language === 'JAVASCRIPT' ? 'NODE' : config.language;
12
12
  const startTime = performance.now();
13
13
  const timeout = commonApi.getTimeout(config);
14
+ const doINeedParent = config.repositoryId && config.language === 'JAVA';
14
15
  const requestBody = {
15
- dependencyTree: analysis,
16
+ parentPom: doINeedParent ? analysis.parentPom : null,
17
+ dependencyTree: doINeedParent ? analysis.dependencyTree : analysis,
16
18
  organizationId: config.organizationId,
17
19
  language: config.language,
18
20
  tool: {
@@ -5,7 +5,10 @@ const getGoDependencies = config => {
5
5
  let cmdStdout;
6
6
  let cwd = config.file ? config.file.replace('go.mod', '') : process.cwd();
7
7
  try {
8
- cmdStdout = child_process.execSync('go mod graph', { cwd });
8
+ cmdStdout = child_process.execSync('go mod graph', {
9
+ cwd: cwd,
10
+ maxBuffer: 50 * 1024 * 1024
11
+ });
9
12
  return cmdStdout.toString();
10
13
  }
11
14
  catch (err) {
@@ -14,6 +17,7 @@ const getGoDependencies = config => {
14
17
  '\n\n*************** No transitive dependencies ***************\n\nWe are unable to build a dependency tree view from your repository as there were no transitive dependencies found.';
15
18
  }
16
19
  console.log(i18n.__('goReadProjectFile', cwd, `${err.message ? err.message : ''}`));
20
+ process.exit(1);
17
21
  }
18
22
  };
19
23
  module.exports = {
@@ -24,7 +24,7 @@ const determineProjectTypeAndCwd = (files, config) => {
24
24
  };
25
25
  const buildMaven = (config, projectData, timeout) => {
26
26
  let command = 'mvn';
27
- let args = ['dependency:tree', '-B'];
27
+ let args = ['dependency:tree', '-B', '-Dscope=runtime'];
28
28
  if (config.mavenSettingsPath) {
29
29
  args.push('-s');
30
30
  args.push(config.mavenSettingsPath);
@@ -119,7 +119,7 @@ const computeRelationToLastElement = element => {
119
119
  }
120
120
  };
121
121
  const stripElement = element => {
122
- return element
122
+ const initialStrippedElement = element
123
123
  .replace(/[|]/g, '')
124
124
  .replace('+---', '')
125
125
  .replace('\\---', '')
@@ -127,6 +127,16 @@ const stripElement = element => {
127
127
  .replace('(c)', '')
128
128
  .replace('->', '@')
129
129
  .replace('(*)', '');
130
+ const splitElements = initialStrippedElement.split(':');
131
+ if (splitElements[2] !== undefined &&
132
+ splitElements[2] !== null &&
133
+ splitElements[2].includes('@')) {
134
+ const splitVersions = splitElements[2].split('@');
135
+ return initialStrippedElement
136
+ .replace(':' + splitVersions[0], '')
137
+ .replace('@', ':');
138
+ }
139
+ return initialStrippedElement;
130
140
  };
131
141
  const checkVersion = element => {
132
142
  let version = element.split(':');
@@ -18,12 +18,6 @@ const legacyFlow = async (config, messageToSend) => {
18
18
  await pollForSnapshotCompletion(config, snapshotResponse.id, reportSpinner);
19
19
  succeedSpinner(reportSpinner, i18n.__('auditSCAAnalysisComplete'));
20
20
  await vulnerabilityReportV2(config, snapshotResponse.id);
21
- if (config.save !== undefined) {
22
- await auditSave(config);
23
- }
24
- else {
25
- console.log('\nUse contrast audit --save to generate an SBOM');
26
- }
27
21
  const endTime = performance.now() - startTime;
28
22
  const scanDurationMs = endTime - startTime;
29
23
  console.log(`----- completed in ${(scanDurationMs / 1000).toFixed(2)}s -----`);
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  const projectConfig = require('../commands/github/projectGroup');
3
+ const repoService = require('../commands/github/repoServices');
3
4
  const scaServicesUpload = require('../scaAnalysis/common/scaServicesUpload');
4
- const trackProcess = async (analysis, config, reportSpinner) => {
5
+ const dealWithNoProjectId = async (analysis, config, reportSpinner) => {
5
6
  await projectConfig.registerNewProjectGroup(config);
6
7
  let projectId = await projectConfig.getProjectIdByOrg(config);
7
8
  await projectConfig.registerProjectIdOnCliServices(config, projectId);
@@ -9,31 +10,51 @@ const trackProcess = async (analysis, config, reportSpinner) => {
9
10
  return await scaServicesUpload.scaTreeUpload(analysis, config, reportSpinner);
10
11
  };
11
12
  const repoProcess = async (analysis, config, reportSpinner) => {
12
- let repoInfo = repoService.retrieveRepoId(config);
13
- if (repoInfo.repoId === '') {
14
- repoInfo = repoService.registerRepo(config);
13
+ if (config.debug || config.verbose) {
14
+ console.log('in repository process');
15
+ console.log('repository id: ', config.repositoryId);
15
16
  }
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);
17
+ if (config.repositoryId === '') {
18
+ console.log('Failed to retrieve Repository Id');
19
+ process.exit(1);
22
20
  }
23
- if (!config.track) {
24
- return await scaServicesUpload.noProjectUpload(analysis, config, reportSpinner);
21
+ let repoInfo = await repoService.retrieveProjectInfoViaRepoId(config);
22
+ repoInfo = repoInfo.find(element => config.fileName === element.path &&
23
+ config.fileName === element.name &&
24
+ config.projectGroupId === element.projectGroupId);
25
+ if (config.projectGroupId &&
26
+ !repoInfo?.projectId &&
27
+ (repoInfo === undefined || repoInfo.length === 0)) {
28
+ console.log('*** has projectGroupId, no projectId and repo has no project found that matches');
29
+ repoInfo = await projectConfig.registerProjectWithGroupProjectId(config);
30
+ console.log('new registered group', repoInfo);
31
+ const language = repoInfo.language === 'JAVASCRIPT' ? 'NODE' : repoInfo.language;
32
+ await projectConfig.registerProjectIdOnCliServices(config, repoInfo.projectId);
25
33
  }
34
+ config.projectId = repoInfo.projectId;
35
+ return await scaServicesUpload.scaTreeUpload(analysis, config, reportSpinner);
26
36
  };
27
- const processUpload = async (analysis, config, reportSpinner) => {
37
+ const trackProcess = async (analysis, config, reportSpinner) => {
28
38
  let projectId = await projectConfig.getProjectIdByOrg(config);
29
39
  if (projectId === '') {
30
40
  return dealWithNoProjectId(analysis, config, reportSpinner);
31
41
  }
32
- if (projectId) {
33
- config.projectId = projectId;
34
- return await scaServicesUpload.scaTreeUpload(analysis, config, reportSpinner);
42
+ config.projectId = projectId;
43
+ await projectConfig.registerProjectIdOnCliServices(config, projectId);
44
+ return await scaServicesUpload.scaTreeUpload(analysis, config, reportSpinner);
45
+ };
46
+ const processUpload = async (analysis, config, reportSpinner) => {
47
+ if (config.repositoryId) {
48
+ return repoProcess(analysis, config, reportSpinner);
49
+ }
50
+ if (config.track) {
51
+ return trackProcess(analysis, config, reportSpinner);
52
+ }
53
+ if (!config.track) {
54
+ return await scaServicesUpload.noProjectUpload(analysis, config, reportSpinner);
35
55
  }
36
56
  };
37
57
  module.exports = {
38
- processUpload
58
+ processUpload,
59
+ repoProcess
39
60
  };
@@ -56,7 +56,25 @@ const parsePomFile = jsonPomFile => {
56
56
  };
57
57
  dependencyTree[depName] = parsedDependency;
58
58
  }
59
- return dependencyTree;
59
+ const retrieveParent = getParentDependency(jsonPomFile);
60
+ return {
61
+ parentPom: retrieveParent,
62
+ dependencyTree
63
+ };
64
+ };
65
+ const getParentDependency = jsonPomFile => {
66
+ let parent = {};
67
+ jsonPomFile.project.hasOwnProperty('parent')
68
+ ? (parent = buildParent(jsonPomFile.project.parent))
69
+ : (parent = undefined);
70
+ return parent;
71
+ };
72
+ const buildParent = parent => {
73
+ return {
74
+ group: parent[0].groupId[0],
75
+ name: parent[0].artifactId[0],
76
+ version: parent[0].version[0]
77
+ };
60
78
  };
61
79
  const getVersion = (pomFile, dependencyWithoutVersion) => {
62
80
  let parentVersion = pomFile.project.parent[0].version[0];
@@ -5,7 +5,6 @@ const autoDetection = require('../scan/autoDetection');
5
5
  const rootFile = require('../audit/languageAnalysisEngine/getProjectRootFilenames');
6
6
  const path = require('path');
7
7
  const i18n = require('i18n');
8
- const auditSave = require('../audit/save');
9
8
  const { auditUsageGuide } = require('../commands/audit/help');
10
9
  const repoMode = require('./repoMode');
11
10
  const { dotNetAnalysis } = require('./dotnet');
@@ -27,6 +26,7 @@ const processSca = async (config) => {
27
26
  console.log(auditUsageGuide);
28
27
  process.exit(0);
29
28
  }
29
+ config.repo = config.repositoryId !== undefined;
30
30
  const projectStats = await rootFile.getProjectStats(config.file);
31
31
  let pathWithFile = projectStats.isFile();
32
32
  config.fileName = config.file;
@@ -34,12 +34,14 @@ const processSca = async (config) => {
34
34
  ? rootFile.getDirectoryFromPathGiven(config.file).concat('/')
35
35
  : config.file;
36
36
  filesFound = await autoDetection.autoDetectAuditFilesAndLanguages(config.file);
37
+ filesFound = await autoDetection.detectPackageManager(filesFound);
37
38
  autoDetection.dealWithMultiJava(filesFound);
38
39
  if (filesFound.length > 1 && pathWithFile) {
39
40
  filesFound = filesFound.filter(i => Object.values(i)[0].includes(path.basename(config.fileName)));
40
41
  }
41
42
  let messageToSend = undefined;
42
43
  if (filesFound.length === 1) {
44
+ config.packageManager = filesFound[0]?.packageManager;
43
45
  switch (Object.keys(filesFound[0])[0]) {
44
46
  case JAVA:
45
47
  config.language = JAVA;
@@ -99,13 +101,7 @@ const processSca = async (config) => {
99
101
  startSpinner(reportSpinner);
100
102
  let reportResponse = await processServices.processUpload(messageToSend, config, reportSpinner);
101
103
  const reportModelLibraryList = convertGenericToTypedReportModelSca(reportResponse.reportArray);
102
- auditReport.processAuditReport(config, reportModelLibraryList);
103
- if (config.save !== undefined) {
104
- await auditSave.auditSave(config, reportResponse.reportId);
105
- }
106
- else {
107
- console.log('Use contrast audit --save to generate an SBOM');
108
- }
104
+ await auditReport.processAuditReport(config, reportModelLibraryList, reportResponse.reportId);
109
105
  succeedSpinner(reportSpinner, i18n.__('auditSCAAnalysisComplete'));
110
106
  const endTime = performance.now() - startTime;
111
107
  const scanDurationMs = endTime - startTime;
@@ -8,11 +8,14 @@ const autoDetectFingerprintInfo = async (filePath, depth, config) => {
8
8
  let count = 0;
9
9
  complexObj.forEach(i => {
10
10
  count++;
11
- result.push({
12
- filePath: i,
13
- id: count.toString(),
14
- repositoryId: config.repositoryId
15
- });
11
+ if (!i.includes('package.json')) {
12
+ result.push({
13
+ filePath: i,
14
+ id: count.toString(),
15
+ repositoryId: config.repositoryId,
16
+ projectGroupId: config.projectGroupId
17
+ });
18
+ }
16
19
  });
17
20
  return result;
18
21
  };
@@ -40,15 +43,19 @@ const detectPackageManager = async (array) => {
40
43
  }
41
44
  if (i.filePath.includes('Pipfile')) {
42
45
  i['language'] = PYTHON;
46
+ i['packageManager'] = 'PYPI';
43
47
  }
44
48
  if (i.filePath.includes('csproj')) {
45
49
  i['language'] = DOTNET;
50
+ i['packageManager'] = 'NUGET';
46
51
  }
47
52
  if (i.filePath.includes('Gemfile')) {
48
53
  i['language'] = RUBY;
54
+ i['packageManager'] = 'RUBYGEMS';
49
55
  }
50
56
  if (i.filePath.includes('go.mod')) {
51
57
  i['language'] = GO;
58
+ i['packageManager'] = 'PKG';
52
59
  }
53
60
  });
54
61
  return array;
@@ -16,6 +16,7 @@ const findAllFiles = async (filePath, depth = 2) => {
16
16
  '**/build.gradle',
17
17
  '**/build.gradle.kts',
18
18
  '**/package.json',
19
+ '**/package-lock.json',
19
20
  '**/yarn.lock',
20
21
  '**/Pipfile',
21
22
  '**/*.csproj',
@@ -41,79 +42,92 @@ const findFilesJava = async (languagesFound, filePath, depth = 1) => {
41
42
  cwd: filePath ? filePath : process.cwd()
42
43
  });
43
44
  if (result.length > 0) {
44
- return languagesFound.push({ JAVA: result, language: 'JAVA' });
45
+ let lockFile = result.find(i => i.includes('pom') || i.includes('gradle'));
46
+ return languagesFound.push({
47
+ JAVA: result,
48
+ language: 'JAVA',
49
+ filePath: lockFile
50
+ });
45
51
  }
46
52
  return languagesFound;
47
53
  };
48
- const findFilesJavascript = async (languagesFound, filePath) => {
54
+ const findFilesJavascript = async (languagesFound, filePath, depth = 1) => {
49
55
  const result = await fg(['**/package.json', '**/yarn.lock', '**/package-lock.json'], {
50
56
  dot: false,
51
- deep: 1,
57
+ deep: depth,
52
58
  onlyFiles: true,
53
59
  cwd: filePath ? filePath : process.cwd()
54
60
  });
55
61
  if (result.length > 0) {
56
- return languagesFound.push({ JAVASCRIPT: result, language: 'JAVASCRIPT' });
62
+ let lockFile = result.find(i => i.includes('lock'));
63
+ return languagesFound.push({
64
+ JAVASCRIPT: result,
65
+ language: 'JAVASCRIPT',
66
+ filePath: lockFile
67
+ });
57
68
  }
58
69
  return languagesFound;
59
70
  };
60
- const findFilesPython = async (languagesFound, filePath) => {
71
+ const findFilesPython = async (languagesFound, filePath, depth = 1) => {
61
72
  const result = await fg(['**/Pipfile.lock', '**/Pipfile'], {
62
73
  dot: false,
63
- deep: 3,
74
+ deep: depth,
64
75
  onlyFiles: true,
65
76
  cwd: filePath ? filePath : process.cwd()
66
77
  });
67
78
  if (result.length > 0) {
68
- return languagesFound.push({ PYTHON: result });
79
+ return languagesFound.push({ PYTHON: result, filePath: 'Pipfile' });
69
80
  }
70
81
  return languagesFound;
71
82
  };
72
- const findFilesGo = async (languagesFound, filePath) => {
83
+ const findFilesGo = async (languagesFound, filePath, depth = 1) => {
73
84
  const result = await fg(['**/go.mod'], {
74
85
  dot: false,
75
- deep: 3,
86
+ deep: depth,
76
87
  onlyFiles: true,
77
88
  cwd: filePath ? filePath : process.cwd()
78
89
  });
79
90
  if (result.length > 0) {
80
- return languagesFound.push({ GO: result });
91
+ return languagesFound.push({ GO: result, filePath: 'go.mod' });
81
92
  }
82
93
  return languagesFound;
83
94
  };
84
- const findFilesRuby = async (languagesFound, filePath) => {
95
+ const findFilesRuby = async (languagesFound, filePath, depth = 1) => {
85
96
  const result = await fg(['**/Gemfile', '**/Gemfile.lock'], {
86
97
  dot: false,
87
- deep: 3,
98
+ deep: depth,
88
99
  onlyFiles: true,
89
100
  cwd: filePath ? filePath : process.cwd()
90
101
  });
91
102
  if (result.length > 0) {
92
- return languagesFound.push({ RUBY: result });
103
+ return languagesFound.push({ RUBY: result, filePath: 'Gemfile' });
93
104
  }
94
105
  return languagesFound;
95
106
  };
96
- const findFilesPhp = async (languagesFound, filePath) => {
107
+ const findFilesPhp = async (languagesFound, filePath, depth = 1) => {
97
108
  const result = await fg(['**/composer.json', '**/composer.lock'], {
98
109
  dot: false,
99
- deep: 3,
110
+ deep: depth,
100
111
  onlyFiles: true,
101
112
  cwd: filePath ? filePath : process.cwd()
102
113
  });
103
114
  if (result.length > 0) {
104
- return languagesFound.push({ PHP: result });
115
+ return languagesFound.push({ PHP: result, filePath: 'composer.lock' });
105
116
  }
106
117
  return languagesFound;
107
118
  };
108
- const findFilesDotNet = async (languagesFound, filePath) => {
119
+ const findFilesDotNet = async (languagesFound, filePath, depth = 1) => {
109
120
  const result = await fg(['**/*.csproj', '**/packages.lock.json'], {
110
121
  dot: false,
111
- deep: 3,
122
+ deep: depth,
112
123
  onlyFiles: true,
113
124
  cwd: filePath ? filePath : process.cwd()
114
125
  });
115
126
  if (result.length > 0) {
116
- return languagesFound.push({ DOTNET: result });
127
+ return languagesFound.push({
128
+ DOTNET: result,
129
+ filePath: 'packages.lock.json'
130
+ });
117
131
  }
118
132
  return languagesFound;
119
133
  };
@@ -2,7 +2,7 @@
2
2
  const commandlineAuth = require('./commandlineParams');
3
3
  const configStoreParams = require('./configStoreParams');
4
4
  const envVariableParams = require('./envVariableParams');
5
- const { validateAuthParams } = require('../validationCheck');
5
+ const { validateAuthParams, validateFingerprintParams } = require('../validationCheck');
6
6
  const i18n = require('i18n');
7
7
  const getAuth = params => {
8
8
  let commandLineAuthParamsAuth = commandlineAuth.getAuth(params);
@@ -22,4 +22,13 @@ const getAuth = params => {
22
22
  process.exit(1);
23
23
  }
24
24
  };
25
- module.exports = { getAuth };
25
+ const getFingerprint = params => {
26
+ if (validateFingerprintParams(params)) {
27
+ return params;
28
+ }
29
+ else {
30
+ console.log('missing fingerprint params please check repository-url and repository-name');
31
+ process.exit(1);
32
+ }
33
+ };
34
+ module.exports = { getAuth, getFingerprint };
@@ -19,8 +19,12 @@ const validateAuthParams = params => {
19
19
  params.host &&
20
20
  params.authorization);
21
21
  };
22
+ const validateFingerprintParams = params => {
23
+ return !!(params.repositoryUrl && params.repositoryName);
24
+ };
22
25
  module.exports = {
23
26
  checkConfigHasRequiredValues: checkConfigHasRequiredValues,
24
27
  validateAuthParams: validateAuthParams,
25
- validateRequiredScanParams: validateRequiredScanParams
28
+ validateRequiredScanParams: validateRequiredScanParams,
29
+ validateFingerprintParams: validateFingerprintParams
26
30
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/contrast",
3
- "version": "2.0.1",
3
+ "version": "2.0.2-beta.0",
4
4
  "description": "Contrast Security's command line tool",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -61,7 +61,9 @@
61
61
  "cross-spawn": "^7.0.3",
62
62
  "dotenv": "^16.0.0",
63
63
  "fast-glob": "^3.2.11",
64
+ "got": "11.8.6",
64
65
  "gradle-to-js": "^2.0.1",
66
+ "hpagent": "^1.2.0",
65
67
  "i18n": "^0.15.1",
66
68
  "js-yaml": "^4.1.0",
67
69
  "lodash": "^4.17.21",
@@ -74,7 +76,7 @@
74
76
  "string-builder": "^0.1.8",
75
77
  "string-multiple-replace": "^1.0.5",
76
78
  "tmp": "^0.2.1",
77
- "xml2js": "^0.4.23",
79
+ "xml2js": "^0.5.0",
78
80
  "yarn-lockfile": "^1.1.1"
79
81
  },
80
82
  "devDependencies": {
@@ -93,8 +95,9 @@
93
95
  "eslint-plugin-prettier": "^4.2.1",
94
96
  "husky": "^3.1.0",
95
97
  "jest": "^27.5.1",
96
- "jest-junit": "^13.2.0",
98
+ "jest-junit": "^16.0.0",
97
99
  "mocha": "^10.2.0",
100
+ "nock": "^13.3.0",
98
101
  "npm-license-crawler": "^0.2.1",
99
102
  "nyc": "^15.1.0",
100
103
  "pkg": "^5.6.0",
@@ -12,6 +12,7 @@ import chalk from 'chalk'
12
12
  import * as constants from '../../constants/constants'
13
13
  import { SeverityCountModel } from './models/severityCountModel'
14
14
  import * as common from '../../common/fail'
15
+ import { auditSave } from '../save'
15
16
 
16
17
  export function convertKeysToStandardFormat(config: any, guidance: any) {
17
18
  let convertedGuidance = guidance
@@ -96,6 +97,12 @@ export async function vulnerabilityReportV2(config: any, reportId: string) {
96
97
  : {}
97
98
  )
98
99
 
100
+ if (config.save !== undefined) {
101
+ await auditSave(config)
102
+ } else {
103
+ console.log('\nUse contrast audit --save to generate an SBOM')
104
+ }
105
+
99
106
  if (config.fail) {
100
107
  common.processFail(config, output[2])
101
108
  }
@@ -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
  }