@contrast/contrast 1.0.0 → 1.0.3
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/.prettierignore +3 -0
- package/README.md +115 -78
- package/dist/audit/AnalysisEngine.js +37 -0
- package/dist/audit/catalogueApplication/catalogueApplication.js +36 -0
- package/dist/audit/dotnetAnalysisEngine/index.js +25 -0
- package/dist/audit/dotnetAnalysisEngine/parseLockFileContents.js +35 -0
- package/dist/audit/dotnetAnalysisEngine/parseProjectFileContents.js +15 -0
- package/dist/audit/dotnetAnalysisEngine/readLockFileContents.js +18 -0
- package/dist/audit/dotnetAnalysisEngine/readProjectFileContents.js +14 -0
- package/dist/audit/dotnetAnalysisEngine/sanitizer.js +9 -0
- package/dist/audit/goAnalysisEngine/index.js +17 -0
- package/dist/audit/goAnalysisEngine/parseProjectFileContents.js +164 -0
- package/dist/audit/goAnalysisEngine/readProjectFileContents.js +21 -0
- package/dist/audit/goAnalysisEngine/sanitizer.js +5 -0
- package/dist/audit/javaAnalysisEngine/index.js +34 -0
- package/dist/audit/javaAnalysisEngine/parseMavenProjectFileContents.js +153 -0
- package/dist/audit/javaAnalysisEngine/parseProjectFileContents.js +353 -0
- package/dist/audit/javaAnalysisEngine/readProjectFileContents.js +98 -0
- package/dist/audit/javaAnalysisEngine/sanitizer.js +5 -0
- package/dist/audit/languageAnalysisEngine/checkForMultipleIdentifiedLanguages.js +24 -0
- package/dist/audit/languageAnalysisEngine/checkForMultipleIdentifiedProjectFiles.js +24 -0
- package/dist/audit/languageAnalysisEngine/checkIdentifiedLanguageHasLockFile.js +35 -0
- package/dist/audit/languageAnalysisEngine/checkIdentifiedLanguageHasProjectFile.js +23 -0
- package/dist/audit/languageAnalysisEngine/commonApi.js +18 -0
- package/dist/audit/languageAnalysisEngine/constants.js +20 -0
- package/dist/audit/languageAnalysisEngine/filterProjectPath.js +20 -0
- package/dist/audit/languageAnalysisEngine/getIdentifiedLanguageInfo.js +25 -0
- package/dist/audit/languageAnalysisEngine/getProjectRootFilenames.js +39 -0
- package/dist/audit/languageAnalysisEngine/index.js +39 -0
- package/dist/audit/languageAnalysisEngine/langugageAnalysisFactory.js +95 -0
- package/dist/audit/languageAnalysisEngine/reduceIdentifiedLanguages.js +121 -0
- package/dist/audit/languageAnalysisEngine/report/checkIgnoreDevDep.js +17 -0
- package/dist/audit/languageAnalysisEngine/report/commonReportingFunctions.js +257 -0
- package/dist/audit/languageAnalysisEngine/report/newReportingFeature.js +81 -0
- package/dist/audit/languageAnalysisEngine/report/reportingFeature.js +133 -0
- package/dist/audit/languageAnalysisEngine/sendSnapshot.js +41 -0
- package/dist/audit/languageAnalysisEngine/util/capabilities.js +11 -0
- package/dist/audit/languageAnalysisEngine/util/generalAPI.js +39 -0
- package/dist/audit/languageAnalysisEngine/util/requestUtils.js +14 -0
- package/dist/audit/nodeAnalysisEngine/handleNPMLockFileV2.js +40 -0
- package/dist/audit/nodeAnalysisEngine/index.js +31 -0
- package/dist/audit/nodeAnalysisEngine/parseNPMLockFileContents.js +18 -0
- package/dist/audit/nodeAnalysisEngine/parseYarn2LockFileContents.js +51 -0
- package/dist/audit/nodeAnalysisEngine/parseYarnLockFileContents.js +18 -0
- package/dist/audit/nodeAnalysisEngine/readNPMLockFileContents.js +17 -0
- package/dist/audit/nodeAnalysisEngine/readProjectFileContents.js +14 -0
- package/dist/audit/nodeAnalysisEngine/readYarnLockFileContents.js +24 -0
- package/dist/audit/nodeAnalysisEngine/sanitizer.js +9 -0
- package/dist/audit/phpAnalysisEngine/index.js +23 -0
- package/dist/audit/phpAnalysisEngine/parseLockFileContents.js +52 -0
- package/dist/audit/phpAnalysisEngine/readLockFileContents.js +13 -0
- package/dist/audit/phpAnalysisEngine/readProjectFileContents.js +16 -0
- package/dist/audit/phpAnalysisEngine/sanitizer.js +5 -0
- package/dist/audit/pythonAnalysisEngine/index.js +25 -0
- package/dist/audit/pythonAnalysisEngine/parsePipfileLockContents.js +17 -0
- package/dist/audit/pythonAnalysisEngine/parseProjectFileContents.js +21 -0
- package/dist/audit/pythonAnalysisEngine/readPipfileLockFileContents.js +13 -0
- package/dist/audit/pythonAnalysisEngine/readPythonProjectFileContents.js +14 -0
- package/dist/audit/pythonAnalysisEngine/sanitizer.js +7 -0
- package/dist/audit/rubyAnalysisEngine/index.js +25 -0
- package/dist/audit/rubyAnalysisEngine/parseGemfileLockContents.js +176 -0
- package/dist/audit/rubyAnalysisEngine/parsedGemfile.js +22 -0
- package/dist/audit/rubyAnalysisEngine/readGemfileContents.js +14 -0
- package/dist/audit/rubyAnalysisEngine/readGemfileLockContents.js +14 -0
- package/dist/audit/rubyAnalysisEngine/sanitizer.js +6 -0
- package/dist/commands/audit/auditConfig.js +25 -0
- package/dist/commands/audit/auditController.js +31 -0
- package/dist/commands/audit/help.js +52 -0
- package/dist/commands/audit/processAudit.js +18 -0
- package/dist/commands/audit/saveFile.js +11 -0
- package/dist/commands/auth/auth.js +20 -2
- package/dist/commands/config/config.js +19 -8
- package/dist/commands/scan/processScan.js +9 -13
- package/dist/common/HTTPClient.js +112 -13
- package/dist/common/errorHandling.js +65 -1
- package/dist/common/versionChecker.js +30 -0
- package/dist/constants/constants.js +4 -2
- package/dist/constants/lambda.js +32 -4
- package/dist/constants/locales.js +60 -21
- package/dist/constants.js +181 -21
- package/dist/index.js +50 -23
- package/dist/lambda/aws.js +14 -11
- package/dist/lambda/help.js +4 -0
- package/dist/lambda/lambda.js +50 -27
- package/dist/lambda/lambdaUtils.js +72 -0
- package/dist/lambda/logUtils.js +11 -1
- package/dist/lambda/scanDetailCompletion.js +4 -4
- package/dist/lambda/scanRequest.js +11 -5
- package/dist/lambda/utils.js +110 -53
- package/dist/sbom/generateSbom.js +20 -0
- package/dist/scan/autoDetection.js +0 -32
- package/dist/scan/fileUtils.js +1 -1
- package/dist/scan/help.js +14 -40
- package/dist/scan/populateProjectIdAndProjectName.js +5 -0
- package/dist/scan/saveResults.js +14 -0
- package/dist/scan/scan.js +105 -40
- package/dist/scan/scanConfig.js +39 -0
- package/dist/scan/scanController.js +19 -16
- package/dist/scan/scanResults.js +24 -16
- package/dist/utils/commonApi.js +3 -3
- package/dist/utils/paramsUtil/commandlineParams.js +1 -20
- package/dist/utils/paramsUtil/paramHandler.js +3 -6
- package/dist/utils/parsedCLIOptions.js +14 -8
- package/dist/utils/requestUtils.js +1 -1
- package/dist/utils/saveFile.js +19 -0
- package/package.json +26 -21
- package/src/audit/AnalysisEngine.js +103 -0
- package/src/audit/catalogueApplication/catalogueApplication.js +42 -0
- package/src/audit/dotnetAnalysisEngine/index.js +26 -0
- package/src/audit/dotnetAnalysisEngine/parseLockFileContents.js +47 -0
- package/src/audit/dotnetAnalysisEngine/parseProjectFileContents.js +29 -0
- package/src/audit/dotnetAnalysisEngine/readLockFileContents.js +30 -0
- package/src/audit/dotnetAnalysisEngine/readProjectFileContents.js +26 -0
- package/src/audit/dotnetAnalysisEngine/sanitizer.js +11 -0
- package/src/audit/goAnalysisEngine/index.js +18 -0
- package/src/audit/goAnalysisEngine/parseProjectFileContents.js +209 -0
- package/src/audit/goAnalysisEngine/readProjectFileContents.js +31 -0
- package/src/audit/goAnalysisEngine/sanitizer.js +7 -0
- package/src/audit/javaAnalysisEngine/index.js +41 -0
- package/src/audit/javaAnalysisEngine/parseMavenProjectFileContents.js +222 -0
- package/src/audit/javaAnalysisEngine/parseProjectFileContents.js +420 -0
- package/src/audit/javaAnalysisEngine/readProjectFileContents.js +141 -0
- package/src/audit/javaAnalysisEngine/sanitizer.js +6 -0
- package/src/audit/languageAnalysisEngine/checkForMultipleIdentifiedLanguages.js +35 -0
- package/src/audit/languageAnalysisEngine/checkForMultipleIdentifiedProjectFiles.js +41 -0
- package/src/audit/languageAnalysisEngine/checkIdentifiedLanguageHasLockFile.js +54 -0
- package/src/audit/languageAnalysisEngine/checkIdentifiedLanguageHasProjectFile.js +32 -0
- package/src/audit/languageAnalysisEngine/commonApi.js +20 -0
- package/src/audit/languageAnalysisEngine/constants.js +23 -0
- package/src/audit/languageAnalysisEngine/filterProjectPath.js +21 -0
- package/src/audit/languageAnalysisEngine/getIdentifiedLanguageInfo.js +41 -0
- package/src/audit/languageAnalysisEngine/getProjectRootFilenames.js +72 -0
- package/src/audit/languageAnalysisEngine/index.js +45 -0
- package/src/audit/languageAnalysisEngine/langugageAnalysisFactory.js +126 -0
- package/src/audit/languageAnalysisEngine/reduceIdentifiedLanguages.js +177 -0
- package/src/audit/languageAnalysisEngine/report/checkIgnoreDevDep.js +27 -0
- package/src/audit/languageAnalysisEngine/report/commonReportingFunctions.js +303 -0
- package/src/audit/languageAnalysisEngine/report/newReportingFeature.js +124 -0
- package/src/audit/languageAnalysisEngine/report/reportingFeature.js +190 -0
- package/src/audit/languageAnalysisEngine/sendSnapshot.js +51 -0
- package/src/audit/languageAnalysisEngine/util/capabilities.js +12 -0
- package/src/audit/languageAnalysisEngine/util/generalAPI.js +43 -0
- package/src/audit/languageAnalysisEngine/util/requestUtils.js +17 -0
- package/src/audit/nodeAnalysisEngine/handleNPMLockFileV2.js +49 -0
- package/src/audit/nodeAnalysisEngine/index.js +35 -0
- package/src/audit/nodeAnalysisEngine/parseNPMLockFileContents.js +20 -0
- package/src/audit/nodeAnalysisEngine/parseYarn2LockFileContents.js +63 -0
- package/src/audit/nodeAnalysisEngine/parseYarnLockFileContents.js +26 -0
- package/src/audit/nodeAnalysisEngine/readNPMLockFileContents.js +23 -0
- package/src/audit/nodeAnalysisEngine/readProjectFileContents.js +27 -0
- package/src/audit/nodeAnalysisEngine/readYarnLockFileContents.js +36 -0
- package/src/audit/nodeAnalysisEngine/sanitizer.js +11 -0
- package/src/audit/phpAnalysisEngine/index.js +27 -0
- package/src/audit/phpAnalysisEngine/parseLockFileContents.js +60 -0
- package/src/audit/phpAnalysisEngine/readLockFileContents.js +14 -0
- package/src/audit/phpAnalysisEngine/readProjectFileContents.js +25 -0
- package/src/audit/phpAnalysisEngine/sanitizer.js +4 -0
- package/src/audit/pythonAnalysisEngine/index.js +55 -0
- package/src/audit/pythonAnalysisEngine/parsePipfileLockContents.js +23 -0
- package/src/audit/pythonAnalysisEngine/parseProjectFileContents.js +33 -0
- package/src/audit/pythonAnalysisEngine/readPipfileLockFileContents.js +16 -0
- package/src/audit/pythonAnalysisEngine/readPythonProjectFileContents.js +22 -0
- package/src/audit/pythonAnalysisEngine/sanitizer.js +9 -0
- package/src/audit/rubyAnalysisEngine/index.js +30 -0
- package/src/audit/rubyAnalysisEngine/parseGemfileLockContents.js +215 -0
- package/src/audit/rubyAnalysisEngine/parsedGemfile.js +39 -0
- package/src/audit/rubyAnalysisEngine/readGemfileContents.js +18 -0
- package/src/audit/rubyAnalysisEngine/readGemfileLockContents.js +17 -0
- package/src/audit/rubyAnalysisEngine/sanitizer.js +8 -0
- package/src/commands/audit/auditConfig.ts +30 -0
- package/src/commands/audit/auditController.ts +31 -0
- package/src/commands/audit/help.ts +48 -0
- package/src/commands/audit/processAudit.ts +18 -0
- package/src/commands/audit/saveFile.ts +6 -0
- package/src/commands/auth/auth.js +26 -2
- package/src/commands/config/config.js +22 -8
- package/src/commands/scan/processScan.js +9 -13
- package/src/common/HTTPClient.js +149 -14
- package/src/common/errorHandling.ts +85 -2
- package/src/common/versionChecker.ts +39 -0
- package/src/constants/constants.js +5 -4
- package/src/constants/lambda.js +45 -4
- package/src/constants/locales.js +76 -26
- package/src/constants.js +204 -23
- package/src/index.ts +67 -27
- package/src/lambda/aws.ts +13 -12
- package/src/lambda/help.ts +4 -0
- package/src/lambda/lambda.ts +53 -34
- package/src/lambda/lambdaUtils.ts +111 -0
- package/src/lambda/logUtils.ts +19 -1
- package/src/lambda/scanDetailCompletion.ts +4 -4
- package/src/lambda/scanRequest.ts +13 -11
- package/src/lambda/utils.ts +149 -81
- package/src/sbom/generateSbom.ts +17 -0
- package/src/scan/autoDetection.js +0 -29
- package/src/scan/fileUtils.js +1 -1
- package/src/scan/help.js +14 -45
- package/src/scan/populateProjectIdAndProjectName.js +5 -0
- package/src/scan/saveResults.js +14 -0
- package/src/scan/scan.js +127 -58
- package/src/scan/scanConfig.js +54 -0
- package/src/scan/scanController.js +22 -15
- package/src/scan/scanResults.js +32 -19
- package/src/utils/commonApi.js +2 -3
- package/src/utils/getConfig.ts +2 -0
- package/src/utils/paramsUtil/commandlineParams.js +1 -26
- package/src/utils/paramsUtil/paramHandler.js +3 -7
- package/src/utils/parsedCLIOptions.js +11 -9
- package/src/utils/requestUtils.js +1 -1
- package/src/utils/saveFile.js +19 -0
- package/dist/lambda/scanDetail.js +0 -30
- package/dist/scan/fileFinder.js +0 -15
- package/dist/utils/paramsUtil/yamlParams.js +0 -6
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const { lambda } = require('./lambda');
|
|
3
|
+
const chalk = require('chalk');
|
|
3
4
|
const en_locales = () => {
|
|
4
5
|
return {
|
|
5
6
|
successHeader: 'SUCCESS',
|
|
@@ -101,29 +102,33 @@ const en_locales = () => {
|
|
|
101
102
|
constantsGradleMultiProject: 'Specify the sub project within your gradle application.',
|
|
102
103
|
constantsScan: 'Upload java binaries to the static scan service',
|
|
103
104
|
constantsWaitForScan: 'Waits for the result of the scan',
|
|
104
|
-
constantsProjectName: '
|
|
105
|
-
constantsFileName: 'The name of the file to Scan',
|
|
105
|
+
constantsProjectName: 'Contrast project name. If not specified, Contrast uses contrast.settings to identify the project or creates a project.',
|
|
106
106
|
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.',
|
|
107
|
-
constantsScanTimeout: 'Set a specific time span before the function times out. Default timeout is 300 seconds if scan_timeout is not set. The format of the value of the parameter is "20" seconds or "80" seconds.',
|
|
108
107
|
constantsReport: 'Display vulnerability information for this application',
|
|
109
108
|
constantsFail: 'Set the process to fail if this option is set in combination with the --report and --cve_severity.',
|
|
110
109
|
failOptionErrorMessage: " FAIL - CVE's have been detected that match at least the cve_severity or cve_threshold option specified.",
|
|
111
110
|
constantsSeverity: 'Combined with the --report command, 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.',
|
|
112
111
|
constantsCount: "The number of CVE's that must be exceeded to fail a build",
|
|
113
|
-
constantsHeader: 'Contrast
|
|
112
|
+
constantsHeader: 'CodeSec by Contrast Security',
|
|
114
113
|
constantsPrerequisitesContentScanLanguages: 'Java & JavaScript supported',
|
|
115
|
-
constantsContrastContent: 'Use the Contrast CLI,
|
|
114
|
+
constantsContrastContent: 'Use the Contrast CLI to run a scan(Java, JavaScript and .NET ) or lambda command (Java and Python) to find your vulnerabilities and start securing your code.',
|
|
116
115
|
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.',
|
|
117
116
|
constantsPrerequisitesHeader: 'Pre-requisites',
|
|
117
|
+
constantsAuthUsageHeader: 'Usage',
|
|
118
|
+
constantsAuthUsageContents: 'contrast auth',
|
|
119
|
+
constantsAuthHeaderContents: 'Authorize with external identity provider to perform scans on code',
|
|
120
|
+
configHeader: 'Config',
|
|
121
|
+
constantsConfigUsageContents: 'view / clear the configuration',
|
|
118
122
|
constantsPrerequisitesContent: 'To scan a Java project you will need a .jar or .war file for analysis\n' +
|
|
119
|
-
'To scan a Javascript project you will need a .js or.zip file for analysis\n'
|
|
123
|
+
'To scan a Javascript project you will need a .js or.zip file for analysis\n' +
|
|
124
|
+
'To scan a .NET c# webforms project you will need a .exe or a .zip file for analysis\n',
|
|
120
125
|
constantsUsage: 'Usage',
|
|
121
126
|
constantsUsageCommandExample: 'contrast [command] [options]',
|
|
122
|
-
constantsUsageCommandInfo: 'The file argument is optional. If no file is given, Contrast will search for a .jar, .war, .
|
|
127
|
+
constantsUsageCommandInfo: 'The file argument is optional. If no file is given, Contrast will search for a .jar, .war, .exe or .zip file in the working directory.\n',
|
|
123
128
|
constantsUsageCommandInfo24Hours: 'Submitted files are encrypted during upload and deleted in 24 hours.',
|
|
124
129
|
constantsAnd: 'AND',
|
|
125
130
|
constantsJava: 'AND Maven build platform, including the dependency plugin. For a Gradle project, use build.gradle. A gradle-wrapper.properties file is also required. Kotlin is also supported requiring a build.gradle.kts file.',
|
|
126
|
-
constantsJavaNote: '
|
|
131
|
+
constantsJavaNote: 'Note: Running "mvn dependency:tree" or "./gradlew dependencies" in the project directory locally must be successful.',
|
|
127
132
|
constantsJavaNoteGradle: 'We currently support v4.8 and upwards on Gradle projects',
|
|
128
133
|
constantsDotNet: 'MSBuild 15.0 or greater and have a packages.lock.json file are supported.',
|
|
129
134
|
constantsDotNetNote: 'Please Note: If the packages.lock.json file is not in place it can be generated by setting RestorePackagesWithLockFile to true within each *.csproj and running dotnet build',
|
|
@@ -170,6 +175,7 @@ const en_locales = () => {
|
|
|
170
175
|
constantsTags: 'Apply labels to an application. Labels must be formatted as a comma-delimited list. Example - label1,label2,label3',
|
|
171
176
|
constantsCode: 'Add the application code this application should use in the Contrast UI',
|
|
172
177
|
constantsIgnoreCertErrors: ' For EOP users with a local Teamserver install, this will bypass the SSL certificate and recognise a self signed certificate.',
|
|
178
|
+
constantsSave: ' Saves the Scan Results JSON to file.',
|
|
173
179
|
constantsIgnoreDev: 'Combined with the --report command excludes developer dependencies from the vulnerabilities report. By default all dependencies are included in a report.',
|
|
174
180
|
constantsCommands: 'Commands',
|
|
175
181
|
constantsScanOptions: 'Scan Options',
|
|
@@ -187,9 +193,11 @@ const en_locales = () => {
|
|
|
187
193
|
noFileFoundScan: "We could't find a suitable file in your directories (we go 3 deep)",
|
|
188
194
|
specifyFileScanError: 'Java Scan requires a .war or .jar file. Javascript Scan requires a .js or .zip file.\nTo start a Scan enter "contrast scan -f <path-to-file>"',
|
|
189
195
|
populateProjectIdMessage: 'project ID is %s',
|
|
196
|
+
genericServiceError: 'returned with status code %s',
|
|
197
|
+
permissionsError: 'You do not have the correct permissions here. \n Contact support@contrastsecurity.com to get this fixed.',
|
|
190
198
|
scanErrorFileMessage: 'We only accept the following file types: \nJava - .jar, .war \nJavaScript - .js or .zip files',
|
|
191
199
|
helpAuthSummary: 'Authenticate Contrast using your Github or Google account',
|
|
192
|
-
helpScanSummary: '
|
|
200
|
+
helpScanSummary: 'Perform static analysis on binaries / code artifacts',
|
|
193
201
|
helpLambdaSummary: 'Perform scan on AWS Lambda functions',
|
|
194
202
|
helpVersionSummary: 'Displays version of Contrast CLI',
|
|
195
203
|
helpConfigSummary: 'Displays stored credentials',
|
|
@@ -200,36 +208,36 @@ const en_locales = () => {
|
|
|
200
208
|
versionName: 'version',
|
|
201
209
|
configName: 'config',
|
|
202
210
|
helpName: 'help',
|
|
203
|
-
|
|
204
|
-
scanOptionsLanguage: '-l, --language',
|
|
205
|
-
scanOptionsName: '-n, --name',
|
|
206
|
-
scanOptionsTimeout: '-t, --time-out',
|
|
207
|
-
scanOptionsVerbose: '-v, --verbose',
|
|
208
|
-
scanOptionsFileNameSummary: 'Path of the file you want to scan. If no file is specified, Contrast searches for a .jar, .war, .js. or .zip file in the working directory.',
|
|
211
|
+
scanOptionsLanguageSummary: 'Valid values are JAVA, JAVASCRIPT and DOTNET',
|
|
209
212
|
scanOptionsLanguageSummaryOptional: 'Language of file to send for analysis. ',
|
|
210
213
|
scanOptionsLanguageSummaryRequired: 'If you scan a .zip file or you use the --file option.',
|
|
211
|
-
scanOptionsNameSummary: 'Contrast project name. If not specified, Contrast uses contrast.settings to identify the project or creates a project.',
|
|
212
214
|
scanOptionsTimeoutSummary: 'Time in seconds to wait for scan to complete. Default value is 300 seconds.',
|
|
213
|
-
|
|
215
|
+
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.',
|
|
216
|
+
scanOptionsVerboseSummary: ' Returns extended information to the terminal.',
|
|
214
217
|
authSuccessMessage: 'Authentication successful',
|
|
215
|
-
|
|
218
|
+
runAuthSuccessMessage: "Now you can use Contrast CLI \nRun 'contrast scan' on your file \n" +
|
|
219
|
+
"or 'contrast help' to learn more about the capabilities.",
|
|
216
220
|
authWaitingMessage: 'Waiting for auth...',
|
|
217
221
|
authTimedOutMessage: 'Auth Timed out, try again',
|
|
218
222
|
zipErrorScan: 'We only support zip files for JAVASCRIPT language, please set the flag --language JAVASCRIPT',
|
|
219
223
|
unknownFileErrorScan: 'Unsupported file selected for Scan.',
|
|
220
|
-
foundScanFile: '
|
|
221
|
-
|
|
222
|
-
|
|
224
|
+
foundScanFile: 'Found: %s',
|
|
225
|
+
foundDetailedVulnerabilities: chalk.bold('%s Critical') +
|
|
226
|
+
' | ' +
|
|
227
|
+
chalk.bold('%s High') +
|
|
228
|
+
' | %s Medium | %s Low | %s Note',
|
|
223
229
|
requiredParams: 'All required parameters are not present.',
|
|
224
230
|
timeoutScan: 'Timeout set to 5 minutes.',
|
|
225
231
|
searchingScanFileDirectory: 'Searching for file to scan from %s...',
|
|
226
232
|
scanHeader: 'Contrast Scan CLI',
|
|
233
|
+
authHeader: 'Auth',
|
|
227
234
|
lambdaHeader: 'Contrast lambda help',
|
|
228
235
|
lambdaSummary: 'Performs static security scan on an AWS Lambda Function.\nProduces CVE (Vulnerable Dependencies) and Least Privilege violations/remediation results.',
|
|
229
236
|
lambdaUsage: 'contrast lambda --function-name <function> [options]',
|
|
230
237
|
lambdaPrerequisitesContent: 'contrast cli',
|
|
231
238
|
scanFileNameOption: ' -f, --file',
|
|
232
239
|
lambdaFunctionNameOption: ' -f, --function-name',
|
|
240
|
+
lambdaListFunctionsOption: ' -l, --list-functions',
|
|
233
241
|
lambdaEndpointOption: '-e, --endpoint-url',
|
|
234
242
|
lambdaRegionOption: '-r, --region',
|
|
235
243
|
lambdaProfileOption: '-p, --profile',
|
|
@@ -237,6 +245,7 @@ const en_locales = () => {
|
|
|
237
245
|
lambdaVerboseOption: '-v, --verbose',
|
|
238
246
|
lambdaHelpOption: '-h, --help',
|
|
239
247
|
lambdaFunctionNameSummery: 'Name of AWS lambda function to scan.',
|
|
248
|
+
lambdaListFunctionsSummery: 'List all available lambda functions to scan.',
|
|
240
249
|
lambdaEndpointSummery: 'AWS Endpoint override, works like in AWS CLI.',
|
|
241
250
|
lambdaRegionSummery: 'Region override, default to AWS_DEAFAULT_REGION env var, works like in AWS CLI.',
|
|
242
251
|
lambdaProfileSummery: 'AWS configuration profile override, works like in AWS CLI.',
|
|
@@ -251,6 +260,36 @@ const en_locales = () => {
|
|
|
251
260
|
connectionError: 'An error has occurred when trying to get the Project Id please check your internet connection or provide the Project Id manually',
|
|
252
261
|
internalServerErrorHeader: '500 error - Internal server error',
|
|
253
262
|
resourceLockedErrorHeader: '423 error - Resource is locked',
|
|
263
|
+
auditHeader: 'Contrast Audit',
|
|
264
|
+
auditHeaderMessage: `
|
|
265
|
+
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
|
|
266
|
+
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.`,
|
|
267
|
+
constantsAuditPrerequisitesContentSupportedLanguages: 'Supported languages and their requirements are:',
|
|
268
|
+
constantsAuditPrerequisitesContentJava: 'Java: ',
|
|
269
|
+
constantsAuditPrerequisitesContentMessage: `
|
|
270
|
+
pom.xml AND Maven build platform, including the dependency plugin.
|
|
271
|
+
For a Gradle project (v4.8+) use build.gradle. A gradle-wrapper.properties file is also required.
|
|
272
|
+
Kotlin is also supported requiring a build.gradle.kts file.`,
|
|
273
|
+
constantsAuditPrerequisitesContentDotNet: '.NET framework and .NET core: ',
|
|
274
|
+
constantsAuditPrerequisitesContentDotNetMessage: `
|
|
275
|
+
MSBuild 15.0 or greater and have a packages.lock.json file are supported.\n
|
|
276
|
+
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`,
|
|
277
|
+
constantsAuditPrerequisitesContentLanguageNode: 'Node: ',
|
|
278
|
+
constantsAuditPrerequisitesContentLanguageRuby: 'Ruby: ',
|
|
279
|
+
constantsAuditPrerequisitesContentLanguagePython: 'Python: ',
|
|
280
|
+
constantsAuditPrerequisitesContentLanguageNodeMessage: '*.package.json AND a lock file either *.package-lock.json or *.yarn.lock',
|
|
281
|
+
constantsAuditPrerequisitesContentLanguageRubyMessage: 'gemfile AND gemfile.lock',
|
|
282
|
+
constantsAuditPrerequisitesContentLanguagePythonMessage: 'pipfile AND pipfile.lock',
|
|
283
|
+
constantsAuditOptions: 'Audit Options',
|
|
284
|
+
auditOptionsIgnoreDevDependencies: '-igd, --ignore-dev',
|
|
285
|
+
auditOptionsIgnoreDevDependenciesDescription: 'ignores DevDependencies',
|
|
286
|
+
auditOptionsSave: '-s, --save',
|
|
287
|
+
auditOptionsSaveDescription: 'saves the output in specified format Txt text, sbom',
|
|
288
|
+
scanNoVulnerabilitiesFound: '👏 No vulnerabilities found',
|
|
289
|
+
scanNoFiletypeSpecifiedForSave: 'Please specify file type to save results to, accepted value is SARIF',
|
|
290
|
+
auditSBOMSaveSuccess: '\n Software Bill of Materials (SBOM) saved successfully',
|
|
291
|
+
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.')}`,
|
|
292
|
+
auditBadFiletypeSpecifiedForSave: `\n ${chalk.yellow.bold('Bad file type specified for --save option. Use audit --help to see valid --save options.')}`,
|
|
254
293
|
...lambda
|
|
255
294
|
};
|
|
256
295
|
};
|
package/dist/constants.js
CHANGED
|
@@ -17,13 +17,21 @@ const scanOptionDefinitions = [
|
|
|
17
17
|
'}: ' +
|
|
18
18
|
i18n.__('constantsProjectName')
|
|
19
19
|
},
|
|
20
|
+
{
|
|
21
|
+
name: 'language',
|
|
22
|
+
alias: 'l',
|
|
23
|
+
description: '{bold ' +
|
|
24
|
+
i18n.__('constantsOptional') +
|
|
25
|
+
'}: ' +
|
|
26
|
+
i18n.__('scanOptionsLanguageSummary')
|
|
27
|
+
},
|
|
20
28
|
{
|
|
21
29
|
name: 'file',
|
|
22
30
|
alias: 'f',
|
|
23
31
|
description: '{bold ' +
|
|
24
32
|
i18n.__('constantsOptional') +
|
|
25
33
|
'}: ' +
|
|
26
|
-
i18n.__('
|
|
34
|
+
i18n.__('scanOptionsFileNameSummary')
|
|
27
35
|
},
|
|
28
36
|
{
|
|
29
37
|
name: 'project-id',
|
|
@@ -40,15 +48,7 @@ const scanOptionDefinitions = [
|
|
|
40
48
|
description: '{bold ' +
|
|
41
49
|
i18n.__('constantsOptional') +
|
|
42
50
|
'}: ' +
|
|
43
|
-
i18n.__('
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
name: 'language',
|
|
47
|
-
alias: 'l',
|
|
48
|
-
description: '{bold ' +
|
|
49
|
-
i18n.__('constantsRequiredCatalogue') +
|
|
50
|
-
'}: ' +
|
|
51
|
-
i18n.__('constantsLanguage')
|
|
51
|
+
i18n.__('scanOptionsTimeoutSummary')
|
|
52
52
|
},
|
|
53
53
|
{
|
|
54
54
|
name: 'organization-id',
|
|
@@ -58,14 +58,6 @@ const scanOptionDefinitions = [
|
|
|
58
58
|
'}: ' +
|
|
59
59
|
i18n.__('constantsOrganizationId')
|
|
60
60
|
},
|
|
61
|
-
{
|
|
62
|
-
name: 'yaml-path',
|
|
63
|
-
alias: 'y',
|
|
64
|
-
description: '{bold ' +
|
|
65
|
-
i18n.__('constantsOptional') +
|
|
66
|
-
'}: ' +
|
|
67
|
-
i18n.__('constantsYamlPath')
|
|
68
|
-
},
|
|
69
61
|
{
|
|
70
62
|
name: 'api-key',
|
|
71
63
|
description: '{bold ' +
|
|
@@ -82,8 +74,6 @@ const scanOptionDefinitions = [
|
|
|
82
74
|
},
|
|
83
75
|
{
|
|
84
76
|
name: 'host',
|
|
85
|
-
alias: 'h',
|
|
86
|
-
defaultValue: 'app.contrastsecurity.com',
|
|
87
77
|
description: '{bold ' +
|
|
88
78
|
i18n.__('constantsRequired') +
|
|
89
79
|
'}: ' +
|
|
@@ -112,11 +102,177 @@ const scanOptionDefinitions = [
|
|
|
112
102
|
'}:' +
|
|
113
103
|
i18n.__('constantsIgnoreCertErrors')
|
|
114
104
|
},
|
|
105
|
+
{
|
|
106
|
+
name: 'verbose',
|
|
107
|
+
alias: 'v',
|
|
108
|
+
type: Boolean,
|
|
109
|
+
description: '{bold ' +
|
|
110
|
+
i18n.__('constantsOptional') +
|
|
111
|
+
'}:' +
|
|
112
|
+
i18n.__('scanOptionsVerboseSummary')
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: 'save',
|
|
116
|
+
alias: 's',
|
|
117
|
+
description: '{bold ' + i18n.__('constantsOptional') + '}:' + i18n.__('constantsSave')
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: 'help',
|
|
121
|
+
alias: 'h',
|
|
122
|
+
type: Boolean
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: 'debug',
|
|
126
|
+
alias: 'd',
|
|
127
|
+
type: Boolean
|
|
128
|
+
}
|
|
129
|
+
];
|
|
130
|
+
const authOptionDefinitions = [
|
|
115
131
|
{
|
|
116
132
|
name: 'help',
|
|
133
|
+
alias: 'h',
|
|
117
134
|
type: Boolean
|
|
118
135
|
}
|
|
119
136
|
];
|
|
137
|
+
const configOptionDefinitions = [
|
|
138
|
+
{
|
|
139
|
+
name: 'help',
|
|
140
|
+
alias: 'h',
|
|
141
|
+
type: Boolean,
|
|
142
|
+
description: 'Help text'
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
name: 'clear',
|
|
146
|
+
alias: 'c',
|
|
147
|
+
type: Boolean,
|
|
148
|
+
description: 'Clear the currently stored config'
|
|
149
|
+
}
|
|
150
|
+
];
|
|
151
|
+
const auditOptionDefinitions = [
|
|
152
|
+
{
|
|
153
|
+
name: 'application-id',
|
|
154
|
+
description: '{bold ' +
|
|
155
|
+
i18n.__('constantsRequired') +
|
|
156
|
+
'}: ' +
|
|
157
|
+
i18n.__('constantsApplicationId')
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
name: 'application-name',
|
|
161
|
+
description: '{bold ' +
|
|
162
|
+
i18n.__('constantsOptional') +
|
|
163
|
+
'}: ' +
|
|
164
|
+
i18n.__('constantsApplicationName')
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
name: 'project-path',
|
|
168
|
+
defaultValue: process.env.PWD,
|
|
169
|
+
description: '{bold ' +
|
|
170
|
+
i18n.__('constantsOptional') +
|
|
171
|
+
'}: ' +
|
|
172
|
+
i18n.__('constantsProjectPath')
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
name: 'app-groups',
|
|
176
|
+
description: '{bold ' +
|
|
177
|
+
i18n.__('constantsOptionalForCatalogue') +
|
|
178
|
+
'}: ' +
|
|
179
|
+
i18n.__('constantsAppGroups')
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
name: 'sub-project',
|
|
183
|
+
description: '{bold ' +
|
|
184
|
+
i18n.__('constantsOptional') +
|
|
185
|
+
'}: ' +
|
|
186
|
+
i18n.__('constantsGradleMultiProject')
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
name: 'metadata',
|
|
190
|
+
description: '{bold ' +
|
|
191
|
+
i18n.__('constantsOptional') +
|
|
192
|
+
'}: ' +
|
|
193
|
+
i18n.__('constantsMetadata')
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
name: 'tags',
|
|
197
|
+
description: '{bold ' + i18n.__('constantsOptional') + '}: ' + i18n.__('constantsTags')
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
name: 'code',
|
|
201
|
+
description: '{bold ' + i18n.__('constantsOptional') + '}: ' + i18n.__('constantsCode')
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
name: 'ignore-dev',
|
|
205
|
+
type: Boolean,
|
|
206
|
+
description: '{bold ' +
|
|
207
|
+
i18n.__('constantsOptional') +
|
|
208
|
+
'}: ' +
|
|
209
|
+
i18n.__('constantsIgnoreDev')
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
name: 'maven-settings-path'
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
name: 'language',
|
|
216
|
+
alias: 'l',
|
|
217
|
+
description: '{bold ' +
|
|
218
|
+
i18n.__('constantsRequiredCatalogue') +
|
|
219
|
+
'}: ' +
|
|
220
|
+
i18n.__('constantsLanguage')
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
name: 'organization-id',
|
|
224
|
+
alias: 'o',
|
|
225
|
+
description: '{bold ' +
|
|
226
|
+
i18n.__('constantsRequired') +
|
|
227
|
+
'}: ' +
|
|
228
|
+
i18n.__('constantsOrganizationId')
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
name: 'api-key',
|
|
232
|
+
description: '{bold ' +
|
|
233
|
+
i18n.__('constantsRequired') +
|
|
234
|
+
'}: ' +
|
|
235
|
+
i18n.__('constantsApiKey')
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
name: 'authorization',
|
|
239
|
+
description: '{bold ' +
|
|
240
|
+
i18n.__('constantsRequired') +
|
|
241
|
+
'}: ' +
|
|
242
|
+
i18n.__('constantsAuthorization')
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
name: 'host',
|
|
246
|
+
alias: 'h',
|
|
247
|
+
description: '{bold ' +
|
|
248
|
+
i18n.__('constantsRequired') +
|
|
249
|
+
'}: ' +
|
|
250
|
+
i18n.__('constantsHostId')
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
name: 'proxy',
|
|
254
|
+
description: '{bold ' +
|
|
255
|
+
i18n.__('constantsOptional') +
|
|
256
|
+
'}: ' +
|
|
257
|
+
i18n.__('constantsProxyServer')
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
name: 'ignore-cert-errors',
|
|
261
|
+
type: Boolean,
|
|
262
|
+
description: '{bold ' +
|
|
263
|
+
i18n.__('constantsOptional') +
|
|
264
|
+
'}:' +
|
|
265
|
+
i18n.__('constantsIgnoreCertErrors')
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
name: 'save',
|
|
269
|
+
alias: 's',
|
|
270
|
+
description: '{bold ' +
|
|
271
|
+
i18n.__('constantsOptional') +
|
|
272
|
+
'}: ' +
|
|
273
|
+
i18n.__('auditOptionsSaveDescription')
|
|
274
|
+
}
|
|
275
|
+
];
|
|
120
276
|
const mainUsageGuide = commandLineUsage([
|
|
121
277
|
{
|
|
122
278
|
header: i18n.__('constantsHeader'),
|
|
@@ -130,6 +286,7 @@ const mainUsageGuide = commandLineUsage([
|
|
|
130
286
|
header: i18n.__('constantsCommands'),
|
|
131
287
|
content: [
|
|
132
288
|
{ name: i18n.__('authName'), summary: i18n.__('helpAuthSummary') },
|
|
289
|
+
{ name: i18n.__('scanName'), summary: i18n.__('helpScanSummary') },
|
|
133
290
|
{ name: i18n.__('lambdaName'), summary: i18n.__('helpLambdaSummary') },
|
|
134
291
|
{ name: i18n.__('versionName'), summary: i18n.__('helpVersionSummary') },
|
|
135
292
|
{ name: i18n.__('configName'), summary: i18n.__('helpConfigSummary') },
|
|
@@ -145,6 +302,9 @@ module.exports = {
|
|
|
145
302
|
commandLineDefinitions: {
|
|
146
303
|
mainUsageGuide,
|
|
147
304
|
mainDefinition,
|
|
148
|
-
scanOptionDefinitions
|
|
305
|
+
scanOptionDefinitions,
|
|
306
|
+
auditOptionDefinitions,
|
|
307
|
+
authOptionDefinitions,
|
|
308
|
+
configOptionDefinitions
|
|
149
309
|
}
|
|
150
310
|
};
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const command_line_args_1 = __importDefault(require("command-line-args"));
|
|
7
|
+
const processAudit_1 = require("./commands/audit/processAudit");
|
|
7
8
|
const auth_1 = require("./commands/auth/auth");
|
|
8
9
|
const config_1 = require("./commands/config/config");
|
|
9
10
|
const processScan_1 = require("./commands/scan/processScan");
|
|
@@ -11,6 +12,8 @@ const constants_1 = __importDefault(require("./constants"));
|
|
|
11
12
|
const constants_2 = require("./constants/constants");
|
|
12
13
|
const lambda_1 = require("./lambda/lambda");
|
|
13
14
|
const getConfig_1 = require("./utils/getConfig");
|
|
15
|
+
const versionChecker_1 = require("./common/versionChecker");
|
|
16
|
+
const errorHandling_1 = require("./common/errorHandling");
|
|
14
17
|
const { commandLineDefinitions: { mainUsageGuide, mainDefinition } } = constants_1.default;
|
|
15
18
|
const config = (0, getConfig_1.localConfig)(constants_2.APP_NAME, constants_2.APP_VERSION);
|
|
16
19
|
const getMainOption = () => {
|
|
@@ -26,31 +29,55 @@ const getMainOption = () => {
|
|
|
26
29
|
};
|
|
27
30
|
};
|
|
28
31
|
const start = async () => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
32
|
+
if (await (0, versionChecker_1.isCorrectNodeVersion)(process.version)) {
|
|
33
|
+
const { mainOptions, argv: argvMain } = getMainOption();
|
|
34
|
+
const command = mainOptions.command != undefined ? mainOptions.command.toLowerCase() : '';
|
|
35
|
+
if (command === 'version' ||
|
|
36
|
+
argvMain.includes('--v') ||
|
|
37
|
+
argvMain.includes('--version')) {
|
|
38
|
+
console.log(constants_2.APP_VERSION);
|
|
39
|
+
await (0, versionChecker_1.findLatestCLIVersion)();
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
config.set('numOfRuns', config.get('numOfRuns') + 1);
|
|
43
|
+
if (config.get('numOfRuns') >= 5) {
|
|
44
|
+
await (0, versionChecker_1.findLatestCLIVersion)();
|
|
45
|
+
config.set('numOfRuns', 0);
|
|
46
|
+
}
|
|
47
|
+
if (command === 'config') {
|
|
48
|
+
return (0, config_1.processConfig)(argvMain, config);
|
|
49
|
+
}
|
|
50
|
+
if (command === 'auth') {
|
|
51
|
+
return await (0, auth_1.processAuth)(argvMain, config);
|
|
52
|
+
}
|
|
53
|
+
if (command === 'lambda') {
|
|
54
|
+
return await (0, lambda_1.processLambda)(argvMain);
|
|
55
|
+
}
|
|
56
|
+
if (command === 'scan') {
|
|
57
|
+
return await (0, processScan_1.processScan)(argvMain);
|
|
58
|
+
}
|
|
59
|
+
if (command === 'audit') {
|
|
60
|
+
return await (0, processAudit_1.processAudit)(argvMain);
|
|
61
|
+
}
|
|
62
|
+
if (command === 'help' ||
|
|
63
|
+
argvMain.includes('--help') ||
|
|
64
|
+
Object.keys(mainOptions).length === 0) {
|
|
65
|
+
console.log(mainUsageGuide);
|
|
66
|
+
}
|
|
67
|
+
else if (mainOptions._unknown !== undefined) {
|
|
68
|
+
const foundCommand = (0, errorHandling_1.findCommandOnError)(mainOptions._unknown);
|
|
69
|
+
foundCommand
|
|
70
|
+
? console.log(`Unknown Command: Did you mean "${foundCommand}"? \nUse "${foundCommand} --help" for the full list of options`)
|
|
71
|
+
: console.log(`Unknown Command: ${command} \nUse --help for the full list`);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
console.log(`Unknown Command: ${command} \nUse --help for the full list`);
|
|
75
|
+
}
|
|
76
|
+
process.exit(9);
|
|
51
77
|
}
|
|
52
78
|
else {
|
|
53
|
-
console.log('
|
|
79
|
+
console.log('Contrast supports Node versions >=16.13.2 <17. Please use one of those versions.');
|
|
80
|
+
process.exit(9);
|
|
54
81
|
}
|
|
55
82
|
};
|
|
56
83
|
start();
|
package/dist/lambda/aws.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.throwAwsError = exports.getLambdaPolicies = exports.getLayersLinks = exports.getLambdaFunctionConfiguration = exports.getLambdaClient = exports.getIAMClient = exports.getRolePolicyNames = exports.getAttachedPolicyNames = void 0;
|
|
7
|
+
const i18n_1 = __importDefault(require("i18n"));
|
|
4
8
|
const client_lambda_1 = require("@aws-sdk/client-lambda");
|
|
5
9
|
const client_iam_1 = require("@aws-sdk/client-iam");
|
|
6
10
|
const credential_provider_ini_1 = require("@aws-sdk/credential-provider-ini");
|
|
@@ -20,11 +24,9 @@ const getLambdaClient = (lambdaOptions) => {
|
|
|
20
24
|
return new client_lambda_1.Lambda(clientOptions);
|
|
21
25
|
}
|
|
22
26
|
catch (error) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
throw error;
|
|
27
|
+
throw new cliError_1.CliError(constants_1.ERRORS.AWS_ERROR, {
|
|
28
|
+
description: error.message
|
|
29
|
+
});
|
|
28
30
|
}
|
|
29
31
|
};
|
|
30
32
|
exports.getLambdaClient = getLambdaClient;
|
|
@@ -60,7 +62,9 @@ const getLayersLinks = async (client, functionConfiguration) => {
|
|
|
60
62
|
}
|
|
61
63
|
catch (e) {
|
|
62
64
|
if (e instanceof client_lambda_1.ResourceNotFoundException) {
|
|
63
|
-
e.message =
|
|
65
|
+
e.message = i18n_1.default.__('layerNotFound', {
|
|
66
|
+
layerArn: layerDict.Arn || 'unknown_arn'
|
|
67
|
+
});
|
|
64
68
|
throw e;
|
|
65
69
|
}
|
|
66
70
|
throw e;
|
|
@@ -135,9 +139,8 @@ const getRolePolicies = async (roleName, client) => {
|
|
|
135
139
|
const getAttachedPolicies = async (roleName, client) => {
|
|
136
140
|
const listAttachedPolicies = await exports.getAttachedPolicyNames(roleName, client);
|
|
137
141
|
const attachedPoliciesPromises = listAttachedPolicies.map(async (policyDict) => {
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
});
|
|
142
|
+
const { PolicyArn, PolicyName } = policyDict;
|
|
143
|
+
const getPolicyCommand = new client_iam_1.GetPolicyCommand({ PolicyArn });
|
|
141
144
|
const policy = await client.send(getPolicyCommand);
|
|
142
145
|
if (policy.Policy) {
|
|
143
146
|
const getPolicyVersionCommand = new client_iam_1.GetPolicyVersionCommand({
|
|
@@ -146,8 +149,8 @@ const getAttachedPolicies = async (roleName, client) => {
|
|
|
146
149
|
});
|
|
147
150
|
const policyVersion = await client.send(getPolicyVersionCommand);
|
|
148
151
|
const policyDoc = JSON.parse(decodeURIComponent(policyVersion?.PolicyVersion?.Document || '{}'));
|
|
149
|
-
policyDoc['PolicyName'] =
|
|
150
|
-
policyDoc['PolicyArn'] =
|
|
152
|
+
policyDoc['PolicyName'] = PolicyName;
|
|
153
|
+
policyDoc['PolicyArn'] = PolicyArn;
|
|
151
154
|
return policyDoc;
|
|
152
155
|
}
|
|
153
156
|
});
|
package/dist/lambda/help.js
CHANGED
|
@@ -26,6 +26,10 @@ const lambdaUsageGuide = (0, command_line_usage_1.default)([
|
|
|
26
26
|
name: i18n_1.default.__('lambdaFunctionNameOption'),
|
|
27
27
|
summary: i18n_1.default.__('lambdaFunctionNameSummery')
|
|
28
28
|
},
|
|
29
|
+
{
|
|
30
|
+
name: i18n_1.default.__('lambdaListFunctionsOption'),
|
|
31
|
+
summary: i18n_1.default.__('lambdaListFunctionsSummery')
|
|
32
|
+
},
|
|
29
33
|
{
|
|
30
34
|
name: i18n_1.default.__('lambdaEndpointOption'),
|
|
31
35
|
summary: '{italic ' +
|