Skip to content

non-sys tenant should not support cluster level backup(#1.1-dev) - #15383

Merged
sukki37 merged 4 commits into
matrixorigin:1.1-devfrom
YANGGMM:fix-back-1.1-dev
Apr 8, 2024
Merged

sukki37 merged 4 commits into
matrixorigin:1.1-devfrom
YANGGMM:fix-back-1.1-dev

Conversation

@YANGGMM

@YANGGMM YANGGMM commented Apr 8, 2024

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 #https://github.com/matrixorigin/MO-Cloud/issues/2932

What this PR does / why we need it:

non-sys tenant should not support cluster level backup

@matrix-meow matrix-meow added the size/S Denotes a PR that changes [10,99] lines label Apr 8, 2024
@matrix-meow

Copy link
Copy Markdown
Contributor

@YANGGMM Thanks for your contributions!

Pull Request Review:

Title:

The title of the pull request is clear and concise, indicating that non-sys tenants should not support cluster-level backup.

Body:

The body of the pull request provides relevant information about the type of PR (BUG), the specific issue it fixes, and the reason for the changes made.

Changes:

  1. In authenticate.go:
    • Line 5879: Changed the privilegeKind from privilegeKindNone to privilegeKindSpecial and added specialTagAdmin for tree.BackupStart.
    • Line 7429: Added a new function checkBackUpStartPrivilege to restrict the execution of backup statements to only moAdmin.
    • Line 7456: Added a case for tree.BackupStart to call the checkBackUpStartPrivilege function.

Feedback and Suggestions for Improvement:

  1. Security Issue - Authorization Flaw:

    • The addition of checkBackUpStartPrivilege function is a step in the right direction to restrict backup statements to moAdmin. However, the implementation should also check if the user executing the backup statement is an moAdmin before allowing it. This check is missing and could lead to unauthorized users being able to execute backup statements.
  2. Optimization:

    • Instead of just checking if the tenant is a sysTenant in checkBackUpStartPrivilege, it would be more secure to also verify if the user is an moAdmin before allowing the backup operation. This can prevent unauthorized users from executing backup commands.
  3. Consistency:

    • Ensure that the naming conventions are consistent throughout the codebase. For example, checkBackUpStartPrivilege could be renamed to checkBackupStartPrivilege for better readability and consistency.
  4. Documentation:

    • It would be beneficial to update the code comments to reflect the changes made, especially in the checkBackUpStartPrivilege function, to explain the authorization logic clearly.
  5. Testing:

    • Consider adding test cases to cover the new authorization logic introduced for BackupStart statements to ensure that the functionality works as expected and unauthorized users are blocked from executing backups.

Overall:

The pull request addresses the issue of restricting non-sys tenants from supporting cluster-level backup. However, there is a security concern regarding the authorization logic that needs to be addressed to ensure the system's security. Additionally, optimizing the authorization checks and maintaining consistency in naming conventions will improve the code quality.

@mergify
mergify Bot requested a review from sukki37 April 8, 2024 06:50
@mergify mergify Bot added the kind/bug Something isn't working label Apr 8, 2024
@sukki37
sukki37 merged commit 38bc3c0 into matrixorigin:1.1-dev Apr 8, 2024
LeftHandCold added a commit to LeftHandCold/matrixone that referenced this pull request Apr 28, 2024
@YANGGMM
YANGGMM deleted the fix-back-1.1-dev branch May 13, 2024 02:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants