Skip to content

Commit 5dc7b0a

Browse files
committed
Fix search-ql-code.ts and environment-builder.test.ts
1 parent 5db2095 commit 5dc7b0a

File tree

5 files changed

+21
-33
lines changed

5 files changed

+21
-33
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"$schema":"https://json.schemastore.org/sarif-2.1.0.json","version":"2.1.0","runs":[{"tool":{"driver":{"name":"CodeQL","organization":"GitHub","semanticVersion":"2.25.2","rules":[{"id":"test/query","name":"test/query","shortDescription":{"text":"ExampleQuery1"},"fullDescription":{"text":"Example query for integration testing of the codeql_test_extract MCP server tool."},"defaultConfiguration":{"enabled":true,"level":"warning"},"help":{"text":"# Query Help for JavaScript ExampleQuery1\n\nTODO\n","markdown":"# Query Help for JavaScript ExampleQuery1\n\nTODO\n"},"properties":{"tags":["mcp-integration-tests"],"description":"Example query for integration testing of the codeql_test_extract MCP server tool.","id":"test/query","kind":"problem","name":"ExampleQuery1","precision":"medium","problem.severity":"warning"}}]},"extensions":[{"name":"mcp-client-integration-tests-static-javascript-src","semanticVersion":"0.0.1+fe0e7d2a7059ebb6c6075ff8eaea04f382747656","locations":[{"uri":"file:///home/runner/work/codeql-development-mcp-server/codeql-development-mcp-server/client/integration-tests/static/javascript/src/","description":{"text":"The QL pack root directory."},"properties":{"tags":["CodeQL/LocalPackRoot"]}},{"uri":"file:///home/runner/work/codeql-development-mcp-server/codeql-development-mcp-server/client/integration-tests/static/javascript/src/codeql-pack.yml","description":{"text":"The QL pack definition file."},"properties":{"tags":["CodeQL/LocalPackDefinitionFile"]}}]},{"name":"codeql/javascript-all","semanticVersion":"2.6.11+ce9c8e6e9fd41ef0967b13849bb6ae2183caf9ad","locations":[{"uri":"file:///home/runner/.codeql/packages/codeql/javascript-all/2.25.2/","description":{"text":"The QL pack root directory."},"properties":{"tags":["CodeQL/LocalPackRoot"]}},{"uri":"file:///home/runner/.codeql/packages/codeql/javascript-all/2.25.2/qlpack.yml","description":{"text":"The QL pack definition file."},"properties":{"tags":["CodeQL/LocalPackDefinitionFile"]}}]},{"name":"codeql/threat-models","semanticVersion":"1.0.31+ce9c8e6e9fd41ef0967b13849bb6ae2183caf9ad","locations":[{"uri":"file:///home/runner/.codeql/packages/codeql/threat-models/2.25.2/","description":{"text":"The QL pack root directory."},"properties":{"tags":["CodeQL/LocalPackRoot"]}},{"uri":"file:///home/runner/.codeql/packages/codeql/threat-models/2.25.2/qlpack.yml","description":{"text":"The QL pack definition file."},"properties":{"tags":["CodeQL/LocalPackDefinitionFile"]}}]}]},"artifacts":[{"location":{"uri":"file:///home/runner/work/codeql-development-mcp-server/codeql-development-mcp-server/client/integration-tests/static/javascript/test/ExampleQuery1/ExampleQuery1.js","index":0}}],"results":[{"ruleId":"test/query","ruleIndex":0,"rule":{"id":"test/query","index":0},"message":{"text":"Example test code file found for codeql_test_extract example query."},"locations":[{"physicalLocation":{"artifactLocation":{"uri":"file:///home/runner/work/codeql-development-mcp-server/codeql-development-mcp-server/client/integration-tests/static/javascript/test/ExampleQuery1/ExampleQuery1.js","index":0}}}]}],"columnKind":"utf16CodeUnits","properties":{"semmle.formatSpecifier":"sarif-latest"}}]}
1+
{"$schema":"https://json.schemastore.org/sarif-2.1.0.json","version":"2.1.0","runs":[{"tool":{"driver":{"name":"CodeQL","organization":"GitHub","semanticVersion":"2.25.2","rules":[{"id":"test/query","name":"test/query","shortDescription":{"text":"ExampleQuery1"},"fullDescription":{"text":"Example query for integration testing of the codeql_test_extract MCP server tool."},"defaultConfiguration":{"enabled":true,"level":"warning"},"help":{"text":"# Query Help for JavaScript ExampleQuery1\n\nTODO\n","markdown":"# Query Help for JavaScript ExampleQuery1\n\nTODO\n"},"properties":{"tags":["mcp-integration-tests"],"description":"Example query for integration testing of the codeql_test_extract MCP server tool.","id":"test/query","kind":"problem","name":"ExampleQuery1","precision":"medium","problem.severity":"warning"}}]},"extensions":[{"name":"mcp-client-integration-tests-static-javascript-src","semanticVersion":"0.0.1+fe0e7d2a7059ebb6c6075ff8eaea04f382747656","locations":[{"uri":"file:///home/runner/work/codeql-development-mcp-server/codeql-development-mcp-server/client/integration-tests/static/javascript/src/","description":{"text":"The QL pack root directory."},"properties":{"tags":["CodeQL/LocalPackRoot"]}},{"uri":"file:///home/runner/work/codeql-development-mcp-server/codeql-development-mcp-server/client/integration-tests/static/javascript/src/codeql-pack.yml","description":{"text":"The QL pack definition file."},"properties":{"tags":["CodeQL/LocalPackDefinitionFile"]}}]},{"name":"codeql/javascript-all","semanticVersion":"2.6.11+ce9c8e6e9fd41ef0967b13849bb6ae2183caf9ad","locations":[{"uri":"file:///home/runner/.codeql/packages/codeql/javascript-all/2.6.11/","description":{"text":"The QL pack root directory."},"properties":{"tags":["CodeQL/LocalPackRoot"]}},{"uri":"file:///home/runner/.codeql/packages/codeql/javascript-all/2.6.11/qlpack.yml","description":{"text":"The QL pack definition file."},"properties":{"tags":["CodeQL/LocalPackDefinitionFile"]}}]},{"name":"codeql/threat-models","semanticVersion":"1.0.31+ce9c8e6e9fd41ef0967b13849bb6ae2183caf9ad","locations":[{"uri":"file:///home/runner/.codeql/packages/codeql/threat-models/1.0.31/","description":{"text":"The QL pack root directory."},"properties":{"tags":["CodeQL/LocalPackRoot"]}},{"uri":"file:///home/runner/.codeql/packages/codeql/threat-models/1.0.31/qlpack.yml","description":{"text":"The QL pack definition file."},"properties":{"tags":["CodeQL/LocalPackDefinitionFile"]}}]}]},"artifacts":[{"location":{"uri":"file:///home/runner/work/codeql-development-mcp-server/codeql-development-mcp-server/client/integration-tests/static/javascript/test/ExampleQuery1/ExampleQuery1.js","index":0}}],"results":[{"ruleId":"test/query","ruleIndex":0,"rule":{"id":"test/query","index":0},"message":{"text":"Example test code file found for codeql_test_extract example query."},"locations":[{"physicalLocation":{"artifactLocation":{"uri":"file:///home/runner/work/codeql-development-mcp-server/codeql-development-mcp-server/client/integration-tests/static/javascript/test/ExampleQuery1/ExampleQuery1.js","index":0}}}]}],"columnKind":"utf16CodeUnits","properties":{"semmle.formatSpecifier":"sarif-latest"}}]}

