codefloe/forgejo-codefloe
Watch
4
12
Fork
You've already forked forgejo-codefloe
0

fix: harden outbound HTTP clients with timeouts and bounded reads #62

Merged
pat-s merged 1 commit from t3code/http-client-hardening into v16.0/forgejo-codefloe 2026-07-28 17:10:21 +00:00
Owner

Addresses the HTTP Requests section of #19.

External API calls previously used http.DefaultClient (which has no timeout) and read responses without bound, so a stalled or misbehaving endpoint could hang a request indefinitely. These are localized changes to stable modules, so they carry little risk of conflicting with future upstream merges.

Changes

  • Timeouts (P0): the reCAPTCHA, Turnstile, hCaptcha and HaveIBeenPwned clients now use a client with a 10s timeout instead of the timeout-less http.DefaultClient.
  • Connection pooling (P1): the update checker reuses a single pooled client instead of building a fresh client and transport on every call.
  • Unbounded response reading (P1): the reCAPTCHA, Turnstile and update-checker response reads are wrapped in an io.LimitReader.
  • Context propagation (P2): the update checker and ActivityPub requests now carry the caller's context and are cancelled when it is done.

Verification

  • go build / go vet on all touched packages
  • go test ./modules/hcaptcha/... ./modules/auth/password/pwn/...
  • gofmt / gofumpt -extra clean

Closes the four HTTP checkboxes in #19.

Addresses the **HTTP Requests** section of #19. External API calls previously used `http.DefaultClient` (which has no timeout) and read responses without bound, so a stalled or misbehaving endpoint could hang a request indefinitely. These are localized changes to stable modules, so they carry little risk of conflicting with future upstream merges. ## Changes - **Timeouts (P0):** the reCAPTCHA, Turnstile, hCaptcha and HaveIBeenPwned clients now use a client with a 10s timeout instead of the timeout-less `http.DefaultClient`. - **Connection pooling (P1):** the update checker reuses a single pooled client instead of building a fresh client and transport on every call. - **Unbounded response reading (P1):** the reCAPTCHA, Turnstile and update-checker response reads are wrapped in an `io.LimitReader`. - **Context propagation (P2):** the update checker and ActivityPub requests now carry the caller's context and are cancelled when it is done. ## Verification - `go build` / `go vet` on all touched packages - `go test ./modules/hcaptcha/... ./modules/auth/password/pwn/...` - `gofmt` / `gofumpt -extra` clean Closes the four HTTP checkboxes in #19.
pat-s force-pushed t3code/http-client-hardening from ba4df35822
Some checks failed
testing / backend-checks (pull_request) Has been cancelled
testing / frontend-checks (pull_request) Has been cancelled
testing / test-unit (pull_request) Has been cancelled
testing / test-e2e (pull_request) Has been cancelled
testing / test-remote-cacher (redis) (pull_request) Has been cancelled
testing / test-remote-cacher (valkey) (pull_request) Has been cancelled
testing / test-remote-cacher (garnet) (pull_request) Has been cancelled
testing / test-mysql (pull_request) Has been cancelled
testing / test-pgsql (pull_request) Has been cancelled
testing / test-sqlite (pull_request) Has been cancelled
to 777d3f5581
All checks were successful
testing / backend-checks (pull_request) Successful in 8m2s
testing / frontend-checks (pull_request) Successful in 1m4s
testing / test-e2e (pull_request) Successful in 25m25s
testing / test-mysql (pull_request) Successful in 30m3s
testing / test-unit (pull_request) Successful in 8m29s
testing / test-pgsql (pull_request) Successful in 51m1s
testing / test-sqlite (pull_request) Successful in 49m19s
testing / test-remote-cacher (redis) (pull_request) Successful in 1m13s
testing / test-remote-cacher (valkey) (pull_request) Successful in 1m17s
testing / test-remote-cacher (garnet) (pull_request) Successful in 1m16s
issue-labels / backporting (pull_request_target) Has been skipped
milestone / set (pull_request_target) Has been skipped
2026-07-28 14:18:32 +00:00
Compare
pat-s scheduled this pull request to auto merge when all checks succeed 2026-07-28 14:41:58 +00:00
pat-s merged commit 75e676d1f4 into v16.0/forgejo-codefloe 2026-07-28 17:10:21 +00:00
pat-s deleted branch t3code/http-client-hardening 2026-07-28 17:10:28 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
codefloe/forgejo-codefloe!62
No description provided.