@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.
- package/README.md +2 -2
- package/dist/audit/languageAnalysisEngine/getProjectRootFilenames.js +16 -25
- package/dist/audit/languageAnalysisEngine/report/commonReportingFunctions.js +103 -57
- package/dist/audit/languageAnalysisEngine/report/models/reportGuidanceModel.js +6 -0
- package/dist/audit/languageAnalysisEngine/report/models/reportOutputModel.js +3 -3
- package/dist/audit/languageAnalysisEngine/report/models/severityCountModel.js +1 -0
- package/dist/audit/languageAnalysisEngine/report/reportingFeature.js +68 -17
- package/dist/audit/languageAnalysisEngine/report/utils/reportUtils.js +39 -7
- package/dist/audit/languageAnalysisEngine/sendSnapshot.js +6 -30
- package/dist/audit/save.js +21 -13
- package/dist/commands/audit/auditConfig.js +3 -19
- package/dist/commands/audit/auditController.js +1 -10
- package/dist/commands/audit/help.js +7 -24
- package/dist/commands/audit/processAudit.js +5 -9
- package/dist/commands/audit/saveFile.js +2 -2
- package/dist/commands/auth/auth.js +1 -1
- package/dist/commands/config/config.js +2 -2
- package/dist/commands/scan/processScan.js +11 -4
- package/dist/commands/scan/sca/scaAnalysis.js +37 -13
- package/dist/common/HTTPClient.js +17 -8
- package/dist/common/errorHandling.js +2 -2
- package/dist/common/fail.js +66 -0
- package/dist/common/versionChecker.js +1 -1
- package/dist/constants/constants.js +7 -2
- package/dist/constants/locales.js +40 -38
- package/dist/constants.js +62 -12
- package/dist/index.js +57 -45
- package/dist/lambda/lambda.js +5 -2
- package/dist/sbom/generateSbom.js +2 -2
- package/dist/scaAnalysis/common/formatMessage.js +7 -1
- package/dist/scaAnalysis/common/scaParserForGoAndJava.js +32 -0
- package/dist/scaAnalysis/common/treeUpload.js +24 -10
- package/dist/scaAnalysis/dotnet/analysis.js +55 -0
- package/dist/scaAnalysis/dotnet/index.js +10 -0
- package/dist/scaAnalysis/go/goAnalysis.js +8 -2
- package/dist/scaAnalysis/java/analysis.js +10 -6
- package/dist/scaAnalysis/java/index.js +7 -1
- package/dist/scaAnalysis/java/javaBuildDepsParser.js +19 -3
- package/dist/scaAnalysis/javascript/analysis.js +4 -7
- package/dist/scaAnalysis/javascript/index.js +16 -4
- package/dist/scaAnalysis/php/analysis.js +14 -33
- package/dist/scaAnalysis/php/index.js +11 -4
- package/dist/scaAnalysis/python/analysis.js +43 -5
- package/dist/scaAnalysis/python/index.js +7 -2
- package/dist/scaAnalysis/ruby/analysis.js +16 -14
- package/dist/scan/autoDetection.js +13 -24
- package/dist/scan/fileUtils.js +31 -12
- package/dist/scan/formatScanOutput.js +9 -8
- package/dist/scan/populateProjectIdAndProjectName.js +5 -0
- package/dist/scan/scan.js +4 -0
- package/dist/scan/scanConfig.js +5 -5
- package/dist/scan/scanResults.js +39 -3
- package/dist/telemetry/telemetry.js +137 -0
- package/dist/utils/commonApi.js +1 -1
- package/dist/utils/getConfig.js +3 -8
- package/dist/utils/parsedCLIOptions.js +3 -1
- package/dist/utils/requestUtils.js +7 -1
- package/package.json +2 -3
- package/src/audit/languageAnalysisEngine/getProjectRootFilenames.js +21 -57
- package/src/audit/languageAnalysisEngine/report/commonReportingFunctions.ts +155 -77
- package/src/audit/languageAnalysisEngine/report/models/reportGuidanceModel.ts +5 -0
- package/src/audit/languageAnalysisEngine/report/models/reportOutputModel.ts +5 -5
- package/src/audit/languageAnalysisEngine/report/models/severityCountModel.ts +2 -0
- package/src/audit/languageAnalysisEngine/report/reportingFeature.ts +56 -27
- package/src/audit/languageAnalysisEngine/report/utils/reportUtils.ts +45 -6
- package/src/audit/languageAnalysisEngine/sendSnapshot.js +6 -32
- package/src/audit/save.js +32 -16
- package/src/commands/audit/auditConfig.ts +10 -28
- package/src/commands/audit/auditController.ts +0 -11
- package/src/commands/audit/help.ts +7 -24
- package/src/commands/audit/processAudit.ts +16 -8
- package/src/commands/audit/saveFile.ts +2 -2
- package/src/commands/auth/auth.js +3 -1
- package/src/commands/config/config.js +4 -2
- package/src/commands/scan/processScan.js +18 -5
- package/src/commands/scan/sca/scaAnalysis.js +50 -18
- package/src/common/HTTPClient.js +23 -9
- package/src/common/errorHandling.ts +2 -3
- package/src/common/fail.js +75 -0
- package/src/common/versionChecker.ts +1 -1
- package/src/constants/constants.js +9 -3
- package/src/constants/locales.js +70 -45
- package/src/constants.js +67 -13
- package/src/index.ts +91 -66
- package/src/lambda/lambda.ts +5 -2
- package/src/lambda/types.ts +1 -0
- package/src/sbom/generateSbom.ts +2 -2
- package/src/scaAnalysis/common/formatMessage.js +8 -1
- package/src/scaAnalysis/common/scaParserForGoAndJava.js +41 -0
- package/src/scaAnalysis/common/treeUpload.js +25 -11
- package/src/scaAnalysis/dotnet/analysis.js +72 -0
- package/src/scaAnalysis/dotnet/index.js +11 -0
- package/src/scaAnalysis/go/goAnalysis.js +9 -2
- package/src/scaAnalysis/java/analysis.js +11 -6
- package/src/scaAnalysis/java/index.js +9 -1
- package/src/scaAnalysis/java/javaBuildDepsParser.js +25 -6
- package/src/scaAnalysis/javascript/analysis.js +6 -7
- package/src/scaAnalysis/javascript/index.js +25 -6
- package/src/scaAnalysis/php/analysis.js +15 -35
- package/src/scaAnalysis/php/index.js +15 -4
- package/src/scaAnalysis/python/analysis.js +49 -5
- package/src/scaAnalysis/python/index.js +7 -2
- package/src/scaAnalysis/ruby/analysis.js +18 -15
- package/src/scan/autoDetection.js +14 -27
- package/src/scan/fileUtils.js +33 -12
- package/src/scan/formatScanOutput.ts +10 -8
- package/src/scan/populateProjectIdAndProjectName.js +5 -1
- package/src/scan/scan.ts +4 -0
- package/src/scan/scanConfig.js +7 -7
- package/src/scan/scanResults.js +46 -3
- package/src/telemetry/telemetry.ts +154 -0
- package/src/utils/commonApi.js +1 -1
- package/src/utils/getConfig.ts +5 -18
- package/src/utils/parsedCLIOptions.js +14 -1
- package/src/utils/requestUtils.js +8 -1
- package/dist/audit/AnalysisEngine.js +0 -37
- package/dist/audit/autodetection/autoDetectLanguage.js +0 -32
- package/dist/audit/dotnetAnalysisEngine/index.js +0 -25
- package/dist/audit/dotnetAnalysisEngine/parseLockFileContents.js +0 -35
- package/dist/audit/dotnetAnalysisEngine/parseProjectFileContents.js +0 -15
- package/dist/audit/dotnetAnalysisEngine/readLockFileContents.js +0 -18
- package/dist/audit/dotnetAnalysisEngine/readProjectFileContents.js +0 -14
- package/dist/audit/dotnetAnalysisEngine/sanitizer.js +0 -9
- package/dist/audit/goAnalysisEngine/index.js +0 -17
- package/dist/audit/goAnalysisEngine/parseProjectFileContents.js +0 -164
- package/dist/audit/goAnalysisEngine/readProjectFileContents.js +0 -21
- package/dist/audit/goAnalysisEngine/sanitizer.js +0 -5
- package/dist/audit/javaAnalysisEngine/index.js +0 -34
- package/dist/audit/javaAnalysisEngine/parseMavenProjectFileContents.js +0 -155
- package/dist/audit/javaAnalysisEngine/parseProjectFileContents.js +0 -353
- package/dist/audit/javaAnalysisEngine/readProjectFileContents.js +0 -98
- package/dist/audit/javaAnalysisEngine/sanitizer.js +0 -5
- package/dist/audit/languageAnalysisEngine/checkForMultipleIdentifiedLanguages.js +0 -25
- package/dist/audit/languageAnalysisEngine/checkForMultipleIdentifiedProjectFiles.js +0 -25
- package/dist/audit/languageAnalysisEngine/checkIdentifiedLanguageHasLockFile.js +0 -35
- package/dist/audit/languageAnalysisEngine/checkIdentifiedLanguageHasProjectFile.js +0 -24
- package/dist/audit/languageAnalysisEngine/constants.js +0 -20
- package/dist/audit/languageAnalysisEngine/getIdentifiedLanguageInfo.js +0 -25
- package/dist/audit/languageAnalysisEngine/index.js +0 -39
- package/dist/audit/languageAnalysisEngine/languageAnalysisFactory.js +0 -66
- package/dist/audit/languageAnalysisEngine/reduceIdentifiedLanguages.js +0 -166
- package/dist/audit/nodeAnalysisEngine/handleNPMLockFileV2.js +0 -40
- package/dist/audit/nodeAnalysisEngine/index.js +0 -31
- package/dist/audit/nodeAnalysisEngine/parseNPMLockFileContents.js +0 -18
- package/dist/audit/nodeAnalysisEngine/parseYarnLockFileContents.js +0 -18
- package/dist/audit/nodeAnalysisEngine/readNPMLockFileContents.js +0 -17
- package/dist/audit/nodeAnalysisEngine/readProjectFileContents.js +0 -14
- package/dist/audit/nodeAnalysisEngine/readYarnLockFileContents.js +0 -24
- package/dist/audit/nodeAnalysisEngine/sanitizer.js +0 -9
- package/dist/audit/phpAnalysisEngine/index.js +0 -23
- package/dist/audit/phpAnalysisEngine/parseLockFileContents.js +0 -52
- package/dist/audit/phpAnalysisEngine/readLockFileContents.js +0 -13
- package/dist/audit/phpAnalysisEngine/readProjectFileContents.js +0 -16
- package/dist/audit/phpAnalysisEngine/sanitizer.js +0 -5
- package/dist/audit/pythonAnalysisEngine/index.js +0 -25
- package/dist/audit/pythonAnalysisEngine/parsePipfileLockContents.js +0 -17
- package/dist/audit/pythonAnalysisEngine/parseProjectFileContents.js +0 -21
- package/dist/audit/pythonAnalysisEngine/readPipfileLockFileContents.js +0 -13
- package/dist/audit/pythonAnalysisEngine/readPythonProjectFileContents.js +0 -14
- package/dist/audit/pythonAnalysisEngine/sanitizer.js +0 -7
- package/dist/audit/rubyAnalysisEngine/index.js +0 -25
- package/dist/audit/rubyAnalysisEngine/parseGemfileLockContents.js +0 -176
- package/dist/audit/rubyAnalysisEngine/parsedGemfile.js +0 -22
- package/dist/audit/rubyAnalysisEngine/readGemfileContents.js +0 -14
- package/dist/audit/rubyAnalysisEngine/readGemfileLockContents.js +0 -14
- package/dist/audit/rubyAnalysisEngine/sanitizer.js +0 -6
- package/src/audit/AnalysisEngine.js +0 -103
- package/src/audit/autodetection/autoDetectLanguage.ts +0 -40
- package/src/audit/dotnetAnalysisEngine/index.js +0 -26
- package/src/audit/dotnetAnalysisEngine/parseLockFileContents.js +0 -47
- package/src/audit/dotnetAnalysisEngine/parseProjectFileContents.js +0 -29
- package/src/audit/dotnetAnalysisEngine/readLockFileContents.js +0 -30
- package/src/audit/dotnetAnalysisEngine/readProjectFileContents.js +0 -26
- package/src/audit/dotnetAnalysisEngine/sanitizer.js +0 -11
- package/src/audit/goAnalysisEngine/index.js +0 -18
- package/src/audit/goAnalysisEngine/parseProjectFileContents.js +0 -209
- package/src/audit/goAnalysisEngine/readProjectFileContents.js +0 -31
- package/src/audit/goAnalysisEngine/sanitizer.js +0 -7
- package/src/audit/javaAnalysisEngine/index.js +0 -41
- package/src/audit/javaAnalysisEngine/parseMavenProjectFileContents.js +0 -225
- package/src/audit/javaAnalysisEngine/parseProjectFileContents.js +0 -420
- package/src/audit/javaAnalysisEngine/readProjectFileContents.js +0 -141
- package/src/audit/javaAnalysisEngine/sanitizer.js +0 -6
- package/src/audit/languageAnalysisEngine/checkForMultipleIdentifiedLanguages.js +0 -36
- package/src/audit/languageAnalysisEngine/checkForMultipleIdentifiedProjectFiles.js +0 -42
- package/src/audit/languageAnalysisEngine/checkIdentifiedLanguageHasLockFile.js +0 -54
- package/src/audit/languageAnalysisEngine/checkIdentifiedLanguageHasProjectFile.js +0 -33
- package/src/audit/languageAnalysisEngine/constants.js +0 -23
- package/src/audit/languageAnalysisEngine/getIdentifiedLanguageInfo.js +0 -41
- package/src/audit/languageAnalysisEngine/index.js +0 -45
- package/src/audit/languageAnalysisEngine/languageAnalysisFactory.js +0 -96
- package/src/audit/languageAnalysisEngine/reduceIdentifiedLanguages.js +0 -251
- package/src/audit/nodeAnalysisEngine/handleNPMLockFileV2.js +0 -49
- package/src/audit/nodeAnalysisEngine/index.js +0 -35
- package/src/audit/nodeAnalysisEngine/parseNPMLockFileContents.js +0 -20
- package/src/audit/nodeAnalysisEngine/parseYarnLockFileContents.js +0 -26
- package/src/audit/nodeAnalysisEngine/readNPMLockFileContents.js +0 -23
- package/src/audit/nodeAnalysisEngine/readProjectFileContents.js +0 -27
- package/src/audit/nodeAnalysisEngine/readYarnLockFileContents.js +0 -36
- package/src/audit/nodeAnalysisEngine/sanitizer.js +0 -11
- package/src/audit/phpAnalysisEngine/index.js +0 -27
- package/src/audit/phpAnalysisEngine/parseLockFileContents.js +0 -60
- package/src/audit/phpAnalysisEngine/readLockFileContents.js +0 -14
- package/src/audit/phpAnalysisEngine/readProjectFileContents.js +0 -25
- package/src/audit/phpAnalysisEngine/sanitizer.js +0 -4
- package/src/audit/pythonAnalysisEngine/index.js +0 -55
- package/src/audit/pythonAnalysisEngine/parsePipfileLockContents.js +0 -23
- package/src/audit/pythonAnalysisEngine/parseProjectFileContents.js +0 -33
- package/src/audit/pythonAnalysisEngine/readPipfileLockFileContents.js +0 -16
- package/src/audit/pythonAnalysisEngine/readPythonProjectFileContents.js +0 -22
- package/src/audit/pythonAnalysisEngine/sanitizer.js +0 -9
- package/src/audit/rubyAnalysisEngine/index.js +0 -30
- package/src/audit/rubyAnalysisEngine/parseGemfileLockContents.js +0 -215
- package/src/audit/rubyAnalysisEngine/parsedGemfile.js +0 -39
- package/src/audit/rubyAnalysisEngine/readGemfileContents.js +0 -18
- package/src/audit/rubyAnalysisEngine/readGemfileLockContents.js +0 -17
- package/src/audit/rubyAnalysisEngine/sanitizer.js +0 -8
package/src/constants/locales.js
CHANGED
|
@@ -20,8 +20,8 @@ const en_locales = () => {
|
|
|
20
20
|
libraryAnalysisError:
|
|
21
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',
|
|
22
22
|
yamlMissingParametersHeader: 'Missing Parameters',
|
|
23
|
-
|
|
24
|
-
'
|
|
23
|
+
genericErrorMessage:
|
|
24
|
+
'An error has occur please check your command again. For more information use the --help commands.',
|
|
25
25
|
unauthenticatedErrorHeader: '401 error - Unauthenticated',
|
|
26
26
|
unauthenticatedErrorMessage:
|
|
27
27
|
'Please check the following keys are correct:\n--organization-id, --api-key or --authorization',
|
|
@@ -53,8 +53,10 @@ const en_locales = () => {
|
|
|
53
53
|
"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.",
|
|
54
54
|
languageAnalysisHasNoLockFile:
|
|
55
55
|
"Identified project language as '%s' but no project lock file was found.",
|
|
56
|
+
languageAnalysisHasNoPackageJsonFile:
|
|
57
|
+
'Identified project language as javascript but no package.json file was found.',
|
|
56
58
|
languageAnalysisHasMultipleLockFiles:
|
|
57
|
-
"Identified project language as '%s' but multiple project lock files were found
|
|
59
|
+
"Identified project language as '%s' but multiple project lock files were found.",
|
|
58
60
|
languageAnalysisProjectFileError:
|
|
59
61
|
"Identified project language as '%s' but no project file was found.",
|
|
60
62
|
languageAnalysisProjectRootFileNameReadError:
|
|
@@ -64,17 +66,20 @@ const en_locales = () => {
|
|
|
64
66
|
languageAnalysisProjectRootFileNameFailure:
|
|
65
67
|
'Failed to get information about the file or directory @ %s because: ',
|
|
66
68
|
languageAnalysisFailure: ' analysis failed because: ',
|
|
67
|
-
languageAnalysisNoLanguage:
|
|
69
|
+
languageAnalysisNoLanguage:
|
|
70
|
+
'We cannot detect a project, use -f <path> to specify a file or folder to analyze.',
|
|
71
|
+
languageAnalysisNoLanguageHelpLine: `${chalk.bold(
|
|
72
|
+
'contrast audit --help'
|
|
73
|
+
)} for more information.`,
|
|
68
74
|
NodeAnalysisFailure: 'NODE analysis failed because: ',
|
|
69
75
|
phpAnalysisFailure: 'PHP analysis failed because: ',
|
|
70
|
-
NodeParseNPM:
|
|
71
|
-
"Failed to parse NODE package-lock.json file @ '%s' because: ",
|
|
76
|
+
NodeParseNPM: 'Failed to parse NODE package-lock.json file because: ',
|
|
72
77
|
phpParseComposerLock:
|
|
73
78
|
"Failed to parse PHP composer.lock file @ '%s' because: ",
|
|
74
79
|
NodeReadNpmError:
|
|
75
80
|
'Failed to read the package-lock.json file @ "%s" because: ',
|
|
76
81
|
phpReadError: 'Failed to read the composer.lock file @ "%s" because: ',
|
|
77
|
-
NodeParseYarn:
|
|
82
|
+
NodeParseYarn: 'Failed to parse yarn.lock version %s because: ',
|
|
78
83
|
NodeParseYarn2: "Failed to parse Node yarn.lock version 2 @ '%s' because: ",
|
|
79
84
|
nodeReadProjectFileError:
|
|
80
85
|
'Failed to read the NODE project file @ "%s" because: ',
|
|
@@ -116,10 +121,11 @@ const en_locales = () => {
|
|
|
116
121
|
'The name of the application cataloged by Contrast UI',
|
|
117
122
|
constantsCatalogueApplication:
|
|
118
123
|
'Provide this if you want to catalogue an application',
|
|
124
|
+
failOptionErrorMessage:
|
|
125
|
+
' FAIL - CVEs have been detected that match at least the cve_severity option specified.',
|
|
119
126
|
constantsLanguage:
|
|
120
127
|
'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',
|
|
121
|
-
constantsFilePath:
|
|
122
|
-
'The directory root of a project/application that you would like analyzed. Defaults to current directory.',
|
|
128
|
+
constantsFilePath: `Specify a directory or the file where dependencies are declared. (By default, CodeSec will search for project files in the current directory.)`,
|
|
123
129
|
constantsSilent: 'Silences JSON output.',
|
|
124
130
|
constantsAppGroups:
|
|
125
131
|
'Assign your application to one or more pre-existing groups when using the catalogue command. Group lists should be comma separated.',
|
|
@@ -138,15 +144,22 @@ const en_locales = () => {
|
|
|
138
144
|
constantsReport: 'Display vulnerability information for this application',
|
|
139
145
|
constantsFail:
|
|
140
146
|
'Set the process to fail if this option is set in combination with --cve_severity.',
|
|
141
|
-
|
|
142
|
-
|
|
147
|
+
failThresholdOptionErrorMessage: 'More than 0 vulnerabilities found',
|
|
148
|
+
failSeverityOptionErrorMessage:
|
|
149
|
+
' FAIL - Results detected vulnerabilities over accepted severity level',
|
|
143
150
|
constantsSeverity:
|
|
144
151
|
'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.',
|
|
145
152
|
constantsCount: 'The number of CVEs that must be exceeded to fail a build',
|
|
146
153
|
constantsHeader: 'CodeSec by Contrast Security',
|
|
147
|
-
|
|
154
|
+
configHeader2: 'Config options',
|
|
155
|
+
clearHeader: '-c, --clear',
|
|
156
|
+
clearContent: 'Removes stored credentials',
|
|
157
|
+
constantsPrerequisitesContentScanLanguages:
|
|
158
|
+
'Java, Javascript and .NET supported',
|
|
148
159
|
constantsContrastContent:
|
|
149
|
-
|
|
160
|
+
'Use the ‘contrast’ command for fast and accurate security analysis of your applications, APIs, serverless functions, and libraries.',
|
|
161
|
+
constantsContrastCategories:
|
|
162
|
+
'\n Code: Java, .NET, .NET Core, JavaScript\n Serverless: AWS Lambda - Java, Python\n Libraries: Java, .NET, Node, Ruby, Python, Go, PHP\n',
|
|
150
163
|
constantsUsageGuideContentRecommendation:
|
|
151
164
|
'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.',
|
|
152
165
|
constantsPrerequisitesHeader: 'Pre-requisites',
|
|
@@ -249,7 +262,7 @@ const en_locales = () => {
|
|
|
249
262
|
scanLabel:
|
|
250
263
|
"adds a label to the scan - defaults to 'Started by CLI tool at current date'",
|
|
251
264
|
constantsIgnoreDev:
|
|
252
|
-
'Excludes developer dependencies from the
|
|
265
|
+
'Excludes developer dependencies from the results. All dependencies are included by default.',
|
|
253
266
|
constantsCommands: 'Commands',
|
|
254
267
|
constantsScanOptions: 'Scan Options',
|
|
255
268
|
sbomError: 'All required parameters are not present.',
|
|
@@ -277,12 +290,17 @@ const en_locales = () => {
|
|
|
277
290
|
'We only accept the following file types: \nJava - .jar, .war \nJavaScript - .js or .zip files',
|
|
278
291
|
helpAuthSummary:
|
|
279
292
|
'Authenticate Contrast using your Github or Google account',
|
|
280
|
-
|
|
281
|
-
|
|
293
|
+
helpAuditSummary:
|
|
294
|
+
'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).]',
|
|
295
|
+
helpScanSummary:
|
|
296
|
+
'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]',
|
|
297
|
+
helpLambdaSummary:
|
|
298
|
+
'Performs a static security scan on an AWS lambda function. lambda --help (for options)',
|
|
282
299
|
helpVersionSummary: 'Displays version of Contrast CLI',
|
|
283
300
|
helpConfigSummary: 'Displays stored credentials',
|
|
284
301
|
helpSummary: 'Displays usage guide',
|
|
285
302
|
authName: 'auth',
|
|
303
|
+
auditName: 'audit',
|
|
286
304
|
scanName: 'scan',
|
|
287
305
|
lambdaName: 'lambda',
|
|
288
306
|
versionName: 'version',
|
|
@@ -300,8 +318,7 @@ const en_locales = () => {
|
|
|
300
318
|
scanOptionsVerboseSummary: ' Returns extended information to the terminal.',
|
|
301
319
|
authSuccessMessage: 'Authentication successful',
|
|
302
320
|
runAuthSuccessMessage:
|
|
303
|
-
"Now you can use Contrast
|
|
304
|
-
"or 'contrast help' to learn more about the capabilities.",
|
|
321
|
+
"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.",
|
|
305
322
|
authWaitingMessage: 'Waiting for auth...',
|
|
306
323
|
authTimedOutMessage: 'Auth Timed out, try again',
|
|
307
324
|
zipErrorScan:
|
|
@@ -329,7 +346,7 @@ const en_locales = () => {
|
|
|
329
346
|
'Supported runtimes: Java & Python',
|
|
330
347
|
lambdaPrerequisitesContentLambdaDescriptionTitle: 'AWS Requirements\n',
|
|
331
348
|
lambdaPrerequisitesContentLambdaDescription:
|
|
332
|
-
'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
|
|
349
|
+
'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',
|
|
333
350
|
scanFileNameOption: '-f, --file',
|
|
334
351
|
lambdaFunctionNameOption: '-f, --function-name',
|
|
335
352
|
lambdaListFunctionsOption: '-l, --list-functions',
|
|
@@ -364,36 +381,44 @@ const en_locales = () => {
|
|
|
364
381
|
'An error has occurred when trying to get the Project Id please check your internet connection or provide the Project Id manually',
|
|
365
382
|
internalServerErrorHeader: '500 error - Internal server error',
|
|
366
383
|
resourceLockedErrorHeader: '423 error - Resource is locked',
|
|
367
|
-
auditHeader: 'Contrast
|
|
368
|
-
auditHeaderMessage:
|
|
369
|
-
|
|
370
|
-
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.`,
|
|
384
|
+
auditHeader: 'Contrast audit help',
|
|
385
|
+
auditHeaderMessage:
|
|
386
|
+
"Use 'contrast audit' to analyze a project’s dependencies for vulnerabilities.",
|
|
371
387
|
constantsAuditPrerequisitesContentSupportedLanguages:
|
|
372
388
|
'Supported languages and their requirements are:',
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
389
|
+
constantsAuditPrerequisitesJavaContentMessage: `
|
|
390
|
+
${chalk.bold('Java:')} pom.xml ${chalk.bold(
|
|
391
|
+
'and'
|
|
392
|
+
)} Maven build platform including the dependency plugin.
|
|
393
|
+
${chalk.bold('Or')} build.gradle ${chalk.bold(
|
|
394
|
+
'and'
|
|
395
|
+
)} gradle dependencies or ./gradlew dependencies must be supported`,
|
|
379
396
|
constantsAuditPrerequisitesContentDotNetMessage: `
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
'
|
|
389
|
-
|
|
390
|
-
|
|
397
|
+
${chalk.bold(
|
|
398
|
+
'.NET framework and .NET core:'
|
|
399
|
+
)} MSBuild 15.0 or greater and a packages.lock.json file.
|
|
400
|
+
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`,
|
|
401
|
+
constantsAuditPrerequisitesContentNodeMessage: `${chalk.bold(
|
|
402
|
+
'Node:'
|
|
403
|
+
)} package.json and a lock file (either .package-lock.json or .yarn.lock.)\n`,
|
|
404
|
+
constantsAuditPrerequisitesContentRubyMessage: `${chalk.bold(
|
|
405
|
+
'Ruby:'
|
|
406
|
+
)} gemfile and gemfile.lock\n`,
|
|
407
|
+
constantsAuditPrerequisitesContentPythonMessage: `${chalk.bold(
|
|
408
|
+
'Python:'
|
|
409
|
+
)} pipfile and pipfile.lock\n`,
|
|
410
|
+
constantsAuditPrerequisitesContentGoMessage: `${chalk.bold(
|
|
411
|
+
'Go:'
|
|
412
|
+
)} go.mod\n`,
|
|
413
|
+
constantsAuditPrerequisitesContentPHPMessage: `${chalk.bold(
|
|
414
|
+
'PHP:'
|
|
415
|
+
)} composer.json and composer.lock\n`,
|
|
391
416
|
constantsAuditOptions: 'Audit Options',
|
|
392
|
-
auditOptionsIgnoreDevDependencies: '-igd, --ignore-dev',
|
|
393
|
-
auditOptionsIgnoreDevDependenciesDescription: 'ignores DevDependencies',
|
|
394
|
-
auditOptionsSave: '-s, --save',
|
|
395
417
|
auditOptionsSaveDescription:
|
|
396
|
-
'
|
|
418
|
+
'Generate and save an SBOM (Software Bill of Materials)\n',
|
|
419
|
+
auditOptionsSaveOptionsDescription:
|
|
420
|
+
'Valid options are: --save spdx and --save cyclonedx (CycloneDX is the default format.)',
|
|
421
|
+
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.`,
|
|
397
422
|
scanNotCompleted:
|
|
398
423
|
'Scan not completed. Check for framework and language support here: %s',
|
|
399
424
|
auditNotCompleted: 'audit not completed. Please try again',
|
|
@@ -415,7 +440,7 @@ const en_locales = () => {
|
|
|
415
440
|
auditReportSuccessMessage: 'Report successfully retrieved',
|
|
416
441
|
auditReportFailureMessage: 'Unable to generate library report',
|
|
417
442
|
auditSCAAnalysisBegins: 'Contrast SCA audit started',
|
|
418
|
-
auditSCAAnalysisComplete: 'Contrast
|
|
443
|
+
auditSCAAnalysisComplete: 'Contrast audit complete',
|
|
419
444
|
...lambda
|
|
420
445
|
}
|
|
421
446
|
}
|
package/src/constants.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const commandLineUsage = require('command-line-usage')
|
|
2
2
|
const i18n = require('i18n')
|
|
3
3
|
const { en_locales } = require('./constants/locales.js')
|
|
4
|
+
const { parseSeverity } = require('./common/fail')
|
|
4
5
|
|
|
5
6
|
i18n.configure({
|
|
6
7
|
staticCatalog: {
|
|
@@ -106,6 +107,24 @@ const scanOptionDefinitions = [
|
|
|
106
107
|
'}: ' +
|
|
107
108
|
i18n.__('constantsProxyServer')
|
|
108
109
|
},
|
|
110
|
+
{
|
|
111
|
+
name: 'fail',
|
|
112
|
+
type: Boolean,
|
|
113
|
+
description:
|
|
114
|
+
'{bold ' +
|
|
115
|
+
i18n.__('constantsOptional') +
|
|
116
|
+
'}: ' +
|
|
117
|
+
i18n.__('failOptionErrorMessage')
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: 'severity',
|
|
121
|
+
type: severity => parseSeverity(severity),
|
|
122
|
+
description:
|
|
123
|
+
'{bold ' +
|
|
124
|
+
i18n.__('constantsOptional') +
|
|
125
|
+
'}: ' +
|
|
126
|
+
i18n.__('constantsSeverity')
|
|
127
|
+
},
|
|
109
128
|
{
|
|
110
129
|
name: 'ff',
|
|
111
130
|
type: Boolean,
|
|
@@ -213,13 +232,31 @@ const auditOptionDefinitions = [
|
|
|
213
232
|
{
|
|
214
233
|
name: 'file',
|
|
215
234
|
alias: 'f',
|
|
216
|
-
defaultValue: process.cwd(),
|
|
235
|
+
defaultValue: process.cwd().concat('/'),
|
|
217
236
|
description:
|
|
218
237
|
'{bold ' +
|
|
219
238
|
i18n.__('constantsOptional') +
|
|
220
239
|
'}: ' +
|
|
221
240
|
i18n.__('constantsFilePath')
|
|
222
241
|
},
|
|
242
|
+
{
|
|
243
|
+
name: 'fail',
|
|
244
|
+
type: Boolean,
|
|
245
|
+
description:
|
|
246
|
+
'{bold ' +
|
|
247
|
+
i18n.__('constantsOptional') +
|
|
248
|
+
'}: ' +
|
|
249
|
+
i18n.__('failOptionErrorMessage')
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
name: 'severity',
|
|
253
|
+
type: severity => parseSeverity(severity),
|
|
254
|
+
description:
|
|
255
|
+
'{bold ' +
|
|
256
|
+
i18n.__('constantsOptional') +
|
|
257
|
+
'}: ' +
|
|
258
|
+
i18n.__('constantsSeverity')
|
|
259
|
+
},
|
|
223
260
|
{
|
|
224
261
|
name: 'app-groups',
|
|
225
262
|
description:
|
|
@@ -257,6 +294,7 @@ const auditOptionDefinitions = [
|
|
|
257
294
|
{
|
|
258
295
|
name: 'ignore-dev',
|
|
259
296
|
type: Boolean,
|
|
297
|
+
alias: 'i',
|
|
260
298
|
description:
|
|
261
299
|
'{bold ' +
|
|
262
300
|
i18n.__('constantsOptional') +
|
|
@@ -266,15 +304,6 @@ const auditOptionDefinitions = [
|
|
|
266
304
|
{
|
|
267
305
|
name: 'maven-settings-path'
|
|
268
306
|
},
|
|
269
|
-
{
|
|
270
|
-
name: 'language',
|
|
271
|
-
alias: 'l',
|
|
272
|
-
description:
|
|
273
|
-
'{bold ' +
|
|
274
|
-
i18n.__('constantsRequiredCatalogue') +
|
|
275
|
-
'}: ' +
|
|
276
|
-
i18n.__('constantsLanguage')
|
|
277
|
-
},
|
|
278
307
|
{
|
|
279
308
|
name: 'organization-id',
|
|
280
309
|
alias: 'o',
|
|
@@ -302,7 +331,6 @@ const auditOptionDefinitions = [
|
|
|
302
331
|
},
|
|
303
332
|
{
|
|
304
333
|
name: 'host',
|
|
305
|
-
alias: 'h',
|
|
306
334
|
description:
|
|
307
335
|
'{bold ' +
|
|
308
336
|
i18n.__('constantsRequired') +
|
|
@@ -333,19 +361,38 @@ const auditOptionDefinitions = [
|
|
|
333
361
|
'{bold ' +
|
|
334
362
|
i18n.__('constantsOptional') +
|
|
335
363
|
'}: ' +
|
|
336
|
-
i18n.__('auditOptionsSaveDescription')
|
|
364
|
+
i18n.__('auditOptionsSaveDescription') +
|
|
365
|
+
i18n.__('auditOptionsSaveOptionsDescription')
|
|
337
366
|
},
|
|
338
367
|
{
|
|
339
368
|
name: 'experimental',
|
|
340
369
|
alias: 'e',
|
|
341
370
|
type: Boolean
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
name: 'timeout',
|
|
374
|
+
alias: 't',
|
|
375
|
+
type: Number,
|
|
376
|
+
description:
|
|
377
|
+
'{bold ' +
|
|
378
|
+
i18n.__('constantsOptional') +
|
|
379
|
+
'}: ' +
|
|
380
|
+
i18n.__('scanOptionsTimeoutSummary')
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
name: 'help',
|
|
384
|
+
alias: 'h',
|
|
385
|
+
type: Boolean
|
|
342
386
|
}
|
|
343
387
|
]
|
|
344
388
|
|
|
345
389
|
const mainUsageGuide = commandLineUsage([
|
|
346
390
|
{
|
|
347
391
|
header: i18n.__('constantsHeader'),
|
|
348
|
-
content: [
|
|
392
|
+
content: [
|
|
393
|
+
i18n.__('constantsContrastContent'),
|
|
394
|
+
i18n.__('constantsContrastCategories')
|
|
395
|
+
]
|
|
349
396
|
},
|
|
350
397
|
{
|
|
351
398
|
header: i18n.__('constantsUsage'),
|
|
@@ -357,6 +404,7 @@ const mainUsageGuide = commandLineUsage([
|
|
|
357
404
|
{ name: i18n.__('authName'), summary: i18n.__('helpAuthSummary') },
|
|
358
405
|
{ name: i18n.__('scanName'), summary: i18n.__('helpScanSummary') },
|
|
359
406
|
{ name: i18n.__('lambdaName'), summary: i18n.__('helpLambdaSummary') },
|
|
407
|
+
{ name: i18n.__('auditName'), summary: i18n.__('helpAuditSummary') },
|
|
360
408
|
{ name: i18n.__('versionName'), summary: i18n.__('helpVersionSummary') },
|
|
361
409
|
{ name: i18n.__('configName'), summary: i18n.__('helpConfigSummary') },
|
|
362
410
|
{ name: i18n.__('helpName'), summary: i18n.__('helpSummary') }
|
|
@@ -365,6 +413,12 @@ const mainUsageGuide = commandLineUsage([
|
|
|
365
413
|
{
|
|
366
414
|
content:
|
|
367
415
|
'{underline https://developer.contrastsecurity.com/} \n For technical support head to {underline https://support.contrastsecurity.com}'
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
header: i18n.__('configHeader2'),
|
|
419
|
+
content: [
|
|
420
|
+
{ name: i18n.__('clearHeader'), summary: i18n.__('clearContent') }
|
|
421
|
+
]
|
|
368
422
|
}
|
|
369
423
|
])
|
|
370
424
|
|
package/src/index.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
isCorrectNodeVersion
|
|
15
15
|
} from './common/versionChecker'
|
|
16
16
|
import { findCommandOnError } from './common/errorHandling'
|
|
17
|
+
import { sendTelemetryConfigAsConfObj } from './telemetry/telemetry'
|
|
17
18
|
|
|
18
19
|
const {
|
|
19
20
|
commandLineDefinitions: { mainUsageGuide, mainDefinition }
|
|
@@ -36,74 +37,98 @@ const getMainOption = () => {
|
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
const start = async () => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
40
|
+
try {
|
|
41
|
+
if (await isCorrectNodeVersion(process.version)) {
|
|
42
|
+
const { mainOptions, argv: argvMain } = getMainOption()
|
|
43
|
+
const command =
|
|
44
|
+
mainOptions.command != undefined
|
|
45
|
+
? mainOptions.command.toLowerCase()
|
|
46
|
+
: ''
|
|
47
|
+
if (
|
|
48
|
+
command === 'version' ||
|
|
49
|
+
argvMain.includes('--v') ||
|
|
50
|
+
argvMain.includes('--version')
|
|
51
|
+
) {
|
|
52
|
+
console.log(APP_VERSION)
|
|
53
|
+
await findLatestCLIVersion(config)
|
|
54
|
+
return
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
config.set('numOfRuns', config.get('numOfRuns') + 1)
|
|
59
|
+
|
|
60
|
+
// @ts-ignore
|
|
61
|
+
if (config.get('numOfRuns') >= 1) {
|
|
62
|
+
await findLatestCLIVersion(config)
|
|
63
|
+
config.set('numOfRuns', 0)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (command === 'config') {
|
|
67
|
+
return processConfig(argvMain, config)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (command === 'auth') {
|
|
71
|
+
return await processAuth(argvMain, config)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (command === 'lambda') {
|
|
75
|
+
return await processLambda(argvMain)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (command === 'scan') {
|
|
79
|
+
return await processScan(config, argvMain)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (command === 'audit') {
|
|
83
|
+
return await processAudit(config, argvMain)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (
|
|
87
|
+
command === 'help' ||
|
|
88
|
+
argvMain.includes('--help') ||
|
|
89
|
+
Object.keys(mainOptions).length === 0
|
|
90
|
+
) {
|
|
91
|
+
console.log(mainUsageGuide)
|
|
92
|
+
} else if (mainOptions._unknown !== undefined) {
|
|
93
|
+
const foundCommand = findCommandOnError(mainOptions._unknown)
|
|
94
|
+
|
|
95
|
+
foundCommand
|
|
96
|
+
? console.log(
|
|
97
|
+
`Unknown Command: Did you mean "${foundCommand}"? \nUse "${foundCommand} --help" for the full list of options`
|
|
98
|
+
)
|
|
99
|
+
: console.log(
|
|
100
|
+
`Unknown Command: ${command} \nUse --help for the full list`
|
|
101
|
+
)
|
|
102
|
+
await sendTelemetryConfigAsConfObj(
|
|
103
|
+
config,
|
|
104
|
+
command,
|
|
105
|
+
argvMain,
|
|
106
|
+
'FAILURE',
|
|
107
|
+
'undefined'
|
|
108
|
+
)
|
|
109
|
+
} else {
|
|
110
|
+
console.log(
|
|
111
|
+
`Unknown Command: ${command} \nUse --help for the full list`
|
|
112
|
+
)
|
|
113
|
+
await sendTelemetryConfigAsConfObj(
|
|
114
|
+
config,
|
|
115
|
+
command,
|
|
116
|
+
argvMain,
|
|
117
|
+
'FAILURE',
|
|
118
|
+
'undefined'
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
process.exit(9)
|
|
98
122
|
} else {
|
|
99
|
-
console.log(
|
|
123
|
+
console.log(
|
|
124
|
+
'Contrast supports Node versions >=16.13.2 <17. Please use one of those versions.'
|
|
125
|
+
)
|
|
126
|
+
process.exit(9)
|
|
100
127
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
console.log(
|
|
104
|
-
|
|
105
|
-
)
|
|
106
|
-
process.exit(9)
|
|
128
|
+
} catch (err: any) {
|
|
129
|
+
console.log()
|
|
130
|
+
console.log(err.message.toString())
|
|
131
|
+
process.exit(1)
|
|
107
132
|
}
|
|
108
133
|
}
|
|
109
134
|
|
package/src/lambda/lambda.ts
CHANGED
|
@@ -16,6 +16,7 @@ import { sleep } from '../utils/requestUtils'
|
|
|
16
16
|
import ora from '../utils/oraWrapper'
|
|
17
17
|
import { postAnalytics } from './analytics'
|
|
18
18
|
import { LambdaOptions, AnalyticsOption, StatusType, EventType } from './types'
|
|
19
|
+
import { APP_VERSION } from '../constants/constants'
|
|
19
20
|
|
|
20
21
|
type ApiParams = {
|
|
21
22
|
organizationId: string
|
|
@@ -73,7 +74,8 @@ const processLambda = async (argv: string[]) => {
|
|
|
73
74
|
const startCommandAnalytics: AnalyticsOption = {
|
|
74
75
|
arguments: lambdaOptions,
|
|
75
76
|
sessionId: commandSessionId,
|
|
76
|
-
eventType: EventType.START
|
|
77
|
+
eventType: EventType.START,
|
|
78
|
+
packageVersion: APP_VERSION
|
|
77
79
|
}
|
|
78
80
|
postAnalytics(startCommandAnalytics).catch((error: Error) => {
|
|
79
81
|
/* ignore */
|
|
@@ -99,7 +101,8 @@ const processLambda = async (argv: string[]) => {
|
|
|
99
101
|
const endCommandAnalytics: AnalyticsOption = {
|
|
100
102
|
sessionId: commandSessionId,
|
|
101
103
|
eventType: EventType.END,
|
|
102
|
-
status: errorMsg ? StatusType.FAILED : StatusType.SUCCESS
|
|
104
|
+
status: errorMsg ? StatusType.FAILED : StatusType.SUCCESS,
|
|
105
|
+
packageVersion: APP_VERSION
|
|
103
106
|
}
|
|
104
107
|
if (errorMsg) {
|
|
105
108
|
endCommandAnalytics.errorMsg = errorMsg
|
package/src/lambda/types.ts
CHANGED
package/src/sbom/generateSbom.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { getHttpClient } from '../utils/commonApi'
|
|
2
2
|
|
|
3
|
-
export const generateSbom = (config: any) => {
|
|
3
|
+
export const generateSbom = (config: any, type: string) => {
|
|
4
4
|
const client = getHttpClient(config)
|
|
5
5
|
return client
|
|
6
|
-
.getSbom(config)
|
|
6
|
+
.getSbom(config, type)
|
|
7
7
|
.then((res: { statusCode: number; body: any }) => {
|
|
8
8
|
if (res.statusCode === 200) {
|
|
9
9
|
return res.body
|
|
@@ -50,11 +50,18 @@ const createPhpTSMessage = phpTree => {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
const createDotNetTSMessage = dotnetTree => {
|
|
54
|
+
return {
|
|
55
|
+
dotnet: dotnetTree
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
53
59
|
module.exports = {
|
|
54
60
|
createJavaScriptTSMessage,
|
|
55
61
|
createJavaTSMessage,
|
|
56
62
|
createGoTSMessage,
|
|
57
63
|
createPhpTSMessage,
|
|
58
64
|
createRubyTSMessage,
|
|
59
|
-
createPythonTSMessage
|
|
65
|
+
createPythonTSMessage,
|
|
66
|
+
createDotNetTSMessage
|
|
60
67
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const parseDependenciesForSCAServices = dependencyTreeObject => {
|
|
2
|
+
let parsedDependencyTree = {}
|
|
3
|
+
let subDeps
|
|
4
|
+
|
|
5
|
+
for (let tree in dependencyTreeObject) {
|
|
6
|
+
let unParsedDependencyTree = dependencyTreeObject[tree]
|
|
7
|
+
for (let dependency in unParsedDependencyTree) {
|
|
8
|
+
subDeps = parseSubDependencies(unParsedDependencyTree[dependency].edges)
|
|
9
|
+
|
|
10
|
+
let parsedDependency = {
|
|
11
|
+
name: unParsedDependencyTree[dependency].artifactID,
|
|
12
|
+
group: unParsedDependencyTree[dependency].group,
|
|
13
|
+
version: unParsedDependencyTree[dependency].version,
|
|
14
|
+
directDependency: unParsedDependencyTree[dependency].type === 'direct',
|
|
15
|
+
isProduction: true,
|
|
16
|
+
dependencies: subDeps
|
|
17
|
+
}
|
|
18
|
+
parsedDependencyTree[dependency] = parsedDependency
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return parsedDependencyTree
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const parseSubDependencies = dependencies => {
|
|
25
|
+
// converting:
|
|
26
|
+
// dependencies: {
|
|
27
|
+
// 'gopkg.in/check.v1@v0.0.0-2': 'gopkg.in/check.v1@v0.0.0-2'
|
|
28
|
+
// }
|
|
29
|
+
// to:
|
|
30
|
+
// dependencies: [ 'gopkg.in/check.v1@v0.0.0-2' ]
|
|
31
|
+
let subDeps = []
|
|
32
|
+
for (let x in dependencies) {
|
|
33
|
+
subDeps.push(dependencies[x])
|
|
34
|
+
}
|
|
35
|
+
return subDeps
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
module.exports = {
|
|
39
|
+
parseDependenciesForSCAServices,
|
|
40
|
+
parseSubDependencies
|
|
41
|
+
}
|