[Bug] isAllowedClient() only checks the first valid CIDR (fixes #105)#106
Conversation
WalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
cmd/socket-proxy/handlehttprequest.go (1)
89-92: Add a regression test for the multi-entry allow list.This loop fix looks right, but there is still no coverage for the case where Line 89 misses one CIDR and a later
AllowFromentry should match. Please add a small table-driven test for something like["10.0.0.0/24", "192.168.1.0/24"]with a192.168.1.xclient so this bug does not creep back in.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@cmd/socket-proxy/handlehttprequest.go` around lines 89 - 92, Add a table-driven unit test that exercises the multi-entry AllowFrom check so we cover the case where the first CIDR does not match but a later one does: create a test (e.g. TestHandleHTTPRequestAllowListMultiEntry) that supplies AllowFrom = ["10.0.0.0/24", "192.168.1.0/24"] and a client IP like "192.168.1.5" and assert the check returns allowed; ensure the test hits the code path using allowedIPNet.Contains over the AllowFrom list so a non-match on the first entry and a match on a later entry is validated and cannot regress.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@cmd/socket-proxy/handlehttprequest.go`:
- Around line 89-92: Add a table-driven unit test that exercises the multi-entry
AllowFrom check so we cover the case where the first CIDR does not match but a
later one does: create a test (e.g. TestHandleHTTPRequestAllowListMultiEntry)
that supplies AllowFrom = ["10.0.0.0/24", "192.168.1.0/24"] and a client IP like
"192.168.1.5" and assert the check returns allowed; ensure the test hits the
code path using allowedIPNet.Contains over the AllowFrom list so a non-match on
the first entry and a match on a later entry is validated and cannot regress.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f4ac3da2-6602-4857-8e33-5cc3e6809ec5
📒 Files selected for processing (1)
cmd/socket-proxy/handlehttprequest.go
see #105
Summary by CodeRabbit