@contrast/contrast 1.0.4 → 1.0.5

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 (62) hide show
  1. package/.prettierignore +2 -0
  2. package/dist/audit/autodetection/autoDetectLanguage.js +32 -0
  3. package/dist/audit/catalogueApplication/catalogueApplication.js +2 -11
  4. package/dist/audit/languageAnalysisEngine/languageAnalysisFactory.js +4 -2
  5. package/dist/audit/languageAnalysisEngine/reduceIdentifiedLanguages.js +25 -0
  6. package/dist/audit/languageAnalysisEngine/report/commonReportingFunctions.js +3 -17
  7. package/dist/audit/languageAnalysisEngine/report/reportingFeature.js +1 -1
  8. package/dist/audit/languageAnalysisEngine/sendSnapshot.js +2 -16
  9. package/dist/commands/audit/auditConfig.js +8 -2
  10. package/dist/commands/audit/auditController.js +8 -2
  11. package/dist/commands/scan/processScan.js +6 -3
  12. package/dist/commands/scan/sca/scaAnalysis.js +44 -0
  13. package/dist/common/HTTPClient.js +0 -1
  14. package/dist/common/errorHandling.js +7 -17
  15. package/dist/constants/constants.js +14 -2
  16. package/dist/constants/locales.js +28 -35
  17. package/dist/constants.js +20 -0
  18. package/dist/scaAnalysis/common/formatMessage.js +11 -0
  19. package/dist/scaAnalysis/common/treeUpload.js +30 -0
  20. package/dist/scaAnalysis/java/analysis.js +116 -0
  21. package/dist/scaAnalysis/java/index.js +18 -0
  22. package/dist/scaAnalysis/java/javaBuildDepsParser.js +326 -0
  23. package/dist/scan/autoDetection.js +46 -1
  24. package/dist/scan/fileUtils.js +73 -1
  25. package/dist/scan/formatScanOutput.js +212 -0
  26. package/dist/scan/help.js +3 -1
  27. package/dist/scan/models/groupedResultsModel.js +2 -1
  28. package/dist/scan/scan.js +1 -96
  29. package/dist/scan/scanController.js +1 -2
  30. package/dist/scan/scanResults.js +3 -17
  31. package/package.json +2 -1
  32. package/src/audit/autodetection/autoDetectLanguage.ts +40 -0
  33. package/src/audit/catalogueApplication/catalogueApplication.js +4 -16
  34. package/src/audit/languageAnalysisEngine/languageAnalysisFactory.js +9 -5
  35. package/src/audit/languageAnalysisEngine/reduceIdentifiedLanguages.js +71 -0
  36. package/src/audit/languageAnalysisEngine/report/commonReportingFunctions.ts +3 -25
  37. package/src/audit/languageAnalysisEngine/report/reportingFeature.ts +1 -1
  38. package/src/audit/languageAnalysisEngine/sendSnapshot.js +2 -24
  39. package/src/commands/audit/auditConfig.ts +12 -3
  40. package/src/commands/audit/auditController.ts +9 -2
  41. package/src/commands/audit/processAudit.ts +3 -0
  42. package/src/commands/scan/processScan.js +8 -3
  43. package/src/commands/scan/sca/scaAnalysis.js +73 -0
  44. package/src/common/HTTPClient.js +1 -1
  45. package/src/common/errorHandling.ts +7 -24
  46. package/src/constants/constants.js +14 -2
  47. package/src/constants/locales.js +30 -49
  48. package/src/constants.js +22 -0
  49. package/src/scaAnalysis/common/formatMessage.js +10 -0
  50. package/src/scaAnalysis/common/treeUpload.js +34 -0
  51. package/src/scaAnalysis/java/analysis.js +159 -0
  52. package/src/scaAnalysis/java/index.js +21 -0
  53. package/src/scaAnalysis/java/javaBuildDepsParser.js +391 -0
  54. package/src/scan/autoDetection.js +54 -1
  55. package/src/scan/fileUtils.js +91 -1
  56. package/src/scan/formatScanOutput.ts +241 -0
  57. package/src/scan/help.js +3 -1
  58. package/src/scan/models/groupedResultsModel.ts +7 -5
  59. package/src/scan/models/resultContentModel.ts +2 -2
  60. package/src/scan/scan.ts +0 -130
  61. package/src/scan/scanController.js +1 -2
  62. package/src/scan/scanResults.js +9 -17
