Skip to content

id-pg: validate allowlist names at construction, refuse unsafe projection columns (#14502) - #14540

Closed
dezren39 wants to merge 1 commit into
mainfrom
lane/code-g/23612-id-pg-allowlist-validate
Closed

dezren39 wants to merge 1 commit into
mainfrom
lane/code-g/23612-id-pg-allowlist-validate

Conversation

@dezren39

@dezren39 dezren39 commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #14391 (merged as dac3cb5, PR #14497).

Declared allowlist names were never validated: a declared column containing a comma, parenthesis, quote, or whitespace — or a reserved name like or — was joined raw into the PostgREST select parameter by resolve_projection, changing the shape of the select list the source parses.

Fix:

  • CollectionAllowlist::validate() in allowlist.rs (relation must be a plain identifier; every declared column must satisfy is_usable_field_name; every unique_key entry must be a declared column), with a doc comment stating what is rejected and why.
  • Invoked at construction time: Translator::new carries it as a debug assertion plus a documented construction contract for the id: impl: Postgres HTTP adapter registration and owner config (from #5805) #13758 registration path (which owns the fallible path).
  • Defense in depth: resolve_projection refuses field_unsupported on every projection path (including * expansion) when any declared column is unsafe, so no select parameter is emitted for the refused query.
  • Existing fix(id-pg): refuse reserved or non-identifier filter/order fields (#14391) #14497 backstop tests that deliberately build invalid configs now construct the struct literally (unchecked_translator), since they intentionally violate the construction contract.

Proof: cargo test -p id-pg green — 16 unit (6 new), 2 property, 15 refusal-table (incl. unchanged withheld_and_unknown_columns_produce_identical_bodies); cargo fmt --check clean.

Closes #14502.

{
  "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:36:58Z",
    "session_id": "ses_e5df148df67ffe6ESbnQcU7NC7",
    "lane": null,
    "host": "amd",
    "worktree": "/home/user/git/code-g-23612",
    "model": null,
    "lane_start_issues": [],
    "workspace_ref": {
      "kind": "worktree",
      "id": "/home/user/git/code-g-23612",
      "repo": "developing-today/code",
      "branch": "lane/code-g/23612-id-pg-allowlist-validate",
      "sha": "461aacb43cd4eab533a9f2ff25bc2559a9924eec"
    },
    "auth_subject": "oc-code-02",
    "stamped_by": "fleet 0.1.0 (native)"
  }
}

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…tion columns (#14502)

CollectionAllowlist::validate() rejects non-identifier relations,
declared columns that fail is_usable_field_name, and unique_key
entries outside the declared set. Translator::new enforces it as a
debug assertion (documented construction contract for #13758
registration); resolve_projection refuses field_unsupported on any
projection path when a declared column is unsafe, so no select
parameter is ever emitted for such a query.

Tests: 6 new unit tests (validate accepts/rejects, select-* refusal);
withheld/unknown identical-bodies test unchanged and green.
@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You'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 26 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0af00cc1-6ffa-4848-8cdc-888d389e0bd6
Commits

Reviewing files that changed from the base of the PR and between 152a81a and 461aacb.

Files selected for processing: 2

  • pkgs/id/crates/id-pg/src/allowlist.rs
  • pkgs/id/crates/id-pg/src/translate.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@developing-today-fleet

Copy link
Copy Markdown
Contributor

Closing as superseded by PR #14541 (merged 2026-11-24T18:38:02Z, 9a7c7d62), which implements the same fix for #14502.

The two PRs were opened a minute apart by two lanes working the same queue task (23612). A §8 salvage diff of this PR against the merged one is recorded on #14502: validate() is functionally identical, the construction-time call differs only in which of the issue's two sanctioned forms it takes (debug assertion here, Result-returning Translator::try_new in #14541), and the projection refusal coverage differs in strictness, not in any acceptance criterion. Nothing in this PR is missing from main, so nothing is ported.

Thank you for the parallel work — the record on #14502 carries the full comparison.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

id-pg: validate allowlist names at construction and refuse unsafe projection columns (follow-up to #14391)

1 participant