Skip to content

Commit

Permalink
Config AnalyzerManager version (#473)
Browse files Browse the repository at this point in the history
  • Loading branch information
attiasas committed Apr 25, 2024
1 parent 216b35a commit 4ec50cc
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@
"configuration": {
"title": "JFrog",
"properties": {
"jfrog.useSpecificScannersVersion": {
"type": "string",
"scope": "application",
"pattern": "^$|^\\d+\\.\\d+\\.\\d+$",
"markdownDescription": "Specifies the JFrog Scanners version to use. (format X.X.X). By default the latest scanners version is used."
},
"jfrog.xray.exclusions": {
"type": "string",
"default": "**/*{.git,test,venv,node_modules,target}*",
Expand Down
19 changes: 14 additions & 5 deletions src/main/scanLogic/scanRunners/analyzerManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@ import { LogUtils } from '../../log/logUtils';
* Analyzer manager is responsible for running the analyzer on the workspace.
*/
export class AnalyzerManager {
private static readonly RELATIVE_DOWNLOAD_URL: string = '/xsc-gen-exe-analyzer-manager-local/v1/[RELEASE]';
private static readonly RELATIVE_DOWNLOAD_URL: string = '/xsc-gen-exe-analyzer-manager-local/v1';
private static readonly BINARY_NAME: string = 'analyzerManager';
public static readonly ANALYZER_MANAGER_PATH: string = Utils.addWinSuffixIfNeeded(
path.join(ScanUtils.getIssuesPath(), AnalyzerManager.BINARY_NAME, AnalyzerManager.BINARY_NAME)
);
private static readonly DOWNLOAD_URL: string = Utils.addZipSuffix(
AnalyzerManager.RELATIVE_DOWNLOAD_URL + '/' + Utils.getPlatformAndArch() + '/' + AnalyzerManager.BINARY_NAME
);

private static readonly JFROG_RELEASES_URL: string = 'https://releases.jfrog.io';
public static readonly JF_RELEASES_REPO: string = 'JF_RELEASES_REPO';
Expand All @@ -41,10 +38,22 @@ export class AnalyzerManager {
private static FINISH_UPDATE_PROMISE: Promise<boolean>;

constructor(private _connectionManager: ConnectionManager, protected _logManager: LogManager) {
this._binary = new Resource(AnalyzerManager.DOWNLOAD_URL, AnalyzerManager.ANALYZER_MANAGER_PATH, _logManager, this.createJFrogCLient());
this._binary = new Resource(AnalyzerManager.getDownloadUrl(), AnalyzerManager.ANALYZER_MANAGER_PATH, _logManager, this.createJFrogCLient());
AnalyzerManager.FINISH_UPDATE_PROMISE = this.checkForUpdates();
}

private static getDownloadUrl(): string {
return Utils.addZipSuffix(
AnalyzerManager.RELATIVE_DOWNLOAD_URL +
'/' +
Configuration.getAnalyzerManagerVersion() +
'/' +
Utils.getPlatformAndArch() +
'/' +
AnalyzerManager.BINARY_NAME
);
}

private createJFrogCLient(): JfrogClient {
const releasesRepo: JfrogClient | undefined = this.getExternalResourcesRepository();
if (!releasesRepo) {
Expand Down
8 changes: 8 additions & 0 deletions src/main/utils/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ export class Configuration {
return vscode.workspace.getConfiguration(this.jfrogSectionConfigurationKey).get('showAdvanceScanLog', false);
}

public static getAnalyzerManagerVersion(): string {
let version: string = vscode.workspace.getConfiguration(this.jfrogSectionConfigurationKey).get('useSpecificScannersVersion', '');
if (version === '') {
version = '[RELEASE]';
}
return version;
}

/**
* @returns the log level
*/
Expand Down

0 comments on commit 4ec50cc

Please sign in to comment.