Skip to content

Commit a4add76

Browse files
Copilotdata-douser
andauthored
Fix markdown injection and platform-dependent path tests in prompt handlers
- Add sanitizeForInlineCode() helper to escape backticks and newlines in user-supplied values embedded in markdown code spans - Apply sanitizer to resolvePromptFilePath 'does not exist' warning (filePath and absolutePath) - Apply sanitizer to formatValidationError issue.received display - Fix POSIX path separator assumptions in tests: use basename only ('mydb', 'database') - Rename createSafePromptHandler tests to clarify they validate the handler wrapper, not MCP SDK validation Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com> Agent-Logs-Url: https://github.com/advanced-security/codeql-development-mcp-server/sessions/2660567b-5822-4505-91c2-37fe3ef00f4e
1 parent 214d088 commit a4add76

File tree

4 files changed

+23
-10
lines changed

4 files changed

+23
-10
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64468,6 +64468,9 @@ var SUPPORTED_LANGUAGES = [
6446864468
"ruby",
6446964469
"swift"
6447064470
];
64471+
function sanitizeForInlineCode(value) {
64472+
return value.replace(/`/g, "'").replace(/\r?\n|\r/g, " ");
64473+
}
6447164474
async function resolvePromptFilePath(filePath, workspaceRoot) {
6447264475
if (!filePath || filePath.trim() === "") {
6447364476
return {
@@ -64503,7 +64506,7 @@ async function resolvePromptFilePath(filePath, workspaceRoot) {
6450364506
} catch {
6450464507
return {
6450564508
resolvedPath: absolutePath,
64506-
warning: `\u26A0 **File path** \`${filePath}\` **does not exist.** Resolved to: \`${absolutePath}\``
64509+
warning: `\u26A0 **File path** \`${sanitizeForInlineCode(filePath)}\` **does not exist.** Resolved to: \`${sanitizeForInlineCode(absolutePath)}\``
6450764510
};
6450864511
}
6450964512
return { resolvedPath: absolutePath };
@@ -64599,7 +64602,7 @@ function formatValidationError(promptName, error2) {
6459964602
if (issue2.code === "invalid_enum_value" && "options" in issue2) {
6460064603
const opts = issue2.options.join(", ");
6460164604
lines.push(
64602-
`- **\`${field}\`**: received \`${String(issue2.received)}\` \u2014 must be one of: ${opts}`
64605+
`- **\`${field}\`**: received \`${sanitizeForInlineCode(String(issue2.received))}\` \u2014 must be one of: ${opts}`
6460364606
);
6460464607
} else if (issue2.code === "invalid_type") {
6460564608
lines.push(

0 commit comments

Comments
 (0)