@contrast/contrast 1.0.22 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/README.md +21 -138
  2. package/dist/audit/languageAnalysisEngine/sendSnapshot.js +2 -19
  3. package/dist/audit/report/commonReportingFunctions.js +1 -1
  4. package/dist/audit/save.js +16 -5
  5. package/dist/cliConstants.js +29 -0
  6. package/dist/commands/audit/auditController.js +2 -1
  7. package/dist/commands/audit/help.js +3 -3
  8. package/dist/commands/audit/processAudit.js +3 -1
  9. package/dist/commands/audit/saveFile.js +5 -1
  10. package/dist/commands/github/projectGroup.js +164 -0
  11. package/dist/common/HTTPClient.js +165 -13
  12. package/dist/constants/constants.js +3 -5
  13. package/dist/constants/locales.js +7 -3
  14. package/dist/index.js +0 -4
  15. package/dist/lambda/lambda.js +3 -1
  16. package/dist/sbom/generateSbom.js +7 -0
  17. package/dist/scaAnalysis/common/commonReportingFunctionsSca.js +6 -6
  18. package/dist/scaAnalysis/common/scaServicesUpload.js +77 -7
  19. package/dist/scaAnalysis/common/treeUpload.js +1 -1
  20. package/dist/scaAnalysis/go/goAnalysis.js +1 -1
  21. package/dist/scaAnalysis/java/analysis.js +24 -32
  22. package/dist/scaAnalysis/java/index.js +1 -1
  23. package/dist/scaAnalysis/javascript/index.js +3 -3
  24. package/dist/scaAnalysis/legacy/legacyFlow.js +33 -0
  25. package/dist/scaAnalysis/php/index.js +1 -1
  26. package/dist/scaAnalysis/processServicesFlow.js +21 -0
  27. package/dist/scaAnalysis/python/analysis.js +1 -1
  28. package/dist/scaAnalysis/python/index.js +1 -1
  29. package/dist/scaAnalysis/repoMode/index.js +2 -2
  30. package/dist/scaAnalysis/ruby/analysis.js +1 -1
  31. package/dist/scaAnalysis/ruby/index.js +1 -1
  32. package/dist/scaAnalysis/scaAnalysis.js +16 -36
  33. package/dist/scan/autoDetection.js +41 -2
  34. package/dist/scan/fileUtils.js +5 -4
  35. package/dist/utils/commonApi.js +26 -1
  36. package/dist/utils/settingsHelper.js +7 -17
  37. package/package.json +6 -6
  38. package/src/audit/languageAnalysisEngine/sendSnapshot.js +3 -22
  39. package/src/audit/report/commonReportingFunctions.js +1 -1
  40. package/src/audit/save.js +21 -10
  41. package/src/cliConstants.js +32 -0
  42. package/src/commands/audit/auditController.js +2 -1
  43. package/src/commands/audit/help.js +3 -3
  44. package/src/commands/audit/processAudit.js +4 -5
  45. package/src/commands/audit/saveFile.js +6 -1
  46. package/src/commands/github/projectGroup.js +187 -0
  47. package/src/common/HTTPClient.js +221 -13
  48. package/src/constants/constants.js +3 -5
  49. package/src/constants/locales.js +9 -3
  50. package/src/index.ts +0 -5
  51. package/src/lambda/lambda.ts +3 -1
  52. package/src/lambda/lambdaUtils.ts +1 -1
  53. package/src/sbom/generateSbom.ts +8 -0
  54. package/src/scaAnalysis/common/commonReportingFunctionsSca.js +6 -6
  55. package/src/scaAnalysis/common/scaServicesUpload.js +92 -7
  56. package/src/scaAnalysis/common/treeUpload.js +1 -1
  57. package/src/scaAnalysis/go/goAnalysis.js +1 -1
  58. package/src/scaAnalysis/java/analysis.js +29 -34
  59. package/src/scaAnalysis/java/index.js +1 -1
  60. package/src/scaAnalysis/javascript/index.js +3 -6
  61. package/src/scaAnalysis/legacy/legacyFlow.js +48 -0
  62. package/src/scaAnalysis/php/index.js +1 -1
  63. package/src/scaAnalysis/processServicesFlow.js +29 -0
  64. package/src/scaAnalysis/python/analysis.js +1 -1
  65. package/src/scaAnalysis/python/index.js +1 -1
  66. package/src/scaAnalysis/repoMode/index.js +2 -2
  67. package/src/scaAnalysis/ruby/analysis.js +1 -1
  68. package/src/scaAnalysis/ruby/index.js +1 -1
  69. package/src/scaAnalysis/scaAnalysis.js +21 -57
  70. package/src/scan/autoDetection.js +44 -3
  71. package/src/scan/fileUtils.js +5 -4
  72. package/src/utils/commonApi.js +29 -1
  73. package/src/utils/settingsHelper.js +8 -18
  74. package/dist/commands/fingerprint/processFingerprint.js +0 -14
  75. package/src/commands/fingerprint/processFingerprint.js +0 -21
  76. /package/dist/commands/{fingerprint → github}/fingerprintConfig.js +0 -0
  77. /package/src/commands/{fingerprint → github}/fingerprintConfig.js +0 -0
