Skip to content

Commit 7aa5535

Browse files
authored
Merge pull request #127 from soulteary/fix/G705-XSS-via-taint-analysis
fix: XSS via taint analysis
2 parents 82040f5 + d6d79fc commit 7aa5535

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

internal/server/server.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ func executeCapturingHook(w http.ResponseWriter, ctx context.Context, matchedHoo
464464
logger.Errorf("[%s] hook %s execution failed (command: %s): %v, output captured", requestID, hookID, matchedHook.ExecuteCommand, err)
465465
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
466466
w.WriteHeader(http.StatusInternalServerError)
467+
// #nosec G705 -- response is command stdout/stderr, returned as text/plain; not interpreted as HTML
467468
_, _ = fmt.Fprint(w, response)
468469
} else {
469470
// 为了保持向后兼容性,使用特定的错误消息
@@ -484,10 +485,12 @@ func executeCapturingHook(w http.ResponseWriter, ctx context.Context, matchedHoo
484485
// 记录审计日志:执行成功
485486
audit.LogHookExecuted(requestID, hookID, ip, userAgent, durationMS)
486487

488+
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
487489
// Check if a success return code is configured for the hook
488490
if matchedHook.SuccessHttpResponseCode != 0 {
489491
writeHttpResponseCode(w, requestID, matchedHook.ID, matchedHook.SuccessHttpResponseCode)
490492
}
493+
// #nosec G705 -- response is command stdout/stderr, returned as text/plain; not interpreted as HTML
491494
_, _ = fmt.Fprint(w, response)
492495
}
493496
}

0 commit comments

Comments
 (0)