Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: added Gradle executable path setting #257

Merged
merged 1 commit into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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