You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix CI lint failures (gosec G710) and bump dependencies (#258)
golangci-lint's latest release added gosec rule G710 (open redirect via
taint analysis), which broke the "Testing push" workflow on master and
on every dependabot branch. Two of the three findings were legitimate:
a request path starting with "//" would produce a scheme-relative
Location header, redirecting to another host. Fix by collapsing
duplicate leading slashes before redirecting, and suppress the
remaining intentional case (operator-configured redirect rules may
target external URLs by design).
Also:
- Bump github.com/yuin/goldmark 1.8.2 -> 1.8.4
- Bump golang.org/x/crypto 0.49.0 -> 0.52.0
- Bump github.com/go-chi/chi/v5 5.2.5 -> 5.3.1
- Bump github.com/klauspost/compress 1.18.6 -> 1.19.0
- Bump github.com/go-playground/validator/v10 10.30.2 -> 10.30.3
- Bump actions/checkout v6 -> v7 in all workflows
- Migrate gomodguard -> gomodguard_v2 (deprecation warning)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
// Collapse duplicate leading slashes so the target can't be
22
+
// interpreted by browsers as a scheme-relative URL ("//evil.com/").
23
+
ifstrings.HasPrefix(target, "//") {
24
+
target="/"+strings.TrimLeft(target, "/")
25
+
}
26
+
27
+
http.Redirect(w, r, target, statusCode) //nolint:gosec // target is derived from the request path with leading slashes collapsed, so it is always same-origin
http.Redirect(w, r, destination, statusCode)//nolint:gosec // destinations come from the operator-provided redirects file; redirecting to external URLs is an intended feature
// Collapse duplicate leading slashes so the target can't be
79
+
// interpreted by browsers as a scheme-relative URL ("//evil.com/").
80
+
ifstrings.HasPrefix(target, "//") {
81
+
target="/"+strings.TrimLeft(target, "/")
82
+
}
83
+
84
+
http.Redirect(w, r, target, http.StatusMovedPermanently) //nolint:gosec // target is derived from the request path with leading slashes collapsed, so it is always same-origin
0 commit comments