@contrast/contrast 1.0.8 → 1.0.11

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 (217) hide show
  1. package/README.md +2 -2
  2. package/dist/audit/languageAnalysisEngine/getProjectRootFilenames.js +16 -25
  3. package/dist/audit/languageAnalysisEngine/report/commonReportingFunctions.js +103 -57
  4. package/dist/audit/languageAnalysisEngine/report/models/reportGuidanceModel.js +6 -0
  5. package/dist/audit/languageAnalysisEngine/report/models/reportOutputModel.js +3 -3
  6. package/dist/audit/languageAnalysisEngine/report/models/severityCountModel.js +1 -0
  7. package/dist/audit/languageAnalysisEngine/report/reportingFeature.js +68 -17
  8. package/dist/audit/languageAnalysisEngine/report/utils/reportUtils.js +39 -7
  9. package/dist/audit/languageAnalysisEngine/sendSnapshot.js +6 -30
  10. package/dist/audit/save.js +21 -13
  11. package/dist/commands/audit/auditConfig.js +3 -19
  12. package/dist/commands/audit/auditController.js +1 -10
  13. package/dist/commands/audit/help.js +7 -24
  14. package/dist/commands/audit/processAudit.js +5 -9
  15. package/dist/commands/audit/saveFile.js +2 -2
  16. package/dist/commands/auth/auth.js +1 -1
  17. package/dist/commands/config/config.js +2 -2
  18. package/dist/commands/scan/processScan.js +11 -4
  19. package/dist/commands/scan/sca/scaAnalysis.js +37 -13
  20. package/dist/common/HTTPClient.js +17 -8
  21. package/dist/common/errorHandling.js +2 -2
  22. package/dist/common/fail.js +66 -0
  23. package/dist/common/versionChecker.js +1 -1
  24. package/dist/constants/constants.js +7 -2
  25. package/dist/constants/locales.js +40 -38
  26. package/dist/constants.js +62 -12
  27. package/dist/index.js +57 -45
  28. package/dist/lambda/lambda.js +5 -2
  29. package/dist/sbom/generateSbom.js +2 -2
  30. package/dist/scaAnalysis/common/formatMessage.js +7 -1
  31. package/dist/scaAnalysis/common/scaParserForGoAndJava.js +32 -0
  32. package/dist/scaAnalysis/common/treeUpload.js +24 -10
  33. package/dist/scaAnalysis/dotnet/analysis.js +55 -0
  34. package/dist/scaAnalysis/dotnet/index.js +10 -0
  35. package/dist/scaAnalysis/go/goAnalysis.js +8 -2
  36. package/dist/scaAnalysis/java/analysis.js +10 -6
  37. package/dist/scaAnalysis/java/index.js +7 -1
  38. package/dist/scaAnalysis/java/javaBuildDepsParser.js +19 -3
  39. package/dist/scaAnalysis/javascript/analysis.js +4 -7
  40. package/dist/scaAnalysis/javascript/index.js +16 -4
  41. package/dist/scaAnalysis/php/analysis.js +14 -33
  42. package/dist/scaAnalysis/php/index.js +11 -4
  43. package/dist/scaAnalysis/python/analysis.js +43 -5
  44. package/dist/scaAnalysis/python/index.js +7 -2
  45. package/dist/scaAnalysis/ruby/analysis.js +16 -14
  46. package/dist/scan/autoDetection.js +13 -24
  47. package/dist/scan/fileUtils.js +31 -12
  48. package/dist/scan/formatScanOutput.js +9 -8
  49. package/dist/scan/populateProjectIdAndProjectName.js +5 -0
  50. package/dist/scan/scan.js +4 -0
  51. package/dist/scan/scanConfig.js +5 -5
  52. package/dist/scan/scanResults.js +39 -3
  53. package/dist/telemetry/telemetry.js +137 -0
  54. package/dist/utils/commonApi.js +1 -1
  55. package/dist/utils/getConfig.js +3 -8
  56. package/dist/utils/parsedCLIOptions.js +3 -1
  57. package/dist/utils/requestUtils.js +7 -1
  58. package/package.json +2 -3
  59. package/src/audit/languageAnalysisEngine/getProjectRootFilenames.js +21 -57
  60. package/src/audit/languageAnalysisEngine/report/commonReportingFunctions.ts +155 -77
  61. package/src/audit/languageAnalysisEngine/report/models/reportGuidanceModel.ts +5 -0
  62. package/src/audit/languageAnalysisEngine/report/models/reportOutputModel.ts +5 -5
  63. package/src/audit/languageAnalysisEngine/report/models/severityCountModel.ts +2 -0
  64. package/src/audit/languageAnalysisEngine/report/reportingFeature.ts +56 -27
  65. package/src/audit/languageAnalysisEngine/report/utils/reportUtils.ts +45 -6
  66. package/src/audit/languageAnalysisEngine/sendSnapshot.js +6 -32
  67. package/src/audit/save.js +32 -16
  68. package/src/commands/audit/auditConfig.ts +10 -28
  69. package/src/commands/audit/auditController.ts +0 -11
  70. package/src/commands/audit/help.ts +7 -24
  71. package/src/commands/audit/processAudit.ts +16 -8
  72. package/src/commands/audit/saveFile.ts +2 -2
  73. package/src/commands/auth/auth.js +3 -1
  74. package/src/commands/config/config.js +4 -2
  75. package/src/commands/scan/processScan.js +18 -5
  76. package/src/commands/scan/sca/scaAnalysis.js +50 -18
  77. package/src/common/HTTPClient.js +23 -9
  78. package/src/common/errorHandling.ts +2 -3
  79. package/src/common/fail.js +75 -0
  80. package/src/common/versionChecker.ts +1 -1
  81. package/src/constants/constants.js +9 -3
  82. package/src/constants/locales.js +70 -45
  83. package/src/constants.js +67 -13
  84. package/src/index.ts +91 -66
  85. package/src/lambda/lambda.ts +5 -2
  86. package/src/lambda/types.ts +1 -0
  87. package/src/sbom/generateSbom.ts +2 -2
  88. package/src/scaAnalysis/common/formatMessage.js +8 -1
  89. package/src/scaAnalysis/common/scaParserForGoAndJava.js +41 -0
  90. package/src/scaAnalysis/common/treeUpload.js +25 -11
  91. package/src/scaAnalysis/dotnet/analysis.js +72 -0
  92. package/src/scaAnalysis/dotnet/index.js +11 -0
  93. package/src/scaAnalysis/go/goAnalysis.js +9 -2
  94. package/src/scaAnalysis/java/analysis.js +11 -6
  95. package/src/scaAnalysis/java/index.js +9 -1
  96. package/src/scaAnalysis/java/javaBuildDepsParser.js +25 -6
  97. package/src/scaAnalysis/javascript/analysis.js +6 -7
  98. package/src/scaAnalysis/javascript/index.js +25 -6
  99. package/src/scaAnalysis/php/analysis.js +15 -35
  100. package/src/scaAnalysis/php/index.js +15 -4
  101. package/src/scaAnalysis/python/analysis.js +49 -5
  102. package/src/scaAnalysis/python/index.js +7 -2
  103. package/src/scaAnalysis/ruby/analysis.js +18 -15
  104. package/src/scan/autoDetection.js +14 -27
  105. package/src/scan/fileUtils.js +33 -12
  106. package/src/scan/formatScanOutput.ts +10 -8
  107. package/src/scan/populateProjectIdAndProjectName.js +5 -1
  108. package/src/scan/scan.ts +4 -0
  109. package/src/scan/scanConfig.js +7 -7
  110. package/src/scan/scanResults.js +46 -3
  111. package/src/telemetry/telemetry.ts +154 -0
  112. package/src/utils/commonApi.js +1 -1
  113. package/src/utils/getConfig.ts +5 -18
  114. package/src/utils/parsedCLIOptions.js +14 -1
  115. package/src/utils/requestUtils.js +8 -1
  116. package/dist/audit/AnalysisEngine.js +0 -37
  117. package/dist/audit/autodetection/autoDetectLanguage.js +0 -32
  118. package/dist/audit/dotnetAnalysisEngine/index.js +0 -25
  119. package/dist/audit/dotnetAnalysisEngine/parseLockFileContents.js +0 -35
  120. package/dist/audit/dotnetAnalysisEngine/parseProjectFileContents.js +0 -15
  121. package/dist/audit/dotnetAnalysisEngine/readLockFileContents.js +0 -18
  122. package/dist/audit/dotnetAnalysisEngine/readProjectFileContents.js +0 -14
  123. package/dist/audit/dotnetAnalysisEngine/sanitizer.js +0 -9
  124. package/dist/audit/goAnalysisEngine/index.js +0 -17
  125. package/dist/audit/goAnalysisEngine/parseProjectFileContents.js +0 -164
  126. package/dist/audit/goAnalysisEngine/readProjectFileContents.js +0 -21
  127. package/dist/audit/goAnalysisEngine/sanitizer.js +0 -5
  128. package/dist/audit/javaAnalysisEngine/index.js +0 -34
  129. package/dist/audit/javaAnalysisEngine/parseMavenProjectFileContents.js +0 -155
  130. package/dist/audit/javaAnalysisEngine/parseProjectFileContents.js +0 -353
  131. package/dist/audit/javaAnalysisEngine/readProjectFileContents.js +0 -98
  132. package/dist/audit/javaAnalysisEngine/sanitizer.js +0 -5
  133. package/dist/audit/languageAnalysisEngine/checkForMultipleIdentifiedLanguages.js +0 -25
  134. package/dist/audit/languageAnalysisEngine/checkForMultipleIdentifiedProjectFiles.js +0 -25
  135. package/dist/audit/languageAnalysisEngine/checkIdentifiedLanguageHasLockFile.js +0 -35
  136. package/dist/audit/languageAnalysisEngine/checkIdentifiedLanguageHasProjectFile.js +0 -24
  137. package/dist/audit/languageAnalysisEngine/constants.js +0 -20
  138. package/dist/audit/languageAnalysisEngine/getIdentifiedLanguageInfo.js +0 -25
  139. package/dist/audit/languageAnalysisEngine/index.js +0 -39
  140. package/dist/audit/languageAnalysisEngine/languageAnalysisFactory.js +0 -66
  141. package/dist/audit/languageAnalysisEngine/reduceIdentifiedLanguages.js +0 -166
  142. package/dist/audit/nodeAnalysisEngine/handleNPMLockFileV2.js +0 -40
  143. package/dist/audit/nodeAnalysisEngine/index.js +0 -31
  144. package/dist/audit/nodeAnalysisEngine/parseNPMLockFileContents.js +0 -18
  145. package/dist/audit/nodeAnalysisEngine/parseYarnLockFileContents.js +0 -18
  146. package/dist/audit/nodeAnalysisEngine/readNPMLockFileContents.js +0 -17
  147. package/dist/audit/nodeAnalysisEngine/readProjectFileContents.js +0 -14
  148. package/dist/audit/nodeAnalysisEngine/readYarnLockFileContents.js +0 -24
  149. package/dist/audit/nodeAnalysisEngine/sanitizer.js +0 -9
  150. package/dist/audit/phpAnalysisEngine/index.js +0 -23
  151. package/dist/audit/phpAnalysisEngine/parseLockFileContents.js +0 -52
  152. package/dist/audit/phpAnalysisEngine/readLockFileContents.js +0 -13
  153. package/dist/audit/phpAnalysisEngine/readProjectFileContents.js +0 -16
  154. package/dist/audit/phpAnalysisEngine/sanitizer.js +0 -5
  155. package/dist/audit/pythonAnalysisEngine/index.js +0 -25
  156. package/dist/audit/pythonAnalysisEngine/parsePipfileLockContents.js +0 -17
  157. package/dist/audit/pythonAnalysisEngine/parseProjectFileContents.js +0 -21
  158. package/dist/audit/pythonAnalysisEngine/readPipfileLockFileContents.js +0 -13
  159. package/dist/audit/pythonAnalysisEngine/readPythonProjectFileContents.js +0 -14
  160. package/dist/audit/pythonAnalysisEngine/sanitizer.js +0 -7
  161. package/dist/audit/rubyAnalysisEngine/index.js +0 -25
  162. package/dist/audit/rubyAnalysisEngine/parseGemfileLockContents.js +0 -176
  163. package/dist/audit/rubyAnalysisEngine/parsedGemfile.js +0 -22
  164. package/dist/audit/rubyAnalysisEngine/readGemfileContents.js +0 -14
  165. package/dist/audit/rubyAnalysisEngine/readGemfileLockContents.js +0 -14
  166. package/dist/audit/rubyAnalysisEngine/sanitizer.js +0 -6
  167. package/src/audit/AnalysisEngine.js +0 -103
  168. package/src/audit/autodetection/autoDetectLanguage.ts +0 -40
  169. package/src/audit/dotnetAnalysisEngine/index.js +0 -26
  170. package/src/audit/dotnetAnalysisEngine/parseLockFileContents.js +0 -47
  171. package/src/audit/dotnetAnalysisEngine/parseProjectFileContents.js +0 -29
  172. package/src/audit/dotnetAnalysisEngine/readLockFileContents.js +0 -30
  173. package/src/audit/dotnetAnalysisEngine/readProjectFileContents.js +0 -26
  174. package/src/audit/dotnetAnalysisEngine/sanitizer.js +0 -11
  175. package/src/audit/goAnalysisEngine/index.js +0 -18
  176. package/src/audit/goAnalysisEngine/parseProjectFileContents.js +0 -209
  177. package/src/audit/goAnalysisEngine/readProjectFileContents.js +0 -31
  178. package/src/audit/goAnalysisEngine/sanitizer.js +0 -7
  179. package/src/audit/javaAnalysisEngine/index.js +0 -41
  180. package/src/audit/javaAnalysisEngine/parseMavenProjectFileContents.js +0 -225
  181. package/src/audit/javaAnalysisEngine/parseProjectFileContents.js +0 -420
  182. package/src/audit/javaAnalysisEngine/readProjectFileContents.js +0 -141
  183. package/src/audit/javaAnalysisEngine/sanitizer.js +0 -6
  184. package/src/audit/languageAnalysisEngine/checkForMultipleIdentifiedLanguages.js +0 -36
  185. package/src/audit/languageAnalysisEngine/checkForMultipleIdentifiedProjectFiles.js +0 -42
  186. package/src/audit/languageAnalysisEngine/checkIdentifiedLanguageHasLockFile.js +0 -54
  187. package/src/audit/languageAnalysisEngine/checkIdentifiedLanguageHasProjectFile.js +0 -33
  188. package/src/audit/languageAnalysisEngine/constants.js +0 -23
  189. package/src/audit/languageAnalysisEngine/getIdentifiedLanguageInfo.js +0 -41
  190. package/src/audit/languageAnalysisEngine/index.js +0 -45
  191. package/src/audit/languageAnalysisEngine/languageAnalysisFactory.js +0 -96
  192. package/src/audit/languageAnalysisEngine/reduceIdentifiedLanguages.js +0 -251
  193. package/src/audit/nodeAnalysisEngine/handleNPMLockFileV2.js +0 -49
  194. package/src/audit/nodeAnalysisEngine/index.js +0 -35
  195. package/src/audit/nodeAnalysisEngine/parseNPMLockFileContents.js +0 -20
  196. package/src/audit/nodeAnalysisEngine/parseYarnLockFileContents.js +0 -26
  197. package/src/audit/nodeAnalysisEngine/readNPMLockFileContents.js +0 -23
  198. package/src/audit/nodeAnalysisEngine/readProjectFileContents.js +0 -27
  199. package/src/audit/nodeAnalysisEngine/readYarnLockFileContents.js +0 -36
  200. package/src/audit/nodeAnalysisEngine/sanitizer.js +0 -11
  201. package/src/audit/phpAnalysisEngine/index.js +0 -27
  202. package/src/audit/phpAnalysisEngine/parseLockFileContents.js +0 -60
  203. package/src/audit/phpAnalysisEngine/readLockFileContents.js +0 -14
  204. package/src/audit/phpAnalysisEngine/readProjectFileContents.js +0 -25
  205. package/src/audit/phpAnalysisEngine/sanitizer.js +0 -4
  206. package/src/audit/pythonAnalysisEngine/index.js +0 -55
  207. package/src/audit/pythonAnalysisEngine/parsePipfileLockContents.js +0 -23
  208. package/src/audit/pythonAnalysisEngine/parseProjectFileContents.js +0 -33
  209. package/src/audit/pythonAnalysisEngine/readPipfileLockFileContents.js +0 -16
  210. package/src/audit/pythonAnalysisEngine/readPythonProjectFileContents.js +0 -22
  211. package/src/audit/pythonAnalysisEngine/sanitizer.js +0 -9
  212. package/src/audit/rubyAnalysisEngine/index.js +0 -30
  213. package/src/audit/rubyAnalysisEngine/parseGemfileLockContents.js +0 -215
  214. package/src/audit/rubyAnalysisEngine/parsedGemfile.js +0 -39
  215. package/src/audit/rubyAnalysisEngine/readGemfileContents.js +0 -18
  216. package/src/audit/rubyAnalysisEngine/readGemfileLockContents.js +0 -17
  217. package/src/audit/rubyAnalysisEngine/sanitizer.js +0 -8
