@contrast/contrast 1.0.3 → 1.0.6

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 (107) hide show
  1. package/.prettierignore +4 -0
  2. package/README.md +20 -14
  3. package/dist/audit/autodetection/autoDetectLanguage.js +32 -0
  4. package/dist/audit/catalogueApplication/catalogueApplication.js +2 -11
  5. package/dist/audit/languageAnalysisEngine/{langugageAnalysisFactory.js → languageAnalysisFactory.js} +6 -14
  6. package/dist/audit/languageAnalysisEngine/reduceIdentifiedLanguages.js +29 -0
  7. package/dist/audit/languageAnalysisEngine/report/commonReportingFunctions.js +101 -234
  8. package/dist/audit/languageAnalysisEngine/report/models/reportLibraryModel.js +19 -0
  9. package/dist/audit/languageAnalysisEngine/report/models/reportListModel.js +24 -0
  10. package/dist/audit/languageAnalysisEngine/report/models/reportOutputModel.js +24 -0
  11. package/dist/audit/languageAnalysisEngine/report/models/reportSeverityModel.js +12 -0
  12. package/dist/audit/languageAnalysisEngine/report/models/severityCountModel.js +13 -0
  13. package/dist/audit/languageAnalysisEngine/report/reportingFeature.js +24 -129
  14. package/dist/audit/languageAnalysisEngine/report/utils/reportUtils.js +99 -0
  15. package/dist/audit/languageAnalysisEngine/sendSnapshot.js +2 -14
  16. package/dist/commands/audit/auditConfig.js +8 -2
  17. package/dist/commands/audit/auditController.js +14 -5
  18. package/dist/commands/scan/processScan.js +10 -6
  19. package/dist/commands/scan/sca/scaAnalysis.js +49 -0
  20. package/dist/common/HTTPClient.js +18 -26
  21. package/dist/common/errorHandling.js +7 -17
  22. package/dist/common/versionChecker.js +14 -12
  23. package/dist/constants/constants.js +24 -2
  24. package/dist/constants/lambda.js +3 -1
  25. package/dist/constants/locales.js +42 -42
  26. package/dist/constants.js +25 -1
  27. package/dist/index.js +2 -2
  28. package/dist/lambda/help.js +22 -14
  29. package/dist/lambda/lambda.js +6 -0
  30. package/dist/scaAnalysis/common/formatMessage.js +19 -0
  31. package/dist/scaAnalysis/common/treeUpload.js +29 -0
  32. package/dist/scaAnalysis/go/goAnalysis.js +17 -0
  33. package/dist/scaAnalysis/go/goParseDeps.js +158 -0
  34. package/dist/scaAnalysis/go/goReadDepFile.js +23 -0
  35. package/dist/scaAnalysis/java/analysis.js +108 -0
  36. package/dist/scaAnalysis/java/index.js +18 -0
  37. package/dist/scaAnalysis/java/javaBuildDepsParser.js +339 -0
  38. package/dist/scan/autoDetection.js +46 -1
  39. package/dist/scan/fileUtils.js +73 -1
  40. package/dist/scan/formatScanOutput.js +215 -0
  41. package/dist/scan/help.js +3 -1
  42. package/dist/scan/models/groupedResultsModel.js +11 -0
  43. package/dist/scan/models/resultContentModel.js +2 -0
  44. package/dist/scan/models/scanResultsModel.js +11 -0
  45. package/dist/scan/scan.js +27 -126
  46. package/dist/scan/scanConfig.js +1 -1
  47. package/dist/scan/scanController.js +11 -5
  48. package/dist/scan/scanResults.js +15 -19
  49. package/dist/utils/getConfig.js +3 -0
  50. package/dist/utils/oraWrapper.js +5 -1
  51. package/package.json +3 -2
  52. package/src/audit/autodetection/autoDetectLanguage.ts +40 -0
  53. package/src/audit/catalogueApplication/catalogueApplication.js +4 -16
  54. package/src/audit/languageAnalysisEngine/{langugageAnalysisFactory.js → languageAnalysisFactory.js} +11 -21
  55. package/src/audit/languageAnalysisEngine/reduceIdentifiedLanguages.js +72 -0
  56. package/src/audit/languageAnalysisEngine/report/commonReportingFunctions.ts +204 -0
  57. package/src/audit/languageAnalysisEngine/report/models/reportLibraryModel.ts +30 -0
  58. package/src/audit/languageAnalysisEngine/report/models/reportListModel.ts +32 -0
  59. package/src/audit/languageAnalysisEngine/report/models/reportOutputModel.ts +29 -0
  60. package/src/audit/languageAnalysisEngine/report/models/reportSeverityModel.ts +13 -0
  61. package/src/audit/languageAnalysisEngine/report/models/severityCountModel.ts +16 -0
  62. package/src/audit/languageAnalysisEngine/report/reportingFeature.ts +56 -0
  63. package/src/audit/languageAnalysisEngine/report/utils/reportUtils.ts +116 -0
  64. package/src/audit/languageAnalysisEngine/sendSnapshot.js +2 -22
  65. package/src/commands/audit/auditConfig.ts +12 -3
  66. package/src/commands/audit/auditController.ts +20 -5
  67. package/src/commands/audit/processAudit.ts +3 -0
  68. package/src/commands/scan/processScan.js +13 -9
  69. package/src/commands/scan/sca/scaAnalysis.js +75 -0
  70. package/src/common/HTTPClient.js +31 -38
  71. package/src/common/errorHandling.ts +7 -25
  72. package/src/common/versionChecker.ts +24 -22
  73. package/src/constants/constants.js +24 -2
  74. package/src/constants/lambda.js +3 -1
  75. package/src/constants/locales.js +47 -56
  76. package/src/constants.js +29 -1
  77. package/src/index.ts +2 -3
  78. package/src/lambda/help.ts +22 -14
  79. package/src/lambda/lambda.ts +8 -0
  80. package/src/scaAnalysis/common/formatMessage.js +20 -0
  81. package/src/scaAnalysis/common/treeUpload.js +30 -0
  82. package/src/scaAnalysis/go/goAnalysis.js +20 -0
  83. package/src/scaAnalysis/go/goParseDeps.js +203 -0
  84. package/src/scaAnalysis/go/goReadDepFile.js +32 -0
  85. package/src/scaAnalysis/java/analysis.js +143 -0
  86. package/src/scaAnalysis/java/index.js +21 -0
  87. package/src/scaAnalysis/java/javaBuildDepsParser.js +404 -0
  88. package/src/scan/autoDetection.js +54 -1
  89. package/src/scan/fileUtils.js +91 -1
  90. package/src/scan/formatScanOutput.ts +250 -0
  91. package/src/scan/help.js +3 -1
  92. package/src/scan/models/groupedResultsModel.ts +20 -0
  93. package/src/scan/models/resultContentModel.ts +86 -0
  94. package/src/scan/models/scanResultsModel.ts +52 -0
  95. package/src/scan/scan.ts +63 -0
  96. package/src/scan/scanConfig.js +1 -1
  97. package/src/scan/scanController.js +15 -7
  98. package/src/scan/scanResults.js +21 -18
  99. package/src/utils/getConfig.ts +10 -0
  100. package/src/utils/oraWrapper.js +6 -1
  101. package/dist/audit/languageAnalysisEngine/report/checkIgnoreDevDep.js +0 -17
  102. package/dist/audit/languageAnalysisEngine/report/newReportingFeature.js +0 -81
  103. package/src/audit/languageAnalysisEngine/report/checkIgnoreDevDep.js +0 -27
  104. package/src/audit/languageAnalysisEngine/report/commonReportingFunctions.js +0 -303
  105. package/src/audit/languageAnalysisEngine/report/newReportingFeature.js +0 -124
  106. package/src/audit/languageAnalysisEngine/report/reportingFeature.js +0 -190
  107. package/src/scan/scan.js +0 -195
