Sync-DbaLoginPermission and Copy-DbaLogin - Database permissions are synced by the name of the login instead of the database user
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 42/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- sql
- Lĩnh vực
- authorization, database
Hướng nghiên cứu
Start in private/functions/Update-SqlPermission.ps1: the revoke calls near lines 261, 262 and 279 and the grant call near line 373 enumerate permissions by login name where the database user name ($newDbUsername, $dbUsername) should be used. Read the reproduction, then add a context to Sync-DbaLoginPermission.Tests.ps1 that fails on the current code. Done means that context passes and the unrelated user keeps its permissions. The issue says to wait for #10801, which changes the same helper, before changing it.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
Update-SqlPermission syncs the database permissions of a login by the name of the login. A database principal is a user, and a user can have a name other than its login. The helper is private. Copy-DbaLogin uses it for every created and updated login, and Sync-DbaLoginPermission for every login it syncs.
On development (72ae9ee82), private/functions/Update-SqlPermission.ps1:
- The revoke part (lines 261, 262 and 279) calls
$destDb.EnumDatabasePermissions($newLoginName)and$sourceDb.EnumDatabasePermissions($loginName), and revokes from$newLoginName. The name of the user is in$newDbUsernameand$dbUsername, set a few lines above. - The grant part (line 373) reads
$sourceDb.EnumDatabasePermissions($loginName)and grants to$newDbUsername.
Reproduction
On development 72ae9ee82, with SQL Server 2022 as the source and SQL Server 2025 as the destination:
- A login
Lhas the same SID on both instances. - A database
Dexists on both, and inDa userUforLhas another name than the login. - On the source:
GRANT VIEW DEFINITION TO [U]. - On the destination:
GRANT ALTER ANY SCHEMA TO [U], and an unrelated user without login that has the name of the login:CREATE USER [L] WITHOUT LOGIN; GRANT VIEW DATABASE STATE TO [L].
Sync-DbaLoginPermission -Source <source> -Destination <destination> -Login L returns Successful without a warning. Afterwards, on the destination:
Ustill hasALTER ANY SCHEMA, which the source user does not have.Udid not getVIEW DEFINITION.- The unrelated user
LlostVIEW DATABASE STATE: the revoke hit a principal that has nothing to do with the login.
The same place has a second gap
The revoke runs without AS <grantor>. For server permissions, #10801 measured that a REVOKE without AS takes back only the grant of sa when two logins granted the same permission, and fixed it there by revoking each row as its grantor (0fc03cbca). The database part has the same call. That was not measured at database level yet.
Proposed fix
Use the database user for both enumerations and for the revoke, and revoke each row as its grantor, as 0fc03cbca does for the server permissions. Regression test: the reproduction above as a new context in Sync-DbaLoginPermission.Tests.ps1. It needs only the copy pair, so it runs in CI. The fix should wait until #10801 is merged, because #10801 changes the same helper.
Related: #9283 (closed), a database user whose name differs from its login, with -LoginRenameHashtable.
This text was created by Claude and reviewed by Andreas Jordan.
- Ngôn ngữ chính
- PowerShell
- Star
- 2.9k
- Fork
- 869
- Merge trung bình
- 2 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 38
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của dataplat/dbatools
-
bugs life triage required
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 2 ngày
-
bugs life triage required
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Invoke-DbaDbPiiScan - Fix broken PII patterns, add Nordic known names, and proposals for metadata-only scan and native classificationCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 2 ngày
-
bugs life triage required
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
dataplat/dbatools#10860 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
bugs life Chrissy needed
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 38/100
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của dataplat/dbatools
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
lidofinance/validator-ejector#233 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
kagent-dev/kagent#3792 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ai-driven-qa bug claude Minor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
linagora/cozy-stack#5370 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug critical
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
hyperlight-dev/hyperlight-js#459 ·
Maintainer thường phản hồi trong vòng 1 ngày