fix(java-spring): resolve CodeQL regex and redirect findings#118
Merged
Conversation
Escape user-supplied genre values before regex compilation and validate trailing-slash redirect targets to prevent open-redirect patterns. Co-authored-by: Cursor <cursoragent@cursor.com>
3 tasks
There was a problem hiding this comment.
Pull request overview
Remediates two CodeQL findings in the Java Spring MFlix server by (1) hardening genre filtering against regex injection and (2) preventing unvalidated redirects in the trailing-slash redirect filter.
Changes:
- Escape user-provided
genrewithPattern.quote()before compiling a case-insensitive regex. - Validate redirect path and query string before writing the
Locationheader for 308 redirects.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| mflix/server/java-spring/src/main/java/com/mongodb/samplemflix/service/MovieServiceImpl.java | Quotes user-supplied genre input to prevent regex injection in Mongo regex criteria. |
| mflix/server/java-spring/src/main/java/com/mongodb/samplemflix/config/WebMvcConfig.java | Adds path/query validation to trailing-slash redirects to mitigate open-redirect / header-injection vectors. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves 2 open CodeQL error findings in the Java Spring MFlix server by hardening genre regex filtering and trailing-slash redirects.
Changes
MovieServiceImpl): wrap user-supplied genre withPattern.quote()before case-insensitive matchingWebMvcConfig): validate redirect path/query before setting theLocationheader (reject//,://, backslashes, null bytes, CRLF)Testing
./mvnw test— 88/89 passed locally (1 integration test failed due to Atlas FTS index quota, unrelated to this change)Related
Made with Cursor