@contrast/contrast 1.0.1 → 1.0.4

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 (94) hide show
  1. package/.prettierignore +2 -0
  2. package/README.md +103 -133
  3. package/dist/audit/languageAnalysisEngine/{langugageAnalysisFactory.js → languageAnalysisFactory.js} +26 -11
  4. package/dist/audit/languageAnalysisEngine/report/commonReportingFunctions.js +62 -234
  5. package/dist/audit/languageAnalysisEngine/report/models/reportLibraryModel.js +19 -0
  6. package/dist/audit/languageAnalysisEngine/report/models/reportListModel.js +24 -0
  7. package/dist/audit/languageAnalysisEngine/report/models/reportSeverityModel.js +10 -0
  8. package/dist/audit/languageAnalysisEngine/report/reportingFeature.js +24 -129
  9. package/dist/audit/languageAnalysisEngine/report/utils/reportUtils.js +85 -0
  10. package/dist/audit/languageAnalysisEngine/sendSnapshot.js +3 -1
  11. package/dist/commands/audit/auditController.js +6 -3
  12. package/dist/commands/audit/saveFile.js +11 -0
  13. package/dist/commands/auth/auth.js +19 -1
  14. package/dist/commands/config/config.js +19 -8
  15. package/dist/commands/scan/processScan.js +8 -25
  16. package/dist/common/HTTPClient.js +30 -26
  17. package/dist/common/errorHandling.js +17 -1
  18. package/dist/common/versionChecker.js +32 -0
  19. package/dist/constants/constants.js +4 -2
  20. package/dist/constants/lambda.js +3 -1
  21. package/dist/constants/locales.js +41 -18
  22. package/dist/constants.js +39 -3
  23. package/dist/index.js +49 -28
  24. package/dist/lambda/help.js +22 -14
  25. package/dist/lambda/lambda.js +6 -0
  26. package/dist/sbom/generateSbom.js +20 -0
  27. package/dist/scan/help.js +4 -2
  28. package/dist/scan/models/groupedResultsModel.js +10 -0
  29. package/dist/scan/models/resultContentModel.js +2 -0
  30. package/dist/scan/models/scanResultsModel.js +11 -0
  31. package/dist/scan/populateProjectIdAndProjectName.js +1 -0
  32. package/dist/scan/saveResults.js +9 -10
  33. package/dist/scan/scan.js +99 -74
  34. package/dist/scan/scanConfig.js +20 -1
  35. package/dist/scan/scanController.js +7 -2
  36. package/dist/scan/scanResults.js +6 -0
  37. package/dist/utils/getConfig.js +3 -0
  38. package/dist/utils/paramsUtil/commandlineParams.js +1 -1
  39. package/dist/utils/requestUtils.js +1 -1
  40. package/dist/utils/saveFile.js +19 -0
  41. package/package.json +2 -2
  42. package/src/audit/languageAnalysisEngine/{langugageAnalysisFactory.js → languageAnalysisFactory.js} +33 -15
  43. package/src/audit/languageAnalysisEngine/report/commonReportingFunctions.ts +127 -0
  44. package/src/audit/languageAnalysisEngine/report/models/reportLibraryModel.ts +30 -0
  45. package/src/audit/languageAnalysisEngine/report/models/reportListModel.ts +32 -0
  46. package/src/audit/languageAnalysisEngine/report/models/reportSeverityModel.ts +9 -0
  47. package/src/audit/languageAnalysisEngine/report/reportingFeature.ts +56 -0
  48. package/src/audit/languageAnalysisEngine/report/utils/reportUtils.ts +110 -0
  49. package/src/audit/languageAnalysisEngine/sendSnapshot.js +3 -1
  50. package/src/commands/audit/auditController.ts +12 -3
  51. package/src/commands/audit/processAudit.ts +0 -1
  52. package/src/commands/audit/saveFile.ts +6 -0
  53. package/src/commands/auth/auth.js +25 -1
  54. package/src/commands/config/config.js +22 -8
  55. package/src/commands/scan/processScan.js +8 -29
  56. package/src/common/HTTPClient.js +42 -36
  57. package/src/common/errorHandling.ts +29 -2
  58. package/src/common/versionChecker.ts +41 -0
  59. package/src/constants/constants.js +5 -4
  60. package/src/constants/lambda.js +3 -1
  61. package/src/constants/locales.js +51 -19
  62. package/src/constants.js +44 -3
  63. package/src/index.ts +63 -31
  64. package/src/lambda/help.ts +22 -14
  65. package/src/lambda/lambda.ts +8 -0
  66. package/src/sbom/generateSbom.ts +17 -0
  67. package/src/scan/help.js +4 -2
  68. package/src/scan/models/groupedResultsModel.ts +18 -0
  69. package/src/scan/models/resultContentModel.ts +86 -0
  70. package/src/scan/models/scanResultsModel.ts +52 -0
  71. package/src/scan/populateProjectIdAndProjectName.js +1 -0
  72. package/src/scan/saveResults.js +8 -9
  73. package/src/scan/scan.ts +192 -0
  74. package/src/scan/scanConfig.js +26 -1
  75. package/src/scan/scanController.js +11 -2
  76. package/src/scan/scanResults.js +11 -0
  77. package/src/utils/getConfig.ts +12 -0
  78. package/src/utils/paramsUtil/commandlineParams.js +1 -1
  79. package/src/utils/requestUtils.js +1 -1
  80. package/src/utils/saveFile.js +19 -0
  81. package/dist/audit/languageAnalysisEngine/report/checkIgnoreDevDep.js +0 -17
  82. package/dist/audit/languageAnalysisEngine/report/newReportingFeature.js +0 -81
  83. package/dist/common/findLatestCLIVersion.js +0 -23
  84. package/dist/lambda/scanDetail.js +0 -30
  85. package/dist/scan/fileFinder.js +0 -15
  86. package/dist/utils/fileUtils.js +0 -31
  87. package/dist/utils/paramsUtil/genericCommandLineParams.js +0 -12
  88. package/dist/utils/paramsUtil/yamlParams.js +0 -6
  89. package/src/audit/languageAnalysisEngine/report/checkIgnoreDevDep.js +0 -27
  90. package/src/audit/languageAnalysisEngine/report/commonReportingFunctions.js +0 -303
  91. package/src/audit/languageAnalysisEngine/report/newReportingFeature.js +0 -124
  92. package/src/audit/languageAnalysisEngine/report/reportingFeature.js +0 -190
  93. package/src/common/findLatestCLIVersion.ts +0 -27
  94. package/src/scan/scan.js +0 -162
