From f7a3ac1bebff2113f5595b05680293c108208b5a Mon Sep 17 00:00:00 2001 From: Leonardo Quimbaya Date: Fri, 27 Jun 2025 15:03:12 -0500 Subject: [PATCH] Added support for specifying query pack location. --- package.json | 8 +++++++- src/services/codeqlService.ts | 16 ++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index a994608..1236387 100644 --- a/package.json +++ b/package.json @@ -152,6 +152,12 @@ "description": "Path to the CodeQL CLI executable", "scope": "application" }, + "codeql-scanner.codeqlQueryPackPath": { + "type": "string", + "default": "", + "description": "Path to where the CodeQL query packs are stored", + "scope": "application" + }, "codeql-scanner.autoDetectGitHubExtension": { "type": "boolean", "default": true, @@ -284,4 +290,4 @@ "axios": "^1.3.4", "js-yaml": "^4.1.0" } -} +} \ No newline at end of file diff --git a/src/services/codeqlService.ts b/src/services/codeqlService.ts index f34edb3..0307ddc 100644 --- a/src/services/codeqlService.ts +++ b/src/services/codeqlService.ts @@ -395,7 +395,7 @@ export class CodeQLService { addedLanguages.add(lang); continue; } - + //TODO: If language detected is typescript, map it to javascript // Check if it's an alias for a CodeQL language for (const [codeqlLang, aliases] of Object.entries(this.languages)) { if (aliases.includes(lang) && !addedLanguages.has(codeqlLang)) { @@ -465,9 +465,8 @@ export class CodeQLService { } progress.report({ - message: `Waiting for analysis (${ - recentAnalysis?.status || "pending" - })...`, + message: `Waiting for analysis (${recentAnalysis?.status || "pending" + })...`, }); } catch (error) { // Continue waiting even if there's an error @@ -954,8 +953,13 @@ export class CodeQLService { } private findQueryPack(language: string): string | undefined { + const config = vscode.workspace.getConfiguration("codeql-scanner") const codeqlDir = this.getCodeQLDirectory(); - const queryPackPath = path.join(codeqlDir, "packages"); + const queryPackPath = config.get( + "codeqlQueryPackPath", + path.join(codeqlDir, "packages") + ); + // const queryPackPath = path.join(codeqlDir, "packages"); // List all directories in the packages folder if (!fs.existsSync(queryPackPath)) { @@ -1092,7 +1096,7 @@ export class CodeQLService { else if (parseLevel >= 5.0) return "medium"; else if (parseLevel >= 3.0) return "low"; else return "info"; - } catch (error) {} + } catch (error) { } // Check if the level is a float switch (level?.toLowerCase()) {