Simplify df.grant_usage/df.revoke_usage privilege helpers#242
Merged
Conversation
Drop the explicit per-function EXECUTE allowlist from df.grant_usage() and make df.revoke_usage() symmetric with it. Schema USAGE on df is the real access gate for ordinary df.* functions, so the helpers now manage schema USAGE, the table privileges, and EXECUTE only on the sensitive functions (df.http, df.grant_usage, df.revoke_usage). Function signatures are unchanged and existing privileges are unaffected. Changes: - src/lib.rs: simplified fresh-install bodies. - sql/pg_durable--0.2.3--0.2.4.sql: CREATE OR REPLACE both helpers so pre-existing installs converge with fresh 0.2.4 installs. - scripts/run-pgspot.sh: allow the two upgrade-script CREATE OR REPLACE PS002 findings (schema-qualified, scoped to these functions). - docs/upgrade-testing.md: v0.2.3 -> v0.2.4 upgrade notes. - CHANGELOG.md: 0.2.4 entry (#242). - tests/e2e/sql/18_delegated_grants.sql: updated expectations. - USER_GUIDE.md: refreshed grant/revoke documentation.
4844589 to
e53a7a1
Compare
This was referenced Jun 18, 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.
Summary
Rationalizes the
df.grant_usage()/df.revoke_usage()privilege helpers for the unreleased v0.2.3, removing defensive code that PostgreSQL already handles and making the two functions symmetric.Changes
grant_usageGRANT EXECUTEallowlist. Ordinarydf.*functions keep PostgreSQL's defaultPUBLIC EXECUTE, soUSAGE ON SCHEMA dfis the single access gate. Only the sensitive functions (df.http,df.grant_usage,df.revoke_usage) — which havePUBLIC EXECUTErevoked at install time — are granted explicitly.GRANT; granting toPUBLICis a deliberate admin choice).revoke_usagegrant_usage(Option A): undoes only whatgrant_usagegrants.sql/pg_durable--0.2.2--0.2.3.sql): sameCREATE OR REPLACEbodies assrc/lib.rs.18_delegated_grants.sql): adds schema/HTTP assertions (5b), asserts loss of schemaUSAGEafter revoke (8), and verifies self-revoke is a harmless no-op (10).USER_GUIDE.md— fixes the inaccurate self-revoke "safety measure" claim, notes thatdf.grant_usage('public')grants cluster-wide, and trims the stale per-function manual-grants list.docs/upgrade-testing.md— documents both simplifications.pgspot gate
The 0.2.2 → 0.2.3 upgrade script is the first non-excluded upgrade script that defines functions. Scanned standalone (without the
CREATE SCHEMA dfthat the install SQL emits, so pgspot can't provedfis extension-owned), the helper bodies tripped PS001/PS005/PS016.grant_usage/revoke_usagebodies —pg_catalog.format(...),OPERATOR(pg_catalog.||), andSET search_path = pg_catalog, pg_temp— applied byte-identically insrc/lib.rsand the upgrade script. The install SQL stays clean because pgspot suppresses those findings via the emittedCREATE SCHEMA df.CREATE OR REPLACE) for the two exact function signatures inscripts/run-pgspot.sh. PostgreSQL 14.5+ blocks theCREATE OR REPLACEattack inside extension scripts, so this is safe.Upgrade & Migration
Testing
cargo fmt -p pg_durable -- --check✅cargo build --features pg17✅ (only the pre-existingextract_hostdead-code warning)./scripts/test-e2e-local.sh 18_delegated_grants --verbose✅ (1 passed, 0 failed)scripts/run-pgspot.sh sql/pg_durable--0.2.2--0.2.3.sql✅ (gate passes; only the two allowlisted PS002 findings)