extensions/vscode/test/bridge/environment-builder.test.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -347,25 +347,6 @@ describe('EnvironmentBuilder', () => {
347347
}
348348
});
349349

350-
it('should preserve ENABLE_ANNOTATION_TOOLS from parent process environment', async () => {
351-
const origValue = process.env.ENABLE_ANNOTATION_TOOLS;
352-
353-
try {
354-
process.env.ENABLE_ANNOTATION_TOOLS = 'false';
355-
356-
builder.invalidate();
357-
const env = await builder.build();
358-
// Inherited process.env value should be preserved
359-
expect(env.ENABLE_ANNOTATION_TOOLS).toBe('false');
360-
} finally {
361-
if (origValue === undefined) {
362-
delete process.env.ENABLE_ANNOTATION_TOOLS;
363-
} else {
364-
process.env.ENABLE_ANNOTATION_TOOLS = origValue;
365-
}
366-
}
367-
});
368-
369350
it('should set CODEQL_MCP_SCAN_EXCLUDE_DIRS when scanExcludeDirs setting is non-empty', async () => {
370351
const vscode = await import('vscode');
371352
const originalGetConfig = vscode.workspace.getConfiguration;

server/dist/codeql-development-mcp-server.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196971,10 +196971,13 @@ var MAX_FILE_SIZE_BYTES = 5 * 1024 * 1024;
196971196971
var MAX_FILES_TRAVERSED = 1e4;
196972196972
var MAX_CONTEXT_LINES = 50;
196973196973
var MAX_MAX_RESULTS = 1e4;
196974-
var SKIP_DIRS2 = getScanExcludeDirs();
196974+
function getSkipDirs() {
196975+
return getScanExcludeDirs();
196976+
}
196975196977
function collectFiles(paths, extensions, fileCount) {
196976196978
const files = [];
196977196979
const visitedDirs = /* @__PURE__ */ new Set();
196980+
const skipDirs = getSkipDirs();
196978196981
function walk(p) {
196979196982
if (fileCount.value >= MAX_FILES_TRAVERSED) return;
196980196983
let stat;
@@ -196990,7 +196993,7 @@ function collectFiles(paths, extensions, fileCount) {
196990196993
}
196991196994
fileCount.value++;
196992196995
} else if (stat.isDirectory()) {
196993-
if (SKIP_DIRS2.has(basename9(p))) return;
196996+
if (skipDirs.has(basename9(p))) return;
196994196997
let realPath;
196995196998
try {
196996196999
realPath = realpathSync2(p);
@@ -198417,7 +198420,7 @@ init_package_paths();
198417198420
var MAX_FILE_COMPLETIONS = 50;
198418198421
var MAX_SCAN_DEPTH = 8;
198419198422
var CACHE_TTL_MS = 5e3;
198420-
var SKIP_DIRS3 = getScanExcludeDirs();
198423+
var SKIP_DIRS2 = getScanExcludeDirs();
198421198424
var scanCache = /* @__PURE__ */ new Map();
198422198425
function getCachedResults(cacheKey2) {
198423198426
const entry = scanCache.get(cacheKey2);
@@ -198445,7 +198448,7 @@ async function findFilesByExtension(dir, baseDir, extensions, maxDepth, results)
198445198448
if (results.length >= MAX_FILE_COMPLETIONS) break;
198446198449
const fullPath = join22(dir, entry.name);
198447198450
if (entry.isDirectory()) {
198448-
if (SKIP_DIRS3.has(entry.name)) {
198451+
if (SKIP_DIRS2.has(entry.name)) {
198449198452
continue;
198450198453
}
198451198454
await findFilesByExtension(fullPath, baseDir, extensions, maxDepth - 1, results);
@@ -198558,7 +198561,7 @@ async function findDatabaseDirs(dir, _baseDir, maxDepth, results) {
198558198561
}
198559198562
for (const entry of entries) {
198560198563
if (results.length >= MAX_FILE_COMPLETIONS) break;
198561-
if (entry.isDirectory() && !SKIP_DIRS3.has(entry.name)) {
198564+
if (entry.isDirectory() && !SKIP_DIRS2.has(entry.name)) {
198562198565
await findDatabaseDirs(join22(dir, entry.name), _baseDir, maxDepth - 1, results);
198563198566
}
198564198567
}
@@ -198585,7 +198588,7 @@ async function completePackRoot(value) {
198585198588
}
198586198589
for (const entry of entries) {
198587198590
if (results.length >= MAX_FILE_COMPLETIONS) break;
198588-
if (entry.isDirectory() && !SKIP_DIRS3.has(entry.name)) {
198591+
if (entry.isDirectory() && !SKIP_DIRS2.has(entry.name)) {
198589198592
await scan(join22(dir, entry.name), depth - 1);
198590198593
}
198591198594
}

server/dist/codeql-development-mcp-server.js.map

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/src/tools/codeql/search-ql-code.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,13 @@ const MAX_CONTEXT_LINES = 50;
3232
const MAX_MAX_RESULTS = 10_000;
3333

3434
/**
35-
* Directory names to skip during traversal.
36-
* Uses the shared, configurable exclusion list from scan-exclude.ts.
35+
* Returns the set of directory names to skip during traversal.
36+
* Re-reads the environment variable on each call so that runtime
37+
* changes to `CODEQL_MCP_SCAN_EXCLUDE_DIRS` are respected.
3738
*/
38-
const SKIP_DIRS: Set<string> = getScanExcludeDirs();
39+
function getSkipDirs(): Set<string> {
40+
return getScanExcludeDirs();
41+
}
3942

4043
// ---------------------------------------------------------------------------
4144
// Types
@@ -73,6 +76,7 @@ function collectFiles(
7376
): string[] {
7477
const files: string[] = [];
7578
const visitedDirs = new Set<string>();
79+
const skipDirs = getSkipDirs();
7680

7781
function walk(p: string): void {
7882
if (fileCount.value >= MAX_FILES_TRAVERSED) return;
@@ -95,7 +99,7 @@ function collectFiles(
9599
fileCount.value++;
96100
} else if (stat.isDirectory()) {
97101
// Skip well-known directories that mirror source or contain deps
98-
if (SKIP_DIRS.has(basename(p))) return;
102+
if (skipDirs.has(basename(p))) return;
99103

100104
// Track visited directories by real path to prevent cycles
101105
let realPath: string;

0 commit comments

Comments
 (0)