Repository navigation
fix(id-pg): validate allowlist names at construction, refuse unsafe projection columns (#14502) - #14541
Merged
developing-today-fleet[bot] merged 1 commit intoNov 24, 2026
Conversation
…rojection columns (#14502) Follow-up to #14391 (PR #14497). The filter/order path refused reserved or non-identifier columns at translate time, but the projection path was unchecked: resolve_projection joined declared column names raw into the select value, and CollectionAllowlist accepted any string as a declared column name. - allowlist.rs: CollectionAllowlist::validate() refuses a relation that is not a plain identifier, a declared column that is not a usable field name (plain identifier, not a reserved PostgREST parameter name), and a unique_key entry that is not a declared column. Registration (#13758) calls it when an allowlist is built. - translate.rs: Translator::try_new, a Result-returning constructor that validates every collection at construction. - translate.rs: defense in depth at translate time — resolve_projection refuses (field_unsupported) when a declared column fails is_usable_field_name, in both the star expansion and an explicit select list; step 8 also refuses a unique-key column that is not a usable field name, since effective_ordering renders it raw into the order parameter and the keyset or group. Tests: cargo test -p id-pg green (19 unit + 2 property + 15 refusal-table), including new validate() tests (a,b refused, or refused, plain accepted), star and explicit projection refusal for a declared x(y), try_new accept/refuse, and the pre-existing withheld_and_unknown_columns_produce_identical_bodies.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 25 minutes. View limit details
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. |
developing-today-fleet
Bot
deleted the
queue/iw199-14502-allowlist-validate
branch
November 24, 2026 18:38
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.
Closes #14502. Follow-up to #14391 (PR #14497, merged 2026-11-24T18:35:16Z as
dac3cb57; this branch is rebased onto that merge).What
PR #14497 refused reserved or non-identifier filter/order columns at translate time, but the projection path was unchecked:
resolve_projectionexpandedselectagainst the declared columns and joined the names raw into theselectvalue, andCollectionAllowlistaccepted any string as a declared column name — a declareda,b,x(y), ororlanded raw in the request.Change
allowlist.rs:CollectionAllowlist::validate() -> Result<(), String>— relation must be a plain identifier; every declared column must satisfyis_usable_field_name(plain identifier, not a reserved PostgREST parameter name); everyunique_keyentry must be a declared column. The doc comment states which names are rejected and why. Registration (id: impl: Postgres HTTP adapter registration and owner config (from #5805) #13758) calls this when an allowlist is built.translate.rs:Translator::try_new— a Result-returning constructor that validates every collection at construction, so a bad config never reaches a request. (Translator::newstays infallible for already-validated sets; translate-time refusals below apply regardless.)translate.rsdefense in depth:resolve_projectionrefuses withfield_unsupportedwhen a declared column failsis_usable_field_name— in the star/empty expansion (viaexpand_declared) and in an explicit select list — so noselectparameter is emitted. Step 8 also refuses a unique-key column that is not a usable field name, sinceeffective_orderingrenders it raw intoorderand the keysetorgroup. All refusals are the samefield_unsupportedshape as an undeclared column, so refusal bodies stay byte-identical for withheld and unknown columns.Tests
cargo test -p id-pginpkgs/id(laptop worktree; code CI runs on main only): 19 unit + 2 property + 15 refusal-table, all pass;cargo fmtclean. (cargo clippy -p id-pgfails on this host before reaching the crate — E0514, serde built by an incompatible rustc, the same environment failure PR #14497's body records; it reproduces with a fresh target dir and is not a code finding.) New tests:validate()refuses declareda,b, refuses declaredor, refuses a non-identifier relation, refuses an undeclared unique-key entry, accepts a plain collection.select *read against a collection declaringx(y)is refused asfield_unsupported; same for an explicitselect x(y).try_newaccepts a valid allowlist and refuses an unvalidated one.withheld_and_unknown_columns_produce_identical_bodiesstill passes.Queue record: task 23612 (repo-health-code-pilot), lane ITEM-WORK-199.
{ "direct_parent": null, "links": [], "lineage": { "design": null, "roadmap_item": null, "priority": null }, "pm_meta": 1, "provenance": { "queue_id": null, "scheduled_start": null, "picked_up_at": null, "work_started_at": null, "created_at": "2026-11-24T18:37:31Z", "session_id": null, "lane": null, "host": "amd", "worktree": "/home/user/wt-lane-iw199-14502", "model": null, "lane_start_issues": [], "workspace_ref": { "kind": "worktree", "id": "/home/user/wt-lane-iw199-14502", "repo": "developing-today/code", "branch": "queue/iw199-14502-allowlist-validate", "sha": "a332cb3338b90d981cdb26ea92107c1b680b8320" }, "auth_subject": "oc-code-02", "stamped_by": "fleet 0.1.0 (native)" } }Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.