@contrast/contrast 1.0.23 → 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 (71) hide show
  1. package/README.md +21 -138
  2. package/dist/audit/languageAnalysisEngine/sendSnapshot.js +2 -19
  3. package/dist/audit/save.js +6 -1
  4. package/dist/cliConstants.js +29 -0
  5. package/dist/commands/audit/auditController.js +2 -1
  6. package/dist/commands/audit/help.js +3 -2
  7. package/dist/commands/audit/processAudit.js +2 -0
  8. package/dist/commands/audit/saveFile.js +5 -1
  9. package/dist/commands/github/projectGroup.js +164 -0
  10. package/dist/common/HTTPClient.js +165 -13
  11. package/dist/constants/constants.js +3 -5
  12. package/dist/constants/locales.js +7 -3
  13. package/dist/index.js +0 -4
  14. package/dist/lambda/lambda.js +3 -1
  15. package/dist/scaAnalysis/common/commonReportingFunctionsSca.js +3 -3
  16. package/dist/scaAnalysis/common/scaServicesUpload.js +77 -7
  17. package/dist/scaAnalysis/common/treeUpload.js +19 -5
  18. package/dist/scaAnalysis/go/goAnalysis.js +6 -1
  19. package/dist/scaAnalysis/java/index.js +6 -1
  20. package/dist/scaAnalysis/javascript/index.js +5 -2
  21. package/dist/scaAnalysis/legacy/legacyFlow.js +33 -0
  22. package/dist/scaAnalysis/php/index.js +8 -2
  23. package/dist/scaAnalysis/processServicesFlow.js +21 -0
  24. package/dist/scaAnalysis/python/analysis.js +10 -4
  25. package/dist/scaAnalysis/python/index.js +6 -1
  26. package/dist/scaAnalysis/repoMode/index.js +2 -2
  27. package/dist/scaAnalysis/ruby/analysis.js +10 -1
  28. package/dist/scaAnalysis/ruby/index.js +6 -1
  29. package/dist/scaAnalysis/scaAnalysis.js +47 -25
  30. package/dist/scan/autoDetection.js +41 -2
  31. package/dist/scan/fileUtils.js +5 -4
  32. package/dist/utils/commonApi.js +26 -1
  33. package/dist/utils/settingsHelper.js +14 -0
  34. package/package.json +8 -5
  35. package/src/audit/languageAnalysisEngine/sendSnapshot.js +3 -22
  36. package/src/audit/save.js +10 -1
  37. package/src/cliConstants.js +32 -0
  38. package/src/commands/audit/auditController.js +2 -1
  39. package/src/commands/audit/help.js +3 -2
  40. package/src/commands/audit/processAudit.js +2 -0
  41. package/src/commands/audit/saveFile.js +6 -1
  42. package/src/commands/github/projectGroup.js +187 -0
  43. package/src/common/HTTPClient.js +221 -13
  44. package/src/constants/constants.js +3 -5
  45. package/src/constants/locales.js +9 -3
  46. package/src/index.ts +0 -5
  47. package/src/lambda/lambda.ts +3 -1
  48. package/src/lambda/lambdaUtils.ts +1 -1
  49. package/src/scaAnalysis/common/commonReportingFunctionsSca.js +3 -3
  50. package/src/scaAnalysis/common/scaServicesUpload.js +92 -7
  51. package/src/scaAnalysis/common/treeUpload.js +20 -5
  52. package/src/scaAnalysis/go/goAnalysis.js +6 -1
  53. package/src/scaAnalysis/java/index.js +6 -1
  54. package/src/scaAnalysis/javascript/index.js +6 -4
  55. package/src/scaAnalysis/legacy/legacyFlow.js +48 -0
  56. package/src/scaAnalysis/php/index.js +8 -2
  57. package/src/scaAnalysis/processServicesFlow.js +29 -0
  58. package/src/scaAnalysis/python/analysis.js +10 -4
  59. package/src/scaAnalysis/python/index.js +6 -1
  60. package/src/scaAnalysis/repoMode/index.js +2 -2
  61. package/src/scaAnalysis/ruby/analysis.js +11 -1
  62. package/src/scaAnalysis/ruby/index.js +6 -1
  63. package/src/scaAnalysis/scaAnalysis.js +61 -37
  64. package/src/scan/autoDetection.js +44 -3
  65. package/src/scan/fileUtils.js +5 -4
  66. package/src/utils/commonApi.js +29 -1
  67. package/src/utils/settingsHelper.js +16 -0
  68. package/dist/commands/fingerprint/processFingerprint.js +0 -14
  69. package/src/commands/fingerprint/processFingerprint.js +0 -21
  70. /package/dist/commands/{fingerprint → github}/fingerprintConfig.js +0 -0
  71. /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
  }
@@ -0,0 +1,16 @@
1
+ const generalAPI = require('./generalAPI')
2
+ const { SAAS } = require('../constants/constants')
3
+
4
+ const getSettings = async config => {
5
+ config.isEOP =
6
+ (await generalAPI.getMode(config)).toUpperCase() === SAAS ? false : true
7
+
8
+ if (config.legacy === undefined) {
9
+ config.legacy = config.isEOP
10
+ }
11
+ return config
12
+ }
13
+
14
+ module.exports = {
15
+ getSettings
16
+ }
@@ -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
- }