Fix dependency security and Sonar quality findings#45
Conversation
Co-authored-by: John | Elite Encoder <john@eliteencoder.net>
📝 WalkthroughWalkthroughThe PR refactors registry parsing, orchestrator discovery probing, and resolver merging; removes ChangesDiscovery service refactors
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Co-authored-by: John | Elite Encoder <john@eliteencoder.net>
Co-authored-by: John | Elite Encoder <john@eliteencoder.net>
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/sources/orch_discovery.go (1)
247-248: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winRespect context cancellation when acquiring the semaphore.
If the system is under high load and the context is canceled (e.g., due to a client disconnect or an outer timeout), goroutines waiting to acquire the semaphore will still block until a slot frees up before checking the context in the subsequent HTTP request. Adding a
selectwithctx.Done()prevents goroutines from needlessly piling up.♻️ Proposed refactor
- sem <- struct{}{} + select { + case sem <- struct{}{}: + case <-ctx.Done(): + results.record(nil, uri, ctx.Err()) + return + } defer func() { <-sem }()🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/sources/orch_discovery.go` around lines 247 - 248, Update the semaphore acquisition in the surrounding discovery operation to select between sending on sem and receiving from ctx.Done(), returning or propagating cancellation when the context is canceled. Keep the deferred semaphore release only for goroutines that successfully acquire the slot, and leave the subsequent HTTP request flow unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@internal/sources/orch_discovery.go`:
- Around line 247-248: Update the semaphore acquisition in the surrounding
discovery operation to select between sending on sem and receiving from
ctx.Done(), returning or propagating cancellation when the context is canceled.
Keep the deferred semaphore release only for goroutines that successfully
acquire the slot, and leave the subsequent HTTP request flow unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 3d50d3b1-09ce-4015-ab8d-095d8cdba93c
⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum
📒 Files selected for processing (7)
go.modinternal/httpapi/server.gointernal/query/query.gointernal/resolver/resolve_helpers.gointernal/sources/orch_discovery.gointernal/sources/registry_parser.gointernal/sources/registry_parser_test.go



Summary
RealIPmiddleware so untrusted forwarding headers cannot spoof the logged client addressVerification
go test -race -count=1 ./...go vet ./...go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.12.2 run --timeout=5mgo run golang.org/x/vuln/cmd/govulncheck@latest ./...CGO_ENABLED=0 go build -o /tmp/discoveryd ./cmd/discoverydgofmtand whitespace checksSummary by CodeRabbit