@@ -12,7 +12,33 @@ const {
12
12
  parametersError,
13
13
  invalidHostNameError
14
14
  } = require('../common/errorHandling')
15
+ const { performance } = require('perf_hooks')
16
+ const requestUtils = require('./requestUtils')
17
+ const oraFunctions = require('./oraWrapper')
15
18
 
19
+ const getTimeout = config => {
20
+ if (config.timeout) {
21
+ return config.timeout
22
+ } else {
23
+ if (config.verbose) {
24
+ console.log('Timeout set to 5 minutes')
25
+ }
26
+ return 300
27
+ }
28
+ }
29
+
30
+ const handleTimeout = (startTime, timeout, reportSpinner) => {
31
+ const endTime = performance.now() - startTime
32
+ if (requestUtils.millisToSeconds(endTime) > timeout) {
33
+ oraFunctions.failSpinner(
34
+ reportSpinner,
35
+ 'Contrast audit timed out at the specified timeout of ' +
36
+ timeout +
37
+ ' seconds.'
38
+ )
39
+ throw new Error('You can update the timeout using --timeout')
40
+ }
41
+ }
16
42
  const handleResponseErrors = (res, api) => {
17
43
  if (res.statusCode === 400) {
18
44
  api === 'catalogue' ? badRequestError(true) : badRequestError(false)
@@ -71,5 +97,7 @@ module.exports = {
71
97
  getValidHost: getValidHost,
72
98
  getProtocol: getProtocol,
73
99
  handleResponseErrors: handleResponseErrors,
74
- getHttpClient: getHttpClient
100
+ getHttpClient: getHttpClient,
101
+ handleTimeout: handleTimeout,
102
+ getTimeout: getTimeout
75
103
  }
@@ -1,24 +1,14 @@
1
- const commonApi = require('./commonApi')
2
- const { getMode } = require('./generalAPI')
3
- const { SAAS, MODE_BUILD } = require('../constants/constants')
1
+ const generalAPI = require('./generalAPI')
2
+ const { SAAS } = require('../constants/constants')
4
3
 
5
4
  const getSettings = async config => {
6
- config.isEOP = (await getMode(config)).toUpperCase() === SAAS ? false : true
7
- config.mode = MODE_BUILD
8
- config.scaServices = await isSCAServicesAvailable(config)
9
- return config
10
- }
5
+ config.isEOP =
6
+ (await generalAPI.getMode(config)).toUpperCase() === SAAS ? false : true
11
7
 
12
- const isSCAServicesAvailable = async config => {
13
- const client = commonApi.getHttpClient(config)
14
- return client
15
- .scaServiceHealth(config)
16
- .then(res => {
17
- return res.body.status === 'UP'
18
- })
19
- .catch(err => {
20
- console.log(err)
21
- })
8
+ if (config.legacy === undefined) {
9
+ config.legacy = config.isEOP
10
+ }
11
+ return config
22
12
  }
23
13
 
24
14
  module.exports = {
@@ -1,14 +0,0 @@
1
- "use strict";
2
- const fingerprintConfig = require('./fingerprintConfig');
3
- const autoDetection = require('../../scan/autoDetection');
4
- const saveResults = require('../../scan/saveResults');
5
- const processFingerprint = async (contrastConf, argvMain) => {
6
- const config = await fingerprintConfig.getFingerprintConfig(contrastConf, 'fingerprint', argvMain);
7
- let fingerprint = await autoDetection.autoDetectFingerprintInfo(config.file, config.depth);
8
- let idArray = fingerprint.map(x => x.id);
9
- await saveResults.writeResultsToFile(fingerprint, 'fingerPrintInfo.json');
10
- return console.log(idArray);
11
- };
12
- module.exports = {
13
- processFingerprint
14
- };
@@ -1,21 +0,0 @@
1
- const fingerprintConfig = require('./fingerprintConfig')
2
- const autoDetection = require('../../scan/autoDetection')
3
- const saveResults = require('../../scan/saveResults')
4
- const processFingerprint = async (contrastConf, argvMain) => {
5
- const config = await fingerprintConfig.getFingerprintConfig(
6
- contrastConf,
7
- 'fingerprint',
8
- argvMain
9
- )
10
- let fingerprint = await autoDetection.autoDetectFingerprintInfo(
11
- config.file,
12
- config.depth
13
- )
14
- let idArray = fingerprint.map(x => x.id)
15
- await saveResults.writeResultsToFile(fingerprint, 'fingerPrintInfo.json')
16
- return console.log(idArray)
17
- }
18
-
19
- module.exports = {
20
- processFingerprint
21
- }