Skip to content

Commit cd47e5f

Browse files
Potential fix for code scanning alert no. 122: Log entries created from user input
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 5422c06 commit cd47e5f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pkg/ollama/handler.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ func NewHandler(log logging.Logger, modelManager *models.Manager, scheduler *sch
5050

5151
// ServeHTTP implements the http.Handler interface
5252
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
53-
h.log.Infof("Ollama API request: %s %s", r.Method, r.URL.Path)
53+
safeMethod := strings.ReplaceAll(strings.ReplaceAll(r.Method, "\n", ""), "\r", "")
54+
safePath := strings.ReplaceAll(strings.ReplaceAll(r.URL.Path, "\n", ""), "\r", "")
55+
h.log.Infof("Ollama API request: %s %s", safeMethod, safePath)
5456
h.httpHandler.ServeHTTP(w, r)
5557
}
5658

0 commit comments

Comments
 (0)