@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
|
@@ -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
|
-
|
|
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
|
-
|
|
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: '
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
99
|
-
|
|
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
|
|
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
|
-
|
|
189
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
262
|
-
|
|
263
|
-
|
|
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
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
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
|
-
|
|
278
|
-
|
|
279
|
-
|
|
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
|
|
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: [
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
config.set('numOfRuns',
|
|
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
|
-
|
|
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(
|
|
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
|
-
|
|
80
|
-
console.log(
|
|
81
|
-
|
|
90
|
+
catch (err) {
|
|
91
|
+
console.log();
|
|
92
|
+
console.log(err.message.toString());
|
|
93
|
+
process.exit(1);
|
|
82
94
|
}
|
|
83
95
|
};
|
|
84
96
|
start();
|
package/dist/lambda/lambda.js
CHANGED
|
@@ -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
|
|
2
|
+
const commonApi = require('../../utils/commonApi');
|
|
3
3
|
const { APP_VERSION } = require('../../constants/constants');
|
|
4
4
|
const commonSendSnapShot = async (analysis, config) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
19
|
-
console.log('error processing dependencies');
|
|
21
|
+
throw new Error(res.statusCode + ` error processing dependencies`);
|
|
20
22
|
}
|
|
21
23
|
})
|
|
22
24
|
.catch(err => {
|
|
23
|
-
|
|
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
|
};
|