@contrast/contrast 1.0.16 → 1.0.17

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 (59) hide show
  1. package/dist/audit/catalogueApplication/catalogueApplication.js +1 -1
  2. package/dist/cliConstants.js +6 -1
  3. package/dist/commands/audit/auditConfig.js +10 -12
  4. package/dist/commands/audit/auditController.js +12 -16
  5. package/dist/commands/audit/help.js +24 -26
  6. package/dist/commands/audit/processAudit.js +16 -22
  7. package/dist/commands/audit/saveFile.js +3 -9
  8. package/dist/commands/scan/processScan.js +5 -7
  9. package/dist/commands/scan/sca/scaAnalysis.js +104 -88
  10. package/dist/common/commonHelp.js +35 -17
  11. package/dist/common/errorHandling.js +28 -57
  12. package/dist/common/versionChecker.js +24 -27
  13. package/dist/constants/constants.js +1 -1
  14. package/dist/constants/locales.js +6 -3
  15. package/dist/lambda/help.js +2 -1
  16. package/dist/lambda/lambda.js +2 -7
  17. package/dist/scaAnalysis/java/analysis.js +40 -5
  18. package/dist/scaAnalysis/java/index.js +15 -2
  19. package/dist/scan/autoDetection.js +12 -3
  20. package/dist/scan/fileUtils.js +24 -1
  21. package/dist/scan/help.js +2 -1
  22. package/dist/scan/saveResults.js +1 -1
  23. package/dist/utils/commonApi.js +10 -1
  24. package/dist/utils/generalAPI.js +1 -2
  25. package/dist/utils/paramsUtil/configStoreParams.js +12 -1
  26. package/dist/utils/paramsUtil/paramHandler.js +7 -1
  27. package/dist/utils/saveFile.js +2 -1
  28. package/package.json +2 -1
  29. package/src/audit/catalogueApplication/catalogueApplication.js +1 -1
  30. package/src/cliConstants.js +6 -1
  31. package/src/commands/audit/auditConfig.js +19 -0
  32. package/src/commands/audit/{auditController.ts → auditController.js} +17 -12
  33. package/src/commands/audit/{help.ts → help.js} +10 -7
  34. package/src/commands/audit/processAudit.js +37 -0
  35. package/src/commands/audit/{saveFile.ts → saveFile.js} +2 -2
  36. package/src/commands/scan/processScan.js +4 -10
  37. package/src/commands/scan/sca/scaAnalysis.js +134 -116
  38. package/src/common/commonHelp.js +43 -0
  39. package/src/common/{errorHandling.ts → errorHandling.js} +6 -31
  40. package/src/common/{versionChecker.ts → versionChecker.js} +15 -10
  41. package/src/constants/constants.js +1 -1
  42. package/src/constants/locales.js +7 -3
  43. package/src/lambda/help.ts +2 -1
  44. package/src/lambda/lambda.ts +2 -10
  45. package/src/scaAnalysis/java/analysis.js +43 -10
  46. package/src/scaAnalysis/java/index.js +19 -2
  47. package/src/scan/autoDetection.js +14 -3
  48. package/src/scan/fileUtils.js +29 -1
  49. package/src/scan/help.js +2 -1
  50. package/src/scan/saveResults.js +1 -1
  51. package/src/utils/commonApi.js +13 -1
  52. package/src/utils/generalAPI.js +1 -2
  53. package/src/utils/getConfig.ts +1 -0
  54. package/src/utils/paramsUtil/configStoreParams.js +14 -1
  55. package/src/utils/paramsUtil/paramHandler.js +9 -1
  56. package/src/utils/saveFile.js +2 -1
  57. package/src/commands/audit/auditConfig.ts +0 -21
  58. package/src/commands/audit/processAudit.ts +0 -40
  59. package/src/common/commonHelp.ts +0 -13
@@ -39,7 +39,7 @@ const tryRetrieveAppIdFromMessages = messages => {
39
39
  return appId;
40
40
  };
41
41
  module.exports = {
42
- catalogueApplication: catalogueApplication,
42
+ catalogueApplication,
43
43
  doesMessagesContainAppId,
44
44
  tryRetrieveAppIdFromMessages
45
45
  };
