@contrast/contrast 1.0.7 → 1.0.10
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 +1 -1
- package/dist/audit/catalogueApplication/catalogueApplication.js +23 -5
- package/dist/audit/languageAnalysisEngine/getProjectRootFilenames.js +17 -26
- package/dist/audit/languageAnalysisEngine/report/commonReportingFunctions.js +98 -37
- package/dist/audit/languageAnalysisEngine/report/models/reportListModel.js +2 -1
- package/dist/audit/languageAnalysisEngine/report/models/reportOutputModel.js +4 -3
- package/dist/audit/languageAnalysisEngine/report/models/severityCountModel.js +3 -0
- package/dist/audit/languageAnalysisEngine/report/reportingFeature.js +87 -19
- package/dist/audit/languageAnalysisEngine/report/utils/reportUtils.js +40 -7
- package/dist/audit/languageAnalysisEngine/sendSnapshot.js +6 -30
- package/dist/audit/save.js +37 -0
- package/dist/commands/audit/auditConfig.js +0 -16
- package/dist/commands/audit/auditController.js +18 -11
- package/dist/commands/audit/help.js +31 -25
- package/dist/commands/audit/processAudit.js +2 -2
- package/dist/commands/audit/saveFile.js +8 -4
- package/dist/commands/scan/sca/scaAnalysis.js +54 -16
- package/dist/common/HTTPClient.js +14 -8
- package/dist/common/errorHandling.js +2 -2
- package/dist/common/versionChecker.js +19 -4
- package/dist/constants/constants.js +7 -2
- package/dist/constants/locales.js +44 -44
- package/dist/constants.js +31 -14
- package/dist/index.js +55 -45
- package/dist/lambda/lambda.js +5 -2
- package/dist/sbom/generateSbom.js +5 -4
- package/dist/scaAnalysis/common/formatMessage.js +33 -6
- package/dist/scaAnalysis/common/treeUpload.js +4 -6
- package/dist/scaAnalysis/dotnet/analysis.js +43 -0
- package/dist/scaAnalysis/dotnet/index.js +10 -0
- package/dist/scaAnalysis/go/goReadDepFile.js +1 -3
- package/dist/scaAnalysis/java/analysis.js +5 -5
- package/dist/scaAnalysis/javascript/analysis.js +107 -0
- package/dist/scaAnalysis/javascript/index.js +53 -0
- package/dist/scaAnalysis/php/analysis.js +70 -0
- package/dist/scaAnalysis/php/index.js +17 -0
- package/dist/scaAnalysis/python/analysis.js +8 -7
- package/dist/scaAnalysis/ruby/analysis.js +8 -16
- package/dist/scaAnalysis/ruby/index.js +2 -2
- package/dist/scan/autoDetection.js +13 -24
- package/dist/scan/fileUtils.js +44 -14
- package/dist/scan/formatScanOutput.js +3 -3
- package/dist/scan/scanConfig.js +2 -2
- package/dist/utils/commonApi.js +1 -1
- package/dist/utils/filterProjectPath.js +7 -2
- package/dist/utils/getConfig.js +1 -6
- package/package.json +2 -3
- package/src/audit/catalogueApplication/catalogueApplication.js +28 -6
- package/src/audit/languageAnalysisEngine/getProjectRootFilenames.js +22 -58
- package/src/audit/languageAnalysisEngine/report/commonReportingFunctions.ts +157 -47
- package/src/audit/languageAnalysisEngine/report/models/reportListModel.ts +4 -1
- package/src/audit/languageAnalysisEngine/report/models/reportOutputModel.ts +11 -5
- package/src/audit/languageAnalysisEngine/report/models/severityCountModel.ts +4 -0
- package/src/audit/languageAnalysisEngine/report/reportingFeature.ts +86 -32
- package/src/audit/languageAnalysisEngine/report/utils/reportUtils.ts +44 -5
- package/src/audit/languageAnalysisEngine/sendSnapshot.js +6 -32
- package/src/audit/save.js +48 -0
- package/src/commands/audit/auditConfig.ts +0 -25
- package/src/commands/audit/auditController.ts +18 -20
- package/src/commands/audit/help.ts +31 -25
- package/src/commands/audit/processAudit.ts +2 -5
- package/src/commands/audit/saveFile.ts +6 -2
- package/src/commands/scan/processScan.js +0 -1
- package/src/commands/scan/sca/scaAnalysis.js +87 -32
- package/src/common/HTTPClient.js +16 -9
- package/src/common/errorHandling.ts +2 -3
- package/src/common/versionChecker.ts +23 -4
- package/src/constants/constants.js +9 -3
- package/src/constants/locales.js +72 -50
- package/src/constants.js +32 -15
- package/src/index.ts +70 -58
- 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 +35 -6
- package/src/scaAnalysis/common/treeUpload.js +4 -6
- package/src/scaAnalysis/dotnet/analysis.js +54 -0
- package/src/scaAnalysis/dotnet/index.js +11 -0
- package/src/scaAnalysis/go/goReadDepFile.js +1 -3
- package/src/scaAnalysis/java/analysis.js +5 -5
- package/src/scaAnalysis/javascript/analysis.js +126 -0
- package/src/scaAnalysis/javascript/index.js +75 -0
- package/src/scaAnalysis/php/analysis.js +78 -0
- package/src/scaAnalysis/php/index.js +22 -0
- package/src/scaAnalysis/python/analysis.js +8 -7
- package/src/scaAnalysis/ruby/analysis.js +8 -17
- package/src/scaAnalysis/ruby/index.js +2 -2
- package/src/scan/autoDetection.js +14 -27
- package/src/scan/fileUtils.js +46 -14
- package/src/scan/formatScanOutput.ts +3 -3
- package/src/scan/scanConfig.js +2 -4
- package/src/utils/commonApi.js +1 -1
- package/src/utils/filterProjectPath.js +6 -2
- package/src/utils/getConfig.ts +1 -12
- 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 -89
- package/dist/audit/languageAnalysisEngine/reduceIdentifiedLanguages.js +0 -159
- 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 -124
- package/src/audit/languageAnalysisEngine/reduceIdentifiedLanguages.js +0 -250
- 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
|
@@ -12,11 +12,11 @@ const en_locales = () => {
|
|
|
12
12
|
vulnerabilitiesFailureMessage: 'Unable to retrieve library vulnerabilities',
|
|
13
13
|
catchErrorMessage: 'Contrast UI error: ',
|
|
14
14
|
dependenciesNote: 'Please Note: We currently only support projects with one .csproj AND *.package.lock.json',
|
|
15
|
-
languageAnalysisFailureMessage: 'SCA
|
|
15
|
+
languageAnalysisFailureMessage: 'SCA audit Failure',
|
|
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: ',
|
|
@@ -78,7 +80,7 @@ const en_locales = () => {
|
|
|
78
80
|
constantsApplicationName: 'The name of the application cataloged by Contrast UI',
|
|
79
81
|
constantsCatalogueApplication: 'Provide this if you want to catalogue an application',
|
|
80
82
|
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
|
-
|
|
83
|
+
constantsFilePath: `Path of the file you want to perform an SCA audit on. If no folder is specified, Contrast searches for dependency files in the working directory.`,
|
|
82
84
|
constantsSilent: 'Silences JSON output.',
|
|
83
85
|
constantsAppGroups: 'Assign your application to one or more pre-existing groups when using the catalogue command. Group lists should be comma separated.',
|
|
84
86
|
constantsVersion: 'Displays CLI Version you are currently on.',
|
|
@@ -90,13 +92,17 @@ const en_locales = () => {
|
|
|
90
92
|
constantsProjectName: 'Contrast project name. If not specified, Contrast uses contrast.settings to identify the project or creates a project.',
|
|
91
93
|
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
94
|
constantsReport: 'Display vulnerability information for this application',
|
|
93
|
-
constantsFail: 'Set the process to fail if this option is set in combination with
|
|
94
|
-
failOptionErrorMessage:
|
|
95
|
-
constantsSeverity: '
|
|
96
|
-
constantsCount:
|
|
95
|
+
constantsFail: 'Set the process to fail if this option is set in combination with --cve_severity.',
|
|
96
|
+
failOptionErrorMessage: ' FAIL - CVEs have been detected that match at least the cve_severity or cve_threshold option specified.',
|
|
97
|
+
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.',
|
|
98
|
+
constantsCount: 'The number of CVEs that must be exceeded to fail a build',
|
|
97
99
|
constantsHeader: 'CodeSec by Contrast Security',
|
|
98
|
-
|
|
99
|
-
|
|
100
|
+
configHeader2: 'Config options',
|
|
101
|
+
clearHeader: '-c, --clear',
|
|
102
|
+
clearContent: 'Removes stored credentials',
|
|
103
|
+
constantsPrerequisitesContentScanLanguages: 'Java, Javascript and .NET supported',
|
|
104
|
+
constantsContrastContent: 'Use the ‘contrast’ command for fast and accurate security analysis of your applications, APIs, serverless functions, and libraries.',
|
|
105
|
+
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
106
|
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
107
|
constantsPrerequisitesHeader: 'Pre-requisites',
|
|
102
108
|
constantsAuthUsageHeader: 'Usage',
|
|
@@ -162,7 +168,7 @@ const en_locales = () => {
|
|
|
162
168
|
constantsIgnoreCertErrors: 'For EOP users with a local Teamserver install, this will bypass the SSL certificate and recognise a self signed certificate.',
|
|
163
169
|
constantsSave: 'Saves the Scan Results SARIF to file.',
|
|
164
170
|
scanLabel: "adds a label to the scan - defaults to 'Started by CLI tool at current date'",
|
|
165
|
-
constantsIgnoreDev: '
|
|
171
|
+
constantsIgnoreDev: 'Excludes developer dependencies from the results. All dependencies are included by default.',
|
|
166
172
|
constantsCommands: 'Commands',
|
|
167
173
|
constantsScanOptions: 'Scan Options',
|
|
168
174
|
sbomError: 'All required parameters are not present.',
|
|
@@ -185,12 +191,14 @@ const en_locales = () => {
|
|
|
185
191
|
permissionsError: 'You do not have the correct permissions here. \n Contact support@contrastsecurity.com to get this fixed.',
|
|
186
192
|
scanErrorFileMessage: 'We only accept the following file types: \nJava - .jar, .war \nJavaScript - .js or .zip files',
|
|
187
193
|
helpAuthSummary: 'Authenticate Contrast using your Github or Google account',
|
|
188
|
-
|
|
189
|
-
|
|
194
|
+
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).]',
|
|
195
|
+
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]',
|
|
196
|
+
helpLambdaSummary: 'Performs a static security scan on an AWS lambda function. lambda --help (for options)',
|
|
190
197
|
helpVersionSummary: 'Displays version of Contrast CLI',
|
|
191
198
|
helpConfigSummary: 'Displays stored credentials',
|
|
192
199
|
helpSummary: 'Displays usage guide',
|
|
193
200
|
authName: 'auth',
|
|
201
|
+
auditName: 'audit',
|
|
194
202
|
scanName: 'scan',
|
|
195
203
|
lambdaName: 'lambda',
|
|
196
204
|
versionName: 'version',
|
|
@@ -203,8 +211,7 @@ const en_locales = () => {
|
|
|
203
211
|
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
212
|
scanOptionsVerboseSummary: ' Returns extended information to the terminal.',
|
|
205
213
|
authSuccessMessage: 'Authentication successful',
|
|
206
|
-
runAuthSuccessMessage: "Now you can use Contrast
|
|
207
|
-
"or 'contrast help' to learn more about the capabilities.",
|
|
214
|
+
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
215
|
authWaitingMessage: 'Waiting for auth...',
|
|
209
216
|
authTimedOutMessage: 'Auth Timed out, try again',
|
|
210
217
|
zipErrorScan: 'We only support zip files for JAVASCRIPT language, please set the flag --language JAVASCRIPT',
|
|
@@ -226,7 +233,7 @@ const en_locales = () => {
|
|
|
226
233
|
lambdaPrerequisitesContent: '',
|
|
227
234
|
lambdaPrerequisitesContentLambdaLanguages: 'Supported runtimes: Java & Python',
|
|
228
235
|
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
|
|
236
|
+
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
237
|
scanFileNameOption: '-f, --file',
|
|
231
238
|
lambdaFunctionNameOption: '-f, --function-name',
|
|
232
239
|
lambdaListFunctionsOption: '-l, --list-functions',
|
|
@@ -253,36 +260,28 @@ const en_locales = () => {
|
|
|
253
260
|
connectionError: 'An error has occurred when trying to get the Project Id please check your internet connection or provide the Project Id manually',
|
|
254
261
|
internalServerErrorHeader: '500 error - Internal server error',
|
|
255
262
|
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.`,
|
|
263
|
+
auditHeader: 'Contrast audit help',
|
|
264
|
+
auditHeaderMessage: "Use 'contrast audit' to analyze a project’s dependencies for vulnerabilities.",
|
|
260
265
|
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: ',
|
|
266
|
+
constantsAuditPrerequisitesJavaContentMessage: `
|
|
267
|
+
${chalk.bold('Java:')} pom.xml ${chalk.bold('and')} Maven build platform including the dependency plugin.
|
|
268
|
+
${chalk.bold('Or')} build.gradle ${chalk.bold('and')} gradle dependencies or ./gradlew dependencies must be supported`,
|
|
267
269
|
constantsAuditPrerequisitesContentDotNetMessage: `
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
constantsAuditPrerequisitesContentLanguagePythonMessage: 'pipfile AND pipfile.lock',
|
|
270
|
+
${chalk.bold('.NET framework and .NET core:')} MSBuild 15.0 or greater and a packages.lock.json file.
|
|
271
|
+
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`,
|
|
272
|
+
constantsAuditPrerequisitesContentNodeMessage: `${chalk.bold('Node:')} package.json and a lock file (either .package-lock.json or .yarn.lock.)\n`,
|
|
273
|
+
constantsAuditPrerequisitesContentRubyMessage: `${chalk.bold('Ruby:')} gemfile and gemfile.lock\n`,
|
|
274
|
+
constantsAuditPrerequisitesContentPythonMessage: `${chalk.bold('Python:')} pipfile and pipfile.lock\n`,
|
|
275
|
+
constantsAuditPrerequisitesContentGoMessage: `${chalk.bold('Go:')} go.mod\n`,
|
|
276
|
+
constantsAuditPrerequisitesContentPHPMessage: `${chalk.bold('PHP:')} composer.json and composer.lock\n`,
|
|
276
277
|
constantsAuditOptions: 'Audit Options',
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
auditOptionsSave: '-s, --save',
|
|
280
|
-
auditOptionsSaveDescription: 'saves the output in specified format Txt text, sbom',
|
|
278
|
+
auditOptionsSaveDescription: 'Generate and save an SBOM (Software Bill of Materials)\n',
|
|
279
|
+
auditOptionsSaveOptionsDescription: 'Valid options are: spdx, cyclonedx (cycloneDX is the default format)',
|
|
281
280
|
scanNotCompleted: 'Scan not completed. Check for framework and language support here: %s',
|
|
282
281
|
auditNotCompleted: 'audit not completed. Please try again',
|
|
283
|
-
scanNoVulnerabilitiesFound: '
|
|
282
|
+
scanNoVulnerabilitiesFound: '🎉 No vulnerabilities found.',
|
|
284
283
|
scanNoVulnerabilitiesFoundSecureCode: '👍 Your code looks secure.',
|
|
285
|
-
scanNoVulnerabilitiesFoundGoodWork: '
|
|
284
|
+
scanNoVulnerabilitiesFoundGoodWork: ' Keep up the good work.',
|
|
286
285
|
scanNoFiletypeSpecifiedForSave: 'Please specify file type to save results to, accepted value is SARIF',
|
|
287
286
|
auditSBOMSaveSuccess: '\n Software Bill of Materials (SBOM) saved successfully',
|
|
288
287
|
auditNoFiletypeSpecifiedForSave: `\n ${chalk.yellow.bold('No file type specified for --save option to save audit results to. Use audit --help to see valid --save options.')}`,
|
|
@@ -291,7 +290,8 @@ const en_locales = () => {
|
|
|
291
290
|
auditReportFail: 'Report Retrieval Failed, please try again',
|
|
292
291
|
auditReportSuccessMessage: 'Report successfully retrieved',
|
|
293
292
|
auditReportFailureMessage: 'Unable to generate library report',
|
|
294
|
-
auditSCAAnalysisBegins: 'Contrast SCA
|
|
293
|
+
auditSCAAnalysisBegins: 'Contrast SCA audit started',
|
|
294
|
+
auditSCAAnalysisComplete: 'Contrast audit complete',
|
|
295
295
|
...lambda
|
|
296
296
|
};
|
|
297
297
|
};
|
package/dist/constants.js
CHANGED
|
@@ -43,7 +43,6 @@ const scanOptionDefinitions = [
|
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
45
|
name: 'project-path',
|
|
46
|
-
alias: 'i',
|
|
47
46
|
description: '{bold ' +
|
|
48
47
|
i18n.__('constantsOptional') +
|
|
49
48
|
'}: ' +
|
|
@@ -188,12 +187,13 @@ const auditOptionDefinitions = [
|
|
|
188
187
|
i18n.__('constantsApplicationName')
|
|
189
188
|
},
|
|
190
189
|
{
|
|
191
|
-
name: '
|
|
192
|
-
|
|
190
|
+
name: 'file',
|
|
191
|
+
alias: 'f',
|
|
192
|
+
defaultValue: process.cwd().concat('/'),
|
|
193
193
|
description: '{bold ' +
|
|
194
194
|
i18n.__('constantsOptional') +
|
|
195
195
|
'}: ' +
|
|
196
|
-
i18n.__('
|
|
196
|
+
i18n.__('constantsFilePath')
|
|
197
197
|
},
|
|
198
198
|
{
|
|
199
199
|
name: 'app-groups',
|
|
@@ -235,14 +235,6 @@ const auditOptionDefinitions = [
|
|
|
235
235
|
{
|
|
236
236
|
name: 'maven-settings-path'
|
|
237
237
|
},
|
|
238
|
-
{
|
|
239
|
-
name: 'language',
|
|
240
|
-
alias: 'l',
|
|
241
|
-
description: '{bold ' +
|
|
242
|
-
i18n.__('constantsRequiredCatalogue') +
|
|
243
|
-
'}: ' +
|
|
244
|
-
i18n.__('constantsLanguage')
|
|
245
|
-
},
|
|
246
238
|
{
|
|
247
239
|
name: 'organization-id',
|
|
248
240
|
alias: 'o',
|
|
@@ -294,13 +286,31 @@ const auditOptionDefinitions = [
|
|
|
294
286
|
description: '{bold ' +
|
|
295
287
|
i18n.__('constantsOptional') +
|
|
296
288
|
'}: ' +
|
|
297
|
-
i18n.__('auditOptionsSaveDescription')
|
|
289
|
+
i18n.__('auditOptionsSaveDescription') +
|
|
290
|
+
i18n.__('auditOptionsSaveOptionsDescription')
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
name: 'experimental',
|
|
294
|
+
alias: 'e',
|
|
295
|
+
type: Boolean
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
name: 'timeout',
|
|
299
|
+
alias: 't',
|
|
300
|
+
type: Number,
|
|
301
|
+
description: '{bold ' +
|
|
302
|
+
i18n.__('constantsOptional') +
|
|
303
|
+
'}: ' +
|
|
304
|
+
i18n.__('scanOptionsTimeoutSummary')
|
|
298
305
|
}
|
|
299
306
|
];
|
|
300
307
|
const mainUsageGuide = commandLineUsage([
|
|
301
308
|
{
|
|
302
309
|
header: i18n.__('constantsHeader'),
|
|
303
|
-
content: [
|
|
310
|
+
content: [
|
|
311
|
+
i18n.__('constantsContrastContent'),
|
|
312
|
+
i18n.__('constantsContrastCategories')
|
|
313
|
+
]
|
|
304
314
|
},
|
|
305
315
|
{
|
|
306
316
|
header: i18n.__('constantsUsage'),
|
|
@@ -312,6 +322,7 @@ const mainUsageGuide = commandLineUsage([
|
|
|
312
322
|
{ name: i18n.__('authName'), summary: i18n.__('helpAuthSummary') },
|
|
313
323
|
{ name: i18n.__('scanName'), summary: i18n.__('helpScanSummary') },
|
|
314
324
|
{ name: i18n.__('lambdaName'), summary: i18n.__('helpLambdaSummary') },
|
|
325
|
+
{ name: i18n.__('auditName'), summary: i18n.__('helpAuditSummary') },
|
|
315
326
|
{ name: i18n.__('versionName'), summary: i18n.__('helpVersionSummary') },
|
|
316
327
|
{ name: i18n.__('configName'), summary: i18n.__('helpConfigSummary') },
|
|
317
328
|
{ name: i18n.__('helpName'), summary: i18n.__('helpSummary') }
|
|
@@ -319,6 +330,12 @@ const mainUsageGuide = commandLineUsage([
|
|
|
319
330
|
},
|
|
320
331
|
{
|
|
321
332
|
content: '{underline https://developer.contrastsecurity.com/} \n For technical support head to {underline https://support.contrastsecurity.com}'
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
header: i18n.__('configHeader2'),
|
|
336
|
+
content: [
|
|
337
|
+
{ name: i18n.__('clearHeader'), summary: i18n.__('clearContent') }
|
|
338
|
+
]
|
|
322
339
|
}
|
|
323
340
|
]);
|
|
324
341
|
const mainDefinition = [{ name: 'command', defaultOption: true }];
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
"use strict";
|
|
2
3
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -29,55 +30,64 @@ const getMainOption = () => {
|
|
|
29
30
|
};
|
|
30
31
|
};
|
|
31
32
|
const start = async () => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
config.set('numOfRuns',
|
|
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
|
-
|
|
33
|
+
try {
|
|
34
|
+
if (await (0, versionChecker_1.isCorrectNodeVersion)(process.version)) {
|
|
35
|
+
const { mainOptions, argv: argvMain } = getMainOption();
|
|
36
|
+
const command = mainOptions.command != undefined
|
|
37
|
+
? mainOptions.command.toLowerCase()
|
|
38
|
+
: '';
|
|
39
|
+
if (command === 'version' ||
|
|
40
|
+
argvMain.includes('--v') ||
|
|
41
|
+
argvMain.includes('--version')) {
|
|
42
|
+
console.log(constants_2.APP_VERSION);
|
|
43
|
+
await (0, versionChecker_1.findLatestCLIVersion)(config);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
config.set('numOfRuns', config.get('numOfRuns') + 1);
|
|
47
|
+
if (config.get('numOfRuns') >= 1) {
|
|
48
|
+
await (0, versionChecker_1.findLatestCLIVersion)(config);
|
|
49
|
+
config.set('numOfRuns', 0);
|
|
50
|
+
}
|
|
51
|
+
if (command === 'config') {
|
|
52
|
+
return (0, config_1.processConfig)(argvMain, config);
|
|
53
|
+
}
|
|
54
|
+
if (command === 'auth') {
|
|
55
|
+
return await (0, auth_1.processAuth)(argvMain, config);
|
|
56
|
+
}
|
|
57
|
+
if (command === 'lambda') {
|
|
58
|
+
return await (0, lambda_1.processLambda)(argvMain);
|
|
59
|
+
}
|
|
60
|
+
if (command === 'scan') {
|
|
61
|
+
return await (0, processScan_1.processScan)(argvMain);
|
|
62
|
+
}
|
|
63
|
+
if (command === 'audit') {
|
|
64
|
+
return await (0, processAudit_1.processAudit)(argvMain);
|
|
65
|
+
}
|
|
66
|
+
if (command === 'help' ||
|
|
67
|
+
argvMain.includes('--help') ||
|
|
68
|
+
Object.keys(mainOptions).length === 0) {
|
|
69
|
+
console.log(mainUsageGuide);
|
|
70
|
+
}
|
|
71
|
+
else if (mainOptions._unknown !== undefined) {
|
|
72
|
+
const foundCommand = (0, errorHandling_1.findCommandOnError)(mainOptions._unknown);
|
|
73
|
+
foundCommand
|
|
74
|
+
? console.log(`Unknown Command: Did you mean "${foundCommand}"? \nUse "${foundCommand} --help" for the full list of options`)
|
|
75
|
+
: console.log(`Unknown Command: ${command} \nUse --help for the full list`);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
console.log(`Unknown Command: ${command} \nUse --help for the full list`);
|
|
79
|
+
}
|
|
80
|
+
process.exit(9);
|
|
72
81
|
}
|
|
73
82
|
else {
|
|
74
|
-
console.log(
|
|
83
|
+
console.log('Contrast supports Node versions >=16.13.2 <17. Please use one of those versions.');
|
|
84
|
+
process.exit(9);
|
|
75
85
|
}
|
|
76
|
-
process.exit(9);
|
|
77
86
|
}
|
|
78
|
-
|
|
79
|
-
console.log(
|
|
80
|
-
|
|
87
|
+
catch (err) {
|
|
88
|
+
console.log();
|
|
89
|
+
console.log(err.message.toString());
|
|
90
|
+
process.exit(1);
|
|
81
91
|
}
|
|
82
92
|
};
|
|
83
93
|
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;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateSbom = void 0;
|
|
3
4
|
const commonApi_1 = require("../utils/commonApi");
|
|
4
|
-
|
|
5
|
+
const generateSbom = (config, type) => {
|
|
5
6
|
const client = (0, commonApi_1.getHttpClient)(config);
|
|
6
7
|
return client
|
|
7
|
-
.getSbom(config)
|
|
8
|
+
.getSbom(config, type)
|
|
8
9
|
.then((res) => {
|
|
9
10
|
if (res.statusCode === 200) {
|
|
10
11
|
return res.body;
|
|
@@ -16,5 +17,5 @@ function generateSbom(config) {
|
|
|
16
17
|
.catch((err) => {
|
|
17
18
|
console.log(err);
|
|
18
19
|
});
|
|
19
|
-
}
|
|
20
|
-
exports.
|
|
20
|
+
};
|
|
21
|
+
exports.generateSbom = generateSbom;
|
|
@@ -6,6 +6,21 @@ const createJavaTSMessage = javaTree => {
|
|
|
6
6
|
}
|
|
7
7
|
};
|
|
8
8
|
};
|
|
9
|
+
const createJavaScriptTSMessage = js => {
|
|
10
|
+
let message = {
|
|
11
|
+
node: {
|
|
12
|
+
packageJSON: js.packageJSON
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
if (js.yarn !== undefined) {
|
|
16
|
+
message.node.yarnLockFile = js.yarn.yarnLockFile;
|
|
17
|
+
message.node.yarnVersion = js.yarn.yarnVersion;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
message.node.npmLockFile = js.npmLockFile;
|
|
21
|
+
}
|
|
22
|
+
return message;
|
|
23
|
+
};
|
|
9
24
|
const createGoTSMessage = goTree => {
|
|
10
25
|
return {
|
|
11
26
|
go: {
|
|
@@ -15,21 +30,33 @@ const createGoTSMessage = goTree => {
|
|
|
15
30
|
};
|
|
16
31
|
const createRubyTSMessage = rubyTree => {
|
|
17
32
|
return {
|
|
18
|
-
ruby:
|
|
19
|
-
rubyDependencyTrees: rubyTree
|
|
20
|
-
}
|
|
33
|
+
ruby: rubyTree
|
|
21
34
|
};
|
|
22
35
|
};
|
|
23
36
|
const createPythonTSMessage = pythonTree => {
|
|
24
37
|
return {
|
|
25
|
-
python:
|
|
26
|
-
|
|
38
|
+
python: pythonTree
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
const createPhpTSMessage = phpTree => {
|
|
42
|
+
return {
|
|
43
|
+
php: {
|
|
44
|
+
composerJSON: phpTree.composerJSON,
|
|
45
|
+
lockFile: phpTree.lockFile
|
|
27
46
|
}
|
|
28
47
|
};
|
|
29
48
|
};
|
|
49
|
+
const createDotNetTSMessage = dotnetTree => {
|
|
50
|
+
return {
|
|
51
|
+
dotnet: dotnetTree
|
|
52
|
+
};
|
|
53
|
+
};
|
|
30
54
|
module.exports = {
|
|
55
|
+
createJavaScriptTSMessage,
|
|
31
56
|
createJavaTSMessage,
|
|
32
57
|
createGoTSMessage,
|
|
58
|
+
createPhpTSMessage,
|
|
33
59
|
createRubyTSMessage,
|
|
34
|
-
createPythonTSMessage
|
|
60
|
+
createPythonTSMessage,
|
|
61
|
+
createDotNetTSMessage
|
|
35
62
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
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
5
|
const requestBody = {
|
|
@@ -7,21 +7,19 @@ const commonSendSnapShot = async (analysis, config) => {
|
|
|
7
7
|
cliVersion: APP_VERSION,
|
|
8
8
|
snapshot: analysis
|
|
9
9
|
};
|
|
10
|
-
const client = getHttpClient(config);
|
|
10
|
+
const client = commonApi.getHttpClient(config);
|
|
11
11
|
return client
|
|
12
12
|
.sendSnapshot(requestBody, config)
|
|
13
13
|
.then(res => {
|
|
14
14
|
if (res.statusCode === 201) {
|
|
15
|
-
console.log('dependencies processed successfully');
|
|
16
15
|
return res.body;
|
|
17
16
|
}
|
|
18
17
|
else {
|
|
19
|
-
|
|
20
|
-
console.log('error processing dependencies');
|
|
18
|
+
throw new Error(res.statusCode + ` error processing dependencies`);
|
|
21
19
|
}
|
|
22
20
|
})
|
|
23
21
|
.catch(err => {
|
|
24
|
-
|
|
22
|
+
throw err;
|
|
25
23
|
});
|
|
26
24
|
};
|
|
27
25
|
module.exports = {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const xml2js = require('xml2js');
|
|
4
|
+
const i18n = require('i18n');
|
|
5
|
+
const readAndParseProjectFile = projectFilePath => {
|
|
6
|
+
const projectFile = fs.readFileSync(projectFilePath);
|
|
7
|
+
return new xml2js.Parser({
|
|
8
|
+
explicitArray: false,
|
|
9
|
+
mergeAttrs: true
|
|
10
|
+
}).parseString(projectFile);
|
|
11
|
+
};
|
|
12
|
+
const readAndParseLockFile = lockFilePath => {
|
|
13
|
+
const lockFile = JSON.parse(fs.readFileSync(lockFilePath).toString());
|
|
14
|
+
let count = 0;
|
|
15
|
+
for (const dependenciesNode in lockFile.dependencies) {
|
|
16
|
+
for (const innerNode in lockFile.dependencies[dependenciesNode]) {
|
|
17
|
+
const nodeValidation = JSON.stringify(lockFile.dependencies[dependenciesNode][innerNode]);
|
|
18
|
+
if (nodeValidation.includes('"type":"Project"')) {
|
|
19
|
+
count += 1;
|
|
20
|
+
delete lockFile.dependencies[dependenciesNode][innerNode];
|
|
21
|
+
lockFile.additionalInfo = 'dependenciesNote';
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (count > 0) {
|
|
26
|
+
const multiLevelProjectWarning = () => {
|
|
27
|
+
console.log('');
|
|
28
|
+
console.log(i18n.__('dependenciesNote'));
|
|
29
|
+
};
|
|
30
|
+
setTimeout(multiLevelProjectWarning, 7000);
|
|
31
|
+
}
|
|
32
|
+
return lockFile;
|
|
33
|
+
};
|
|
34
|
+
const getDotNetDeps = (filePath, languageFiles) => {
|
|
35
|
+
const projectFile = readAndParseProjectFile(filePath + `/${languageFiles[0]}`);
|
|
36
|
+
const lockFile = readAndParseLockFile(filePath + `/${languageFiles[1]}`);
|
|
37
|
+
return { projectFile, lockFile };
|
|
38
|
+
};
|
|
39
|
+
module.exports = {
|
|
40
|
+
getDotNetDeps,
|
|
41
|
+
readAndParseProjectFile,
|
|
42
|
+
readAndParseLockFile
|
|
43
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const { getDotNetDeps } = require('./analysis');
|
|
3
|
+
const { createDotNetTSMessage } = require('../common/formatMessage');
|
|
4
|
+
const dotNetAnalysis = (config, languageFiles) => {
|
|
5
|
+
const dotNetDeps = getDotNetDeps(config.file, languageFiles.DOTNET);
|
|
6
|
+
return createDotNetTSMessage(dotNetDeps);
|
|
7
|
+
};
|
|
8
|
+
module.exports = {
|
|
9
|
+
dotNetAnalysis
|
|
10
|
+
};
|
|
@@ -3,9 +3,7 @@ const child_process = require('child_process');
|
|
|
3
3
|
const i18n = require('i18n');
|
|
4
4
|
const getGoDependencies = config => {
|
|
5
5
|
let cmdStdout;
|
|
6
|
-
let cwd = config.
|
|
7
|
-
? config.projectPath.replace('go.mod', '')
|
|
8
|
-
: process.cwd();
|
|
6
|
+
let cwd = config.file ? config.file.replace('go.mod', '') : process.cwd();
|
|
9
7
|
try {
|
|
10
8
|
cmdStdout = child_process.execSync('go mod graph', { cwd });
|
|
11
9
|
return cmdStdout.toString();
|