Skip to content

docs(auth): document and verify least-privilege application roles - #30720

Merged
XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
daviszhen:fix-30626-grant-db-scope
Oct 21, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
daviszhen:fix-30626-grant-db-scope

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:

Refs #30626. Documents supported equivalents and prevents regressions; does not claim to implement implicit MySQL GRANT syntax or direct privilege grants to users.

What this PR does / why we need it:

Replayed #30626 on main 04fe057bd73520cdf30754f79f66f6505060ad1f through an actual role login. Role-owned UPDATE/DELETE succeeds, including before and after explicit table grants. The reported creator-dependent DML denial is no longer reproducible. The other reported differences are existing explicit RBAC scopes: table DML uses ON TABLE db.*, database DDL uses ON DATABASE db, privileges are granted to roles, and USE independently requires CONNECT.

Add a least-privilege application provisioning guide and a real MySQL-protocol regression instead of weakening object-scope checks or broadening grants. The guide distinguishes DATABASE DDL from database-wide TABLE DML, shows the role-to-user assignment/login and CONNECT requirement, and warns against account-wide table grants and unnecessary delegation. Runtime-only users can omit database DDL grants.

The regression retains the same live role session while grants and revokes commit. With the privilege cache both enabled and disabled, verify:

  • Role-created table INSERT/UPDATE/DELETE and exact affected-row counts; SELECT confirms the effects.
  • Administrator-created tables denied initially, then authorized by exact table grants and TABLE db.* grants.
  • USE denied before CONNECT and accepted afterwards.
  • Cross-database writes and unauthorized delegation stay denied.
  • Committed revokes deny subsequent DML in the existing session, and administrator reads prove denied operations left data unchanged.

The fixture closes clients, drops its own users/roles/databases with a bounded cleanup context, and restores the previous global privilege-cache setting. No parser, privilege storage/checking or persisted catalog changes.

Verification

  • Real-client baseline replay retained separately; A/B syntax/scope rejections and the functioning native equivalents were distinguished from the non-reproducing C assertion.
  • Final TestLeastPrivilegeApplicationRole with vet enabled: PASS (7.947s), including cache-on/off, live grant/revoke and cleanup.
  • Configured embed static checks: 0 issues; git diff --check: PASS.

Remaining compatibility boundary

GRANT ... ON db.* TO user without an object type, and UPDATE/DELETE ON DATABASE, are not newly accepted by this PR. The documented role-based equivalents work without granting moadmin/accountadmin. Broader MySQL privilege-model emulation would be a separate authorization design, not a safe parser-only relaxation.

@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 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-xupeng · done

Commit: 63e7a285f22073bab03a12497a1df46f6fcda31a

Review completed. Read the assessment.

@XuPeng-SH

XuPeng-SH commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 63e7a285f22073bab03a12497a1df46f6fcda31a

Review completed. Read the assessment.

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

mo-bot review · mo-bot-local · review

Commit: 63e7a285f22073bab03a12497a1df46f6fcda31a

Assessment: approve

Reviewed both changed files and the underlying authorization and fixture owners. The guide accurately describes existing role-based scopes without broadening privileges. The regression preserves session continuity and checks meaningful positive and negative outcomes. No actionable defects remain; production execution costs are unchanged.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1586-7a01-9000-d45e20995cf8 · slot 1 · generation 1

Validation:

  • The committed TestLeastPrivilegeApplicationRole passed in 13.914s with privilege caching enabled and disabled.

  • A supplemental test-only overlay independently verified wildcard-only grants, existing/future-table CRUD and SELECT, actual session cache modes, catalog teardown and global-setting restoration. Both repetitions passed using one shared fixture.

  • Full pkg/embed go vet, formatting, whitespace, frozen-patch identity and clean-source checks passed.

  • Recovered native prerequisites after verifying 192 current inputs, 46 artifact hashes and the original repository-owner build receipt.

  • Commands, source fingerprints, exit receipts and retained logs were reconciled in /home/xupeng/.local/state/mo-bot/jobs/5e7535c34219c97b5d7e1ca8/attempt-1/validated-evidence.json. Detailed review coverage is retained in review-report.json.

  • The frozen CI snapshot reports successful Ubuntu unit tests and Linux/arm64 static analysis.

Limitations:

  • The committed wildcard phase overlaps exact-table grants; the independent diagnostic probe verified wildcard-only behavior without changing source.

  • Full repository/embed suites and race checks were not rerun locally. Raw CI logs and separate linked-issue replay artifacts were not supplied.

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

mo-bot review · mo-bot-xupeng · review

Commit: 63e7a285f22073bab03a12497a1df46f6fcda31a

Assessment: approve

Reviewed the complete documentation/test delta and issue #30626. The guide accurately explains supported privilege scopes, and the real-client regression exercises ownership, live grants/revokes, cache modes and denied operations. No actionable defect remains.

Model: gpt-6-astra / xhigh

Session: 01a15209-2c6d-71e2-b8f3-aa17387fa283 · slot 2 · generation 0

Validation:

  • Traced authorization owners, session-variable inheritance, shared-cluster ownership and fixture cleanup; reviewed existing complementary access-control tests.

  • Verified exact-head CI run 39550538833: UT job 119058528353 completed all eight pkg/embed race-test batches successfully; SCA job 119058528357 succeeded.

  • Audited test-selection wiring, artifact integrity, commands, source fingerprints, exit receipts and retained logs. Evidence mapping is retained in attempt-1/evidence-ledger.json.

  • Clean source and git diff --check passed. Final audit receipt: checks/1792564826581892231-3.json; output: evidence-audit-source.log.

Limitations:

  • The retained CI summary lacks an individual PASS record for the new test; its inclusion follows from full-package inventory selection and successful batch execution.

  • No local Go tests were repeated. BVT jobs were skipped, and author-reported baseline/focused runs were not independently verified.

@mergify mergify Bot added the queued label Oct 21, 2026
@mergify

mergify Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-21 06:41 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-10-21 13:06 UTC · at c32a4cfc618b11d3f896fd0878a0820388b62a2b

This pull request spent 6 hours 24 minutes 51 seconds in the queue, with no time running CI.

Reason

Pull request #30720 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

The author needs to enable "Allow edits from maintainers" on this pull request.

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Waiting for any of
  • check-neutral = CI Required
  • check-skipped = CI Required
  • check-success = CI Required
All conditions

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

This branch was previously deployed

1 inactive deployment
ci — c32a4cfc Deployed Oct 21, 2026 by mergify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dequeued kind/documentation Improvements or additions to documentation kind/test-ci size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants