Repository navigation
add protected database - #25008
add protected database#25008
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
✅ APPROVED - Excellent security feature implementation
Feature: Protected databases - write protection for accountadmin/moadmin only
Analysis Summary: 787 lines (489 additions) across 8 files • 22-item systematic checklist • Zero blocking issues
Core Design:
- System variable:
protected_databases(comma-separated, ScopeGlobal, Dynamic) - Authorization: Only accountadmin + moadmin can write
- Coverage: 30+ DDL types + INSERT/UPDATE/DELETE via privilegeTips mechanism
- Safety: Cannot clear protection directly (prevents accidents)
Key Strengths:
- ✅ Comprehensive coverage - 30+ DDL operations (CREATE/DROP/ALTER/TRUNCATE/CLONE/RESTORE/DataBranch)
- ✅ DML protected - INSERT/UPDATE/DELETE via privilegeTips path (tested in BVT)
- ✅ Excellent tests - 119 unit test lines + 115 BVT lines covering 17 operations
- ✅ Robust edge cases - whitespace trim, case sensitivity, multi-DB statements, empty list
- ✅ Security - internal user bypass necessary (PITR/backup), GetFromRealUser() not spoofable
- ✅ Safety guards - reject empty string to prevent accidental clear
Unhappy Paths Validated (10 scenarios, zero issues):
- ✅ Race condition: protection applies immediately (TOCTOU prevented)
- ✅ Internal bypass: cannot be spoofed by user code
- ✅ Case sensitivity: matches MySQL ("CamelDB" != "camedb")
- ✅ Whitespace bypass: strings.TrimSpace catches all
- ✅ Injection: empty parts skipped robustly
- ✅ RENAME across DBs: both source+target checked
- ✅ USE db; DELETE: uses session's current database
- ✅ CTAS: target database checked first
Test Highlights:
- Unit: CLONE/multi-obj/RESTORE target extraction (535, 547, 565)
- Unit: Case sensitivity + whitespace + mixed targets (583, 590)
- BVT: 12 rejected operations + 5 allowed operations (accountadmin + non-protected)
Full review: /tmp/pr_review_25008.md
This PR implements a critical security feature with production-ready quality. Approve and merge! 🔒
Merge Queue Status
This pull request spent 1 hour 53 minutes 12 seconds in the queue, including 1 hour 2 minutes 39 seconds running CI. Required conditions to merge
|
What type of PR is this?
Which issue(s) this PR fixes:
issue #24954
What this PR does / why we need it:
增加protected databases, 只能由accountadmin 和 moadmin 修改