Skip to content

Commit ab9c9e5

Browse files
Copilotdata-douser
andauthored
fix: handle space-separated managed flags in additionalArgs filtering
Replace .filter() with a for-loop that also skips the following value token when a managed flag is supplied in space-separated form (e.g. ['--output', '/override.sarif']) instead of inline form (e.g. ['--output=/override.sarif']). This prevents stray positional arguments from leaking into the CLI invocation. Add test coverage for the space-separated form. Agent-Logs-Url: https://github.com/advanced-security/codeql-development-mcp-server/sessions/fb3b1eea-290e-4eaa-bf2b-26b1521e5a58 Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com>
1 parent 4088c34 commit ab9c9e5

File tree

4 files changed

+101
-21
lines changed

4 files changed

+101
-21
lines changed

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

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57359,16 +57359,25 @@ function registerCLITool(server, definition) {
5735957359
"tuple-counting",
5736057360
"verbosity"
5736157361
]);
57362-
const userAdditionalArgs = queryLogDir ? rawAdditionalArgs.filter((arg) => {
57363-
const m = arg.match(/^--(?:no-)?([^=]+)/);
57364-
if (m && managedFlagNames.has(m[1])) {
57365-
logger.warn(
57366-
`Ignoring "${arg}" from additionalArgs for ${name}: this flag is managed internally. Use the corresponding named parameter instead.`
57367-
);
57368-
return false;
57362+
const userAdditionalArgs = queryLogDir ? (() => {
57363+
const filteredAdditionalArgs = [];
57364+
for (let i = 0; i < rawAdditionalArgs.length; i += 1) {
57365+
const arg = rawAdditionalArgs[i];
57366+
const m = arg.match(/^--(?:no-)?([^=]+)(?:=.*)?$/);
57367+
if (m && managedFlagNames.has(m[1])) {
57368+
logger.warn(
57369+
`Ignoring "${arg}" from additionalArgs for ${name}: this flag is managed internally. Use the corresponding named parameter instead.`
57370+
);
57371+
const hasInlineValue = arg.includes("=");
57372+
if (!hasInlineValue && i + 1 < rawAdditionalArgs.length) {
57373+
i += 1;
57374+
}
57375+
continue;
57376+
}
57377+
filteredAdditionalArgs.push(arg);
5736957378
}
57370-
return true;
57371-
}) : rawAdditionalArgs;
57379+
return filteredAdditionalArgs;
57380+
})() : rawAdditionalArgs;
5737257381
let result;
5737357382
if (command === "codeql") {
5737457383
let cwd;

0 commit comments

Comments
 (0)