Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (5)
📝 WalkthroughWalkthroughThe PR disables automatic HTTP redirect following across attestation, endpoint, and enrollment HTTP clients by setting Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@internal/attestation/attestation_test.go`:
- Around line 305-332: The test has a data race on the variable
redirectTargetCalled in TestManager_GetNonce_RejectsNonOKStatus because the
server handler goroutine writes it and the test goroutine reads it; change
redirectTargetCalled to a concurrency-safe atomic (e.g. a uint32) and replace
writes in the HTTP handler with sync/atomic.StoreUint32(&redirectTargetCalled,
1) and reads in the test assertion with
sync/atomic.LoadUint32(&redirectTargetCalled) == 1, and add sync/atomic to the
imports; rerun go test -race to verify.
In `@internal/endpoint/endpoint_test.go`:
- Around line 19-20: The test uses a non-thread-safe boolean
redirectTargetCalled that is written in the httptest handler goroutine and read
in the test goroutine; make it atomic by replacing the bool with var
redirectTargetCalled uint32, import "sync/atomic", change the handler write to
atomic.StoreUint32(&redirectTargetCalled, 1), and change reads/asserts to use
atomic.LoadUint32(&redirectTargetCalled) (e.g. assert.Zero(t,
atomic.LoadUint32(&redirectTargetCalled))). Ensure all occurrences in
endpoint_test.go are updated and run go test -race.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: c7011c69-82dc-4bf3-b8ff-a8b0e0d5497f
📒 Files selected for processing (6)
internal/attestation/attestation.gointernal/attestation/attestation_test.gointernal/endpoint/endpoint.gointernal/endpoint/endpoint_test.gointernal/enrollment/enrollment.gointernal/enrollment/enrollment_test.go
jingxiang-z
left a comment
There was a problem hiding this comment.
Before merge, would like to see if go test -race passed.
… and CLI clients The exporter client already has CheckRedirect hardened (#165, #168). This covers the remaining three outbound http.Client instances that still follow redirects by default: - attestation nonce endpoint (also adds status code validation and error-field handling so a non-200 or error response is not silently accepted as a valid nonce) - enrollment endpoint - local CLI agent client (NewAgentHTTPClient, used by status/inject) A compromised backend returning a 302 redirect could bounce these clients into making authenticated requests to internal services. Setting CheckRedirect to return http.ErrUseLastResponse makes the client return the redirect response as-is instead of following it. Signed-off-by: Rodrigo Sampaio Vaz <rvaz@nvidia.com>
30f0bbf to
7d6d5a4
Compare
… and CLI clients [1/5] (#169) Signed-off-by: Rodrigo Sampaio Vaz <rvaz@nvidia.com>
The exporter client already has CheckRedirect hardened (#165, #168). This covers the remaining three outbound http.Client instances that still follow redirects by default:
A compromised backend returning a 302 redirect could bounce these clients into making authenticated requests to internal services. Setting CheckRedirect to return http.ErrUseLastResponse makes the client return the redirect response as-is instead of following it.
Description
Checklist
Summary by CodeRabbit
Bug Fixes
Tests