Skip to content

Commit

Permalink
chore: added Gradle executable path setting (#257)
Browse files Browse the repository at this point in the history
Signed-off-by: Ilona Shishov <[email protected]>
  • Loading branch information
IlonaShishov authored May 2, 2024
1 parent ddfa2ae commit 4b512ed
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class Config
usePipDepTree: string;
vulnerabilityAlertSeverity: string;
exhortMvnPath: string;
exhortGradlePath: string;
exhortNpmPath: string;
exhortGoPath: string;
exhortPython3Path: string;
Expand All @@ -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';
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/dependencyAnalysis/analysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
23 changes: 16 additions & 7 deletions test/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ describe('Config tests', () => {
mvn: {
executable: { path: 'mockPath' }
},
gradle: {
executable: { path: 'mockPath' }
},
npm: {
executable: { path: 'mockPath' }
},
Expand Down Expand Up @@ -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: '' },
Expand Down Expand Up @@ -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');
Expand All @@ -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');
Expand All @@ -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');
Expand Down

0 comments on commit 4b512ed

Please sign in to comment.