@contrast/contrast 1.0.6 → 1.0.9
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 +0 -6
- package/dist/audit/catalogueApplication/catalogueApplication.js +23 -5
- package/dist/audit/languageAnalysisEngine/getProjectRootFilenames.js +10 -19
- 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 +46 -16
- package/dist/audit/languageAnalysisEngine/sendSnapshot.js +57 -19
- 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 +3 -3
- package/dist/commands/audit/saveFile.js +8 -4
- package/dist/commands/scan/sca/scaAnalysis.js +55 -10
- package/dist/common/HTTPClient.js +64 -23
- package/dist/common/errorHandling.js +6 -1
- package/dist/common/versionChecker.js +20 -5
- package/dist/constants/constants.js +7 -2
- package/dist/constants/locales.js +35 -38
- package/dist/constants.js +20 -13
- package/dist/index.js +55 -45
- package/dist/lambda/analytics.js +11 -0
- package/dist/lambda/lambda.js +38 -4
- package/dist/lambda/types.js +13 -0
- package/dist/sbom/generateSbom.js +5 -4
- package/dist/scaAnalysis/common/formatMessage.js +44 -1
- 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 -8
- package/dist/scaAnalysis/java/index.js +2 -2
- package/dist/scaAnalysis/javascript/analysis.js +107 -0
- package/dist/scaAnalysis/javascript/index.js +50 -0
- package/dist/scaAnalysis/php/analysis.js +70 -0
- package/dist/scaAnalysis/php/index.js +17 -0
- package/dist/scaAnalysis/python/analysis.js +42 -0
- package/dist/scaAnalysis/python/index.js +10 -0
- package/dist/scaAnalysis/ruby/analysis.js +218 -0
- package/dist/scaAnalysis/ruby/index.js +10 -0
- package/dist/scan/autoDetection.js +23 -22
- package/dist/scan/fileUtils.js +57 -20
- package/dist/scan/formatScanOutput.js +12 -14
- package/dist/scan/models/groupedResultsModel.js +1 -1
- package/dist/scan/models/scanResultsModel.js +3 -1
- package/dist/scan/populateProjectIdAndProjectName.js +2 -1
- package/dist/scan/scan.js +1 -0
- package/dist/scan/scanConfig.js +8 -3
- package/dist/scan/scanController.js +16 -3
- package/dist/scan/scanResults.js +5 -1
- package/dist/utils/commonApi.js +4 -1
- package/dist/utils/filterProjectPath.js +7 -2
- package/dist/utils/getConfig.js +1 -6
- package/package.json +12 -9
- package/src/audit/catalogueApplication/catalogueApplication.js +28 -7
- package/src/audit/languageAnalysisEngine/getProjectRootFilenames.js +10 -39
- package/src/audit/languageAnalysisEngine/report/commonReportingFunctions.ts +183 -68
- package/src/audit/languageAnalysisEngine/report/models/reportLibraryModel.ts +3 -3
- package/src/audit/languageAnalysisEngine/report/models/reportListModel.ts +18 -11
- package/src/audit/languageAnalysisEngine/report/models/reportOutputModel.ts +11 -5
- package/src/audit/languageAnalysisEngine/report/models/reportSeverityModel.ts +6 -1
- 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 +87 -32
- package/src/audit/languageAnalysisEngine/sendSnapshot.js +69 -20
- 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 +3 -6
- package/src/commands/audit/saveFile.ts +6 -2
- package/src/commands/scan/processScan.js +0 -1
- package/src/commands/scan/sca/scaAnalysis.js +84 -30
- package/src/common/HTTPClient.js +81 -34
- package/src/common/errorHandling.ts +10 -1
- package/src/common/versionChecker.ts +24 -5
- package/src/constants/constants.js +9 -3
- package/src/constants/locales.js +58 -43
- package/src/constants.js +21 -14
- package/src/index.ts +70 -58
- package/src/lambda/analytics.ts +9 -0
- package/src/lambda/arn.ts +2 -1
- package/src/lambda/lambda.ts +40 -17
- package/src/lambda/types.ts +36 -0
- package/src/lambda/utils.ts +2 -7
- package/src/sbom/generateSbom.ts +2 -2
- package/src/scaAnalysis/common/formatMessage.js +48 -1
- 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/goAnalysis.js +2 -3
- package/src/scaAnalysis/go/goReadDepFile.js +1 -3
- package/src/scaAnalysis/java/analysis.js +7 -8
- package/src/scaAnalysis/java/index.js +2 -2
- package/src/scaAnalysis/javascript/analysis.js +126 -0
- package/src/scaAnalysis/javascript/index.js +72 -0
- package/src/scaAnalysis/php/analysis.js +78 -0
- package/src/scaAnalysis/php/index.js +22 -0
- package/src/scaAnalysis/python/analysis.js +49 -0
- package/src/scaAnalysis/python/index.js +11 -0
- package/src/scaAnalysis/ruby/analysis.js +273 -0
- package/src/scaAnalysis/ruby/index.js +11 -0
- package/src/scan/autoDetection.js +24 -26
- package/src/scan/fileUtils.js +60 -20
- package/src/scan/formatScanOutput.ts +14 -15
- package/src/scan/models/groupedResultsModel.ts +3 -3
- package/src/scan/models/resultContentModel.ts +1 -1
- package/src/scan/models/scanResultsModel.ts +5 -2
- package/src/scan/populateProjectIdAndProjectName.js +3 -1
- package/src/scan/scan.ts +1 -0
- package/src/scan/scanConfig.js +7 -5
- package/src/scan/scanController.js +18 -4
- package/src/scan/scanResults.js +10 -0
- package/src/utils/commonApi.js +4 -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 -153
- 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 -24
- package/dist/audit/languageAnalysisEngine/checkForMultipleIdentifiedProjectFiles.js +0 -24
- package/dist/audit/languageAnalysisEngine/checkIdentifiedLanguageHasLockFile.js +0 -35
- package/dist/audit/languageAnalysisEngine/checkIdentifiedLanguageHasProjectFile.js +0 -23
- 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 -87
- package/dist/audit/languageAnalysisEngine/reduceIdentifiedLanguages.js +0 -150
- 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 -222
- 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 -35
- package/src/audit/languageAnalysisEngine/checkForMultipleIdentifiedProjectFiles.js +0 -41
- package/src/audit/languageAnalysisEngine/checkIdentifiedLanguageHasLockFile.js +0 -54
- package/src/audit/languageAnalysisEngine/checkIdentifiedLanguageHasProjectFile.js +0 -32
- 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 -116
- package/src/audit/languageAnalysisEngine/reduceIdentifiedLanguages.js +0 -249
- 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,7 +12,7 @@ const MEDIUM = 'MEDIUM';
|
|
|
12
12
|
const HIGH = 'HIGH';
|
|
13
13
|
const CRITICAL = 'CRITICAL';
|
|
14
14
|
const APP_NAME = 'contrast';
|
|
15
|
-
const APP_VERSION = '1.0.
|
|
15
|
+
const APP_VERSION = '1.0.9';
|
|
16
16
|
const TIMEOUT = 120000;
|
|
17
17
|
const HIGH_COLOUR = '#ff9900';
|
|
18
18
|
const CRITICAL_COLOUR = '#e35858';
|
|
@@ -27,9 +27,12 @@ const NOTE_PRIORITY = 5;
|
|
|
27
27
|
const AUTH_UI_URL = 'https://cli-auth.contrastsecurity.com';
|
|
28
28
|
const AUTH_CALLBACK_URL = 'https://cli-auth-api.contrastsecurity.com';
|
|
29
29
|
const SARIF_FILE = 'SARIF';
|
|
30
|
+
const SBOM_CYCLONE_DX_FILE = 'cyclonedx';
|
|
31
|
+
const SBOM_SPDX_FILE = 'spdx';
|
|
30
32
|
const CE_URL = 'https://ce.contrastsecurity.com/';
|
|
31
33
|
module.exports = {
|
|
32
34
|
supportedLanguages: { NODE, DOTNET, JAVA, RUBY, PYTHON, GO, PHP, JAVASCRIPT },
|
|
35
|
+
supportedLanguagesScan: { JAVASCRIPT, DOTNET, JAVA },
|
|
33
36
|
LOW,
|
|
34
37
|
MEDIUM,
|
|
35
38
|
HIGH,
|
|
@@ -50,5 +53,7 @@ module.exports = {
|
|
|
50
53
|
HIGH_PRIORITY,
|
|
51
54
|
MEDIUM_PRIORITY,
|
|
52
55
|
LOW_PRIORITY,
|
|
53
|
-
NOTE_PRIORITY
|
|
56
|
+
NOTE_PRIORITY,
|
|
57
|
+
SBOM_CYCLONE_DX_FILE,
|
|
58
|
+
SBOM_SPDX_FILE
|
|
54
59
|
};
|
|
@@ -12,7 +12,7 @@ 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',
|
|
@@ -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,13 @@ 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
|
-
constantsPrerequisitesContentScanLanguages: 'Java
|
|
99
|
-
constantsContrastContent:
|
|
100
|
+
constantsPrerequisitesContentScanLanguages: 'Java, Javascript and .NET supported',
|
|
101
|
+
constantsContrastContent: "Use the 'contrast' command for fast and accurate security analysis of your applications and APIs (Java, JavaScript and .NET ) as well as serverless functions (AWS lambda, Java and Python).",
|
|
100
102
|
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
103
|
constantsPrerequisitesHeader: 'Pre-requisites',
|
|
102
104
|
constantsAuthUsageHeader: 'Usage',
|
|
@@ -162,7 +164,7 @@ const en_locales = () => {
|
|
|
162
164
|
constantsIgnoreCertErrors: 'For EOP users with a local Teamserver install, this will bypass the SSL certificate and recognise a self signed certificate.',
|
|
163
165
|
constantsSave: 'Saves the Scan Results SARIF to file.',
|
|
164
166
|
scanLabel: "adds a label to the scan - defaults to 'Started by CLI tool at current date'",
|
|
165
|
-
constantsIgnoreDev: '
|
|
167
|
+
constantsIgnoreDev: 'Excludes developer dependencies from the results. All dependencies are included by default.',
|
|
166
168
|
constantsCommands: 'Commands',
|
|
167
169
|
constantsScanOptions: 'Scan Options',
|
|
168
170
|
sbomError: 'All required parameters are not present.',
|
|
@@ -247,40 +249,34 @@ const en_locales = () => {
|
|
|
247
249
|
redirectAuth: '\nOpening the authentication page in your web browser.\nSign in and complete the steps.\nReturn here to start using Contrast.\n\nIf your browser has trouble loading, try this:\n%s \n',
|
|
248
250
|
scanZipError: 'A .zip archive can be used for Javascript Scan. Archive found %s does not contain .JS files for Scan.',
|
|
249
251
|
fileNotExist: 'File specified does not exist, please check and try again.',
|
|
252
|
+
scanFileIsEmpty: 'File specified is empty. Please choose another.',
|
|
250
253
|
fileHasWhiteSpacesError: 'File cannot have spaces, please rename or choose another file to Scan.',
|
|
251
254
|
zipFileException: 'Error reading zip file',
|
|
252
255
|
connectionError: 'An error has occurred when trying to get the Project Id please check your internet connection or provide the Project Id manually',
|
|
253
256
|
internalServerErrorHeader: '500 error - Internal server error',
|
|
254
257
|
resourceLockedErrorHeader: '423 error - Resource is locked',
|
|
255
|
-
auditHeader: 'Contrast
|
|
256
|
-
auditHeaderMessage:
|
|
257
|
-
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
|
|
258
|
-
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.`,
|
|
258
|
+
auditHeader: 'Contrast audit help',
|
|
259
|
+
auditHeaderMessage: "Use 'contrast audit' to analyze a project’s dependencies for vulnerabilities.",
|
|
259
260
|
constantsAuditPrerequisitesContentSupportedLanguages: 'Supported languages and their requirements are:',
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
For a Gradle project (v4.8+) use build.gradle. A gradle-wrapper.properties file is also required.
|
|
264
|
-
Kotlin is also supported requiring a build.gradle.kts file.`,
|
|
265
|
-
constantsAuditPrerequisitesContentDotNet: '.NET framework and .NET core: ',
|
|
261
|
+
constantsAuditPrerequisitesJavaContentMessage: `
|
|
262
|
+
${chalk.bold('Java:')} pom.xml ${chalk.bold('and')} Maven build platform including the dependency plugin.
|
|
263
|
+
${chalk.bold('Or')} build.gradle ${chalk.bold('and')} gradle dependencies or ./gradlew dependencies must be supported`,
|
|
266
264
|
constantsAuditPrerequisitesContentDotNetMessage: `
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
constantsAuditPrerequisitesContentLanguagePythonMessage: 'pipfile AND pipfile.lock',
|
|
265
|
+
${chalk.bold('.NET framework and .NET core:')} MSBuild 15.0 or greater and a packages.lock.json file.
|
|
266
|
+
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`,
|
|
267
|
+
constantsAuditPrerequisitesContentNodeMessage: `${chalk.bold('Node:')} package.json and a lock file (either .package-lock.json or .yarn.lock.)\n`,
|
|
268
|
+
constantsAuditPrerequisitesContentRubyMessage: `${chalk.bold('Ruby:')} gemfile and gemfile.lock\n`,
|
|
269
|
+
constantsAuditPrerequisitesContentPythonMessage: `${chalk.bold('Python:')} pipfile and pipfile.lock\n`,
|
|
270
|
+
constantsAuditPrerequisitesContentGoMessage: `${chalk.bold('Go:')} go.mod\n`,
|
|
271
|
+
constantsAuditPrerequisitesContentPHPMessage: `${chalk.bold('PHP:')} composer.json and composer.lock\n`,
|
|
275
272
|
constantsAuditOptions: 'Audit Options',
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
auditOptionsSave: '-s, --save',
|
|
279
|
-
auditOptionsSaveDescription: 'saves the output in specified format Txt text, sbom',
|
|
273
|
+
auditOptionsSaveDescription: 'Generate and save an SBOM (Software Bill of Materials)\n',
|
|
274
|
+
auditOptionsSaveOptionsDescription: 'Valid options are: spdx, cyclonedx (cycloneDX is the default format)',
|
|
280
275
|
scanNotCompleted: 'Scan not completed. Check for framework and language support here: %s',
|
|
281
|
-
|
|
276
|
+
auditNotCompleted: 'audit not completed. Please try again',
|
|
277
|
+
scanNoVulnerabilitiesFound: '🎉 No vulnerabilities found.',
|
|
282
278
|
scanNoVulnerabilitiesFoundSecureCode: '👍 Your code looks secure.',
|
|
283
|
-
scanNoVulnerabilitiesFoundGoodWork: '
|
|
279
|
+
scanNoVulnerabilitiesFoundGoodWork: ' Keep up the good work.',
|
|
284
280
|
scanNoFiletypeSpecifiedForSave: 'Please specify file type to save results to, accepted value is SARIF',
|
|
285
281
|
auditSBOMSaveSuccess: '\n Software Bill of Materials (SBOM) saved successfully',
|
|
286
282
|
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.')}`,
|
|
@@ -289,7 +285,8 @@ const en_locales = () => {
|
|
|
289
285
|
auditReportFail: 'Report Retrieval Failed, please try again',
|
|
290
286
|
auditReportSuccessMessage: 'Report successfully retrieved',
|
|
291
287
|
auditReportFailureMessage: 'Unable to generate library report',
|
|
292
|
-
auditSCAAnalysisBegins: 'Contrast SCA
|
|
288
|
+
auditSCAAnalysisBegins: 'Contrast SCA audit started',
|
|
289
|
+
auditSCAAnalysisComplete: 'Contrast audit complete',
|
|
293
290
|
...lambda
|
|
294
291
|
};
|
|
295
292
|
};
|
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(),
|
|
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,7 +286,22 @@ 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([
|
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();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.postAnalytics = void 0;
|
|
4
|
+
const commonApi_1 = require("../utils/commonApi");
|
|
5
|
+
const paramHandler_1 = require("../utils/paramsUtil/paramHandler");
|
|
6
|
+
const postAnalytics = (data, provider = 'aws') => {
|
|
7
|
+
const config = (0, paramHandler_1.getAuth)();
|
|
8
|
+
const client = (0, commonApi_1.getHttpClient)(config);
|
|
9
|
+
return client.postAnalyticsFunction(config, provider, data);
|
|
10
|
+
};
|
|
11
|
+
exports.postAnalytics = postAnalytics;
|
package/dist/lambda/lambda.js
CHANGED
|
@@ -20,6 +20,9 @@ const utils_1 = require("./utils");
|
|
|
20
20
|
const lambdaUtils_1 = require("./lambdaUtils");
|
|
21
21
|
const requestUtils_1 = require("../utils/requestUtils");
|
|
22
22
|
const oraWrapper_1 = __importDefault(require("../utils/oraWrapper"));
|
|
23
|
+
const analytics_1 = require("./analytics");
|
|
24
|
+
const types_1 = require("./types");
|
|
25
|
+
const constants_2 = require("../constants/constants");
|
|
23
26
|
const failedStates = [
|
|
24
27
|
'UNSUPPORTED',
|
|
25
28
|
'EXCLUDED',
|
|
@@ -57,9 +60,20 @@ const getLambdaOptions = (argv) => {
|
|
|
57
60
|
}
|
|
58
61
|
};
|
|
59
62
|
const processLambda = async (argv) => {
|
|
63
|
+
let errorMsg;
|
|
64
|
+
let scanInfo;
|
|
65
|
+
const commandSessionId = Date.now().toString(36);
|
|
60
66
|
try {
|
|
61
67
|
const lambdaOptions = getLambdaOptions(argv);
|
|
62
68
|
const { help } = lambdaOptions;
|
|
69
|
+
const startCommandAnalytics = {
|
|
70
|
+
arguments: lambdaOptions,
|
|
71
|
+
sessionId: commandSessionId,
|
|
72
|
+
eventType: types_1.EventType.START,
|
|
73
|
+
packageVersion: constants_2.APP_VERSION
|
|
74
|
+
};
|
|
75
|
+
(0, analytics_1.postAnalytics)(startCommandAnalytics).catch((error) => {
|
|
76
|
+
});
|
|
63
77
|
if (help) {
|
|
64
78
|
return handleLambdaHelp();
|
|
65
79
|
}
|
|
@@ -68,17 +82,36 @@ const processLambda = async (argv) => {
|
|
|
68
82
|
await getAvailableFunctions(lambdaOptions);
|
|
69
83
|
}
|
|
70
84
|
else {
|
|
71
|
-
await actualProcessLambda(lambdaOptions);
|
|
85
|
+
scanInfo = await actualProcessLambda(lambdaOptions);
|
|
72
86
|
}
|
|
73
87
|
}
|
|
74
88
|
catch (error) {
|
|
75
89
|
if (error instanceof cliError_1.CliError) {
|
|
76
|
-
|
|
90
|
+
errorMsg = error.getErrorMessage();
|
|
77
91
|
}
|
|
78
92
|
else if (error instanceof Error) {
|
|
79
|
-
|
|
93
|
+
errorMsg = error.message;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
finally {
|
|
97
|
+
const endCommandAnalytics = {
|
|
98
|
+
sessionId: commandSessionId,
|
|
99
|
+
eventType: types_1.EventType.END,
|
|
100
|
+
status: errorMsg ? types_1.StatusType.FAILED : types_1.StatusType.SUCCESS,
|
|
101
|
+
packageVersion: constants_2.APP_VERSION
|
|
102
|
+
};
|
|
103
|
+
if (errorMsg) {
|
|
104
|
+
endCommandAnalytics.errorMsg = errorMsg;
|
|
105
|
+
console.error(errorMsg);
|
|
106
|
+
}
|
|
107
|
+
if (scanInfo) {
|
|
108
|
+
endCommandAnalytics.scanFunctionData = scanInfo;
|
|
109
|
+
}
|
|
110
|
+
await (0, analytics_1.postAnalytics)(endCommandAnalytics).catch((error) => {
|
|
111
|
+
});
|
|
112
|
+
if (errorMsg) {
|
|
113
|
+
process.exit(1);
|
|
80
114
|
}
|
|
81
|
-
process.exit(1);
|
|
82
115
|
}
|
|
83
116
|
};
|
|
84
117
|
exports.processLambda = processLambda;
|
|
@@ -127,6 +160,7 @@ const actualProcessLambda = async (lambdaOptions) => {
|
|
|
127
160
|
if (results?.length) {
|
|
128
161
|
(0, utils_1.printResults)(results);
|
|
129
162
|
}
|
|
163
|
+
return { functionArn, scanId };
|
|
130
164
|
};
|
|
131
165
|
const validateRequiredLambdaParams = (options) => {
|
|
132
166
|
if (options._unknown?.length) {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EventType = exports.StatusType = void 0;
|
|
4
|
+
var StatusType;
|
|
5
|
+
(function (StatusType) {
|
|
6
|
+
StatusType["FAILED"] = "failed";
|
|
7
|
+
StatusType["SUCCESS"] = "success";
|
|
8
|
+
})(StatusType = exports.StatusType || (exports.StatusType = {}));
|
|
9
|
+
var EventType;
|
|
10
|
+
(function (EventType) {
|
|
11
|
+
EventType["START"] = "start_command_session";
|
|
12
|
+
EventType["END"] = "end_command_session";
|
|
13
|
+
})(EventType = exports.EventType || (exports.EventType = {}));
|
|
@@ -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: {
|
|
@@ -13,7 +28,35 @@ const createGoTSMessage = goTree => {
|
|
|
13
28
|
}
|
|
14
29
|
};
|
|
15
30
|
};
|
|
31
|
+
const createRubyTSMessage = rubyTree => {
|
|
32
|
+
return {
|
|
33
|
+
ruby: rubyTree
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
const createPythonTSMessage = pythonTree => {
|
|
37
|
+
return {
|
|
38
|
+
python: pythonTree
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
const createPhpTSMessage = phpTree => {
|
|
42
|
+
return {
|
|
43
|
+
php: {
|
|
44
|
+
composerJSON: phpTree.composerJSON,
|
|
45
|
+
lockFile: phpTree.lockFile
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
const createDotNetTSMessage = dotnetTree => {
|
|
50
|
+
return {
|
|
51
|
+
dotnet: dotnetTree
|
|
52
|
+
};
|
|
53
|
+
};
|
|
16
54
|
module.exports = {
|
|
55
|
+
createJavaScriptTSMessage,
|
|
17
56
|
createJavaTSMessage,
|
|
18
|
-
createGoTSMessage
|
|
57
|
+
createGoTSMessage,
|
|
58
|
+
createPhpTSMessage,
|
|
59
|
+
createRubyTSMessage,
|
|
60
|
+
createPythonTSMessage,
|
|
61
|
+
createDotNetTSMessage
|
|
19
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();
|