@@ -9,18 +9,20 @@ const constants_1 = require("../constants/constants");
9
9
  const boxen_1 = __importDefault(require("boxen"));
10
10
  const chalk_1 = __importDefault(require("chalk"));
11
11
  const semver_1 = __importDefault(require("semver"));
12
- async function findLatestCLIVersion() {
13
- const latestCLIVersion = await (0, latest_version_1.default)('@contrast/contrast');
14
- if (semver_1.default.lt(constants_1.APP_VERSION, latestCLIVersion)) {
15
- const updateAvailableMessage = `Update available ${chalk_1.default.yellow(constants_1.APP_VERSION)} → ${chalk_1.default.green(latestCLIVersion)}`;
16
- const npmUpdateAvailableCommand = `Run ${chalk_1.default.cyan('npm i @contrast/contrast -g')} to update via npm`;
17
- const homebrewUpdateAvailableCommand = `Run ${chalk_1.default.cyan('brew install contrastsecurity/tap/contrast')} to update via brew`;
18
- console.log((0, boxen_1.default)(`${updateAvailableMessage}\n${npmUpdateAvailableCommand}\n\n${homebrewUpdateAvailableCommand}`, {
19
- titleAlignment: 'center',
20
- margin: 1,
21
- padding: 1,
22
- align: 'center'
23
- }));
12
+ async function findLatestCLIVersion(updateMessageHidden) {
13
+ if (!updateMessageHidden) {
14
+ const latestCLIVersion = await (0, latest_version_1.default)('@contrast/contrast');
15
+ if (semver_1.default.lt(constants_1.APP_VERSION, latestCLIVersion)) {
16
+ const updateAvailableMessage = `Update available ${chalk_1.default.yellow(constants_1.APP_VERSION)} ${chalk_1.default.green(latestCLIVersion)}`;
17
+ const npmUpdateAvailableCommand = `Run ${chalk_1.default.cyan('npm i @contrast/contrast -g')} to update via npm`;
18
+ const homebrewUpdateAvailableCommand = `Run ${chalk_1.default.cyan('brew install contrastsecurity/tap/contrast')} to update via brew`;
19
+ console.log((0, boxen_1.default)(`${updateAvailableMessage}\n${npmUpdateAvailableCommand}\n\n${homebrewUpdateAvailableCommand}`, {
20
+ titleAlignment: 'center',
21
+ margin: 1,
22
+ padding: 1,
23
+ align: 'center'
24
+ }));
25
+ }
24
26
  }
25
27
  }
26
28
  exports.findLatestCLIVersion = findLatestCLIVersion;
@@ -12,11 +12,22 @@ 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.3';
15
+ const APP_VERSION = '1.0.6';
16
16
  const TIMEOUT = 120000;
17
+ const HIGH_COLOUR = '#ff9900';
18
+ const CRITICAL_COLOUR = '#e35858';
19
+ const MEDIUM_COLOUR = '#f1c232';
20
+ const LOW_COLOUR = '#b7b7b7';
21
+ const NOTE_COLOUR = '#999999';
22
+ const CRITICAL_PRIORITY = 1;
23
+ const HIGH_PRIORITY = 2;
24
+ const MEDIUM_PRIORITY = 3;
25
+ const LOW_PRIORITY = 4;
26
+ const NOTE_PRIORITY = 5;
17
27
  const AUTH_UI_URL = 'https://cli-auth.contrastsecurity.com';
18
28
  const AUTH_CALLBACK_URL = 'https://cli-auth-api.contrastsecurity.com';
19
29
  const SARIF_FILE = 'SARIF';
30
+ const CE_URL = 'https://ce.contrastsecurity.com/';
20
31
  module.exports = {
21
32
  supportedLanguages: { NODE, DOTNET, JAVA, RUBY, PYTHON, GO, PHP, JAVASCRIPT },
22
33
  LOW,
@@ -28,5 +39,16 @@ module.exports = {
28
39
  TIMEOUT,
29
40
  AUTH_UI_URL,
30
41
  AUTH_CALLBACK_URL,
31
- SARIF_FILE
42
+ SARIF_FILE,
43
+ HIGH_COLOUR,
44
+ CRITICAL_COLOUR,
45
+ MEDIUM_COLOUR,
46
+ LOW_COLOUR,
47
+ NOTE_COLOUR,
48
+ CE_URL,
49
+ CRITICAL_PRIORITY,
50
+ HIGH_PRIORITY,
51
+ MEDIUM_PRIORITY,
52
+ LOW_PRIORITY,
53
+ NOTE_PRIORITY
32
54
  };
@@ -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:',
@@ -4,43 +4,29 @@ const chalk = require('chalk');
4
4
  const en_locales = () => {
5
5
  return {
6
6
  successHeader: 'SUCCESS',
7
- snapshotSuccessMessage: ' Please go to the Contrast UI to view your dependency tree.',
7
+ snapshotSuccessMessage: 'Please go to the Contrast UI to view your dependency tree.',
8
8
  snapshotFailureHeader: 'FAIL',
9
- snapshotFailureMessage: ' Unable to send library analysis to your Contrast UI.',
10
- snapshotHostMessage: " No host supplied. Using default host 'app.contrastsecurity.com'. Please ensure this is correct.",
11
- vulnerabilitiesSuccessMessage: ' Vulnerability data successfully retrieved',
12
- vulnerabilitiesFailureMessage: ' Unable to retrieve library vulnerabilities from Team Server.',
13
- reportSuccessMessage: ' Report successfully retrieved',
14
- reportFailureMessage: ' Unable to generate library report.',
9
+ snapshotFailureMessage: 'Library analysis failed',
10
+ snapshotHostMessage: "No host supplied. Using default host 'app.contrastsecurity.com'. Please ensure this is correct.",
11
+ vulnerabilitiesSuccessMessage: 'Vulnerability data successfully retrieved',
12
+ vulnerabilitiesFailureMessage: 'Unable to retrieve library vulnerabilities',
15
13
  catchErrorMessage: 'Contrast UI error: ',
16
14
  dependenciesNote: 'Please Note: We currently only support projects with one .csproj AND *.package.lock.json',
17
- languageAnalysisFailureMessage: 'LANGUAGE ANALYSIS FAILED',
15
+ languageAnalysisFailureMessage: 'SCA Analysis Failure',
18
16
  languageAnalysisFactoryFailureHeader: 'FAIL',
19
- projectPathParameter: 'Please set the %s to locate the source code for the project',
20
- apiKeyParameter: 'Please set the %s to connect to the Contrast UI',
21
- applicationNameParameter: 'Please provide a value for %s, to appear in the Contrast UI',
22
- languageParameter: 'Please set the %s to the language of the source project. Allowable values are JAVA, DOTNET, NODE, PYTHON and RUBY.',
23
- hostParameter: 'Please set the %s to the hostname and (optionally) the port expressed as <host>:<port> of the Contrast UI',
24
- organizationIdParameter: 'Please set the %s to correctly identify your organization within the Contrast UI',
25
- authorizationParameter: 'Please set the %s to your authorization header, found in the Contrast UI',
26
- applicationIdParameter: 'Please set the %s to the value provided within the Contrast UI for the target application',
27
- libraryAnalysisError: 'Please ensure the language parameter is set in accordance to the language specified on the project path.\nThe Contrast-CLI must be run in the same directory as the project manifest file OR the project_path parameter must be used to identify the directory containing the project manifest file.\n\nFor further information please read our usage guide, which can be accessed with the following command:\n\ncontrast-cli --help',
17
+ libraryAnalysisError: 'Please ensure the language parameter is set in accordance to the language specified on the project path.\nContrast CLI must be run in the same directory as the project manifest file OR the project_path parameter must be used to identify the directory containing the project manifest file.\n\nFor further information please read our usage guide, which can be accessed with the following command:\n\ncontrast-cli --help',
28
18
  yamlMissingParametersHeader: 'Missing Parameters',
29
- yamlMissingParametersMessage: 'The following parameters are required: \n \norganization_id \napi_key \nauthorization \nhost \napplication_name or application_id \nlanguage \n \nThey must be specified as a command line argument or within the yaml file. \nFor further information please read our usage guide, which can be accessed with the following command:\ncontrast-cli --help',
19
+ yamlMissingParametersMessage: 'The following parameters are required: \n \norganization-id \napi-key \nauthorization \nhost \nlanguage \n \nThey must be specified as a command line argument. \nFor further information please read our usage guide, which can be accessed with the following command:\ncontrast audit --help',
30
20
  unauthenticatedErrorHeader: '401 error - Unauthenticated',
31
- unauthenticatedErrorMessage: 'Please check the following keys are correct:\n--organization_id, --api_key or --authorization',
21
+ unauthenticatedErrorMessage: 'Please check the following keys are correct:\n--organization-id, --api-key or --authorization',
32
22
  badRequestErrorHeader: '400 error - Bad Request',
33
- badRequestErrorMessage: 'Please check the following key is correct: \n--application_id',
23
+ badRequestErrorMessage: 'Please check the following key is correct: \n--application-id',
34
24
  badRequestCatalogueErrorMessage: 'The application name already exists, please use a unique name',
35
25
  forbiddenRequestErrorHeader: '403 error - Forbidden',
36
26
  forbiddenRequestErrorMessage: 'You do not have permission to access this server.',
37
27
  proxyErrorHeader: '407 error - Proxy Authentication Required',
38
28
  proxyErrorMessage: 'Please provide valid authentication credentials for the proxy server.',
39
- downgradeHttpsHttp: 'Connection to ContrastUI using https failed. Attempting to connect using http...',
40
- setSpecifiedParameter: 'Please set the %s ',
41
- catalogueFailureCommand: 'Failed to catalogue a new application for reason: ',
42
- catalogueFailureHostCommand: 'Failed to catalogue a new application, please ensure you have the correct host and authentication. Error: ',
43
- catalogueSuccessCommand: 'This application ID can now be used to send dependency data to Contrast: ',
29
+ catalogueSuccessCommand: 'Application Created',
44
30
  dotnetAnalysisFailure: '.NET analysis failed because: ',
45
31
  dotnetReadLockfile: 'Failed to read the lock file @ %s because: ',
46
32
  dotnetParseLockfile: "Failed to parse .NET lock file @ '%s' because: ",
@@ -84,10 +70,9 @@ const en_locales = () => {
84
70
  constantsOptionalForCatalogue: '(optional for catalogue)',
85
71
  constantsRequired: '(required)',
86
72
  constantsRequiredCatalogue: '(required for catalogue)',
87
- constantsYamlPath: 'If you want to read params from the yaml file then enter the path to the file',
88
73
  constantsApiKey: 'An agent API key as provided by Contrast UI',
89
- constantsAuthorization: 'An agent Authorization credentials as provided by Contrast UI',
90
- constantsOrganizationId: 'The ID of your organization in Contrast UI',
74
+ constantsAuthorization: 'Authorization credentials as provided by Contrast UI',
75
+ constantsOrganizationId: 'The ID of your organization',
91
76
  constantsApplicationId: 'The ID of the application cataloged by Contrast UI',
92
77
  constantsHostId: 'Provide the name of the host and optionally the port expressed as "<host>:<port>".',
93
78
  constantsApplicationName: 'The name of the application cataloged by Contrast UI',
@@ -111,7 +96,7 @@ const en_locales = () => {
111
96
  constantsCount: "The number of CVE's that must be exceeded to fail a build",
112
97
  constantsHeader: 'CodeSec by Contrast Security',
113
98
  constantsPrerequisitesContentScanLanguages: 'Java & JavaScript supported',
114
- 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.',
99
+ 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.',
115
100
  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.',
116
101
  constantsPrerequisitesHeader: 'Pre-requisites',
117
102
  constantsAuthUsageHeader: 'Usage',
@@ -165,17 +150,18 @@ const en_locales = () => {
165
150
  goReadProjectFile: 'Failed to read the project file @ "%s" because: "%s"',
166
151
  goAnalysisError: 'GO analysis failed because: ',
167
152
  goParseProjectFile: 'Failed to parse go mod graph output because: ',
168
- mavenNotInstalledError: " 'mvn' is not available. Please ensure you have Maven installed and available on your path.",
153
+ mavenNotInstalledError: "'mvn' is not available. Please ensure you have Maven installed and available on your path.",
169
154
  mavenDependencyTreeNonZero: 'Building maven dependancy tree failed with a non 0 exit code',
170
- gradleWrapperUnavailable: ' Gradle wrapper not found in root of project. Please ensure gradlew or gradlew.bat is in root of the project.',
155
+ gradleWrapperUnavailable: 'Gradle wrapper not found in root of project. Please ensure gradlew or gradlew.bat is in root of the project.',
171
156
  gradleDependencyTreeNonZero: "Building gradle dependancy tree failed with a non 0 exit code. \n Please check you have the correct version of Java installed to compile your project? \n If running against a muti module project ensure you are using the '--sub-project' flag",
172
- yamlPathCamelCaseError: ' Warning: The "yamlPath" parameter will be deprecated in a future release. Please look at our documentation for further guidance.',
173
- constantsSbom: ' Generate the Software Bill of Materials (SBOM) for the given application',
157
+ yamlPathCamelCaseError: 'Warning: The "yamlPath" parameter will be deprecated in a future release. Please look at our documentation for further guidance.',
158
+ constantsSbom: 'Generate the Software Bill of Materials (SBOM) for the given application',
174
159
  constantsMetadata: 'Define a set of key=value pairs (which conforms to RFC 2253) for specifying user-defined metadata associated with the application.',
175
160
  constantsTags: 'Apply labels to an application. Labels must be formatted as a comma-delimited list. Example - label1,label2,label3',
176
161
  constantsCode: 'Add the application code this application should use in the Contrast UI',
177
- constantsIgnoreCertErrors: ' For EOP users with a local Teamserver install, this will bypass the SSL certificate and recognise a self signed certificate.',
178
- constantsSave: ' Saves the Scan Results JSON to file.',
162
+ constantsIgnoreCertErrors: 'For EOP users with a local Teamserver install, this will bypass the SSL certificate and recognise a self signed certificate.',
163
+ constantsSave: 'Saves the Scan Results SARIF to file.',
164
+ scanLabel: "adds a label to the scan - defaults to 'Started by CLI tool at current date'",
179
165
  constantsIgnoreDev: 'Combined with the --report command excludes developer dependencies from the vulnerabilities report. By default all dependencies are included in a report.',
180
166
  constantsCommands: 'Commands',
181
167
  constantsScanOptions: 'Scan Options',
@@ -184,16 +170,18 @@ const en_locales = () => {
184
170
  ignoreDevDep: 'No private libraries that are not scoped detected',
185
171
  foundExistingProjectScan: 'Found existing project...',
186
172
  projectCreatedScan: 'Project created',
187
- uploadingScan: 'Uploading...',
173
+ uploadingScan: 'Uploading file to scan.',
188
174
  uploadingScanSuccessful: 'Uploaded file successfully.',
189
175
  uploadingScanFail: 'Unable to upload the file.',
190
176
  waitingTimedOut: 'Timed out.',
191
177
  responseMessage: 'Response: %s',
192
178
  searchingDirectoryScan: 'Searched 3 directory levels & found: ',
193
- noFileFoundScan: "We could't find a suitable file in your directories (we go 3 deep)",
179
+ noFileFoundScan: "We couldn't find a suitable file in your directories (we go 3 deep)",
194
180
  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>"',
181
+ specifyFileAuditNotFound: 'No files found for library analysis',
195
182
  populateProjectIdMessage: 'project ID is %s',
196
183
  genericServiceError: 'returned with status code %s',
184
+ projectIdError: 'Your project ID is %s please check this is correct',
197
185
  permissionsError: 'You do not have the correct permissions here. \n Contact support@contrastsecurity.com to get this fixed.',
198
186
  scanErrorFileMessage: 'We only accept the following file types: \nJava - .jar, .war \nJavaScript - .js or .zip files',
199
187
  helpAuthSummary: 'Authenticate Contrast using your Github or Google account',
@@ -229,15 +217,19 @@ const en_locales = () => {
229
217
  requiredParams: 'All required parameters are not present.',
230
218
  timeoutScan: 'Timeout set to 5 minutes.',
231
219
  searchingScanFileDirectory: 'Searching for file to scan from %s...',
220
+ searchingAuditFileDirectory: 'Searching for package manager files from %s...',
232
221
  scanHeader: 'Contrast Scan CLI',
233
222
  authHeader: 'Auth',
234
- lambdaHeader: 'Contrast lambda help',
223
+ lambdaHeader: 'Contrast Lambda CLI',
235
224
  lambdaSummary: 'Performs static security scan on an AWS Lambda Function.\nProduces CVE (Vulnerable Dependencies) and Least Privilege violations/remediation results.',
236
225
  lambdaUsage: 'contrast lambda --function-name <function> [options]',
237
- lambdaPrerequisitesContent: 'contrast cli',
238
- scanFileNameOption: ' -f, --file',
239
- lambdaFunctionNameOption: ' -f, --function-name',
240
- lambdaListFunctionsOption: ' -l, --list-functions',
226
+ lambdaPrerequisitesContent: '',
227
+ lambdaPrerequisitesContentLambdaLanguages: 'Supported runtimes: Java & Python',
228
+ lambdaPrerequisitesContentLambdaDescriptionTitle: 'AWS Requirements\n',
229
+ 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',
230
+ scanFileNameOption: '-f, --file',
231
+ lambdaFunctionNameOption: '-f, --function-name',
232
+ lambdaListFunctionsOption: '-l, --list-functions',
241
233
  lambdaEndpointOption: '-e, --endpoint-url',
242
234
  lambdaRegionOption: '-r, --region',
243
235
  lambdaProfileOption: '-p, --profile',
@@ -285,11 +277,19 @@ const en_locales = () => {
285
277
  auditOptionsIgnoreDevDependenciesDescription: 'ignores DevDependencies',
286
278
  auditOptionsSave: '-s, --save',
287
279
  auditOptionsSaveDescription: 'saves the output in specified format Txt text, sbom',
280
+ scanNotCompleted: 'Scan not completed. Check for framework and language support here: %s',
288
281
  scanNoVulnerabilitiesFound: '👏 No vulnerabilities found',
282
+ scanNoVulnerabilitiesFoundSecureCode: '👍 Your code looks secure.',
283
+ scanNoVulnerabilitiesFoundGoodWork: '👏 Keep up the good work.',
289
284
  scanNoFiletypeSpecifiedForSave: 'Please specify file type to save results to, accepted value is SARIF',
290
285
  auditSBOMSaveSuccess: '\n Software Bill of Materials (SBOM) saved successfully',
291
286
  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.')}`,
292
287
  auditBadFiletypeSpecifiedForSave: `\n ${chalk.yellow.bold('Bad file type specified for --save option. Use audit --help to see valid --save options.')}`,
288
+ auditReportWaiting: 'Waiting for report...',
289
+ auditReportFail: 'Report Retrieval Failed, please try again',
290
+ auditReportSuccessMessage: 'Report successfully retrieved',
291
+ auditReportFailureMessage: 'Unable to generate library report',
292
+ auditSCAAnalysisBegins: 'Contrast SCA analysis begins',
293
293
  ...lambda
294
294
  };
295
295
  };
package/dist/constants.js CHANGED
@@ -41,6 +41,14 @@ const scanOptionDefinitions = [
41
41
  '}: ' +
42
42
  i18n.__('constantsProjectId')
43
43
  },
44
+ {
45
+ name: 'project-path',
46
+ alias: 'i',
47
+ description: '{bold ' +
48
+ i18n.__('constantsOptional') +
49
+ '}: ' +
50
+ i18n.__('constantsProjectPath')
51
+ },
44
52
  {
45
53
  name: 'timeout',
46
54
  alias: 't',
@@ -116,6 +124,10 @@ const scanOptionDefinitions = [
116
124
  alias: 's',
117
125
  description: '{bold ' + i18n.__('constantsOptional') + '}:' + i18n.__('constantsSave')
118
126
  },
127
+ {
128
+ name: 'label',
129
+ description: '{bold ' + i18n.__('constantsOptional') + '}:' + i18n.__('scanLabel')
130
+ },
119
131
  {
120
132
  name: 'help',
121
133
  alias: 'h',
@@ -125,6 +137,18 @@ const scanOptionDefinitions = [
125
137
  name: 'debug',
126
138
  alias: 'd',
127
139
  type: Boolean
140
+ },
141
+ {
142
+ name: 'experimental',
143
+ alias: 'e',
144
+ type: Boolean
145
+ },
146
+ {
147
+ name: 'application-name',
148
+ description: '{bold ' +
149
+ i18n.__('constantsOptional') +
150
+ '}: ' +
151
+ i18n.__('constantsApplicationName')
128
152
  }
129
153
  ];
130
154
  const authOptionDefinitions = [
@@ -294,7 +318,7 @@ const mainUsageGuide = commandLineUsage([
294
318
  ]
295
319
  },
296
320
  {
297
- content: '{underline https://www.contrastsecurity.com}'
321
+ content: '{underline https://developer.contrastsecurity.com/} \n For technical support head to {underline https://support.contrastsecurity.com}'
298
322
  }
299
323
  ]);
300
324
  const mainDefinition = [{ name: 'command', defaultOption: true }];
package/dist/index.js CHANGED
@@ -36,12 +36,12 @@ const start = async () => {
36
36
  argvMain.includes('--v') ||
37
37
  argvMain.includes('--version')) {
38
38
  console.log(constants_2.APP_VERSION);
39
- await (0, versionChecker_1.findLatestCLIVersion)();
39
+ await (0, versionChecker_1.findLatestCLIVersion)(config.get('updateMessageHidden'));
40
40
  return;
41
41
  }
42
42
  config.set('numOfRuns', config.get('numOfRuns') + 1);
43
43
  if (config.get('numOfRuns') >= 5) {
44
- await (0, versionChecker_1.findLatestCLIVersion)();
44
+ await (0, versionChecker_1.findLatestCLIVersion)(config.get('updateMessageHidden'));
45
45
  config.set('numOfRuns', 0);
46
46
  }
47
47
  if (command === 'config') {
@@ -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,19 @@
1
+ "use strict";
2
+ const createJavaTSMessage = javaTree => {
3
+ return {
4
+ java: {
5
+ mavenDependencyTrees: javaTree
6
+ }
7
+ };
8
+ };
9
+ const createGoTSMessage = goTree => {
10
+ return {
11
+ go: {
12
+ goDependencyTrees: goTree
13
+ }
14
+ };
15
+ };
16
+ module.exports = {
17
+ createJavaTSMessage,
18
+ createGoTSMessage
19
+ };
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ const { getHttpClient } = require('../../utils/commonApi');
3
+ const { APP_VERSION } = require('../../constants/constants');
4
+ const commonSendSnapShot = async (analysis, config) => {
5
+ const requestBody = {
6
+ appID: config.applicationId,
7
+ cliVersion: APP_VERSION,
8
+ snapshot: analysis
9
+ };
10
+ const client = getHttpClient(config);
11
+ return client
12
+ .sendSnapshot(requestBody, config)
13
+ .then(res => {
14
+ if (res.statusCode === 201) {
15
+ console.log('dependencies processed successfully');
16
+ return res.body;
17
+ }
18
+ else {
19
+ console.log(res.statusCode);
20
+ console.log('error processing dependencies');
21
+ }
22
+ })
23
+ .catch(err => {
24
+ console.log(err);
25
+ });
26
+ };
27
+ module.exports = {
28
+ commonSendSnapShot
29
+ };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ const { createGoTSMessage } = require('../common/formatMessage');
3
+ const goReadDepFile = require('./goReadDepFile');
4
+ const goParseDeps = require('./goParseDeps');
5
+ const goAnalysis = (config, languageFiles) => {
6
+ try {
7
+ const rawGoDependencies = goReadDepFile.getGoDependencies(config);
8
+ const parsedGoDependencies = goParseDeps.parseGoDependencies(rawGoDependencies);
9
+ return createGoTSMessage(parsedGoDependencies);
10
+ }
11
+ catch (e) {
12
+ console.log(e.message.toString());
13
+ }
14
+ };
15
+ module.exports = {
16
+ goAnalysis
17
+ };