JS: Handle Next.js files named 'page' or 'route'#20916
Merged
asgerf merged 8 commits intogithub:mainfrom Jan 14, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in the Next.js model to properly detect server-side taint sources in files named route.ts or page.tsx/.jsx that appear outside the traditional api and pages folders, specifically within the app directory structure used by Next.js 13+ App Router.
Key Changes
- Refactored folder resolution predicates to support recursive traversal of
appandpagesdirectories - Extended
getAPagesModule()to recognize files namedpageanywhere within the app folder hierarchy - Enhanced
NextAppRouteHandlerto recognize files namedrouteanywhere within the app folder hierarchy
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| javascript/ql/lib/semmle/javascript/frameworks/Next.qll | Refactored folder predicates and extended route/page file detection to support Next.js App Router structure |
| javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/app/blah/route.ts | Added test case for route handler in non-api folder |
| javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/app/blah/page.jsx | Added test case for page component with server-side functions in non-pages folder |
| javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/ReflectedXssWithCustomSanitizer.expected | Updated expected test results to include new test cases |
| javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/ReflectedXss.expected | Updated expected test results to include new test cases |
| javascript/ql/src/change-notes/2025-11-26-nextjs-page-route-files.md | Added change note documenting the bug fix |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Napalys Klicius <napalys@github.com>
Napalys
approved these changes
Jan 13, 2026
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.
The Next.js model was missing cases for files named
route.tsorpage.tsoutside thepagesorapifolders.