Repository navigation
feat: olla hardening June 2026 - #173
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughThis PR implements Phase 3 security hardening and concurrency safety: atomic proxy configuration and compute-once endpoint resources, response-header canonicalisation and X-Olla-* stripping, non-proxy request-size enforcement, upstream error-body read caps, request-ID sanitisation, and allocation cleanup in status handlers, with tests. ChangesSecurity & Concurrency Hardening Phase 3
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
internal/adapter/proxy/olla/service.go (1)
69-69: ⚡ Quick winAdd comment explaining why atomic configuration is needed.
The
atomic.Pointer[Configuration]field lacks a comment explaining the concurrency rationale. Per coding guidelines, comments should explain "why" rather than "what". Consider adding a comment above line 69 explaining that atomicity prevents torn reads during hot config reloads.📝 Suggested comment
// Buffer pool for streaming bufferPool *pool.Pool[*[]byte] transport *http.Transport + // Configuration uses atomic.Pointer to ensure in-flight requests always read + // a complete, consistent snapshot during hot config reloads. configuration atomic.Pointer[Configuration]🤖 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/adapter/proxy/olla/service.go` at line 69, Add a brief "why" comment above the configuration atomic.Pointer[Configuration] field explaining the concurrency rationale: note that the pointer is atomically loaded/stored to allow lock-free, race-free hot configuration reloads and to prevent torn/inconsistent reads across goroutines (rather than describing what atomic.Pointer does); reference the use of atomic.Load/Store semantics and that this choice avoids a mutex for frequent reads while supporting safe swaps during updates.Source: Coding guidelines
🤖 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.
Inline comments:
In `@internal/adapter/proxy/core/common_test.go`:
- Around line 1025-1030: The test currently checks len(vals) with t.Errorf but
then immediately indexes vals[0], which can panic; change the length assertion
to a fatal assertion (use t.Fatalf) or return/stop the test when len(vals) != 1
so you never access vals[0] on an empty slice—update the block around the
len(vals) check in the test (the code that inspects vals and the
"X-Olla-Endpoint" expectation) so the test fails fast before the subsequent
vals[0] comparison.
In `@internal/adapter/security/request_size_limit.go`:
- Around line 185-193: The chunked-body overflow branch in request_size_limit.go
logs and returns without recording the violation, so update the overflow
handling blocks (the one inside the readErr != nil branch around the
sv.logger.Warn call and the similar branch between lines 205-238) to also call
the metrics recording function used elsewhere (recordViolation /
SecurityMetricsService.recordViolation) with the same contextual info (request r
and a "body_too_large" or equivalent reason) before writing the HTTP 413
response; ensure you call the same helper used by other size-limit rejects so
these chunked overflows are captured in SecurityMetricsService.
---
Nitpick comments:
In `@internal/adapter/proxy/olla/service.go`:
- Line 69: Add a brief "why" comment above the configuration
atomic.Pointer[Configuration] field explaining the concurrency rationale: note
that the pointer is atomically loaded/stored to allow lock-free, race-free hot
configuration reloads and to prevent torn/inconsistent reads across goroutines
(rather than describing what atomic.Pointer does); reference the use of
atomic.Load/Store semantics and that this choice avoids a mutex for frequent
reads while supporting safe swaps during updates.
🪄 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
Run ID: a176c35b-9d45-436c-b6dd-f7083f7d8be7
📒 Files selected for processing (32)
internal/adapter/proxy/core/base.gointernal/adapter/proxy/core/common.gointernal/adapter/proxy/core/common_test.gointernal/adapter/proxy/olla/benchmark_url_building_test.gointernal/adapter/proxy/olla/service.gointernal/adapter/proxy/olla/service_concurrency_test.gointernal/adapter/proxy/olla/service_leak_test.gointernal/adapter/proxy/olla/service_preserve_path_test.gointernal/adapter/proxy/olla/service_retry.gointernal/adapter/proxy/olla/service_transport_test.gointernal/adapter/proxy/olla/service_url_test.gointernal/adapter/proxy/olla/streaming_helpers.gointernal/adapter/security/factory.gointernal/adapter/security/request_size_limit.gointernal/adapter/security/request_size_limit_test.gointernal/adapter/unifier/lifecycle_unifier.gointernal/app/handlers/application.gointernal/app/handlers/handler_status.gointernal/app/handlers/handler_status_models.gointernal/app/handlers/handler_status_models_test.gointernal/app/handlers/handler_status_race_test.gointernal/app/handlers/handler_translation.gointernal/app/handlers/handler_translation_security_test.gointernal/app/handlers/server.gointernal/app/middleware/logging.gointernal/app/middleware/logging_test.gointernal/app/services/http.gointernal/core/constants/security.gointernal/core/domain/endpoint.gointernal/core/domain/json_safety_test.gointernal/router/registry.gointernal/router/registry_security_test.go
💤 Files with no reviewable changes (3)
- internal/adapter/unifier/lifecycle_unifier.go
- internal/adapter/proxy/core/base.go
- internal/app/handlers/server.go
…r test CodeRabbit pickup: the chunked-body 413 path was the only size-limit rejection that didn't feed SecurityMetricsService, so those rejects were invisible. Route it through recordViolation like every other path. Also swap a t.Errorf for t.Fatalf so the header test fails fast instead of panicking on an empty slice.
Some hardening of Olla based on reviews, and todo's from last couple of months + using Fable 5 - though quite a number were not actual issues.
Fixes
Security
Cleanup
read.
Important changes of existing behaviour and user awareness:
Summary by CodeRabbit
New Features
Bug Fixes
Security
Tests