Sync-DbaLoginPermission and Copy-DbaLogin - Database permissions are synced by the name of the login instead of the database user
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 42/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- sql
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- PowerShell
- スター
- 2.9k
- フォーク
- 869
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 38
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
dataplat/dbatools のほかの issue
-
bugs life triage required
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 2 日以内に返信
-
bugs life triage required
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 2 日以内に返信
-
Invoke-DbaDbPiiScan - Fix broken PII patterns, add Nordic known names, and proposals for metadata-only scan and native classification対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
メンテナーはふだん 2 日以内に返信
-
bugs life triage required
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
dataplat/dbatools#10860 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
bugs life Chrissy needed
難易度 3/5 半日 初心者へのやさしさ 38/100
メンテナーはふだん 2 日以内に返信
dataplat/dbatools の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
lidofinance/validator-ejector#233 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
kagent-dev/kagent#3792 ·
メンテナーはふだん 1 日以内に返信
-
ai-driven-qa bug claude Minor
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
linagora/cozy-stack#5370 ·
メンテナーはふだん 1 日以内に返信
-
bug critical
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
hyperlight-dev/hyperlight-js#459 ·
メンテナーはふだん 1 日以内に返信