Skip to content

chore: remove explicit postgres grant for lifecycle state - #1671

Merged
ferhatelmas merged 1 commit into
masterfrom
ferhat/lf-explicit-grant
Nov 6, 2026
Merged

ferhatelmas merged 1 commit into
masterfrom
ferhat/lf-explicit-grant

Conversation

@ferhatelmas

@ferhatelmas ferhatelmas commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

What kind of change does this PR introduce?

chore

What is the current behavior?

Explicit postgres grant was added in migration 76 and 79 for internal lifecycle state.

What is the new behavior?

In hosted version, postgres isn't the owner and these are internal to storage, we don't want users to play with them so remove explicit grant.

Additional context

Related to #1620

@ferhatelmas
ferhatelmas requested a review from a team as a code owner November 6, 2026 12:18
Copilot AI balanced review requested due to automatic review settings November 6, 2026 12:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the lifecycle grant cleanup.

No open issues 🎉

What changed in this PR

This PR removes explicit postgres grants on internal lifecycle state introduced by migrations 76 and 79, while preserving access when postgres is a configured role or owns the object.

Changes:

  • Adds migration 80 to revoke extra grants on two lifecycle tables and two functions.
  • Registers the migration in DBMigration.
  • Adds upgrade coverage for role and ownership safeguards, preservation of service-role grants, and repeated execution.
File Description
src/​test/​lifecycle-migration-upgrade.test.ts Tests grant removal, access safeguards, and repeated execution.
src/​internal/​database/​migrations/​types.ts Registers migration 80.
migrations/​tenant/​0080-revoke-extra-lifecycle-postgres-grants.sql Revokes extra postgres grants while retaining configured-role and owner access.

Review effort: Balanced

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Findings marked 🟡 are optional suggestions and need no follow-up push.

@coveralls

coveralls commented Nov 6, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 42226886497

Coverage remained the same at 87.542%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 15991
Covered Lines: 14438
Line Coverage: 90.29%
Relevant Branches: 10169
Covered Branches: 8463
Branch Coverage: 83.22%
Branches in Coverage %: Yes
Coverage Strength: 1297.55 hits per line

💛 - Coveralls

Signed-off-by: Ferhat Elmas <elmas.ferhat@gmail.com>
@ferhatelmas
ferhatelmas force-pushed the ferhat/lf-explicit-grant branch from 1c2c3dc to 91a514a Compare November 6, 2026 13:36
@ferhatelmas

Copy link
Copy Markdown
Member Author

@claude review always

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This run found no new bugs. The latest revision grants SELECT back to postgres on both lifecycle tables after the REVOKE ALL, which fixes the dump-read concern from my earlier review. This migration changes role privileges on tenant schemas, and the repo's CODEOWNERS covers these paths, so a maintainer should still look at it.

What was reviewed:

  • The early-exit guards in 0080: no postgres role, or postgres configured as super_user or service_role. Also the relowner/proowner checks that skip objects owned by postgres.
  • Whether the function revokes take effect. 0079 already revokes EXECUTE on both functions from PUBLIC, so removing postgres's grant actually removes its access.
  • The DBMigration entry 80, which matches the file number.
Extended reasoning...

The change adds tenant migration 0080, which changes privileges for the postgres role. It narrows table access to SELECT on storage.bucket_lifecycle_states and storage.lifecycle_abandoned_artifacts, and drops EXECUTE on two lifecycle functions. It also registers the migration in types.ts and adds an integration test. The security-sensitive surface is database permissions. The earlier review raised a read-access concern, and the current diff fixes it with GRANT SELECT. Approval is not appropriate because this is a permissions change on every tenant and a CODEOWNERS team owns the whole repository.

@ferhatelmas
ferhatelmas merged commit 6bb2e4c into master Nov 6, 2026
37 checks passed
@ferhatelmas
ferhatelmas deleted the ferhat/lf-explicit-grant branch November 6, 2026 16:34
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.

4 participants