@@ -295,6 +295,10 @@ const auditOptionDefinitions = [
295
295
  {
296
296
  name: 'maven-settings-path'
297
297
  },
298
+ {
299
+ name: 'fingerprint',
300
+ type: Boolean
301
+ },
298
302
  {
299
303
  name: 'organization-id',
300
304
  alias: 'o',
@@ -412,7 +416,8 @@ const mainUsageGuide = commandLineUsage([
412
416
  { name: i18n.__('clearHeader'), summary: i18n.__('clearContent') }
413
417
  ]
414
418
  },
415
- commonHelpLinks()
419
+ commonHelpLinks()[0],
420
+ commonHelpLinks()[1]
416
421
  ]);
417
422
  const mainDefinition = [{ name: 'command', defaultOption: true }];
418
423
  module.exports = {
@@ -1,15 +1,13 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getAuditConfig = void 0;
7
- const paramHandler_1 = __importDefault(require("../../utils/paramsUtil/paramHandler"));
8
- const cliConstants_1 = __importDefault(require("../../cliConstants"));
9
- const parsedCLIOptions_1 = require("../../utils/parsedCLIOptions");
2
+ const { getCommandLineArgsCustom } = require('../../utils/parsedCLIOptions');
3
+ const constants = require('../../cliConstants');
4
+ const paramHandler = require('../../utils/paramsUtil/paramHandler');
10
5
  const getAuditConfig = async (contrastConf, command, argv) => {
11
- const auditParameters = await (0, parsedCLIOptions_1.getCommandLineArgsCustom)(contrastConf, command, argv, cliConstants_1.default.commandLineDefinitions.auditOptionDefinitions);
12
- const paramsAuth = paramHandler_1.default.getAuth(auditParameters);
13
- return { ...paramsAuth, ...auditParameters };
6
+ const auditParameters = await getCommandLineArgsCustom(contrastConf, command, argv, constants.commandLineDefinitions.auditOptionDefinitions);
7
+ const paramsAuth = paramHandler.getAuth(auditParameters);
8
+ const javaAgreement = paramHandler.getAgreement();
9
+ return { ...paramsAuth, ...auditParameters, ...javaAgreement };
10
+ };
11
+ module.exports = {
12
+ getAuditConfig
14
13
  };
15
- exports.getAuditConfig = getAuditConfig;
@@ -1,23 +1,18 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getAppName = exports.dealWithNoAppId = void 0;
7
- const catalogueApplication_1 = require("../../audit/catalogueApplication/catalogueApplication");
8
- const commonApi_1 = __importDefault(require("../../audit/languageAnalysisEngine/commonApi"));
2
+ const catalogue = require('../../audit/catalogueApplication/catalogueApplication');
3
+ const commonApi = require('../../audit/languageAnalysisEngine/commonApi');
9
4
  const dealWithNoAppId = async (config) => {
10
5
  let appID;
11
6
  try {
12
- appID = await commonApi_1.default.returnAppId(config);
7
+ appID = await commonApi.returnAppId(config);
13
8
  if (!appID && config.applicationName) {
14
- return await (0, catalogueApplication_1.catalogueApplication)(config);
9
+ return await catalogue.catalogueApplication(config);
15
10
  }
16
11
  if (!appID && !config.applicationName) {
17
- config.applicationName = (0, exports.getAppName)(config.file);
18
- appID = await commonApi_1.default.returnAppId(config);
12
+ config.applicationName = getAppName(config.file);
13
+ appID = await commonApi.returnAppId(config);
19
14
  if (!appID) {
20
- return await (0, catalogueApplication_1.catalogueApplication)(config);
15
+ return await catalogue.catalogueApplication(config);
21
16
  }
22
17
  }
23
18
  }
@@ -30,8 +25,7 @@ const dealWithNoAppId = async (config) => {
30
25
  }
31
26
  return appID;
32
27
  };
33
- exports.dealWithNoAppId = dealWithNoAppId;
34
- const getAppName = (file) => {
28
+ const getAppName = file => {
35
29
  const last = file.charAt(file.length - 1);
36
30
  if (last !== '/') {
37
31
  return file.split('/').pop();
@@ -41,7 +35,9 @@ const getAppName = (file) => {
41
35
  return str.split('/').pop();
42
36
  }
43
37
  };
44
- exports.getAppName = getAppName;
45
- const removeLastChar = (str) => {
38
+ const removeLastChar = str => {
46
39
  return str.substring(0, str.length - 1);
47
40
  };
41
+ module.exports = {
42
+ dealWithNoAppId
43
+ };
@@ -1,36 +1,31 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.auditUsageGuide = void 0;
7
- const command_line_usage_1 = __importDefault(require("command-line-usage"));
8
- const i18n_1 = __importDefault(require("i18n"));
9
- const cliConstants_1 = __importDefault(require("../../cliConstants"));
10
- const commonHelp_1 = require("../../common/commonHelp");
11
- const auditUsageGuide = (0, command_line_usage_1.default)([
2
+ const commandLineUsage = require('command-line-usage');
3
+ const i18n = require('i18n');
4
+ const constants = require('../../cliConstants');
5
+ const { commonHelpLinks } = require('../../common/commonHelp');
6
+ const auditUsageGuide = commandLineUsage([
12
7
  {
13
- header: i18n_1.default.__('auditHeader'),
14
- content: [i18n_1.default.__('auditHeaderMessage')]
8
+ header: i18n.__('auditHeader'),
9
+ content: [i18n.__('auditHeaderMessage')]
15
10
  },
16
11
  {
17
- header: i18n_1.default.__('constantsPrerequisitesHeader'),
12
+ header: i18n.__('constantsPrerequisitesHeader'),
18
13
  content: [
19
14
  '{bold ' +
20
- i18n_1.default.__('constantsAuditPrerequisitesContentSupportedLanguages') +
15
+ i18n.__('constantsAuditPrerequisitesContentSupportedLanguages') +
21
16
  '}',
22
- i18n_1.default.__('constantsAuditPrerequisitesJavaContentMessage'),
23
- i18n_1.default.__('constantsAuditPrerequisitesContentDotNetMessage'),
24
- i18n_1.default.__('constantsAuditPrerequisitesContentNodeMessage'),
25
- i18n_1.default.__('constantsAuditPrerequisitesContentRubyMessage'),
26
- i18n_1.default.__('constantsAuditPrerequisitesContentPythonMessage'),
27
- i18n_1.default.__('constantsAuditPrerequisitesContentGoMessage'),
28
- i18n_1.default.__('constantsAuditPrerequisitesContentPHPMessage')
17
+ i18n.__('constantsAuditPrerequisitesJavaContentMessage'),
18
+ i18n.__('constantsAuditPrerequisitesContentDotNetMessage'),
19
+ i18n.__('constantsAuditPrerequisitesContentNodeMessage'),
20
+ i18n.__('constantsAuditPrerequisitesContentRubyMessage'),
21
+ i18n.__('constantsAuditPrerequisitesContentPythonMessage'),
22
+ i18n.__('constantsAuditPrerequisitesContentGoMessage'),
23
+ i18n.__('constantsAuditPrerequisitesContentPHPMessage')
29
24
  ]
30
25
  },
31
26
  {
32
- header: i18n_1.default.__('constantsAuditOptions'),
33
- optionList: cliConstants_1.default.commandLineDefinitions.auditOptionDefinitions,
27
+ header: i18n.__('constantsAuditOptions'),
28
+ optionList: constants.commandLineDefinitions.auditOptionDefinitions,
34
29
  hide: [
35
30
  'application-id',
36
31
  'application-name',
@@ -54,9 +49,12 @@ const auditUsageGuide = (0, command_line_usage_1.default)([
54
49
  'app-groups',
55
50
  'metadata',
56
51
  'track',
57
- 'branch'
52
+ 'fingerprint'
58
53
  ]
59
54
  },
60
- (0, commonHelp_1.commonHelpLinks)()
55
+ commonHelpLinks()[0],
56
+ commonHelpLinks()[1]
61
57
  ]);
62
- exports.auditUsageGuide = auditUsageGuide;
58
+ module.exports = {
59
+ auditUsageGuide
60
+ };
@@ -1,30 +1,24 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.processAudit = void 0;
7
- const auditConfig_1 = require("./auditConfig");
8
- const help_1 = require("./help");
9
- const scaAnalysis_1 = require("../scan/sca/scaAnalysis");
10
- const telemetry_1 = require("../../telemetry/telemetry");
11
- const chalk_1 = __importDefault(require("chalk"));
12
- const processAudit = async (contrastConf, argv) => {
13
- if (argv.indexOf('--help') != -1) {
2
+ const auditConfig = require('./auditConfig');
3
+ const { auditUsageGuide } = require('./help');
4
+ const scaController = require('../scan/sca/scaAnalysis');
5
+ const { sendTelemetryConfigAsObject } = require('../../telemetry/telemetry');
6
+ const { postRunMessage } = require('../../common/commonHelp');
7
+ const processAudit = async (contrastConf, argvMain) => {
8
+ if (argvMain.indexOf('--help') !== -1) {
14
9
  printHelpMessage();
15
10
  process.exit(0);
16
11
  }
17
- const config = await (0, auditConfig_1.getAuditConfig)(contrastConf, 'audit', argv);
18
- await (0, scaAnalysis_1.processSca)(config);
19
- postRunMessage();
20
- await (0, telemetry_1.sendTelemetryConfigAsObject)(config, 'audit', argv, 'SUCCESS', config.language);
12
+ const config = await auditConfig.getAuditConfig(contrastConf, 'audit', argvMain);
13
+ await scaController.processSca(config);
14
+ if (!config.fingerprint) {
15
+ postRunMessage('audit');
16
+ await sendTelemetryConfigAsObject(config, 'audit', argvMain, 'SUCCESS', config.language);
17
+ }
21
18
  };
22
- exports.processAudit = processAudit;
23
19
  const printHelpMessage = () => {
24
- console.log(help_1.auditUsageGuide);
20
+ console.log(auditUsageGuide);
25
21
  };
26
- const postRunMessage = () => {
27
- console.log('\n' + chalk_1.default.underline.bold('Other Codesec Features:'));
28
- console.log("'contrast scan' to run CodeSec’s industry leading SAST scanner");
29
- console.log("'contrast lambda' to secure your AWS serverless functions\n");
22
+ module.exports = {
23
+ processAudit
30
24
  };
@@ -1,15 +1,9 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.saveFile = void 0;
7
- const fs_1 = __importDefault(require("fs"));
2
+ const fs = require('fs');
8
3
  const saveFile = (config, type, rawResults) => {
9
4
  const fileName = `${config.applicationId}-sbom-${type}.json`;
10
- fs_1.default.writeFileSync(fileName, JSON.stringify(rawResults));
5
+ fs.writeFileSync(fileName, JSON.stringify(rawResults));
11
6
  };
12
- exports.saveFile = saveFile;
13
7
  module.exports = {
14
- saveFile: exports.saveFile
8
+ saveFile
15
9
  };
@@ -6,7 +6,7 @@ const { ScanResultsModel } = require('../../scan/models/scanResultsModel');
6
6
  const { formatScanOutput } = require('../../scan/formatScanOutput');
7
7
  const common = require('../../common/fail');
8
8
  const { sendTelemetryConfigAsObject } = require('../../telemetry/telemetry');
9
- const chalk = require('chalk');
9
+ const { postRunMessage } = require('../../common/commonHelp');
10
10
  const processScan = async (contrastConf, argv) => {
11
11
  let config = await scanConfig.getScanConfig(contrastConf, 'scan', argv);
12
12
  let output = undefined;
@@ -18,15 +18,13 @@ const processScan = async (contrastConf, argv) => {
18
18
  if (config.save !== undefined) {
19
19
  await saveScanFile(config, scanResults);
20
20
  }
21
+ else {
22
+ console.log('\nUse contrast scan --save to save results as a SARIF');
23
+ }
21
24
  if (config.fail) {
22
25
  common.processFail(config, output);
23
26
  }
24
- postRunMessage();
25
- };
26
- const postRunMessage = () => {
27
- console.log('\n' + chalk.underline.bold('Other Codesec Features:'));
28
- console.log("'contrast audit' to find vulnerabilities in your open source dependencies");
29
- console.log("'contrast lambda' to secure your AWS serverless functions\n");
27
+ postRunMessage('scan');
30
28
  };
31
29
  module.exports = {
32
30
  processScan
@@ -11,7 +11,7 @@ const path = require('path');
11
11
  const i18n = require('i18n');
12
12
  const auditSave = require('../../../audit/save');
13
13
  const { auditUsageGuide } = require('../../audit/help');
14
- const { buildRepo } = require('../../../scaAnalysis/repoMode/index');
14
+ const repoMode = require('../../../scaAnalysis/repoMode/index');
15
15
  const { dotNetAnalysis } = require('../../../scaAnalysis/dotnet');
16
16
  const { goAnalysis } = require('../../../scaAnalysis/go/goAnalysis');
17
17
  const { phpAnalysis } = require('../../../scaAnalysis/php/index');
@@ -23,6 +23,7 @@ const auditReport = require('../../../scaAnalysis/common/auditReport');
23
23
  const scaUpload = require('../../../scaAnalysis/common/scaServicesUpload');
24
24
  const settingsHelper = require('../../../utils/settingsHelper');
25
25
  const chalk = require('chalk');
26
+ const saveResults = require('../../../scan/saveResults');
26
27
  const processSca = async (config) => {
27
28
  config = await settingsHelper.getSettings(config);
28
29
  const startTime = performance.now();
@@ -37,99 +38,114 @@ const processSca = async (config) => {
37
38
  config.file = pathWithFile
38
39
  ? rootFile.getDirectoryFromPathGiven(config.file).concat('/')
39
40
  : config.file;
40
- filesFound = await autoDetection.autoDetectAuditFilesAndLanguages(config.file);
41
- if (filesFound.length > 1 && pathWithFile) {
42
- filesFound = filesFound.filter(i => Object.values(i)[0].includes(path.basename(config.fileName)));
41
+ if (config.fingerprint && config.experimental) {
42
+ let fingerprint = await autoDetection.autoDetectFingerprintInfo(config.file);
43
+ let idArray = fingerprint.map(x => x.id);
44
+ await saveResults.writeResultsToFile(fingerprint, 'fingerPrintInfo.json');
45
+ console.log(idArray);
43
46
  }
44
- if (config.mode === 'repo') {
45
- try {
46
- return buildRepo(config, filesFound[0]);
47
- }
48
- catch (e) {
49
- console.log('Unable to build in repository mode. Check your project file');
50
- process.exit(0);
51
- }
52
- }
53
- let messageToSend = undefined;
54
- if (filesFound.length === 1) {
55
- switch (Object.keys(filesFound[0])[0]) {
56
- case JAVA:
57
- messageToSend = javaAnalysis.javaAnalysis(config, filesFound[0]);
58
- config.language = JAVA;
59
- break;
60
- case JAVASCRIPT:
61
- messageToSend = await jsAnalysis.jsAnalysis(config, filesFound[0]);
62
- config.language = NODE;
63
- break;
64
- case PYTHON:
65
- messageToSend = pythonAnalysis(config, filesFound[0]);
66
- config.language = PYTHON;
67
- break;
68
- case RUBY:
69
- messageToSend = rubyAnalysis(config, filesFound[0]);
70
- config.language = RUBY;
71
- break;
72
- case PHP:
73
- messageToSend = phpAnalysis(config, filesFound[0]);
74
- config.language = PHP;
75
- break;
76
- case GO:
77
- messageToSend = goAnalysis(config, filesFound[0]);
78
- config.language = GO;
79
- break;
80
- case DOTNET:
81
- messageToSend = dotNetAnalysis(config, filesFound[0]);
82
- config.language = DOTNET;
83
- break;
84
- default:
85
- console.log('No supported language detected in project path');
86
- return;
87
- }
88
- if (!config.applicationId) {
89
- config.applicationId = await auditController.dealWithNoAppId(config);
47
+ else {
48
+ filesFound = await autoDetection.autoDetectAuditFilesAndLanguages(config.file);
49
+ if (filesFound.length > 1 && pathWithFile) {
50
+ filesFound = filesFound.filter(i => Object.values(i)[0].includes(path.basename(config.fileName)));
90
51
  }
91
- if (config.experimental) {
92
- console.log('');
93
- const reportSpinner = returnOra(i18n.__('auditSCAAnalysisBegins'));
94
- startSpinner(reportSpinner);
95
- const [reports, reportId] = await scaUpload.scaTreeUpload(messageToSend, config);
96
- auditReport.processAuditReport(config, reports[0]);
97
- succeedSpinner(reportSpinner, i18n.__('auditSCAAnalysisComplete'));
98
- if (config.save !== undefined) {
99
- await auditSave.auditSave(config, reportId);
52
+ let messageToSend = undefined;
53
+ if (filesFound.length === 1) {
54
+ switch (Object.keys(filesFound[0])[0]) {
55
+ case JAVA:
56
+ config.language = JAVA;
57
+ if (config.mode === 'repo') {
58
+ try {
59
+ return repoMode.buildRepo(config, filesFound[0]);
60
+ }
61
+ catch (e) {
62
+ throw new Error('Unable to build in repository mode. Check your project file');
63
+ }
64
+ }
65
+ else {
66
+ messageToSend = await javaAnalysis.javaAnalysis(config, filesFound[0]);
67
+ }
68
+ break;
69
+ case JAVASCRIPT:
70
+ messageToSend = await jsAnalysis.jsAnalysis(config, filesFound[0]);
71
+ config.language = NODE;
72
+ break;
73
+ case PYTHON:
74
+ messageToSend = pythonAnalysis(config, filesFound[0]);
75
+ config.language = PYTHON;
76
+ break;
77
+ case RUBY:
78
+ messageToSend = rubyAnalysis(config, filesFound[0]);
79
+ config.language = RUBY;
80
+ break;
81
+ case PHP:
82
+ messageToSend = phpAnalysis(config, filesFound[0]);
83
+ config.language = PHP;
84
+ break;
85
+ case GO:
86
+ messageToSend = goAnalysis(config, filesFound[0]);
87
+ config.language = GO;
88
+ break;
89
+ case DOTNET:
90
+ messageToSend = dotNetAnalysis(config, filesFound[0]);
91
+ config.language = DOTNET;
92
+ break;
93
+ default:
94
+ console.log('No supported language detected in project path');
95
+ return;
100
96
  }
101
- const endTime = performance.now() - startTime;
102
- const scanDurationMs = endTime - startTime;
103
- console.log(`----- completed in ${(scanDurationMs / 1000).toFixed(2)}s -----`);
104
- }
105
- else {
106
- console.log('');
107
- const reportSpinner = returnOra(i18n.__('auditSCAAnalysisBegins'));
108
- startSpinner(reportSpinner);
109
- const snapshotResponse = await treeUpload.commonSendSnapShot(messageToSend, config);
110
- await pollForSnapshotCompletion(config, snapshotResponse.id, reportSpinner);
111
- succeedSpinner(reportSpinner, i18n.__('auditSCAAnalysisComplete'));
112
- await vulnerabilityReportV2(config, snapshotResponse.id);
113
- if (config.save !== undefined) {
114
- await auditSave.auditSave(config);
97
+ if (!config.applicationId) {
98
+ config.applicationId = await auditController.dealWithNoAppId(config);
99
+ }
100
+ if (config.experimental) {
101
+ console.log('');
102
+ const reportSpinner = returnOra(i18n.__('auditSCAAnalysisBegins'));
103
+ startSpinner(reportSpinner);
104
+ const [reports, reportId] = await scaUpload.scaTreeUpload(messageToSend, config);
105
+ auditReport.processAuditReport(config, reports[0]);
106
+ succeedSpinner(reportSpinner, i18n.__('auditSCAAnalysisComplete'));
107
+ if (config.save !== undefined) {
108
+ await auditSave.auditSave(config, reportId);
109
+ }
110
+ else {
111
+ console.log('Use contrast audit --save to generate an SBOM');
112
+ }
113
+ const endTime = performance.now() - startTime;
114
+ const scanDurationMs = endTime - startTime;
115
+ console.log(`----- completed in ${(scanDurationMs / 1000).toFixed(2)}s -----`);
116
+ }
117
+ else {
118
+ console.log('');
119
+ const reportSpinner = returnOra(i18n.__('auditSCAAnalysisBegins'));
120
+ startSpinner(reportSpinner);
121
+ const snapshotResponse = await treeUpload.commonSendSnapShot(messageToSend, config);
122
+ await pollForSnapshotCompletion(config, snapshotResponse.id, reportSpinner);
123
+ succeedSpinner(reportSpinner, i18n.__('auditSCAAnalysisComplete'));
124
+ await vulnerabilityReportV2(config, snapshotResponse.id);
125
+ if (config.save !== undefined) {
126
+ await auditSave.auditSave(config);
127
+ }
128
+ else {
129
+ console.log('\nUse contrast audit --save to generate an SBOM');
130
+ }
131
+ const endTime = performance.now() - startTime;
132
+ const scanDurationMs = endTime - startTime;
133
+ console.log(`----- completed in ${(scanDurationMs / 1000).toFixed(2)}s -----`);
115
134
  }
116
- const endTime = performance.now() - startTime;
117
- const scanDurationMs = endTime - startTime;
118
- console.log(`----- completed in ${(scanDurationMs / 1000).toFixed(2)}s -----`);
119
- }
120
- }
121
- else {
122
- if (filesFound.length === 0) {
123
- console.log(i18n.__('languageAnalysisNoLanguage'));
124
- console.log(i18n.__('languageAnalysisNoLanguageHelpLine'));
125
- throw new Error();
126
135
  }
127
136
  else {
128
- console.log(chalk.bold(`\nMultiple language files detected \n`));
129
- filesFound.forEach(file => {
130
- console.log(`${Object.keys(file)[0]} : `, Object.values(file)[0]);
131
- });
132
- throw new Error(`Please use --file to audit one language only. \nExample: contrast audit --file package-lock.json`);
137
+ if (filesFound.length === 0) {
138
+ console.log(i18n.__('languageAnalysisNoLanguage'));
139
+ console.log(i18n.__('languageAnalysisNoLanguageHelpLine'));
140
+ throw new Error();
141
+ }
142
+ else {
143
+ console.log(chalk.bold(`\nMultiple language files detected \n`));
144
+ filesFound.forEach(file => {
145
+ console.log(`${Object.keys(file)[0]} : `, Object.values(file)[0]);
146
+ });
147
+ throw new Error(`Please use --file to audit one language only. \nExample: contrast audit --file package-lock.json`);
148
+ }
133
149
  }
134
150
  }
135
151
  };
@@ -1,19 +1,37 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+ const i18n = require('i18n');
3
+ const chalk = require('chalk');
4
+ const commonHelpLinks = () => {
5
+ return [
6
+ {
7
+ header: i18n.__('commonHelpHeader'),
8
+ content: [
9
+ i18n.__('commonHelpCheckOutHeader') + i18n.__('commonHelpCheckOutText'),
10
+ i18n.__('commonHelpLearnMoreHeader') +
11
+ i18n.__('commonHelpLearnMoreText'),
12
+ i18n.__('commonHelpJoinDiscussionHeader') +
13
+ i18n.__('commonHelpJoinDiscussionText')
14
+ ]
15
+ },
16
+ {
17
+ header: i18n.__('commonHelpEnterpriseHeader'),
18
+ content: [
19
+ i18n.__('commonHelpLearnMoreEnterpriseHeader') +
20
+ i18n.__('commonHelpLearnMoreEnterpriseText')
21
+ ]
22
+ }
23
+ ];
24
+ };
25
+ const postRunMessage = commandName => {
26
+ console.log('\n' + chalk.underline.bold('Other Features:'));
27
+ if (commandName !== 'scan')
28
+ console.log("'contrast scan' to run Contrasts’ industry leading SAST scanner");
29
+ if (commandName !== 'audit')
30
+ console.log("'contrast audit' to find vulnerabilities in your open source dependencies");
31
+ if (commandName !== 'lambda')
32
+ console.log("'contrast lambda' to secure your AWS serverless functions");
33
+ };
34
+ module.exports = {
35
+ commonHelpLinks,
36
+ postRunMessage
4
37
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.commonHelpLinks = void 0;
7
- const i18n_1 = __importDefault(require("i18n"));
8
- function commonHelpLinks() {
9
- return {
10
- header: i18n_1.default.__('commonHelpHeader'),
11
- content: [
12
- i18n_1.default.__('commonHelpCheckOutHeader') + i18n_1.default.__('commonHelpCheckOutText'),
13
- i18n_1.default.__('commonHelpLearnMoreHeader') + i18n_1.default.__('commonHelpLearnMoreText'),
14
- i18n_1.default.__('commonHelpJoinDiscussionHeader') +
15
- i18n_1.default.__('commonHelpJoinDiscussionText')
16
- ]
17
- };
18
- }
19
- exports.commonHelpLinks = commonHelpLinks;