You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix bqrs_interpret: auto-resolve --source-location-prefix from database metadata
When the `database` parameter is provided to `codeql_bqrs_interpret`, read
`codeql-database.yml` and extract `sourceLocationPrefix` to auto-set
`--source-location-prefix`. This fixes the "Missing required argument(s):
--source-location-prefix" error reported in v2.25.1-next.2 evaluation.
TDD: Added 2 handler behavior tests in cli-tool-registry.test.ts and
9 definition tests in bqrs-interpret.test.ts.
Agent-Logs-Url: https://github.com/advanced-security/codeql-development-mcp-server/sessions/6ff74bab-c637-4e18-a5dc-92e3065583f4
Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com>
Copy file name to clipboardExpand all lines: server/dist/codeql-development-mcp-server.js
+23-14Lines changed: 23 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -184635,7 +184635,7 @@ function cacheDatabaseAnalyzeResults(params, logger2) {
184635
184635
184636
184636
// src/lib/cli-tool-registry.ts
184637
184637
init_package_paths();
184638
-
import { writeFileSync as writeFileSync4, rmSync, existsSync as existsSync6, mkdirSync as mkdirSync8, realpathSync } from "fs";
184638
+
import { existsSync as existsSync6, mkdirSync as mkdirSync8, readFileSync as readFileSync7, realpathSync, rmSync, writeFileSync as writeFileSync4 } from "fs";
184639
184639
import { delimiter as delimiter5, dirname as dirname5, isAbsolute as isAbsolute4, join as join10, resolve as resolve4 } from "path";
184640
184640
184641
184641
// ../node_modules/js-yaml/dist/js-yaml.mjs
@@ -187500,6 +187500,15 @@ function registerCLITool(server, definition) {
187500
187500
`CodeQL database at "${dbPath}" does not contain a source archive (expected "src.zip" file or "src" directory).`
@@ -187793,7 +187802,7 @@ var codeqlBqrsInterpretTool = {
187793
187802
file: external_exports.string().describe("The BQRS file to interpret"),
187794
187803
format: external_exports.enum(["csv", "sarif-latest", "sarifv2.1.0", "graphtext", "dgml", "dot"]).describe("Output format: csv (comma-separated), sarif-latest/sarifv2.1.0 (SARIF), graphtext/dgml/dot (graph formats, only for @kind graph queries)"),
187795
187804
output: createCodeQLSchemas.output(),
187796
-
database: external_exports.string().optional().describe("Path to the CodeQL database, used to resolve sourcearchive context for SARIF interpretation (provides file contents and snippets)"),
187805
+
database: external_exports.string().optional().describe("Path to the CodeQL database. When provided, auto-resolves --source-archive (for file contents/snippets) and --source-location-prefix (from codeql-database.yml metadata) so SARIF results include full source context"),
187797
187806
t: external_exports.array(external_exports.string()).describe('Query metadata key=value pairs in KEY=VALUE format. At least "kind" and "id" must be specified. Example: ["kind=problem", "id=js/sql-injection"]. Common keys: kind (problem|path-problem|graph|metric|diagnostic), id (query identifier like js/xss)'),
187798
187807
"max-paths": external_exports.number().optional().describe("Maximum number of paths to produce for each alert with paths (default: 4)"),
187799
187808
"sarif-add-file-contents": external_exports.boolean().optional().describe("[SARIF only] Include full file contents for all files referenced in results"),
@@ -188351,7 +188360,7 @@ var codeqlGenerateQueryHelpTool = {
188351
188360
};
188352
188361
188353
188362
// src/tools/codeql/list-databases.ts
188354
-
import { existsSync as existsSync8, readdirSync as readdirSync4, readFileSync as readFileSync8, statSync as statSync4 } from "fs";
188363
+
import { existsSync as existsSync8, readdirSync as readdirSync4, readFileSync as readFileSync9, statSync as statSync4 } from "fs";
188355
188364
import { join as join12 } from "path";
188356
188365
188357
188366
// src/lib/discovery-config.ts
@@ -188376,7 +188385,7 @@ function getQueryRunResultsDirs() {
188376
188385
init_logger();
188377
188386
function parseDatabaseYml(ymlPath) {
188378
188387
try {
188379
-
const content = readFileSync8(ymlPath, "utf-8");
188388
+
const content = readFileSync9(ymlPath, "utf-8");
188380
188389
const info = {};
188381
188390
for (const line of content.split("\n")) {
188382
188391
const trimmed = line.trim();
@@ -188505,7 +188514,7 @@ function registerListDatabasesTool(server) {
188505
188514
}
188506
188515
188507
188516
// src/tools/codeql/list-mrva-run-results.ts
188508
-
import { existsSync as existsSync9, readdirSync as readdirSync5, readFileSync as readFileSync9, statSync as statSync5 } from "fs";
188517
+
import { existsSync as existsSync9, readdirSync as readdirSync5, readFileSync as readFileSync10, statSync as statSync5 } from "fs";
188509
188518
import { join as join13 } from "path";
188510
188519
init_logger();
188511
188520
var NUMERIC_DIR_PATTERN = /^\d+$/;
@@ -188541,7 +188550,7 @@ async function discoverMrvaRunResults(resultsDirs, runId) {
@@ -190391,7 +190400,7 @@ var codeqlResolveTestsTool = {
190391
190400
};
190392
190401
190393
190402
// src/tools/codeql/search-ql-code.ts
190394
-
import { closeSync as closeSync2, createReadStream as createReadStream3, fstatSync as fstatSync2, lstatSync, openSync as openSync2, readdirSync as readdirSync8, readFileSync as readFileSync12, realpathSync as realpathSync2 } from "fs";
190403
+
import { closeSync as closeSync2, createReadStream as createReadStream3, fstatSync as fstatSync2, lstatSync, openSync as openSync2, readdirSync as readdirSync8, readFileSync as readFileSync13, realpathSync as realpathSync2 } from "fs";
190395
190404
import { basename as basename8, extname as extname2, join as join19, resolve as resolve9 } from "path";
190396
190405
import { createInterface as createInterface3 } from "readline";
.describe('Output format: csv (comma-separated), sarif-latest/sarifv2.1.0 (SARIF), graphtext/dgml/dot (graph formats, only for @kind graph queries)'),
17
17
output: createCodeQLSchemas.output(),
18
18
database: z.string().optional()
19
-
.describe('Path to the CodeQL database, used to resolve sourcearchive context for SARIF interpretation (provides file contents and snippets)'),
19
+
.describe('Path to the CodeQL database. When provided, auto-resolves --source-archive (for file contents/snippets) and --source-location-prefix (from codeql-database.yml metadata) so SARIF results include full source context'),
20
20
t: z.array(z.string())
21
21
.describe('Query metadata key=value pairs in KEY=VALUE format. At least "kind" and "id" must be specified. Example: ["kind=problem", "id=js/sql-injection"]. Common keys: kind (problem|path-problem|graph|metric|diagnostic), id (query identifier like js/xss)'),
0 commit comments