🍱 reduce complexity and set the remediationHeader to 'challenge' instead of decision.Action

This commit is contained in:
maxlerebourg committed 2026-09-12 11:41:15 +02:00
1 parent bf6709c048
commit c8d7751878
2 files changed
+3 -11

No files matched your search

+1 -1
View File
@@ -428,7 +428,7 @@ make run
- RemediationHeadersCustomName
- string
- default: ""
- Name of the header you want in response when request are handled by plugin (possible value of the header `ban`, `captcha` or `solved-captcha`)
- Name of the header you want in response when request are handled by plugin (possible value of the header `ban`, `challenge`, `captcha` or `solved-captcha`)
- ForwardedHeadersCustomName
- string
- default: "X-Forwarded-For"
+2 -10
View File
@@ -531,21 +531,13 @@ func (bouncer *Bouncer) handleAppsecResponseServeHTTP(rw http.ResponseWriter, re
rw.Header().Add("Set-Cookie", cookie)
}
if bouncer.remediationCustomHeader != "" {
rw.Header().Set(bouncer.remediationCustomHeader, decision.Action)
}
if rw.Header().Get("Content-Type") == "" && bouncer.banTemplateContentType != "" {
rw.Header().Set("Content-Type", bouncer.banTemplateContentType)
rw.Header().Set(bouncer.remediationCustomHeader, "challenge")
}
status := decision.HTTPStatus
if status == 0 {
if status == 0 || status < 100 || status > 999 {
status = bouncer.remediationStatusCode
}
if status < 100 || status > 999 {
status = bouncer.remediationStatusCode
}
rw.WriteHeader(status)
if req.Method == http.MethodHead || decision.UserBodyContent == "" {