@@ -12,10 +12,11 @@ const MEDIUM = 'MEDIUM';
12
12
  const HIGH = 'HIGH';
13
13
  const CRITICAL = 'CRITICAL';
14
14
  const APP_NAME = 'contrast';
15
- const APP_VERSION = '1.0.1';
15
+ const APP_VERSION = '1.0.4';
16
16
  const TIMEOUT = 120000;
17
17
  const AUTH_UI_URL = 'https://cli-auth.contrastsecurity.com';
18
18
  const AUTH_CALLBACK_URL = 'https://cli-auth-api.contrastsecurity.com';
19
+ const SARIF_FILE = 'SARIF';
19
20
  module.exports = {
20
21
  supportedLanguages: { NODE, DOTNET, JAVA, RUBY, PYTHON, GO, PHP, JAVASCRIPT },
21
22
  LOW,
@@ -26,5 +27,6 @@ module.exports = {
26
27
  APP_NAME,
27
28
  TIMEOUT,
28
29
  AUTH_UI_URL,
29
- AUTH_CALLBACK_URL
30
+ AUTH_CALLBACK_URL,
31
+ SARIF_FILE
30
32
  };
@@ -25,9 +25,11 @@ const lambda = {
25
25
  loadingFunctionList: 'Loading lambda function list',
26
26
  functionsFound: '{{count}} functions found',
27
27
  noFunctionsFound: 'No functions found',
28
- failedToLoadFunctions: 'Faled to load lambda functions',
28
+ failedToLoadFunctions: 'Failed to load lambda functions',
29
29
  availableForScan: '{{icon}} {{count}} available for scan',
30
30
  runtimeCount: '----- {{runtime}} ({{count}}) -----',
31
+ gatherResults: 'Gathering results...',
32
+ doneGatherResults: 'Done gathering results',
31
33
  whatHappenedTitle: 'What happened:',
32
34
  whatHappenedItem: '{{policy}} have:\n{{comments}}\n',
33
35
  recommendation: 'Recommendation:',
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  const { lambda } = require('./lambda');
3
+ const chalk = require('chalk');
3
4
  const en_locales = () => {
4
5
  return {
5
6
  successHeader: 'SUCCESS',
@@ -9,8 +10,6 @@ const en_locales = () => {
9
10
  snapshotHostMessage: " No host supplied. Using default host 'app.contrastsecurity.com'. Please ensure this is correct.",
10
11
  vulnerabilitiesSuccessMessage: ' Vulnerability data successfully retrieved',
11
12
  vulnerabilitiesFailureMessage: ' Unable to retrieve library vulnerabilities from Team Server.',
12
- reportSuccessMessage: ' Report successfully retrieved',
13
- reportFailureMessage: ' Unable to generate library report.',
14
13
  catchErrorMessage: 'Contrast UI error: ',
15
14
  dependenciesNote: 'Please Note: We currently only support projects with one .csproj AND *.package.lock.json',
16
15
  languageAnalysisFailureMessage: 'LANGUAGE ANALYSIS FAILED',
@@ -108,17 +107,22 @@ const en_locales = () => {
108
107
  failOptionErrorMessage: " FAIL - CVE's have been detected that match at least the cve_severity or cve_threshold option specified.",
109
108
  constantsSeverity: 'Combined with the --report command, allows the user to report libraries with vulnerabilities above a chosen severity level. For example, cve_severity medium only reports libraries with vulnerabilities at medium or higher severity. Values for level are high, medium or low.',
110
109
  constantsCount: "The number of CVE's that must be exceeded to fail a build",
111
- constantsHeader: 'Contrast CLI',
110
+ constantsHeader: 'CodeSec by Contrast Security',
112
111
  constantsPrerequisitesContentScanLanguages: 'Java & JavaScript supported',
113
- constantsContrastContent: 'Use the Contrast CLI, the fastest and most accurate code scan, to help find and eliminate security bugs in your code.',
112
+ constantsContrastContent: 'Use the Contrast CLI to run a scan (Java, JavaScript and .NET ) or lambda command (Java and Python) to find your vulnerabilities and start securing your code.',
114
113
  constantsUsageGuideContentRecommendation: 'Our recommendation is that this is invoked as part of a CI pipeline so that running the cli is automated as part of your build process.',
115
114
  constantsPrerequisitesHeader: 'Pre-requisites',
115
+ constantsAuthUsageHeader: 'Usage',
116
+ constantsAuthUsageContents: 'contrast auth',
117
+ constantsAuthHeaderContents: 'Authorize with external identity provider to perform scans on code',
118
+ configHeader: 'Config',
119
+ constantsConfigUsageContents: 'view / clear the configuration',
116
120
  constantsPrerequisitesContent: 'To scan a Java project you will need a .jar or .war file for analysis\n' +
117
121
  'To scan a Javascript project you will need a .js or.zip file for analysis\n' +
118
122
  'To scan a .NET c# webforms project you will need a .exe or a .zip file for analysis\n',
119
123
  constantsUsage: 'Usage',
120
124
  constantsUsageCommandExample: 'contrast [command] [options]',
121
- constantsUsageCommandInfo: 'The file argument is optional. If no file is given, Contrast will search for a .jar, .war, .js, .exe or .zip file in the working directory.\n',
125
+ constantsUsageCommandInfo: 'The file argument is optional. If no file is given, Contrast will search for a .jar, .war, .exe or .zip file in the working directory.\n',
122
126
  constantsUsageCommandInfo24Hours: 'Submitted files are encrypted during upload and deleted in 24 hours.',
123
127
  constantsAnd: 'AND',
124
128
  constantsJava: 'AND Maven build platform, including the dependency plugin. For a Gradle project, use build.gradle. A gradle-wrapper.properties file is also required. Kotlin is also supported requiring a build.gradle.kts file.',
@@ -169,7 +173,8 @@ const en_locales = () => {
169
173
  constantsTags: 'Apply labels to an application. Labels must be formatted as a comma-delimited list. Example - label1,label2,label3',
170
174
  constantsCode: 'Add the application code this application should use in the Contrast UI',
171
175
  constantsIgnoreCertErrors: ' For EOP users with a local Teamserver install, this will bypass the SSL certificate and recognise a self signed certificate.',
172
- constantsSave: ' Saves the Scan Results JSON to file.',
176
+ constantsSave: ' Saves the Scan Results SARIF to file.',
177
+ scanLabel: "adds a label to the scan - defaults to 'Started by CLI tool at current date'",
173
178
  constantsIgnoreDev: 'Combined with the --report command excludes developer dependencies from the vulnerabilities report. By default all dependencies are included in a report.',
174
179
  constantsCommands: 'Commands',
175
180
  constantsScanOptions: 'Scan Options',
@@ -178,7 +183,7 @@ const en_locales = () => {
178
183
  ignoreDevDep: 'No private libraries that are not scoped detected',
179
184
  foundExistingProjectScan: 'Found existing project...',
180
185
  projectCreatedScan: 'Project created',
181
- uploadingScan: 'Uploading...',
186
+ uploadingScan: 'Uploading file to scan.',
182
187
  uploadingScanSuccessful: 'Uploaded file successfully.',
183
188
  uploadingScanFail: 'Unable to upload the file.',
184
189
  waitingTimedOut: 'Timed out.',
@@ -187,10 +192,12 @@ const en_locales = () => {
187
192
  noFileFoundScan: "We could't find a suitable file in your directories (we go 3 deep)",
188
193
  specifyFileScanError: 'Java Scan requires a .war or .jar file. Javascript Scan requires a .js or .zip file.\nTo start a Scan enter "contrast scan -f <path-to-file>"',
189
194
  populateProjectIdMessage: 'project ID is %s',
195
+ genericServiceError: 'returned with status code %s',
196
+ projectIdError: 'Your project ID is %s please check this is correct',
190
197
  permissionsError: 'You do not have the correct permissions here. \n Contact support@contrastsecurity.com to get this fixed.',
191
198
  scanErrorFileMessage: 'We only accept the following file types: \nJava - .jar, .war \nJavaScript - .js or .zip files',
192
199
  helpAuthSummary: 'Authenticate Contrast using your Github or Google account',
193
- helpScanSummary: 'Searches for a .jar, .war, .js or .zip file in the working directory, uploads for analysis and returns the results',
200
+ helpScanSummary: 'Perform static analysis on binaries / code artifacts',
194
201
  helpLambdaSummary: 'Perform scan on AWS Lambda functions',
195
202
  helpVersionSummary: 'Displays version of Contrast CLI',
196
203
  helpConfigSummary: 'Displays stored credentials',
@@ -201,30 +208,39 @@ const en_locales = () => {
201
208
  versionName: 'version',
202
209
  configName: 'config',
203
210
  helpName: 'help',
211
+ scanOptionsLanguageSummary: 'Valid values are JAVA, JAVASCRIPT and DOTNET',
204
212
  scanOptionsLanguageSummaryOptional: 'Language of file to send for analysis. ',
205
213
  scanOptionsLanguageSummaryRequired: 'If you scan a .zip file or you use the --file option.',
206
214
  scanOptionsTimeoutSummary: 'Time in seconds to wait for scan to complete. Default value is 300 seconds.',
207
- scanOptionsFileNameSummary: 'Path of the file you want to scan. If no file is specified, Contrast searches for a .jar, .war, .js, .exe or .zip file in the working directory.',
215
+ scanOptionsFileNameSummary: '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.',
208
216
  scanOptionsVerboseSummary: ' Returns extended information to the terminal.',
209
217
  authSuccessMessage: 'Authentication successful',
210
- runAuthSuccessMessage: 'Now you can use Contrast CLI',
218
+ runAuthSuccessMessage: "Now you can use Contrast CLI \nRun 'contrast scan' on your file \n" +
219
+ "or 'contrast help' to learn more about the capabilities.",
211
220
  authWaitingMessage: 'Waiting for auth...',
212
221
  authTimedOutMessage: 'Auth Timed out, try again',
213
222
  zipErrorScan: 'We only support zip files for JAVASCRIPT language, please set the flag --language JAVASCRIPT',
214
223
  unknownFileErrorScan: 'Unsupported file selected for Scan.',
215
- foundScanFile: 'found: %s',
216
- foundDetailedVulnerabilities: '%s Critical %s High %s Medium %s Low %s Note',
224
+ foundScanFile: 'Found: %s',
225
+ foundDetailedVulnerabilities: chalk.bold('%s Critical') +
226
+ ' | ' +
227
+ chalk.bold('%s High') +
228
+ ' | %s Medium | %s Low | %s Note',
217
229
  requiredParams: 'All required parameters are not present.',
218
230
  timeoutScan: 'Timeout set to 5 minutes.',
219
231
  searchingScanFileDirectory: 'Searching for file to scan from %s...',
220
232
  scanHeader: 'Contrast Scan CLI',
221
- lambdaHeader: 'Contrast lambda help',
233
+ authHeader: 'Auth',
234
+ lambdaHeader: 'Contrast Lambda CLI',
222
235
  lambdaSummary: 'Performs static security scan on an AWS Lambda Function.\nProduces CVE (Vulnerable Dependencies) and Least Privilege violations/remediation results.',
223
236
  lambdaUsage: 'contrast lambda --function-name <function> [options]',
224
- lambdaPrerequisitesContent: 'contrast cli',
225
- scanFileNameOption: ' -f, --file',
226
- lambdaFunctionNameOption: ' -f, --function-name',
227
- lambdaListFunctionsOption: ' -l, --list-functions',
237
+ lambdaPrerequisitesContent: '',
238
+ lambdaPrerequisitesContentLambdaLanguages: 'Supported runtimes: Java & Python',
239
+ lambdaPrerequisitesContentLambdaDescriptionTitle: 'AWS Requirements\n',
240
+ lambdaPrerequisitesContentLambdaDescription: 'Make sure you have the AWS credentials configured on your local environment. \nYou need the following AWS permissions configured on your IAM user:\n - Lambda: GetFunction, GetLayerVersionֿ\n - IAM: GetRolePolicy, GetPolicy, GetPolicyVersion, ListRolePolicies, ListAttachedRolePolicies',
241
+ scanFileNameOption: '-f, --file',
242
+ lambdaFunctionNameOption: '-f, --function-name',
243
+ lambdaListFunctionsOption: '-l, --list-functions',
228
244
  lambdaEndpointOption: '-e, --endpoint-url',
229
245
  lambdaRegionOption: '-r, --region',
230
246
  lambdaProfileOption: '-p, --profile',
@@ -273,7 +289,14 @@ const en_locales = () => {
273
289
  auditOptionsSave: '-s, --save',
274
290
  auditOptionsSaveDescription: 'saves the output in specified format Txt text, sbom',
275
291
  scanNoVulnerabilitiesFound: '👏 No vulnerabilities found',
276
- scanNoFiletypeSpecifiedForSave: 'Please specify file type to save results to',
292
+ scanNoFiletypeSpecifiedForSave: 'Please specify file type to save results to, accepted value is SARIF',
293
+ auditSBOMSaveSuccess: '\n Software Bill of Materials (SBOM) saved successfully',
294
+ auditNoFiletypeSpecifiedForSave: `\n ${chalk.yellow.bold('No file type specified for --save option to save audit results to. Use audit --help to see valid --save options.')}`,
295
+ auditBadFiletypeSpecifiedForSave: `\n ${chalk.yellow.bold('Bad file type specified for --save option. Use audit --help to see valid --save options.')}`,
296
+ auditReportWaiting: 'Waiting for report...',
297
+ auditReportFail: 'Report Retrieval Failed, please try again',
298
+ auditReportSuccessMessage: ' Report successfully retrieved',
299
+ auditReportFailureMessage: ' Unable to generate library report.',
277
300
  ...lambda
278
301
  };
279
302
  };
package/dist/constants.js CHANGED
@@ -17,6 +17,14 @@ const scanOptionDefinitions = [
17
17
  '}: ' +
18
18
  i18n.__('constantsProjectName')
19
19
  },
20
+ {
21
+ name: 'language',
22
+ alias: 'l',
23
+ description: '{bold ' +
24
+ i18n.__('constantsOptional') +
25
+ '}: ' +
26
+ i18n.__('scanOptionsLanguageSummary')
27
+ },
20
28
  {
21
29
  name: 'file',
22
30
  alias: 'f',
@@ -66,7 +74,6 @@ const scanOptionDefinitions = [
66
74
  },
67
75
  {
68
76
  name: 'host',
69
- alias: 'h',
70
77
  description: '{bold ' +
71
78
  i18n.__('constantsRequired') +
72
79
  '}: ' +
@@ -109,8 +116,13 @@ const scanOptionDefinitions = [
109
116
  alias: 's',
110
117
  description: '{bold ' + i18n.__('constantsOptional') + '}:' + i18n.__('constantsSave')
111
118
  },
119
+ {
120
+ name: 'label',
121
+ description: '{bold ' + i18n.__('constantsOptional') + '}:' + i18n.__('scanLabel')
122
+ },
112
123
  {
113
124
  name: 'help',
125
+ alias: 'h',
114
126
  type: Boolean
115
127
  },
116
128
  {
@@ -119,6 +131,27 @@ const scanOptionDefinitions = [
119
131
  type: Boolean
120
132
  }
121
133
  ];
134
+ const authOptionDefinitions = [
135
+ {
136
+ name: 'help',
137
+ alias: 'h',
138
+ type: Boolean
139
+ }
140
+ ];
141
+ const configOptionDefinitions = [
142
+ {
143
+ name: 'help',
144
+ alias: 'h',
145
+ type: Boolean,
146
+ description: 'Help text'
147
+ },
148
+ {
149
+ name: 'clear',
150
+ alias: 'c',
151
+ type: Boolean,
152
+ description: 'Clear the currently stored config'
153
+ }
154
+ ];
122
155
  const auditOptionDefinitions = [
123
156
  {
124
157
  name: 'application-id',
@@ -257,6 +290,7 @@ const mainUsageGuide = commandLineUsage([
257
290
  header: i18n.__('constantsCommands'),
258
291
  content: [
259
292
  { name: i18n.__('authName'), summary: i18n.__('helpAuthSummary') },
293
+ { name: i18n.__('scanName'), summary: i18n.__('helpScanSummary') },
260
294
  { name: i18n.__('lambdaName'), summary: i18n.__('helpLambdaSummary') },
261
295
  { name: i18n.__('versionName'), summary: i18n.__('helpVersionSummary') },
262
296
  { name: i18n.__('configName'), summary: i18n.__('helpConfigSummary') },
@@ -264,7 +298,7 @@ const mainUsageGuide = commandLineUsage([
264
298
  ]
265
299
  },
266
300
  {
267
- content: '{underline https://www.contrastsecurity.com}'
301
+ content: '{underline https://developer.contrastsecurity.com/} \n For technical support head to {underline https://support.contrastsecurity.com}'
268
302
  }
269
303
  ]);
270
304
  const mainDefinition = [{ name: 'command', defaultOption: true }];
@@ -273,6 +307,8 @@ module.exports = {
273
307
  mainUsageGuide,
274
308
  mainDefinition,
275
309
  scanOptionDefinitions,
276
- auditOptionDefinitions
310
+ auditOptionDefinitions,
311
+ authOptionDefinitions,
312
+ configOptionDefinitions
277
313
  }
278
314
  };
package/dist/index.js CHANGED
@@ -12,7 +12,8 @@ const constants_1 = __importDefault(require("./constants"));
12
12
  const constants_2 = require("./constants/constants");
13
13
  const lambda_1 = require("./lambda/lambda");
14
14
  const getConfig_1 = require("./utils/getConfig");
15
- const findLatestCLIVersion_1 = __importDefault(require("./common/findLatestCLIVersion"));
15
+ const versionChecker_1 = require("./common/versionChecker");
16
+ const errorHandling_1 = require("./common/errorHandling");
16
17
  const { commandLineDefinitions: { mainUsageGuide, mainDefinition } } = constants_1.default;
17
18
  const config = (0, getConfig_1.localConfig)(constants_2.APP_NAME, constants_2.APP_VERSION);
18
19
  const getMainOption = () => {
@@ -28,35 +29,55 @@ const getMainOption = () => {
28
29
  };
29
30
  };
30
31
  const start = async () => {
31
- const { mainOptions, argv: argvMain } = getMainOption();
32
- const command = mainOptions.command != undefined ? mainOptions.command.toLowerCase() : '';
33
- if (command === 'version') {
34
- console.log(constants_2.APP_VERSION);
35
- return;
36
- }
37
- await (0, findLatestCLIVersion_1.default)();
38
- if (command === 'config') {
39
- return (0, config_1.processConfig)(argvMain, config);
40
- }
41
- if (command === 'auth') {
42
- return await (0, auth_1.processAuth)(config);
43
- }
44
- if (command === 'lambda') {
45
- return await (0, lambda_1.processLambda)(argvMain);
46
- }
47
- if (command === 'scan') {
48
- return await (0, processScan_1.processScan)(argvMain);
49
- }
50
- if (command === 'audit') {
51
- return await (0, processAudit_1.processAudit)(argvMain);
52
- }
53
- if (command === 'help' ||
54
- argvMain.includes('--help') ||
55
- Object.keys(mainOptions).length === 0) {
56
- console.log(mainUsageGuide);
32
+ if (await (0, versionChecker_1.isCorrectNodeVersion)(process.version)) {
33
+ const { mainOptions, argv: argvMain } = getMainOption();
34
+ const command = mainOptions.command != undefined ? mainOptions.command.toLowerCase() : '';
35
+ if (command === 'version' ||
36
+ argvMain.includes('--v') ||
37
+ argvMain.includes('--version')) {
38
+ console.log(constants_2.APP_VERSION);
39
+ await (0, versionChecker_1.findLatestCLIVersion)(config.get('updateMessageHidden'));
40
+ return;
41
+ }
42
+ config.set('numOfRuns', config.get('numOfRuns') + 1);
43
+ if (config.get('numOfRuns') >= 5) {
44
+ await (0, versionChecker_1.findLatestCLIVersion)(config.get('updateMessageHidden'));
45
+ config.set('numOfRuns', 0);
46
+ }
47
+ if (command === 'config') {
48
+ return (0, config_1.processConfig)(argvMain, config);
49
+ }
50
+ if (command === 'auth') {
51
+ return await (0, auth_1.processAuth)(argvMain, config);
52
+ }
53
+ if (command === 'lambda') {
54
+ return await (0, lambda_1.processLambda)(argvMain);
55
+ }
56
+ if (command === 'scan') {
57
+ return await (0, processScan_1.processScan)(argvMain);
58
+ }
59
+ if (command === 'audit') {
60
+ return await (0, processAudit_1.processAudit)(argvMain);
61
+ }
62
+ if (command === 'help' ||
63
+ argvMain.includes('--help') ||
64
+ Object.keys(mainOptions).length === 0) {
65
+ console.log(mainUsageGuide);
66
+ }
67
+ else if (mainOptions._unknown !== undefined) {
68
+ const foundCommand = (0, errorHandling_1.findCommandOnError)(mainOptions._unknown);
69
+ foundCommand
70
+ ? console.log(`Unknown Command: Did you mean "${foundCommand}"? \nUse "${foundCommand} --help" for the full list of options`)
71
+ : console.log(`Unknown Command: ${command} \nUse --help for the full list`);
72
+ }
73
+ else {
74
+ console.log(`Unknown Command: ${command} \nUse --help for the full list`);
75
+ }
76
+ process.exit(9);
57
77
  }
58
78
  else {
59
- console.log('Unknown Command: ' + command + ' \nUse --help for the full list');
79
+ console.log('Contrast supports Node versions >=16.13.2 <17. Please use one of those versions.');
80
+ process.exit(9);
60
81
  }
61
82
  };
62
83
  start();
@@ -13,7 +13,15 @@ const lambdaUsageGuide = (0, command_line_usage_1.default)([
13
13
  },
14
14
  {
15
15
  header: i18n_1.default.__('constantsPrerequisitesHeader'),
16
- content: [i18n_1.default.__('lambdaPrerequisitesContent')]
16
+ content: [
17
+ '{bold ' +
18
+ i18n_1.default.__('lambdaPrerequisitesContentLambdaLanguages') +
19
+ '}\n\n' +
20
+ '{bold ' +
21
+ i18n_1.default.__('lambdaPrerequisitesContentLambdaDescriptionTitle') +
22
+ '}' +
23
+ i18n_1.default.__('lambdaPrerequisitesContentLambdaDescription')
24
+ ]
17
25
  },
18
26
  {
19
27
  header: i18n_1.default.__('constantsUsage'),
@@ -23,44 +31,44 @@ const lambdaUsageGuide = (0, command_line_usage_1.default)([
23
31
  header: i18n_1.default.__('constantsOptions'),
24
32
  content: [
25
33
  {
26
- name: i18n_1.default.__('lambdaFunctionNameOption'),
34
+ name: '{bold ' + i18n_1.default.__('lambdaFunctionNameOption') + '}',
27
35
  summary: i18n_1.default.__('lambdaFunctionNameSummery')
28
36
  },
29
37
  {
30
- name: i18n_1.default.__('lambdaListFunctionsOption'),
38
+ name: '{bold ' + i18n_1.default.__('lambdaListFunctionsOption') + '}',
31
39
  summary: i18n_1.default.__('lambdaListFunctionsSummery')
32
40
  },
33
41
  {
34
- name: i18n_1.default.__('lambdaEndpointOption'),
35
- summary: '{italic ' +
42
+ name: '{bold ' + i18n_1.default.__('lambdaEndpointOption') + '}',
43
+ summary: '{bold ' +
36
44
  i18n_1.default.__('constantsOptional') +
37
45
  '}: ' +
38
46
  i18n_1.default.__('lambdaEndpointSummery')
39
47
  },
40
48
  {
41
- name: i18n_1.default.__('lambdaRegionOption'),
42
- summary: '{italic ' +
49
+ name: '{bold ' + i18n_1.default.__('lambdaRegionOption') + '}',
50
+ summary: '{bold ' +
43
51
  i18n_1.default.__('constantsOptional') +
44
52
  '}: ' +
45
53
  i18n_1.default.__('lambdaRegionSummery')
46
54
  },
47
55
  {
48
- name: i18n_1.default.__('lambdaProfileOption'),
49
- summary: '{italic ' +
56
+ name: '{bold ' + i18n_1.default.__('lambdaProfileOption') + '}',
57
+ summary: '{bold ' +
50
58
  i18n_1.default.__('constantsOptional') +
51
59
  '}: ' +
52
60
  i18n_1.default.__('lambdaProfileSummery')
53
61
  },
54
62
  {
55
- name: i18n_1.default.__('lambdaJsonOption'),
56
- summary: '{italic ' +
63
+ name: '{bold ' + i18n_1.default.__('lambdaJsonOption') + '}',
64
+ summary: '{bold ' +
57
65
  i18n_1.default.__('constantsOptional') +
58
66
  '}: ' +
59
67
  i18n_1.default.__('lambdaJsonSummery')
60
68
  },
61
69
  {
62
- name: i18n_1.default.__('lambdaVerboseOption'),
63
- summary: '{italic ' +
70
+ name: '{bold ' + i18n_1.default.__('lambdaVerboseOption') + '}',
71
+ summary: '{bold ' +
64
72
  i18n_1.default.__('constantsOptional') +
65
73
  '}: ' +
66
74
  i18n_1.default.__('lambdaVerbosSummery')
@@ -73,7 +81,7 @@ const lambdaUsageGuide = (0, command_line_usage_1.default)([
73
81
  ]
74
82
  },
75
83
  {
76
- content: '{underline https://www.contrastsecurity.com}'
84
+ content: '{underline https://www.contrastsecurity.com/developer/codesec}'
77
85
  }
78
86
  ]);
79
87
  exports.lambdaUsageGuide = lambdaUsageGuide;
@@ -18,6 +18,8 @@ const scanRequest_1 = require("./scanRequest");
18
18
  const scanResults_1 = require("./scanResults");
19
19
  const utils_1 = require("./utils");
20
20
  const lambdaUtils_1 = require("./lambdaUtils");
21
+ const requestUtils_1 = require("../utils/requestUtils");
22
+ const oraWrapper_1 = __importDefault(require("../utils/oraWrapper"));
21
23
  const failedStates = [
22
24
  'UNSUPPORTED',
23
25
  'EXCLUDED',
@@ -101,6 +103,10 @@ const actualProcessLambda = async (lambdaOptions) => {
101
103
  description: failedScan.stateReasonText
102
104
  });
103
105
  }
106
+ const startGetherResultsSpinner = oraWrapper_1.default.returnOra(i18n_1.default.__('gatherResults'));
107
+ oraWrapper_1.default.startSpinner(startGetherResultsSpinner);
108
+ await (0, requestUtils_1.sleep)(15 * 1000);
109
+ oraWrapper_1.default.succeedSpinner(startGetherResultsSpinner, 'Done gathering results');
104
110
  const resultsResponse = await (0, scanResults_1.getScanResults)(auth, params, scanId, functionArn);
105
111
  if (jsonOutput) {
106
112
  console.log(JSON.stringify(resultsResponse?.data?.results, null, 2));
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const commonApi_1 = require("../utils/commonApi");
4
+ function generateSbom(config) {
5
+ const client = (0, commonApi_1.getHttpClient)(config);
6
+ return client
7
+ .getSbom(config)
8
+ .then((res) => {
9
+ if (res.statusCode === 200) {
10
+ return res.body;
11
+ }
12
+ else {
13
+ console.log('Unable to retrieve Software Bill of Materials (SBOM)');
14
+ }
15
+ })
16
+ .catch((err) => {
17
+ console.log(err);
18
+ });
19
+ }
20
+ exports.default = generateSbom;
package/dist/scan/help.js CHANGED
@@ -21,14 +21,16 @@ const scanUsageGuide = commandLineUsage([
21
21
  optionList: constants.commandLineDefinitions.scanOptionDefinitions,
22
22
  hide: [
23
23
  'project-id',
24
- 'language',
25
24
  'organization-id',
26
25
  'api-key',
27
26
  'authorization',
28
27
  'host',
29
28
  'proxy',
29
+ 'help',
30
30
  'ff',
31
- 'ignore-cert-errors'
31
+ 'ignore-cert-errors',
32
+ 'verbose',
33
+ 'debug'
32
34
  ]
33
35
  },
34
36
  {
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GroupedResultsModel = void 0;
4
+ class GroupedResultsModel {
5
+ constructor(ruleId) {
6
+ this.ruleId = ruleId;
7
+ this.lineInfoSet = new Set;
8
+ }
9
+ }
10
+ exports.GroupedResultsModel = GroupedResultsModel;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScanResultsModel = void 0;
4
+ class ScanResultsModel {
5
+ constructor(scan) {
6
+ this.projectOverview = scan.projectOverview;
7
+ this.scanDetail = scan.scanDetail;
8
+ this.scanResultsInstances = scan.scanResultsInstances;
9
+ }
10
+ }
11
+ exports.ScanResultsModel = ScanResultsModel;
@@ -21,6 +21,7 @@ const createProjectId = async (config, client) => {
21
21
  }
22
22
  if (res.statusCode === 403) {
23
23
  console.log(i18n.__('permissionsError'));
24
+ process.exit(1);
24
25
  return;
25
26
  }
26
27
  if (res.statusCode === 201) {
@@ -1,15 +1,14 @@
1
1
  "use strict";
2
2
  const fs = require('fs');
3
- const writeResultsToFile = (responseBody, name = 'results.sarif') => {
4
- fs.writeFile(name, JSON.stringify(responseBody, null, 2), err => {
5
- if (err) {
6
- console.log('Error writing Scan Results to file');
7
- }
8
- else {
9
- console.log(`Scan Results saved to ${name}`);
10
- }
11
- });
3
+ const writeResultsToFile = async (responseBody, name = 'results.sarif') => {
4
+ try {
5
+ fs.writeFileSync(name, JSON.stringify(responseBody, null, 2));
6
+ console.log(`Scan Results saved to ${name}`);
7
+ }
8
+ catch (err) {
9
+ console.log('Error writing Scan Results to file');
10
+ }
12
11
  };
13
12
  module.exports = {
14
- writeResultsToFile
13
+ writeResultsToFile: writeResultsToFile
15
14
  };