Skip to content

cherrypick: add protected database - #25058

Merged
2 commits merged into
matrixorigin:3.0-devfrom
daviszhen:0618-pick-main-to-3.0-b8eae0f
Jun 19, 2026
Merged

2 commits merged into
matrixorigin:3.0-devfrom
daviszhen:0618-pick-main-to-3.0-b8eae0f

Conversation

@daviszhen

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #24954

What this PR does / why we need it:

增加 protected database

@daviszhen
daviszhen requested a review from XuPeng-SH as a code owner June 18, 2026 11:15
@daviszhen
daviszhen requested a review from a user June 18, 2026 11:15
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH XuPeng-SH 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.

Protected-database enforcement is still bypassable through CALL, so the PR does not yet guarantee that protected DBs are safe from non-admin writes.

CallStmt marks the statement as writing directly, but does not populate writeDatabaseTargets, and the new protected-db guard returns early when that slice is empty. The procedure body then executes through a background session created without preserving fromRealUser, while the new helpers explicitly skip enforcement for non-real-user sessions. In practice, a non-admin can still modify a protected database by invoking a stored procedure whose body performs DDL/DML there.

Please preserve fromRealUser when executing procedure bodies and/or enforce protected-db checks on each statement executed inside procedures, then add a regression covering a non-admin CALL that writes into a protected database.

@daviszhen

daviszhen commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor Author

Protected-database enforcement is still bypassable through CALL, so the PR does not yet guarantee that protected DBs are safe from non-admin writes.

CallStmt marks the statement as writing directly, but does not populate writeDatabaseTargets, and the new protected-db guard returns early when that slice is empty. The procedure body then executes through a background session created without preserving fromRealUser, while the new helpers explicitly skip enforcement for non-real-user sessions. In practice, a non-admin can still modify a protected database by invoking a stored procedure whose body performs DDL/DML there.

Please preserve fromRealUser when executing procedure bodies and/or enforce protected-db checks on each statement executed inside procedures, then add a regression covering a non-admin CALL that writes into a protected database.

存储过程 是废的, 不能正常工作。 暂不考虑call的完整权限问题。

@ghost
ghost merged commit 82a1e04 into matrixorigin:3.0-dev Jun 19, 2026
42 of 43 checks passed
This pull request was closed.

This branch was previously deployed

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

Labels

kind/enhancement kind/feature size/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants