fix: support routine privilege diffs#292
Draft
dilame wants to merge 1 commit into
Draft
Conversation
Track function and procedure EXECUTE ACLs from pg_proc, including PostgreSQL's implicit PUBLIC EXECUTE default, so plans can revoke leaked routine access and grant the declared role-specific access.
Constraint: PostgreSQL stores default routine EXECUTE grants as NULL proacl, so schema fetch must expand ACLDEFAULT('f', owner).
Rejected: Treat has_function_privilege() as the diff source | it reports effective inherited access instead of declarative ACL state.
Confidence: high
Scope-risk: moderate
Directive: Keep routine privilege validation aligned with table privilege validation because privilege statements are skipped when roles are absent in temp DB.
Tested: go test ./... with PostgreSQL 17 server utilities and PostgreSQL 18 pg_dump for --restrict-key support
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.
What changed
Adds schema tracking and migration generation for function/procedure
EXECUTEprivileges.pg_proc, expandingACLDEFAULT('f', proowner)so implicitPUBLIC EXECUTEis visible in the schema model.PrivilegestoFunctionandProcedureschema objects.GRANT/REVOKE EXECUTE ON FUNCTION/PROCEDUREstatements for routine ACL drift.PUBLIC EXECUTEstays revoked.Why
PostgreSQL grants
EXECUTEon functions/procedures toPUBLICby default, often represented asproacl = NULL. Before this change, pg-schema-diff did not model routine ACLs, so it could miss drift where production still allowedPUBLIC EXECUTEbut the declarative schema had revoked it and granted access only to a specific role.Validation
Ran full test suite with PostgreSQL 17 server utilities and PostgreSQL 18
pg_dumpfor--restrict-keysupport:go test ./...