MCPcopy Create free account
hub / github.com/github/gh-aw / sanitizeForLog

Function sanitizeForLog

pkg/cli/mcp_server_http.go:19–24  ·  view source on GitHub ↗

sanitizeForLog removes newline and carriage return characters from user input to prevent log injection attacks where malicious users could forge log entries.

(input string)

Source from the content-addressed store, hash-verified

17// sanitizeForLog removes newline and carriage return characters from user input
18// to prevent log injection attacks where malicious users could forge log entries.
19func sanitizeForLog(input string) string {
20 // Remove both \n and \r to prevent log injection
21 sanitized := strings.ReplaceAll(input, "\n", "")
22 sanitized = strings.ReplaceAll(sanitized, "\r", "")
23 return sanitized
24}
25
26// responseWriter wraps http.ResponseWriter to capture the status code.
27type responseWriter struct {

Calls

no outgoing calls