@@ -16,7 +16,7 @@ const en_locales = () => {
16
16
  languageAnalysisFactoryFailureHeader: 'FAIL',
17
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',
18
18
  yamlMissingParametersHeader: 'Missing Parameters',
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',
19
+ genericErrorMessage: 'An error has occur please check your command again. For more information use the --help commands.',
20
20
  unauthenticatedErrorHeader: '401 error - Unauthenticated',
21
21
  unauthenticatedErrorMessage: 'Please check the following keys are correct:\n--organization-id, --api-key or --authorization',
22
22
  badRequestErrorHeader: '400 error - Bad Request',
@@ -38,20 +38,22 @@ const en_locales = () => {
38
38
  languageAnalysisMultipleLanguages2: 'Please specify which project file you would like analyzed with the %s CLI option.',
39
39
  languageAnalysisProjectFiles: "Identified project language as '%s' but found multiple project files: %s. Please specify which project file you would like analyzed with the %s CLI option.",
40
40
  languageAnalysisHasNoLockFile: "Identified project language as '%s' but no project lock file was found.",
41
- languageAnalysisHasMultipleLockFiles: "Identified project language as '%s' but multiple project lock files were found: %s \n",
41
+ languageAnalysisHasNoPackageJsonFile: 'Identified project language as javascript but no package.json file was found.',
42
+ languageAnalysisHasMultipleLockFiles: "Identified project language as '%s' but multiple project lock files were found.",
42
43
  languageAnalysisProjectFileError: "Identified project language as '%s' but no project file was found.",
43
44
  languageAnalysisProjectRootFileNameReadError: 'Failed to read the contents of the directory @ %s because: ',
44
45
  languageAnalysisProjectRootFileNameMissingError: "%s isn't a file or directory",
45
46
  languageAnalysisProjectRootFileNameFailure: 'Failed to get information about the file or directory @ %s because: ',
46
47
  languageAnalysisFailure: ' analysis failed because: ',
47
- languageAnalysisNoLanguage: 'No language detected in project path @ %s',
48
+ languageAnalysisNoLanguage: 'We cannot detect a project, use -f <path> to specify a file or folder to analyze.',
49
+ languageAnalysisNoLanguageHelpLine: `${chalk.bold('contrast audit --help')} for more information.`,
48
50
  NodeAnalysisFailure: 'NODE analysis failed because: ',
49
51
  phpAnalysisFailure: 'PHP analysis failed because: ',
50
- NodeParseNPM: "Failed to parse NODE package-lock.json file @ '%s' because: ",
52
+ NodeParseNPM: 'Failed to parse NODE package-lock.json file because: ',
51
53
  phpParseComposerLock: "Failed to parse PHP composer.lock file @ '%s' because: ",
52
54
  NodeReadNpmError: 'Failed to read the package-lock.json file @ "%s" because: ',
53
55
  phpReadError: 'Failed to read the composer.lock file @ "%s" because: ',
54
- NodeParseYarn: "Failed to parse Node yarn.lock version 1 @ '%s' because: ",
56
+ NodeParseYarn: 'Failed to parse yarn.lock version %s because: ',
55
57
  NodeParseYarn2: "Failed to parse Node yarn.lock version 2 @ '%s' because: ",
56
58
  nodeReadProjectFileError: 'Failed to read the NODE project file @ "%s" because: ',
57
59
  phpReadProjectFileError: 'Failed to read the PHP project file @ "%s" because: ',
@@ -77,8 +79,9 @@ const en_locales = () => {
77
79
  constantsHostId: 'Provide the name of the host and optionally the port expressed as "<host>:<port>".',
78
80
  constantsApplicationName: 'The name of the application cataloged by Contrast UI',
79
81
  constantsCatalogueApplication: 'Provide this if you want to catalogue an application',
82
+ failOptionErrorMessage: ' FAIL - CVEs have been detected that match at least the cve_severity option specified.',
80
83
  constantsLanguage: 'Valid values are JAVA, DOTNET, NODE, PYTHON and RUBY. If there are multiple project configuration files in the project_path, language is also required. Also, provide this when cataloguing an application',
81
- constantsFilePath: 'The directory root of a project/application that you would like analyzed. Defaults to current directory.',
84
+ constantsFilePath: `Specify a directory or the file where dependencies are declared. (By default, CodeSec will search for project files in the current directory.)`,
82
85
  constantsSilent: 'Silences JSON output.',
83
86
  constantsAppGroups: 'Assign your application to one or more pre-existing groups when using the catalogue command. Group lists should be comma separated.',
84
87
  constantsVersion: 'Displays CLI Version you are currently on.',
@@ -91,12 +94,17 @@ const en_locales = () => {
91
94
  constantsProjectId: 'The ID associated with a scan project. Replace <ProjectID> with the ID for the scan project. To find the ID, select a scan project in Contrast and locate the last number in the URL.',
92
95
  constantsReport: 'Display vulnerability information for this application',
93
96
  constantsFail: 'Set the process to fail if this option is set in combination with --cve_severity.',
94
- failOptionErrorMessage: ' FAIL - CVEs have been detected that match at least the cve_severity or cve_threshold option specified.',
97
+ failThresholdOptionErrorMessage: 'More than 0 vulnerabilities found',
98
+ failSeverityOptionErrorMessage: ' FAIL - Results detected vulnerabilities over accepted severity level',
95
99
  constantsSeverity: '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.',
96
100
  constantsCount: 'The number of CVEs that must be exceeded to fail a build',
97
101
  constantsHeader: 'CodeSec by Contrast Security',
98
- constantsPrerequisitesContentScanLanguages: 'Java & JavaScript supported',
99
- constantsContrastContent: "Use the 'contrast' command for fast and accurate security analysis of your applications and APIs (Java, JavaScript and .NET ) as well as serverless functions (AWS lambda, Java and Python).",
102
+ configHeader2: 'Config options',
103
+ clearHeader: '-c, --clear',
104
+ clearContent: 'Removes stored credentials',
105
+ constantsPrerequisitesContentScanLanguages: 'Java, Javascript and .NET supported',
106
+ constantsContrastContent: 'Use the ‘contrast’ command for fast and accurate security analysis of your applications, APIs, serverless functions, and libraries.',
107
+ constantsContrastCategories: '\n Code: Java, .NET, .NET Core, JavaScript\n Serverless: AWS Lambda - Java, Python\n Libraries: Java, .NET, Node, Ruby, Python, Go, PHP\n',
100
108
  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.',
101
109
  constantsPrerequisitesHeader: 'Pre-requisites',
102
110
  constantsAuthUsageHeader: 'Usage',
@@ -162,7 +170,7 @@ const en_locales = () => {
162
170
  constantsIgnoreCertErrors: 'For EOP users with a local Teamserver install, this will bypass the SSL certificate and recognise a self signed certificate.',
163
171
  constantsSave: 'Saves the Scan Results SARIF to file.',
164
172
  scanLabel: "adds a label to the scan - defaults to 'Started by CLI tool at current date'",
165
- constantsIgnoreDev: 'Excludes developer dependencies from the output. By default all dependencies are included.',
173
+ constantsIgnoreDev: 'Excludes developer dependencies from the results. All dependencies are included by default.',
166
174
  constantsCommands: 'Commands',
167
175
  constantsScanOptions: 'Scan Options',
168
176
  sbomError: 'All required parameters are not present.',
@@ -185,12 +193,14 @@ const en_locales = () => {
185
193
  permissionsError: 'You do not have the correct permissions here. \n Contact support@contrastsecurity.com to get this fixed.',
186
194
  scanErrorFileMessage: 'We only accept the following file types: \nJava - .jar, .war \nJavaScript - .js or .zip files',
187
195
  helpAuthSummary: 'Authenticate Contrast using your Github or Google account',
188
- helpScanSummary: 'Perform static analysis on binaries / code artifacts',
189
- helpLambdaSummary: 'Perform scan on AWS Lambda functions',
196
+ helpAuditSummary: 'Searches for a suitable file in the working directory to perform a security audit of dependencies and returns the results. [Contrast audit --help (for options).]',
197
+ helpScanSummary: 'Searches for a .jar, .war, .js, or .zip file in the working directory, uploads files for analysis, and returns the results. [For further help/options, enter scan --help]',
198
+ helpLambdaSummary: 'Performs a static security scan on an AWS lambda function. lambda --help (for options)',
190
199
  helpVersionSummary: 'Displays version of Contrast CLI',
191
200
  helpConfigSummary: 'Displays stored credentials',
192
201
  helpSummary: 'Displays usage guide',
193
202
  authName: 'auth',
203
+ auditName: 'audit',
194
204
  scanName: 'scan',
195
205
  lambdaName: 'lambda',
196
206
  versionName: 'version',
@@ -203,8 +213,7 @@ const en_locales = () => {
203
213
  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.',
204
214
  scanOptionsVerboseSummary: ' Returns extended information to the terminal.',
205
215
  authSuccessMessage: 'Authentication successful',
206
- runAuthSuccessMessage: "Now you can use Contrast CLI \nRun 'contrast scan' on your file \n" +
207
- "or 'contrast help' to learn more about the capabilities.",
216
+ runAuthSuccessMessage: "Now you can use CodeSec by Contrast \nRun: \n'contrast scan' on your file \n'contrast audit' on a file or directory,\n'contrast lambda' on an AWS function.\nor 'contrast help' to learn more about the capabilities.",
208
217
  authWaitingMessage: 'Waiting for auth...',
209
218
  authTimedOutMessage: 'Auth Timed out, try again',
210
219
  zipErrorScan: 'We only support zip files for JAVASCRIPT language, please set the flag --language JAVASCRIPT',
@@ -226,7 +235,7 @@ const en_locales = () => {
226
235
  lambdaPrerequisitesContent: '',
227
236
  lambdaPrerequisitesContentLambdaLanguages: 'Supported runtimes: Java & Python',
228
237
  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',
238
+ 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, ListFunctions\n - IAM: GetRolePolicy, GetPolicy, GetPolicyVersion, ListRolePolicies, ListAttachedRolePolicies',
230
239
  scanFileNameOption: '-f, --file',
231
240
  lambdaFunctionNameOption: '-f, --function-name',
232
241
  lambdaListFunctionsOption: '-l, --list-functions',
@@ -253,31 +262,24 @@ const en_locales = () => {
253
262
  connectionError: 'An error has occurred when trying to get the Project Id please check your internet connection or provide the Project Id manually',
254
263
  internalServerErrorHeader: '500 error - Internal server error',
255
264
  resourceLockedErrorHeader: '423 error - Resource is locked',
256
- auditHeader: 'Contrast Audit',
257
- auditHeaderMessage: `
258
- Performs software composition analysis (SCA) on your application/code time to show you the dependencies between open source libraries, including where vulnerabilities were introduced.\n
259
- 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.`,
265
+ auditHeader: 'Contrast audit help',
266
+ auditHeaderMessage: "Use 'contrast audit' to analyze a project’s dependencies for vulnerabilities.",
260
267
  constantsAuditPrerequisitesContentSupportedLanguages: 'Supported languages and their requirements are:',
261
- constantsAuditPrerequisitesContentJava: 'Java: ',
262
- constantsAuditPrerequisitesContentMessage: `
263
- pom.xml AND Maven build platform, including the dependency plugin.
264
- For a Gradle project (v4.8+) use build.gradle. A gradle-wrapper.properties file is also required.
265
- Kotlin is also supported requiring a build.gradle.kts file.`,
266
- constantsAuditPrerequisitesContentDotNet: '.NET framework and .NET core: ',
268
+ constantsAuditPrerequisitesJavaContentMessage: `
269
+ ${chalk.bold('Java:')} pom.xml ${chalk.bold('and')} Maven build platform including the dependency plugin.
270
+ ${chalk.bold('Or')} build.gradle ${chalk.bold('and')} gradle dependencies or ./gradlew dependencies must be supported`,
267
271
  constantsAuditPrerequisitesContentDotNetMessage: `
268
- MSBuild 15.0 or greater and have a packages.lock.json file are supported.\n
269
- Note: If the packages.lock.json file is unavailable it can be generated by setting RestorePackagesWithLockFile to true within each *.csproj file and running dotnet build.\n`,
270
- constantsAuditPrerequisitesContentLanguageNode: 'Node: ',
271
- constantsAuditPrerequisitesContentLanguageRuby: 'Ruby: ',
272
- constantsAuditPrerequisitesContentLanguagePython: 'Python: ',
273
- constantsAuditPrerequisitesContentLanguageNodeMessage: '*.package.json AND a lock file either *.package-lock.json or *.yarn.lock',
274
- constantsAuditPrerequisitesContentLanguageRubyMessage: 'gemfile AND gemfile.lock',
275
- constantsAuditPrerequisitesContentLanguagePythonMessage: 'pipfile AND pipfile.lock',
272
+ ${chalk.bold('.NET framework and .NET core:')} MSBuild 15.0 or greater and a packages.lock.json file.
273
+ Note: If the packages.lock.json file is unavailable it can be generated by setting RestorePackagesWithLockFile to true within each *.csproj file and running dotnet build.\n`,
274
+ constantsAuditPrerequisitesContentNodeMessage: `${chalk.bold('Node:')} package.json and a lock file (either .package-lock.json or .yarn.lock.)\n`,
275
+ constantsAuditPrerequisitesContentRubyMessage: `${chalk.bold('Ruby:')} gemfile and gemfile.lock\n`,
276
+ constantsAuditPrerequisitesContentPythonMessage: `${chalk.bold('Python:')} pipfile and pipfile.lock\n`,
277
+ constantsAuditPrerequisitesContentGoMessage: `${chalk.bold('Go:')} go.mod\n`,
278
+ constantsAuditPrerequisitesContentPHPMessage: `${chalk.bold('PHP:')} composer.json and composer.lock\n`,
276
279
  constantsAuditOptions: 'Audit Options',
277
- auditOptionsIgnoreDevDependencies: '-igd, --ignore-dev',
278
- auditOptionsIgnoreDevDependenciesDescription: 'ignores DevDependencies',
279
- auditOptionsSave: '-s, --save',
280
- auditOptionsSaveDescription: 'saves the output in specified format, options: sbom',
280
+ auditOptionsSaveDescription: 'Generate and save an SBOM (Software Bill of Materials)\n',
281
+ auditOptionsSaveOptionsDescription: 'Valid options are: --save spdx and --save cyclonedx (CycloneDX is the default format.)',
282
+ exceededFreeTier: `It looks like you are really loving CodeSec! \nYou have reached the monthly scan limit on the FREE tier. \nPlease contact sales@contrastsecurity.com to upgrade.`,
281
283
  scanNotCompleted: 'Scan not completed. Check for framework and language support here: %s',
282
284
  auditNotCompleted: 'audit not completed. Please try again',
283
285
  scanNoVulnerabilitiesFound: '🎉 No vulnerabilities found.',
@@ -292,7 +294,7 @@ const en_locales = () => {
292
294
  auditReportSuccessMessage: 'Report successfully retrieved',
293
295
  auditReportFailureMessage: 'Unable to generate library report',
294
296
  auditSCAAnalysisBegins: 'Contrast SCA audit started',
295
- auditSCAAnalysisComplete: 'Contrast SCA audit complete',
297
+ auditSCAAnalysisComplete: 'Contrast audit complete',
296
298
  ...lambda
297
299
  };
298
300
  };
package/dist/constants.js CHANGED
@@ -2,6 +2,7 @@
2
2
  const commandLineUsage = require('command-line-usage');
3
3
  const i18n = require('i18n');
4
4
  const { en_locales } = require('./constants/locales.js');
5
+ const { parseSeverity } = require('./common/fail');
5
6
  i18n.configure({
6
7
  staticCatalog: {
7
8
  en: en_locales()
@@ -93,6 +94,22 @@ const scanOptionDefinitions = [
93
94
  '}: ' +
94
95
  i18n.__('constantsProxyServer')
95
96
  },
97
+ {
98
+ name: 'fail',
99
+ type: Boolean,
100
+ description: '{bold ' +
101
+ i18n.__('constantsOptional') +
102
+ '}: ' +
103
+ i18n.__('failOptionErrorMessage')
104
+ },
105
+ {
106
+ name: 'severity',
107
+ type: severity => parseSeverity(severity),
108
+ description: '{bold ' +
109
+ i18n.__('constantsOptional') +
110
+ '}: ' +
111
+ i18n.__('constantsSeverity')
112
+ },
96
113
  {
97
114
  name: 'ff',
98
115
  type: Boolean,
@@ -189,12 +206,28 @@ const auditOptionDefinitions = [
189
206
  {
190
207
  name: 'file',
191
208
  alias: 'f',
192
- defaultValue: process.cwd(),
209
+ defaultValue: process.cwd().concat('/'),
193
210
  description: '{bold ' +
194
211
  i18n.__('constantsOptional') +
195
212
  '}: ' +
196
213
  i18n.__('constantsFilePath')
197
214
  },
215
+ {
216
+ name: 'fail',
217
+ type: Boolean,
218
+ description: '{bold ' +
219
+ i18n.__('constantsOptional') +
220
+ '}: ' +
221
+ i18n.__('failOptionErrorMessage')
222
+ },
223
+ {
224
+ name: 'severity',
225
+ type: severity => parseSeverity(severity),
226
+ description: '{bold ' +
227
+ i18n.__('constantsOptional') +
228
+ '}: ' +
229
+ i18n.__('constantsSeverity')
230
+ },
198
231
  {
199
232
  name: 'app-groups',
200
233
  description: '{bold ' +
@@ -227,6 +260,7 @@ const auditOptionDefinitions = [
227
260
  {
228
261
  name: 'ignore-dev',
229
262
  type: Boolean,
263
+ alias: 'i',
230
264
  description: '{bold ' +
231
265
  i18n.__('constantsOptional') +
232
266
  '}: ' +
@@ -235,14 +269,6 @@ const auditOptionDefinitions = [
235
269
  {
236
270
  name: 'maven-settings-path'
237
271
  },
238
- {
239
- name: 'language',
240
- alias: 'l',
241
- description: '{bold ' +
242
- i18n.__('constantsRequiredCatalogue') +
243
- '}: ' +
244
- i18n.__('constantsLanguage')
245
- },
246
272
  {
247
273
  name: 'organization-id',
248
274
  alias: 'o',
@@ -267,7 +293,6 @@ const auditOptionDefinitions = [
267
293
  },
268
294
  {
269
295
  name: 'host',
270
- alias: 'h',
271
296
  description: '{bold ' +
272
297
  i18n.__('constantsRequired') +
273
298
  '}: ' +
@@ -294,18 +319,36 @@ const auditOptionDefinitions = [
294
319
  description: '{bold ' +
295
320
  i18n.__('constantsOptional') +
296
321
  '}: ' +
297
- i18n.__('auditOptionsSaveDescription')
322
+ i18n.__('auditOptionsSaveDescription') +
323
+ i18n.__('auditOptionsSaveOptionsDescription')
298
324
  },
299
325
  {
300
326
  name: 'experimental',
301
327
  alias: 'e',
302
328
  type: Boolean
329
+ },
330
+ {
331
+ name: 'timeout',
332
+ alias: 't',
333
+ type: Number,
334
+ description: '{bold ' +
335
+ i18n.__('constantsOptional') +
336
+ '}: ' +
337
+ i18n.__('scanOptionsTimeoutSummary')
338
+ },
339
+ {
340
+ name: 'help',
341
+ alias: 'h',
342
+ type: Boolean
303
343
  }
304
344
  ];
305
345
  const mainUsageGuide = commandLineUsage([
306
346
  {
307
347
  header: i18n.__('constantsHeader'),
308
- content: [i18n.__('constantsContrastContent')]
348
+ content: [
349
+ i18n.__('constantsContrastContent'),
350
+ i18n.__('constantsContrastCategories')
351
+ ]
309
352
  },
310
353
  {
311
354
  header: i18n.__('constantsUsage'),
@@ -317,6 +360,7 @@ const mainUsageGuide = commandLineUsage([
317
360
  { name: i18n.__('authName'), summary: i18n.__('helpAuthSummary') },
318
361
  { name: i18n.__('scanName'), summary: i18n.__('helpScanSummary') },
319
362
  { name: i18n.__('lambdaName'), summary: i18n.__('helpLambdaSummary') },
363
+ { name: i18n.__('auditName'), summary: i18n.__('helpAuditSummary') },
320
364
  { name: i18n.__('versionName'), summary: i18n.__('helpVersionSummary') },
321
365
  { name: i18n.__('configName'), summary: i18n.__('helpConfigSummary') },
322
366
  { name: i18n.__('helpName'), summary: i18n.__('helpSummary') }
@@ -324,6 +368,12 @@ const mainUsageGuide = commandLineUsage([
324
368
  },
325
369
  {
326
370
  content: '{underline https://developer.contrastsecurity.com/} \n For technical support head to {underline https://support.contrastsecurity.com}'
371
+ },
372
+ {
373
+ header: i18n.__('configHeader2'),
374
+ content: [
375
+ { name: i18n.__('clearHeader'), summary: i18n.__('clearContent') }
376
+ ]
327
377
  }
328
378
  ]);
329
379
  const mainDefinition = [{ name: 'command', defaultOption: true }];
package/dist/index.js CHANGED
@@ -15,6 +15,7 @@ const lambda_1 = require("./lambda/lambda");
15
15
  const getConfig_1 = require("./utils/getConfig");
16
16
  const versionChecker_1 = require("./common/versionChecker");
17
17
  const errorHandling_1 = require("./common/errorHandling");
18
+ const telemetry_1 = require("./telemetry/telemetry");
18
19
  const { commandLineDefinitions: { mainUsageGuide, mainDefinition } } = constants_1.default;
19
20
  const config = (0, getConfig_1.localConfig)(constants_2.APP_NAME, constants_2.APP_VERSION);
20
21
  const getMainOption = () => {
@@ -30,55 +31,66 @@ const getMainOption = () => {
30
31
  };
31
32
  };
32
33
  const start = async () => {
33
- if (await (0, versionChecker_1.isCorrectNodeVersion)(process.version)) {
34
- const { mainOptions, argv: argvMain } = getMainOption();
35
- const command = mainOptions.command != undefined ? mainOptions.command.toLowerCase() : '';
36
- if (command === 'version' ||
37
- argvMain.includes('--v') ||
38
- argvMain.includes('--version')) {
39
- console.log(constants_2.APP_VERSION);
40
- await (0, versionChecker_1.findLatestCLIVersion)(config);
41
- return;
42
- }
43
- config.set('numOfRuns', config.get('numOfRuns') + 1);
44
- if (config.get('numOfRuns') >= 1) {
45
- await (0, versionChecker_1.findLatestCLIVersion)(config);
46
- config.set('numOfRuns', 0);
47
- }
48
- if (command === 'config') {
49
- return (0, config_1.processConfig)(argvMain, config);
50
- }
51
- if (command === 'auth') {
52
- return await (0, auth_1.processAuth)(argvMain, config);
53
- }
54
- if (command === 'lambda') {
55
- return await (0, lambda_1.processLambda)(argvMain);
56
- }
57
- if (command === 'scan') {
58
- return await (0, processScan_1.processScan)(argvMain);
59
- }
60
- if (command === 'audit') {
61
- return await (0, processAudit_1.processAudit)(argvMain);
62
- }
63
- if (command === 'help' ||
64
- argvMain.includes('--help') ||
65
- Object.keys(mainOptions).length === 0) {
66
- console.log(mainUsageGuide);
67
- }
68
- else if (mainOptions._unknown !== undefined) {
69
- const foundCommand = (0, errorHandling_1.findCommandOnError)(mainOptions._unknown);
70
- foundCommand
71
- ? console.log(`Unknown Command: Did you mean "${foundCommand}"? \nUse "${foundCommand} --help" for the full list of options`)
72
- : console.log(`Unknown Command: ${command} \nUse --help for the full list`);
34
+ try {
35
+ if (await (0, versionChecker_1.isCorrectNodeVersion)(process.version)) {
36
+ const { mainOptions, argv: argvMain } = getMainOption();
37
+ const command = mainOptions.command != undefined
38
+ ? mainOptions.command.toLowerCase()
39
+ : '';
40
+ if (command === 'version' ||
41
+ argvMain.includes('--v') ||
42
+ argvMain.includes('--version')) {
43
+ console.log(constants_2.APP_VERSION);
44
+ await (0, versionChecker_1.findLatestCLIVersion)(config);
45
+ return;
46
+ }
47
+ config.set('numOfRuns', config.get('numOfRuns') + 1);
48
+ if (config.get('numOfRuns') >= 1) {
49
+ await (0, versionChecker_1.findLatestCLIVersion)(config);
50
+ config.set('numOfRuns', 0);
51
+ }
52
+ if (command === 'config') {
53
+ return (0, config_1.processConfig)(argvMain, config);
54
+ }
55
+ if (command === 'auth') {
56
+ return await (0, auth_1.processAuth)(argvMain, config);
57
+ }
58
+ if (command === 'lambda') {
59
+ return await (0, lambda_1.processLambda)(argvMain);
60
+ }
61
+ if (command === 'scan') {
62
+ return await (0, processScan_1.processScan)(config, argvMain);
63
+ }
64
+ if (command === 'audit') {
65
+ return await (0, processAudit_1.processAudit)(config, argvMain);
66
+ }
67
+ if (command === 'help' ||
68
+ argvMain.includes('--help') ||
69
+ Object.keys(mainOptions).length === 0) {
70
+ console.log(mainUsageGuide);
71
+ }
72
+ else if (mainOptions._unknown !== undefined) {
73
+ const foundCommand = (0, errorHandling_1.findCommandOnError)(mainOptions._unknown);
74
+ foundCommand
75
+ ? console.log(`Unknown Command: Did you mean "${foundCommand}"? \nUse "${foundCommand} --help" for the full list of options`)
76
+ : console.log(`Unknown Command: ${command} \nUse --help for the full list`);
77
+ await (0, telemetry_1.sendTelemetryConfigAsConfObj)(config, command, argvMain, 'FAILURE', 'undefined');
78
+ }
79
+ else {
80
+ console.log(`Unknown Command: ${command} \nUse --help for the full list`);
81
+ await (0, telemetry_1.sendTelemetryConfigAsConfObj)(config, command, argvMain, 'FAILURE', 'undefined');
82
+ }
83
+ process.exit(9);
73
84
  }
74
85
  else {
75
- console.log(`Unknown Command: ${command} \nUse --help for the full list`);
86
+ console.log('Contrast supports Node versions >=16.13.2 <17. Please use one of those versions.');
87
+ process.exit(9);
76
88
  }
77
- process.exit(9);
78
89
  }
79
- else {
80
- console.log('Contrast supports Node versions >=16.13.2 <17. Please use one of those versions.');
81
- process.exit(9);
90
+ catch (err) {
91
+ console.log();
92
+ console.log(err.message.toString());
93
+ process.exit(1);
82
94
  }
83
95
  };
84
96
  start();
@@ -22,6 +22,7 @@ const requestUtils_1 = require("../utils/requestUtils");
22
22
  const oraWrapper_1 = __importDefault(require("../utils/oraWrapper"));
23
23
  const analytics_1 = require("./analytics");
24
24
  const types_1 = require("./types");
25
+ const constants_2 = require("../constants/constants");
25
26
  const failedStates = [
26
27
  'UNSUPPORTED',
27
28
  'EXCLUDED',
@@ -68,7 +69,8 @@ const processLambda = async (argv) => {
68
69
  const startCommandAnalytics = {
69
70
  arguments: lambdaOptions,
70
71
  sessionId: commandSessionId,
71
- eventType: types_1.EventType.START
72
+ eventType: types_1.EventType.START,
73
+ packageVersion: constants_2.APP_VERSION
72
74
  };
73
75
  (0, analytics_1.postAnalytics)(startCommandAnalytics).catch((error) => {
74
76
  });
@@ -95,7 +97,8 @@ const processLambda = async (argv) => {
95
97
  const endCommandAnalytics = {
96
98
  sessionId: commandSessionId,
97
99
  eventType: types_1.EventType.END,
98
- status: errorMsg ? types_1.StatusType.FAILED : types_1.StatusType.SUCCESS
100
+ status: errorMsg ? types_1.StatusType.FAILED : types_1.StatusType.SUCCESS,
101
+ packageVersion: constants_2.APP_VERSION
99
102
  };
100
103
  if (errorMsg) {
101
104
  endCommandAnalytics.errorMsg = errorMsg;
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateSbom = void 0;
4
4
  const commonApi_1 = require("../utils/commonApi");
5
- const generateSbom = (config) => {
5
+ const generateSbom = (config, type) => {
6
6
  const client = (0, commonApi_1.getHttpClient)(config);
7
7
  return client
8
- .getSbom(config)
8
+ .getSbom(config, type)
9
9
  .then((res) => {
10
10
  if (res.statusCode === 200) {
11
11
  return res.body;
@@ -46,11 +46,17 @@ const createPhpTSMessage = phpTree => {
46
46
  }
47
47
  };
48
48
  };
49
+ const createDotNetTSMessage = dotnetTree => {
50
+ return {
51
+ dotnet: dotnetTree
52
+ };
53
+ };
49
54
  module.exports = {
50
55
  createJavaScriptTSMessage,
51
56
  createJavaTSMessage,
52
57
  createGoTSMessage,
53
58
  createPhpTSMessage,
54
59
  createRubyTSMessage,
55
- createPythonTSMessage
60
+ createPythonTSMessage,
61
+ createDotNetTSMessage
56
62
  };
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ const parseDependenciesForSCAServices = dependencyTreeObject => {
3
+ let parsedDependencyTree = {};
4
+ let subDeps;
5
+ for (let tree in dependencyTreeObject) {
6
+ let unParsedDependencyTree = dependencyTreeObject[tree];
7
+ for (let dependency in unParsedDependencyTree) {
8
+ subDeps = parseSubDependencies(unParsedDependencyTree[dependency].edges);
9
+ let parsedDependency = {
10
+ name: unParsedDependencyTree[dependency].artifactID,
11
+ group: unParsedDependencyTree[dependency].group,
12
+ version: unParsedDependencyTree[dependency].version,
13
+ directDependency: unParsedDependencyTree[dependency].type === 'direct',
14
+ isProduction: true,
15
+ dependencies: subDeps
16
+ };
17
+ parsedDependencyTree[dependency] = parsedDependency;
18
+ }
19
+ }
20
+ return parsedDependencyTree;
21
+ };
22
+ const parseSubDependencies = dependencies => {
23
+ let subDeps = [];
24
+ for (let x in dependencies) {
25
+ subDeps.push(dependencies[x]);
26
+ }
27
+ return subDeps;
28
+ };
29
+ module.exports = {
30
+ parseDependenciesForSCAServices,
31
+ parseSubDependencies
32
+ };
@@ -1,13 +1,16 @@
1
1
  "use strict";
2
- const { getHttpClient } = require('../../utils/commonApi');
2
+ const commonApi = require('../../utils/commonApi');
3
3
  const { APP_VERSION } = require('../../constants/constants');
4
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);
5
+ let requestBody = {};
6
+ config.experimental === true
7
+ ? (requestBody = sendToSCAServices(config, analysis))
8
+ : (requestBody = {
9
+ appID: config.applicationId,
10
+ cliVersion: APP_VERSION,
11
+ snapshot: analysis
12
+ });
13
+ const client = commonApi.getHttpClient(config);
11
14
  return client
12
15
  .sendSnapshot(requestBody, config)
13
16
  .then(res => {
@@ -15,14 +18,25 @@ const commonSendSnapShot = async (analysis, config) => {
15
18
  return res.body;
16
19
  }
17
20
  else {
18
- console.log(res.statusCode);
19
- console.log('error processing dependencies');
21
+ throw new Error(res.statusCode + ` error processing dependencies`);
20
22
  }
21
23
  })
22
24
  .catch(err => {
23
- console.log(err);
25
+ throw err;
24
26
  });
25
27
  };
28
+ const sendToSCAServices = (config, analysis) => {
29
+ return {
30
+ applicationId: config.applicationId,
31
+ dependencyTree: analysis,
32
+ organizationId: config.organizationId,
33
+ language: config.language,
34
+ tool: {
35
+ name: 'Contrast Codesec',
36
+ version: APP_VERSION
37
+ }
38
+ };
39
+ };
26
40
  module.exports = {
27
41
  commonSendSnapShot
28
42
  };