@@ -1,23 +1,8 @@
1
- const prettyjson = require('prettyjson')
2
- const i18n = require('i18n')
3
1
  const { getHttpClient } = require('../../utils/commonApi')
4
2
  const { handleResponseErrors } = require('../../common/errorHandling')
5
3
  const { APP_VERSION } = require('../../constants/constants')
6
4
 
7
- function displaySnapshotSuccessMessage(config) {
8
- console.log(
9
- '\n **************************' +
10
- i18n.__('successHeader') +
11
- '************************** '
12
- )
13
- console.log('\n' + i18n.__('snapshotSuccessMessage') + '\n')
14
- console.log(
15
- ` ${config.host}/Contrast/static/ng/index.html#/${config.organizationId}/applications/${config.applicationId}/libs/dependency-tree`
16
- )
17
- console.log('\n ***********************************************************')
18
- }
19
-
20
- const newSendSnapShot = async (analysis, applicationId) => {
5
+ const newSendSnapShot = async analysis => {
21
6
  const analysisLanguage = analysis.config.language.toLowerCase()
22
7
  const requestBody = {
23
8
  appID: analysis.config.applicationId,
@@ -30,13 +15,7 @@ const newSendSnapShot = async (analysis, applicationId) => {
30
15
  return client
31
16
  .sendSnapshot(requestBody, analysis.config)
32
17
  .then(res => {
33
- // if (!analysis.config.silent) {
34
- // console.log(prettyjson.render(requestBody))
35
- // }
36
18
  if (res.statusCode === 201) {
37
- if (analysis.config.host !== 'https://ce.contrastsecurity.com/') {
38
- displaySnapshotSuccessMessage(analysis.config)
39
- }
40
19
  return res.body
41
20
  } else {
42
21
  handleResponseErrors(res, 'snapshot')
@@ -48,6 +27,5 @@ const newSendSnapShot = async (analysis, applicationId) => {
48
27
  }
49
28
 
50
29
  module.exports = {
51
- newSendSnapShot: newSendSnapShot,
52
- displaySnapshotSuccessMessage: displaySnapshotSuccessMessage
30
+ newSendSnapShot: newSendSnapShot
53
31
  }
@@ -2,6 +2,10 @@ import paramHandler from '../../utils/paramsUtil/paramHandler'
2
2
  import constants from '../../constants'
3
3
  import cliOptions from '../../utils/parsedCLIOptions'
4
4
  import languageAnalysisEngine from '../../audit/languageAnalysisEngine/constants'
5
+ import {
6
+ determineProjectLanguage,
7
+ identifyLanguages
8
+ } from '../../audit/autodetection/autoDetectLanguage'
5
9
 
6
10
  const {
7
11
  supportedLanguages: { NODE, JAVASCRIPT }
@@ -18,9 +22,14 @@ export const getAuditConfig = (argv: string[]): { [key: string]: string } => {
18
22
  auditParameters.language === undefined ||
19
23
  auditParameters.language === null
20
24
  ) {
21
- //error no language
22
- console.log('error, --language parameter is required')
23
- process.exit(1)
25
+ try {
26
+ auditParameters.language = determineProjectLanguage(
27
+ identifyLanguages(auditParameters)
28
+ )
29
+ } catch (err: any) {
30
+ console.log(err.message)
31
+ process.exit(1)
32
+ }
24
33
  } else if (auditParameters.language.toUpperCase() === JAVASCRIPT) {
25
34
  auditParameters.language = NODE.toLowerCase()
26
35
  }
@@ -3,14 +3,21 @@ import commonApi from '../../audit/languageAnalysisEngine/commonApi'
3
3
 
4
4
  const identifyLanguageAE = require('./../../audit/languageAnalysisEngine')
5
5
  const languageFactory = require('../../audit/languageAnalysisEngine/languageAnalysisFactory')
6
+ const { v4: uuidv4 } = require('uuid')
6
7
 
7
- const dealWithNoAppId = async (config: { [x: string]: string }) => {
8
- let appID
8
+ export const dealWithNoAppId = async (config: { [x: string]: string }) => {
9
+ let appID: string
9
10
  try {
11
+ // @ts-ignore
10
12
  appID = await commonApi.returnAppId(config)
13
+ // console.log('appid', appID)
11
14
  if (!appID && config.applicationName) {
12
15
  return await catalogueApplication(config)
13
16
  }
17
+ if (!appID && !config.applicationName) {
18
+ config.applicationName = uuidv4()
19
+ return await catalogueApplication(config)
20
+ }
14
21
  // @ts-ignore
15
22
  } catch (e) {
16
23
  // @ts-ignore
@@ -10,6 +10,9 @@ export const processAudit = async (argv: parameterInput) => {
10
10
  process.exit(1)
11
11
  }
12
12
  const config = getAuditConfig(argv)
13
+
14
+ // console.log(config)
15
+
13
16
  const auditResults = await startAudit(config)
14
17
  }
15
18
 
@@ -1,12 +1,17 @@
1
- const { startScan } = require('../../scan/scanController')
2
- const { scanUsageGuide } = require('../../scan/help')
3
1
  const scanConfig = require('../../scan/scanConfig')
2
+ const { startScan } = require('../../scan/scanController')
4
3
  const { saveScanFile } = require('../../utils/saveFile')
5
4
  const { ScanResultsModel } = require('../../scan/models/scanResultsModel')
6
- const { formatScanOutput } = require('../../scan/scan')
5
+ const { formatScanOutput } = require('../../scan/formatScanOutput')
6
+ const { processSca } = require('./sca/scaAnalysis')
7
7
 
8
8
  const processScan = async argvMain => {
9
9
  let config = scanConfig.getScanConfig(argvMain)
10
+ // console.log(config)
11
+ //try SCA analysis first
12
+ if (config.experimental) {
13
+ await processSca(config)
14
+ }
10
15
 
11
16
  let scanResults = new ScanResultsModel(await startScan(config))
12
17
  if (scanResults) {
@@ -0,0 +1,73 @@
1
+ const autoDetection = require('../../../scan/autoDetection')
2
+ const { javaAnalysis } = require('../../../scaAnalysis/java')
3
+ const { commonSendSnapShot } = require('../../../scaAnalysis/common/treeUpload')
4
+ const {
5
+ manualDetectAuditFilesAndLanguages
6
+ } = require('../../../scan/autoDetection')
7
+ const { dealWithNoAppId } = require('../../audit/auditController')
8
+ const {
9
+ supportedLanguages: { JAVA }
10
+ } = require('../../../audit/languageAnalysisEngine/constants')
11
+
12
+ const processSca = async config => {
13
+ let filesFound
14
+ if (config.projectPath) {
15
+ filesFound = await manualDetectAuditFilesAndLanguages(config.projectPath)
16
+ } else {
17
+ filesFound = await autoDetection.autoDetectAuditFilesAndLanguages(config)
18
+ }
19
+
20
+ // files found looks like [ { javascript: [ Array ] } ]
21
+ //check we have the language and call the right analyser
22
+ //refactor new analyser and see if we can clean it up
23
+ let messageToSend = undefined
24
+ if (filesFound.length === 1) {
25
+ switch (Object.keys(filesFound[0])[0]) {
26
+ case JAVA:
27
+ messageToSend = await javaAnalysis(config, filesFound[0])
28
+ config.language = JAVA
29
+ break
30
+ // case 'javascript':
31
+ // // code block
32
+ // break;
33
+ // case 'dotnet':
34
+ // // code block
35
+ // break;
36
+ // case 'python':
37
+ // // code block
38
+ // break;
39
+ // case 'ruby':
40
+ // // code block
41
+ // break;
42
+ // case 'php':
43
+ // // code block
44
+ // break;
45
+ // case 'go':
46
+ // // code block
47
+ // break;
48
+ default:
49
+ //something is wrong
50
+ console.log('language detected not supported')
51
+ return
52
+ }
53
+
54
+ if (!config.applicationId) {
55
+ config.applicationId = await dealWithNoAppId(config)
56
+ }
57
+ //send message to TS
58
+ console.log('processing dependencies')
59
+ const response = await commonSendSnapShot(messageToSend, config)
60
+ } else {
61
+ if (filesFound.length === 0) {
62
+ console.log('no compatible dependency files detected. Continuing...')
63
+ } else {
64
+ console.log(
65
+ 'multiple language files detected, please use --project-path to specify a directory or the file where dependencies are declared'
66
+ )
67
+ }
68
+ }
69
+ }
70
+
71
+ module.exports = {
72
+ processSca
73
+ }
@@ -191,7 +191,7 @@ HTTPClient.prototype.catalogueCommand = function catalogueCommand(config) {
191
191
 
192
192
  HTTPClient.prototype.sendSnapshot = function sendSnapshot(requestBody, config) {
193
193
  if (config.language.toUpperCase() === 'RUBY') {
194
- console.log('sendSnapshot requestBody', requestBody.snapshot.ruby)
194
+ //console.log('sendSnapshot requestBody', requestBody.snapshot.ruby)
195
195
  }
196
196
  const options = _.cloneDeep(this.requestOptions)
197
197
  let url = createSnapshotURL(config)
@@ -27,30 +27,15 @@ const libraryAnalysisError = () => {
27
27
  }
28
28
 
29
29
  const snapshotFailureError = () => {
30
- console.log(
31
- '\n ******************************** ' +
32
- i18n.__('snapshotFailureHeader') +
33
- ' *********************************\n' +
34
- i18n.__('snapshotFailureMessage')
35
- )
30
+ console.log(i18n.__('snapshotFailureMessage'))
36
31
  }
37
32
 
38
33
  const vulnerabilitiesFailureError = () => {
39
- console.log(
40
- '\n ******************************** ' +
41
- i18n.__('snapshotFailureHeader') +
42
- ' *********************************\n' +
43
- i18n.__('vulnerabilitiesFailureMessage')
44
- )
34
+ console.log(i18n.__('vulnerabilitiesFailureMessage'))
45
35
  }
46
36
 
47
37
  const reportFailureError = () => {
48
- console.log(
49
- '\n ******************************** ' +
50
- i18n.__('snapshotFailureHeader') +
51
- ' *********************************\n' +
52
- i18n.__('reportFailureMessage')
53
- )
38
+ console.log(i18n.__('auditReportFailureMessage'))
54
39
  }
55
40
 
56
41
  const genericError = (missingCliOption: string) => {
@@ -79,10 +64,6 @@ const proxyError = () => {
79
64
  generalError('proxyErrorHeader', 'proxyErrorMessage')
80
65
  }
81
66
 
82
- const hostWarningError = () => {
83
- console.log(i18n.__('snapshotHostMessage'))
84
- }
85
-
86
67
  const failOptionError = () => {
87
68
  console.log(
88
69
  '\n ******************************** ' +
@@ -152,10 +133,12 @@ export {
152
133
  forbiddenError,
153
134
  proxyError,
154
135
  failOptionError,
155
- hostWarningError,
156
136
  generalError,
157
137
  getErrorMessage,
158
138
  handleResponseErrors,
159
139
  libraryAnalysisError,
160
- findCommandOnError
140
+ findCommandOnError,
141
+ snapshotFailureError,
142
+ vulnerabilitiesFailureError,
143
+ reportFailureError
161
144
  }
@@ -13,12 +13,18 @@ const MEDIUM = 'MEDIUM'
13
13
  const HIGH = 'HIGH'
14
14
  const CRITICAL = 'CRITICAL'
15
15
  const APP_NAME = 'contrast'
16
- const APP_VERSION = '1.0.4'
16
+ const APP_VERSION = '1.0.5'
17
17
  const TIMEOUT = 120000
18
+ const HIGH_COLOUR = '#ff9900'
19
+ const CRITICAL_COLOUR = '#e35858'
20
+ const MEDIUM_COLOUR = '#f1c232'
21
+ const LOW_COLOUR = '#ff9900'
22
+ const NOTE_COLOUR = '#999999'
18
23
 
19
24
  const AUTH_UI_URL = 'https://cli-auth.contrastsecurity.com'
20
25
  const AUTH_CALLBACK_URL = 'https://cli-auth-api.contrastsecurity.com'
21
26
  const SARIF_FILE = 'SARIF'
27
+ const CE_URL = 'https://ce.contrastsecurity.com/'
22
28
 
23
29
  module.exports = {
24
30
  supportedLanguages: { NODE, DOTNET, JAVA, RUBY, PYTHON, GO, PHP, JAVASCRIPT },
@@ -31,5 +37,11 @@ module.exports = {
31
37
  TIMEOUT,
32
38
  AUTH_UI_URL,
33
39
  AUTH_CALLBACK_URL,
34
- SARIF_FILE
40
+ SARIF_FILE,
41
+ HIGH_COLOUR,
42
+ CRITICAL_COLOUR,
43
+ MEDIUM_COLOUR,
44
+ LOW_COLOUR,
45
+ NOTE_COLOUR,
46
+ CE_URL
35
47
  }
@@ -5,46 +5,29 @@ const en_locales = () => {
5
5
  return {
6
6
  successHeader: 'SUCCESS',
7
7
  snapshotSuccessMessage:
8
- ' Please go to the Contrast UI to view your dependency tree.',
8
+ 'Please go to the Contrast UI to view your dependency tree.',
9
9
  snapshotFailureHeader: 'FAIL',
10
- snapshotFailureMessage:
11
- ' Unable to send library analysis to your Contrast UI.',
10
+ snapshotFailureMessage: 'Library analysis failed',
12
11
  snapshotHostMessage:
13
- " No host supplied. Using default host 'app.contrastsecurity.com'. Please ensure this is correct.",
14
- vulnerabilitiesSuccessMessage: ' Vulnerability data successfully retrieved',
15
- vulnerabilitiesFailureMessage:
16
- ' Unable to retrieve library vulnerabilities from Team Server.',
12
+ "No host supplied. Using default host 'app.contrastsecurity.com'. Please ensure this is correct.",
13
+ vulnerabilitiesSuccessMessage: 'Vulnerability data successfully retrieved',
14
+ vulnerabilitiesFailureMessage: 'Unable to retrieve library vulnerabilities',
17
15
  catchErrorMessage: 'Contrast UI error: ',
18
16
  dependenciesNote:
19
17
  'Please Note: We currently only support projects with one .csproj AND *.package.lock.json',
20
- languageAnalysisFailureMessage: 'LANGUAGE ANALYSIS FAILED',
18
+ languageAnalysisFailureMessage: 'SCA Analysis Failure',
21
19
  languageAnalysisFactoryFailureHeader: 'FAIL',
22
- projectPathParameter:
23
- 'Please set the %s to locate the source code for the project',
24
- apiKeyParameter: 'Please set the %s to connect to the Contrast UI',
25
- applicationNameParameter:
26
- 'Please provide a value for %s, to appear in the Contrast UI',
27
- languageParameter:
28
- 'Please set the %s to the language of the source project. Allowable values are JAVA, DOTNET, NODE, PYTHON and RUBY.',
29
- hostParameter:
30
- 'Please set the %s to the hostname and (optionally) the port expressed as <host>:<port> of the Contrast UI',
31
- organizationIdParameter:
32
- 'Please set the %s to correctly identify your organization within the Contrast UI',
33
- authorizationParameter:
34
- 'Please set the %s to your authorization header, found in the Contrast UI',
35
- applicationIdParameter:
36
- 'Please set the %s to the value provided within the Contrast UI for the target application',
37
20
  libraryAnalysisError:
38
- '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',
21
+ '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',
39
22
  yamlMissingParametersHeader: 'Missing Parameters',
40
23
  yamlMissingParametersMessage:
41
- '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',
24
+ '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',
42
25
  unauthenticatedErrorHeader: '401 error - Unauthenticated',
43
26
  unauthenticatedErrorMessage:
44
- 'Please check the following keys are correct:\n--organization_id, --api_key or --authorization',
27
+ 'Please check the following keys are correct:\n--organization-id, --api-key or --authorization',
45
28
  badRequestErrorHeader: '400 error - Bad Request',
46
29
  badRequestErrorMessage:
47
- 'Please check the following key is correct: \n--application_id',
30
+ 'Please check the following key is correct: \n--application-id',
48
31
  badRequestCatalogueErrorMessage:
49
32
  'The application name already exists, please use a unique name',
50
33
  forbiddenRequestErrorHeader: '403 error - Forbidden',
@@ -53,15 +36,7 @@ const en_locales = () => {
53
36
  proxyErrorHeader: '407 error - Proxy Authentication Required',
54
37
  proxyErrorMessage:
55
38
  'Please provide valid authentication credentials for the proxy server.',
56
- downgradeHttpsHttp:
57
- 'Connection to ContrastUI using https failed. Attempting to connect using http...',
58
- setSpecifiedParameter: 'Please set the %s ',
59
- catalogueFailureCommand:
60
- 'Failed to catalogue a new application for reason: ',
61
- catalogueFailureHostCommand:
62
- 'Failed to catalogue a new application, please ensure you have the correct host and authentication. Error: ',
63
- catalogueSuccessCommand:
64
- 'This application ID can now be used to send dependency data to Contrast: ',
39
+ catalogueSuccessCommand: 'Application Created',
65
40
  dotnetAnalysisFailure: '.NET analysis failed because: ',
66
41
  dotnetReadLockfile: 'Failed to read the lock file @ %s because: ',
67
42
  dotnetParseLockfile: "Failed to parse .NET lock file @ '%s' because: ",
@@ -129,12 +104,10 @@ const en_locales = () => {
129
104
  constantsOptionalForCatalogue: '(optional for catalogue)',
130
105
  constantsRequired: '(required)',
131
106
  constantsRequiredCatalogue: '(required for catalogue)',
132
- constantsYamlPath:
133
- 'If you want to read params from the yaml file then enter the path to the file',
134
107
  constantsApiKey: 'An agent API key as provided by Contrast UI',
135
108
  constantsAuthorization:
136
- 'An agent Authorization credentials as provided by Contrast UI',
137
- constantsOrganizationId: 'The ID of your organization in Contrast UI',
109
+ 'Authorization credentials as provided by Contrast UI',
110
+ constantsOrganizationId: 'The ID of your organization',
138
111
  constantsApplicationId:
139
112
  'The ID of the application cataloged by Contrast UI',
140
113
  constantsHostId:
@@ -253,17 +226,17 @@ const en_locales = () => {
253
226
  goAnalysisError: 'GO analysis failed because: ',
254
227
  goParseProjectFile: 'Failed to parse go mod graph output because: ',
255
228
  mavenNotInstalledError:
256
- " 'mvn' is not available. Please ensure you have Maven installed and available on your path.",
229
+ "'mvn' is not available. Please ensure you have Maven installed and available on your path.",
257
230
  mavenDependencyTreeNonZero:
258
231
  'Building maven dependancy tree failed with a non 0 exit code',
259
232
  gradleWrapperUnavailable:
260
- ' Gradle wrapper not found in root of project. Please ensure gradlew or gradlew.bat is in root of the project.',
233
+ 'Gradle wrapper not found in root of project. Please ensure gradlew or gradlew.bat is in root of the project.',
261
234
  gradleDependencyTreeNonZero:
262
235
  "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",
263
236
  yamlPathCamelCaseError:
264
- ' Warning: The "yamlPath" parameter will be deprecated in a future release. Please look at our documentation for further guidance.',
237
+ 'Warning: The "yamlPath" parameter will be deprecated in a future release. Please look at our documentation for further guidance.',
265
238
  constantsSbom:
266
- ' Generate the Software Bill of Materials (SBOM) for the given application',
239
+ 'Generate the Software Bill of Materials (SBOM) for the given application',
267
240
  constantsMetadata:
268
241
  'Define a set of key=value pairs (which conforms to RFC 2253) for specifying user-defined metadata associated with the application.',
269
242
  constantsTags:
@@ -271,8 +244,8 @@ const en_locales = () => {
271
244
  constantsCode:
272
245
  'Add the application code this application should use in the Contrast UI',
273
246
  constantsIgnoreCertErrors:
274
- ' For EOP users with a local Teamserver install, this will bypass the SSL certificate and recognise a self signed certificate.',
275
- constantsSave: ' Saves the Scan Results SARIF to file.',
247
+ 'For EOP users with a local Teamserver install, this will bypass the SSL certificate and recognise a self signed certificate.',
248
+ constantsSave: 'Saves the Scan Results SARIF to file.',
276
249
  scanLabel:
277
250
  "adds a label to the scan - defaults to 'Started by CLI tool at current date'",
278
251
  constantsIgnoreDev:
@@ -291,9 +264,10 @@ const en_locales = () => {
291
264
  responseMessage: 'Response: %s',
292
265
  searchingDirectoryScan: 'Searched 3 directory levels & found: ',
293
266
  noFileFoundScan:
294
- "We could't find a suitable file in your directories (we go 3 deep)",
267
+ "We couldn't find a suitable file in your directories (we go 3 deep)",
295
268
  specifyFileScanError:
296
269
  '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>"',
270
+ specifyFileAuditNotFound: 'No files found for library analysis',
297
271
  populateProjectIdMessage: 'project ID is %s',
298
272
  genericServiceError: 'returned with status code %s',
299
273
  projectIdError: 'Your project ID is %s please check this is correct',
@@ -342,6 +316,8 @@ const en_locales = () => {
342
316
  requiredParams: 'All required parameters are not present.',
343
317
  timeoutScan: 'Timeout set to 5 minutes.',
344
318
  searchingScanFileDirectory: 'Searching for file to scan from %s...',
319
+ searchingAuditFileDirectory:
320
+ 'Searching for package manager files from %s...',
345
321
  scanHeader: 'Contrast Scan CLI',
346
322
  authHeader: 'Auth',
347
323
  lambdaHeader: 'Contrast Lambda CLI',
@@ -417,7 +393,11 @@ const en_locales = () => {
417
393
  auditOptionsSave: '-s, --save',
418
394
  auditOptionsSaveDescription:
419
395
  'saves the output in specified format Txt text, sbom',
396
+ scanNotCompleted:
397
+ 'Scan not completed. Check for framework and language support here: %s',
420
398
  scanNoVulnerabilitiesFound: '👏 No vulnerabilities found',
399
+ scanNoVulnerabilitiesFoundSecureCode: '👍 Your code looks secure.',
400
+ scanNoVulnerabilitiesFoundGoodWork: '👏 Keep up the good work.',
421
401
  scanNoFiletypeSpecifiedForSave:
422
402
  'Please specify file type to save results to, accepted value is SARIF',
423
403
  auditSBOMSaveSuccess:
@@ -430,8 +410,9 @@ const en_locales = () => {
430
410
  )}`,
431
411
  auditReportWaiting: 'Waiting for report...',
432
412
  auditReportFail: 'Report Retrieval Failed, please try again',
433
- auditReportSuccessMessage: ' Report successfully retrieved',
434
- auditReportFailureMessage: ' Unable to generate library report.',
413
+ auditReportSuccessMessage: 'Report successfully retrieved',
414
+ auditReportFailureMessage: 'Unable to generate library report',
415
+ auditSCAAnalysisBegins: 'Contrast SCA analysis begins',
435
416
  ...lambda
436
417
  }
437
418
  }
package/src/constants.js CHANGED
@@ -47,6 +47,15 @@ const scanOptionDefinitions = [
47
47
  '}: ' +
48
48
  i18n.__('constantsProjectId')
49
49
  },
50
+ {
51
+ name: 'project-path',
52
+ alias: 'i',
53
+ description:
54
+ '{bold ' +
55
+ i18n.__('constantsOptional') +
56
+ '}: ' +
57
+ i18n.__('constantsProjectPath')
58
+ },
50
59
  {
51
60
  name: 'timeout',
52
61
  alias: 't',
@@ -146,6 +155,19 @@ const scanOptionDefinitions = [
146
155
  name: 'debug',
147
156
  alias: 'd',
148
157
  type: Boolean
158
+ },
159
+ {
160
+ name: 'experimental',
161
+ alias: 'e',
162
+ type: Boolean
163
+ },
164
+ {
165
+ name: 'application-name',
166
+ description:
167
+ '{bold ' +
168
+ i18n.__('constantsOptional') +
169
+ '}: ' +
170
+ i18n.__('constantsApplicationName')
149
171
  }
150
172
  ]
151
173
 
@@ -0,0 +1,10 @@
1
+ const createJavaTSMessage = javaTree => {
2
+ return {
3
+ java: {
4
+ mavenDependencyTrees: javaTree
5
+ }
6
+ }
7
+ }
8
+ module.exports = {
9
+ createJavaTSMessage
10
+ }
@@ -0,0 +1,34 @@
1
+ const { getHttpClient } = require('../../utils/commonApi')
2
+ const { handleResponseErrors } = require('../../common/errorHandling')
3
+ const { APP_VERSION } = require('../../constants/constants')
4
+
5
+ const commonSendSnapShot = async (analysis, config) => {
6
+ const requestBody = {
7
+ appID: config.applicationId,
8
+ cliVersion: APP_VERSION,
9
+ snapshot: analysis
10
+ }
11
+
12
+ //console.log(JSON.stringify(analysis))
13
+
14
+ //console.log(JSON.stringify(requestBody))
15
+ const client = getHttpClient(config)
16
+ return client
17
+ .sendSnapshot(requestBody, config)
18
+ .then(res => {
19
+ if (res.statusCode === 201) {
20
+ console.log('snapshot processed successfully')
21
+ return res.body
22
+ } else {
23
+ console.log(res.statusCode)
24
+ handleResponseErrors(res, 'snapshot')
25
+ }
26
+ })
27
+ .catch(err => {
28
+ console.log(err)
29
+ })
30
+ }
31
+
32
+ module.exports = {
33
+ commonSendSnapShot
34
+ }