Repository navigation
fix: allowlist order_by and direction on list queries (EN-229) - #5
Merged
Merged
Conversation
OrderClause joined order_by and order into ORDER BY unchecked. It now takes the columns a query may sort by and accepts only asc or desc, falling back to the query's default otherwise. The programs overview and class outcomes queries, which bypassed it, and the raw-SQL attendance roster now go through it. Ported from unlocked-core ea045a9e, which EN-207's move dropped.
carddev81
approved these changes
Nov 9, 2026
carddev81
left a comment
Contributor
There was a problem hiding this comment.
good to go, tested good.
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.
Pre-Submission PR Checklist
feat:,fix:,docs:...); a squash merge lands under the PR title, and both become the changelogDescription of the change
OrderClausejoined the request'sorder_byandorderintoORDER BYunchecked, and three queries bypassed it entirely. This portsfeat:,fix:,docs:...); a squash merge lands under the PR title, and both become the changelogDescription of the change
OrderClausejoined the request'sorder_byandorderintoORDER BYunchecked, and three queries bypassed it entirely. This ports the fix from unlocked-coreea045a9e, which was dropped when EN-207 moved Programs out of core.OrderClause(fallback, allowed ...string)ininternal/models/query_context.goreturns<order_by> <dir>only whenorder_byis inallowedand the direction isascordesc(case-insensitive;ascwhen absent). Anything else returnsfallback.internal/database/order_columns.goholds each list query's allowedorder_byvalues, and everyOrderClausecall site passes its list (programs, overview, class details, class history, user programs, enrollments, attendees).OrderBy + " " + Order) and the class outcomes (Order(args.OrderBy), now defaulting tomonths.month asc).GetEnrollmentsWithAttendanceForEventbuilds itsORDER BYwithrosterOrder: name sorts only, elsee.id ASC.internal/models/order_clause_test.go(direction and allowlist cases) andinternal/database/order_clause_test.go(each store query with a hostileorder_byororderis built with its default order and no payload; the roster's order; the sort keys the frontend sends stay allowed).Behavior change: an
order_byoutside a query's list falls back to that query's default instead of reaching the database. Class outcomes now honororderand default tomonths.month asc.EN-229 also needs UnlockedLabs/unlocked-core#1294 (core users lists) and UnlockedLabs/unlocked-provider-platforms#4 (
getOutcomesForUser).Release
fix(patch bump).