sqlserver::user::permissions always applied as corrective
Đánh giá
- Độ khó
- 1/5
- Thời gian dự kiến
- Dưới một giờ
- Mức phù hợp với người mới
- 92/100
Hướng nghiên cứu
Bắt đầu với templates/query/user/permission_exists.sql.epp và so sánh nó với templates/create/user/permission.sql.epp và templates/query/role/permission_exists.sql.epp. Kiểm tra thiết lập của biến permission, sau đó chạy bản tái hiện Puppet đã nêu hai lần. Hoàn tất khi lần chạy thứ hai báo cáo rằng tài nguyên sqlserver_tsql đã đồng bộ mà không áp dụng lại các quyền GRANT.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the Bug
When declaring sqlserver::user::permissions with GRANT permissions, Puppet re-applies the permissions on every run as a corrective change, even though the permissions are already in the desired state.
Expected Behavior
On the second Puppet run (after permissions are already granted), the sqlserver_tsql resource should be in sync and no corrective change should occur.
Steps to Reproduce
- Declare
sqlserver::user::permissionswith e.g.permissions: ['SELECT', 'INSERT']andstate: GRANT - Run Puppet agent — permissions are applied
- Run Puppet agent again — permissions are re-applied as corrective
Root Cause
The onlyif query template templates/query/user/permission_exists.sql.epp iterates over permissions but never assigns the SQL variable @permission:
<% $permissions.each |$requested_permission| { %>
<% $permission = $requested_permission.upcase %>
<%= epp('sqlserver/snippets/user/permission/exists.sql.epp', ...) %>
<% } %>
The Puppet variable $permission is set, but the SQL variable @permission stays NULL. Since permission_name = NULL is never TRUE in SQL Server, the subquery always returns NULL, ISNULL coerces it to 'REVOKE', and the check always sees a mismatch — causing Puppet to re-grant every time.
The create template (templates/create/user/permission.sql.epp) and the role equivalent (templates/query/role/permission_exists.sql.epp) both correctly set @permission. This is the same class of bug as #464 / #500 which fixed the login permission template.
Fix
Add the missing SET @permission = '<%= $permission %>'; line in the query template, matching the create template.
- Ngôn ngữ chính
- Ruby
- Star
- 5
- Fork
- 23
- Merge trung bình
- 3 giờ 17 phút
- Pull request đã merge (30 ngày)
- 1
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 puppetlabs/puppetlabs-sqlserver
-
Paramter as_sysadmin_accounts does not behave in the same way as sql_sysadmin_accountsCó thể đã có người làm @jst-cyr đã nhận 42 ngày trước. Đang mởbugfix community
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
puppetlabs/puppetlabs-sqlserver#505 · 1 bình luận · 2 reaction ·
-
Add support for OS LinuxĐang mởcommunity
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
puppetlabs/puppetlabs-sqlserver#465 · 1 reaction ·
-
community
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
-
bugfix community
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
puppetlabs/puppetlabs-sqlserver#427 · 4 bình luận · 2 reaction ·
Tất cả issue của puppetlabs/puppetlabs-sqlserver
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/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 72/100
aws/aws-sdk-ruby#3460 ·
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 67/100
Maintainer thường phản hồi trong vòng 17 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
riscv/riscv-unified-db#2755 ·
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 68/100
ossf/best-practices-badge#3081 ·
Maintainer thường phản hồi trong vòng 1 ngày