fix: synchronize remotestorage SSRF test-seam swap with atomic pointers - #1274
Merged
Conversation
Test helpers substitute permissive SSRF checks for the duration of a test, then restore the originals in t.Cleanup. Production dial logic reads the active check from inside net.Dialer.Control, which net/http.Transport can invoke on a background goroutine that outlives the synchronous test call that spawned it, so the previous unsynchronized swap/restore raced against that goroutine's read under go test -race. Back the swap with atomic.Pointer instead of plain vars, and consolidate the two previously-duplicated swap/restore implementations onto one shared helper. No production behavior, defaults, or exported signatures change.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
Contributor
✅ Supply Chain Verification Results✅ PASSED 📦 SBOM Summary
🔍 Vulnerability Scan
📎 Artifacts
Generated by Supply Chain Verification workflow • View Details |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
go test -racein CI (surfaced on an unrelated PR, chore(deps): update dependency golangci/golangci-lint to v2.13.1 #1271) caught a genuine data race ininternal/services/remotestorage's SSRF test seam. Confirmed pre-existing ondevelopment, unrelated to that PR.ssrfValidateHost/ssrfValidateDialAddressto permissive no-ops for the duration of a test and restore the originals int.Cleanup. Production dial logic reads the active check from insidenet.Dialer.Control, whichnet/http.Transportcan invoke on a background goroutine that outlives the synchronous test call that spawned it — so the previous unsynchronized swap/restore raced against that goroutine's read.atomic.Pointer[func]instead of plain vars, and consolidates the two previously-duplicated swap/restore implementations onto one sharedswapSSRFValidatorshelper. No production behavior, defaults, or exported signatures change.Test plan
go test -race -run TestWebDAVUploader_InsecureSkipVerify_AllowsSelfSignedCert ./internal/services/remotestorage/... -count=5)DATA RACE, all PASS — reproduced independently twiceTestSwapSSRFValidators_ConcurrentAccess_NoRace(concurrent stress, not just probabilistic-race -count=Nluck)go test -race ./internal/services/remotestorage/... ./internal/services/... -count=2—remotestorageclean, zero DATA RACEgo build ./...,go vet ./internal/services/remotestorage/...cleanmake lint-staticcheck-only— 0 issues;lefthook run pre-commitclean (ran on the real commit)Note
The broader
-racesweep across sibling packageinternal/servicessurfaced a separate, pre-existing test-isolation bug (TestAuthService_RegisterUNIQUE-constraint collision under repeated runs, a nil-pointer panic inTestProxyHostService_DomainNamesRequired). Confirmed viagit stashthat it reproduces identically on unmodifieddevelopmentHEAD — not a race, not caused by this change, out of scope for this single-concern fix. Flagging for a follow-up issue rather than absorbing into this PR.