Merge pull request #10 from Pet3cy/security-fix-sensitive-data-exposure-logs-8322086360319645856

🔒 [security fix] Fix sensitive data exposure in MCP Inference logs
This commit is contained in:
Pet3cy
2026-02-24 18:42:50 +01:00
committed by GitHub
6 changed files with 25 additions and 27 deletions
+2 -2
View File
@@ -143,9 +143,9 @@ function validateAndMaskHeaders(headers: Record<string, unknown>): Record<string
const lowerName = name.toLowerCase()
const isSensitive = sensitivePatterns.some(pattern => lowerName.includes(pattern))
if (isSensitive) {
core.info(`Custom header added: ${name}: ***MASKED***`)
core.debug(`Custom header added: ${name}: ***MASKED***`)
} else {
core.info(`Custom header added: ${name}: ${stringValue}`)
core.debug(`Custom header added: ${name}: ${stringValue}`)
}
}
+4 -6
View File
@@ -76,7 +76,7 @@ export async function simpleInference(request: InferenceRequest): Promise<string
const response = await chatCompletion(client, chatCompletionRequest, 'simpleInference')
const modelResponse = response.choices[0]?.message?.content
core.info(`Model response: ${modelResponse || 'No response content'}`)
core.debug(`Model response: ${modelResponse || 'No response content'}`)
return modelResponse || null
}
@@ -131,7 +131,7 @@ export async function mcpInference(
const modelResponse = assistantMessage?.content
const toolCalls = assistantMessage?.tool_calls
core.info(`Model response: ${modelResponse || 'No response content'}`)
core.debug(`Model response: ${modelResponse || 'No response content'}`)
messages.push({
role: 'assistant',
@@ -196,16 +196,14 @@ async function chatCompletion(
try {
response = JSON.parse(response)
} catch (e) {
const preview = response.slice(0, 400)
throw new Error(
`${context}: Chat completion response was a string and not valid JSON (${(e as Error).message}). Preview: ${preview}`,
`${context}: Chat completion response was a string and not valid JSON (${(e as Error).message})`,
)
}
}
if (!response || typeof response !== 'object' || !('choices' in response)) {
const preview = JSON.stringify(response)?.slice(0, 800)
throw new Error(`${context}: Unexpected response shape (no choices). Preview: ${preview}`)
throw new Error(`${context}: Unexpected response shape (no choices)`)
}
return response as OpenAI.Chat.Completions.ChatCompletion
+2 -2
View File
@@ -96,7 +96,7 @@ export async function connectToGitHubMCP(token: string, toolsets?: string): Prom
* Execute a single tool call via GitHub MCP
*/
export async function executeToolCall(githubMcpClient: Client, toolCall: ToolCall): Promise<ToolResult> {
core.info(`Executing GitHub MCP tool: ${toolCall.function.name} with args: ${toolCall.function.arguments}`)
core.debug(`Executing GitHub MCP tool: ${toolCall.function.name} with args: ${toolCall.function.arguments}`)
try {
const args = JSON.parse(toolCall.function.arguments)
@@ -106,7 +106,7 @@ export async function executeToolCall(githubMcpClient: Client, toolCall: ToolCal
arguments: args,
})
core.info(`GitHub MCP tool ${toolCall.function.name} executed successfully`)
core.debug(`GitHub MCP tool ${toolCall.function.name} executed successfully`)
return {
tool_call_id: toolCall.id,