Restrict shallow ETag filter routes#482
Conversation
|
@copilot add tests that check actual existence of etag header for all desired endpoints and it being absent for the undesired endpoint. |
There was a problem hiding this comment.
Pull request overview
This PR narrows the scope of Spring’s ShallowEtagHeaderFilter so it no longer applies globally (and thus no longer forces response-body buffering) on large/unbounded endpoints like /relay/location/day/{day}, while keeping ETag support for selected smaller routes.
Changes:
- Replace the globally-registered
ShallowEtagHeaderFilterbean with aFilterRegistrationBeanlimited to specific URL patterns. - Add/adjust a Spring context test to assert the filter registration URL patterns.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| backend/src/main/kotlin/org/tormap/config/AppConfig.kt | Registers ShallowEtagHeaderFilter via FilterRegistrationBean and restricts it to a small set of URL patterns. |
| backend/src/test/kotlin/org/tormap/config/SecurityConfigTest.kt | Adds assertions that the filter registration bean exists and is configured with the expected URL patterns. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Agent-Logs-Url: https://github.com/TorMap/tormap/sessions/c1e9774b-a138-41fe-98f2-7167f46f895e Co-authored-by: JuliusHenke <23460202+JuliusHenke@users.noreply.github.com>
Implemented in commit Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Motivation
ShallowEtagHeaderFilterwas being registered as an unrestricted bean which causes Spring to buffer full response bodies for ETag generation and can amplify memory/CPU usage for large public endpoints such as/relay/location/day/{day}.Description
ShallowEtagHeaderFilterbean with aFilterRegistrationBean<ShallowEtagHeaderFilter>so the filter is only applied to explicitly listed small/bounded routes inbackend/src/main/kotlin/org/tormap/config/AppConfig.kt./relay/location/days,/relay/details/relay/*,/relay/details/family/*) to avoid buffering large day-by-day relay responses.backend/src/test/kotlin/org/tormap/config/SecurityConfigTest.ktto assert theFilterRegistrationBeanis registered with the expected URL patterns.Testing
SecurityConfigTestwith Gradle (./gradlew --no-daemon test --tests org.tormap.config.SecurityConfigTest), but the build failed in this environment because the Kotlin Gradle plugin could not be resolved from the plugin portal. (Test not executed.)JAVA_HOMEset to Java 17 to work around a Java parsing issue, but the run still failed due to inability to resolve theorg.jetbrains.kotlin.jvm:1.9.25plugin from the Gradle plugin repository in this environment. (Test not executed.)git diff --check) which reported no whitespace/diff errors on the modified files.Codex Task