Skip to content

Commit 2877cd1

Browse files
committed
More fixes for PR review feedback
1 parent 3f86dc6 commit 2877cd1

File tree

5 files changed

+25
-15
lines changed

5 files changed

+25
-15
lines changed

client/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ BINARY_NAME := gh-ql-mcp-client
22
MODULE := github.com/advanced-security/codeql-development-mcp-server/client
33
VERSION := $(shell grep 'Version = ' cmd/root.go | head -1 | sed 's/.*"\(.*\)"/\1/')
44

5+
# Use bash as the Make recipe shell (required on Windows where the default
6+
# shell cannot execute .sh scripts).
7+
SHELL := bash
8+
59
# Disable CGO to avoid Xcode/C compiler dependency
610
export CGO_ENABLED = 0
711

client/scripts/start-server.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,17 @@ fi
3636
# Change to root directory
3737
cd "$ROOT_DIR"
3838

39+
# Align the server's tmp base with the Go client's {{tmpdir}} placeholder
40+
# so that log-directory validation passes in HTTP mode (where the server
41+
# is a separate process that doesn't inherit the Go client's env).
42+
CODEQL_MCP_TMP_DIR="${CODEQL_MCP_TMP_DIR:-$ROOT_DIR/.tmp}"
43+
3944
# Start server in background and capture PID
4045
HTTP_HOST="$HTTP_HOST" \
4146
HTTP_PORT="$HTTP_PORT" \
4247
TRANSPORT_MODE="$TRANSPORT_MODE" \
4348
ENABLE_MONITORING_TOOLS="$ENABLE_MONITORING_TOOLS" \
49+
CODEQL_MCP_TMP_DIR="$CODEQL_MCP_TMP_DIR" \
4450
node server/dist/codeql-development-mcp-server.js > "$CLIENT_DIR/server.log" 2>&1 &
4551

