From 4b512edf26c1523b767385c96eca0d21845bd4e4 Mon Sep 17 00:00:00 2001 From: Ilona Shishov Date: Thu, 2 May 2024 12:15:33 +0300 Subject: [PATCH] chore: added Gradle executable path setting (#257) Signed-off-by: Ilona Shishov --- src/config.ts | 4 ++++ src/dependencyAnalysis/analysis.ts | 1 + test/config.test.ts | 23 ++++++++++++++++------- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/config.ts b/src/config.ts index e432ef79..86285447 100644 --- a/src/config.ts +++ b/src/config.ts @@ -22,6 +22,7 @@ class Config usePipDepTree: string; vulnerabilityAlertSeverity: string; exhortMvnPath: string; + exhortGradlePath: string; exhortNpmPath: string; exhortGoPath: string; exhortPython3Path: string; @@ -38,6 +39,7 @@ class Config private readonly DEFAULT_VULNERABILITY_ALERT_SEVERITY = 'Error'; private readonly DEFAULT_MVN_EXECUTABLE = 'mvn'; + private readonly DEFAULT_GRADLE_EXECUTABLE = 'gradle'; private readonly DEFAULT_NPM_EXECUTABLE = 'npm'; private readonly DEFAULT_GO_EXECUTABLE = 'go'; private readonly DEFAULT_PYTHON3_EXECUTABLE = 'python3'; @@ -69,6 +71,7 @@ class Config this.usePipDepTree = process.env.VSCEXT_USE_PIP_DEP_TREE || 'false'; this.vulnerabilityAlertSeverity = process.env.VSCEXT_VULNERABILITY_ALERT_SEVERITY || this.DEFAULT_VULNERABILITY_ALERT_SEVERITY; this.exhortMvnPath = process.env.VSCEXT_EXHORT_MVN_PATH || this.DEFAULT_MVN_EXECUTABLE; + this.exhortGradlePath = process.env.VSCEXT_EXHORT_GRADLE_PATH || this.DEFAULT_GRADLE_EXECUTABLE; this.exhortNpmPath = process.env.VSCEXT_EXHORT_NPM_PATH || this.DEFAULT_NPM_EXECUTABLE; this.exhortGoPath = process.env.VSCEXT_EXHORT_GO_PATH || this.DEFAULT_GO_EXECUTABLE; this.exhortPython3Path = process.env.VSCEXT_EXHORT_PYTHON3_PATH || this.DEFAULT_PYTHON3_EXECUTABLE; @@ -96,6 +99,7 @@ class Config this.usePipDepTree = rhdaConfig.usePipDepTree ? 'true' : 'false'; this.vulnerabilityAlertSeverity = rhdaConfig.vulnerabilityAlertSeverity; this.exhortMvnPath = rhdaConfig.mvn.executable.path || this.DEFAULT_MVN_EXECUTABLE; + this.exhortGradlePath = rhdaConfig.gradle.executable.path || this.DEFAULT_GRADLE_EXECUTABLE; this.exhortNpmPath = rhdaConfig.npm.executable.path || this.DEFAULT_NPM_EXECUTABLE; this.exhortGoPath = rhdaConfig.go.executable.path || this.DEFAULT_GO_EXECUTABLE; this.exhortPython3Path = rhdaConfig.python3.executable.path || this.DEFAULT_PYTHON3_EXECUTABLE; diff --git a/src/dependencyAnalysis/analysis.ts b/src/dependencyAnalysis/analysis.ts index 55cea70c..bdab01dc 100644 --- a/src/dependencyAnalysis/analysis.ts +++ b/src/dependencyAnalysis/analysis.ts @@ -165,6 +165,7 @@ async function executeComponentAnalysis (diagnosticFilePath: string, contents: s 'EXHORT_PYTHON_INSTALL_BEST_EFFORTS': globalConfig.enablePythonBestEffortsInstallation, 'EXHORT_PIP_USE_DEP_TREE': globalConfig.usePipDepTree, 'EXHORT_MVN_PATH': globalConfig.exhortMvnPath, + 'EXHORT_GRADLE_PATH': globalConfig.exhortGradlePath, 'EXHORT_NPM_PATH': globalConfig.exhortNpmPath, 'EXHORT_GO_PATH': globalConfig.exhortGoPath, 'EXHORT_PYTHON3_PATH': globalConfig.exhortPython3Path, diff --git a/test/config.test.ts b/test/config.test.ts index b7f6767f..9c1fb92b 100644 --- a/test/config.test.ts +++ b/test/config.test.ts @@ -25,6 +25,9 @@ describe('Config tests', () => { mvn: { executable: { path: 'mockPath' } }, + gradle: { + executable: { path: 'mockPath' } + }, npm: { executable: { path: 'mockPath' } }, @@ -68,25 +71,28 @@ describe('Config tests', () => { enablePythonBestEffortsInstallation: false, usePipDepTree: false, mvn: { - executable: { path: '' } + executable: { path: '' } + }, + gradle: { + executable: { path: '' } }, npm: { - executable: { path: '' } + executable: { path: '' } }, go: { - executable: { path: '' } + executable: { path: '' } }, python3: { - executable: { path: '' } + executable: { path: '' } }, pip3: { - executable: { path: '' } + executable: { path: '' } }, python: { - executable: { path: '' } + executable: { path: '' } }, pip: { - executable: { path: '' } + executable: { path: '' } }, syft: { executable: { path: '' }, @@ -117,6 +123,7 @@ describe('Config tests', () => { expect(mockConfig.enablePythonBestEffortsInstallation).to.eq('false'); expect(mockConfig.usePipDepTree).to.eq('false'); expect(mockConfig.exhortMvnPath).to.eq('mvn'); + expect(mockConfig.exhortGradlePath).to.eq('gradle'); expect(mockConfig.exhortNpmPath).to.eq('npm'); expect(mockConfig.exhortGoPath).to.eq('go'); expect(mockConfig.exhortPython3Path).to.eq('python3'); @@ -142,6 +149,7 @@ describe('Config tests', () => { expect(mockConfig.enablePythonBestEffortsInstallation).to.eq('true'); expect(mockConfig.usePipDepTree).to.eq('true'); expect(mockConfig.exhortMvnPath).to.eq('mockPath'); + expect(mockConfig.exhortGradlePath).to.eq('mockPath'); expect(mockConfig.exhortNpmPath).to.eq('mockPath'); expect(mockConfig.exhortGoPath).to.eq('mockPath'); expect(mockConfig.exhortPython3Path).to.eq('mockPath'); @@ -167,6 +175,7 @@ describe('Config tests', () => { expect(mockConfig.enablePythonBestEffortsInstallation).to.eq('false'); expect(mockConfig.usePipDepTree).to.eq('false'); expect(mockConfig.exhortMvnPath).to.eq('mvn'); + expect(mockConfig.exhortGradlePath).to.eq('gradle'); expect(mockConfig.exhortNpmPath).to.eq('npm'); expect(mockConfig.exhortGoPath).to.eq('go'); expect(mockConfig.exhortPython3Path).to.eq('python3');