4652
SERVER_PID=$!

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38735,7 +38735,7 @@ var require_send = __commonJS({
3873538735
var join22 = path3.join;
3873638736
var normalize2 = path3.normalize;
3873738737
var resolve15 = path3.resolve;
38738-
var sep3 = path3.sep;
38738+
var sep4 = path3.sep;
3873938739
var BYTES_RANGE_REGEXP = /^ *bytes=/;
3874038740
var MAX_MAXAGE = 60 * 60 * 24 * 365 * 1e3;
3874138741
var UP_PATH_REGEXP = /(?:^|[\\/])\.\.(?:[\\/]|$)/;
@@ -38896,22 +38896,22 @@ var require_send = __commonJS({
3889638896
var parts;
3889738897
if (root !== null) {
3889838898
if (path4) {
38899-
path4 = normalize2("." + sep3 + path4);
38899+
path4 = normalize2("." + sep4 + path4);
3890038900
}
3890138901
if (UP_PATH_REGEXP.test(path4)) {
3890238902
debug('malicious path "%s"', path4);
3890338903
this.error(403);
3890438904
return res;
3890538905
}
38906-
parts = path4.split(sep3);
38906+
parts = path4.split(sep4);
3890738907
path4 = normalize2(join22(root, path4));
3890838908
} else {
3890938909
if (UP_PATH_REGEXP.test(path4)) {
3891038910
debug('malicious path "%s"', path4);
3891138911
this.error(403);
3891238912
return res;
3891338913
}
38914-
parts = normalize2(path4).split(sep3);
38914+
parts = normalize2(path4).split(sep4);
3891538915
path4 = resolve15(path4);
3891638916
}
3891738917
if (containsDotFile(parts)) {
@@ -39005,7 +39005,7 @@ var require_send = __commonJS({
3900539005
var self2 = this;
3900639006
debug('stat "%s"', path4);
3900739007
fs3.stat(path4, function onstat(err, stat) {
39008-
var pathEndsWithSep = path4[path4.length - 1] === sep3;
39008+
var pathEndsWithSep = path4[path4.length - 1] === sep4;
3900939009
if (err && err.code === "ENOENT" && !extname3(path4) && !pathEndsWithSep) {
3901039010
return next(err);
3901139011
}
@@ -172214,8 +172214,8 @@ var require_adm_zip = __commonJS({
172214172214
return null;
172215172215
}
172216172216
function fixPath(zipPath) {
172217-
const { join: join22, normalize: normalize2, sep: sep3 } = pth.posix;
172218-
return join22(pth.isAbsolute(zipPath) ? "/" : ".", normalize2(sep3 + zipPath.split("\\").join(sep3) + sep3));
172217+
const { join: join22, normalize: normalize2, sep: sep4 } = pth.posix;
172218+
return join22(pth.isAbsolute(zipPath) ? "/" : ".", normalize2(sep4 + zipPath.split("\\").join(sep4) + sep4));
172219172219
}
172220172220
function filenameFilter(filterfn) {
172221172221
if (filterfn instanceof RegExp) {
@@ -188554,12 +188554,12 @@ init_logger();
188554188554
// src/lib/log-directory-manager.ts
188555188555
init_temp_dir();
188556188556
import { mkdirSync as mkdirSync3, existsSync as existsSync5 } from "fs";
188557-
import { join as join7, resolve as resolve3 } from "path";
188557+
import { join as join7, resolve as resolve3, sep } from "path";
188558188558
import { randomBytes } from "crypto";
188559188559
function ensurePathWithinBase(baseDir, targetPath) {
188560188560
const absBase = resolve3(baseDir);
188561188561
const absTarget = resolve3(targetPath);
188562-
if (!absTarget.startsWith(absBase + "/") && absTarget !== absBase) {
188562+
if (!absTarget.startsWith(absBase + sep) && absTarget !== absBase) {
188563188563
throw new Error(`Provided log directory is outside the allowed base directory: ${absBase}`);
188564188564
}
188565188565
return absTarget;
@@ -198038,7 +198038,7 @@ function registerLanguageResources(server) {
198038198038

198039198039
// src/prompts/workflow-prompts.ts
198040198040
import { access as access2 } from "fs/promises";
198041-
import { basename as basename9, isAbsolute as isAbsolute7, normalize, relative, resolve as resolve13, sep as sep2 } from "path";
198041+
import { basename as basename9, isAbsolute as isAbsolute7, normalize, relative, resolve as resolve13, sep as sep3 } from "path";
198042198042
import { fileURLToPath as fileURLToPath3 } from "url";
198043198043

198044198044
// src/prompts/check-for-duplicated-code.prompt.md
@@ -198190,7 +198190,7 @@ async function resolvePromptFilePath(filePath, workspaceRoot) {
198190198190
const absolutePath = inputWasAbsolute ? normalizedPath : resolve13(effectiveRoot, normalizedPath);
198191198191
if (!inputWasAbsolute) {
198192198192
const rel = relative(effectiveRoot, absolutePath);
198193-
if (rel === ".." || rel.startsWith(`..${sep2}`) || isAbsolute7(rel)) {
198193+
if (rel === ".." || rel.startsWith(`..${sep3}`) || isAbsolute7(rel)) {
198194198194
return {
198195198195
blocked: true,
198196198196
resolvedPath: "",

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

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

server/src/lib/log-directory-manager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44

55
import { mkdirSync, existsSync } from 'fs';
6-
import { join, resolve } from 'path';
6+
import { join, resolve, sep } from 'path';
77
import { randomBytes } from 'crypto';
88
import { getProjectTmpDir } from '../utils/temp-dir';
99

@@ -14,7 +14,7 @@ import { getProjectTmpDir } from '../utils/temp-dir';
1414
function ensurePathWithinBase(baseDir: string, targetPath: string): string {
1515
const absBase = resolve(baseDir);
1616
const absTarget = resolve(targetPath);
17-
if (!absTarget.startsWith(absBase + '/') && absTarget !== absBase) {
17+
if (!absTarget.startsWith(absBase + sep) && absTarget !== absBase) {
1818
throw new Error(`Provided log directory is outside the allowed base directory: ${absBase}`);
1919
}
2020
return absTarget;

0 commit comments

Comments
 (0)