Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions modules/TierModel/public/Repair-TierModelCanonicalAcl.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,20 @@ function Repair-TierModelCanonicalAcl {
$null -ne $q -and $q.AceQualifier -eq [System.Security.AccessControl.AceQualifier]::AccessAllowed -and
-not ((([int]$_.Ace.AceFlags) -band ([int][System.Security.AccessControl.AceFlags]::Inherited)) -ne 0)
}
$printedOverlapNotice = $false
foreach ($dEntry in $explicitDenies) {
$dq = $dEntry.Ace -as [System.Security.AccessControl.QualifiedAce]
foreach ($aEntry in $explicitAllows) {
$aq = $aEntry.Ace -as [System.Security.AccessControl.QualifiedAce]
if ($dq.SecurityIdentifier -eq $aq.SecurityIdentifier -and
(([int]$dq.AccessMask) -band ([int]$aq.AccessMask)) -ne 0) {
$sidName = try { $dq.SecurityIdentifier.Translate([System.Security.Principal.NTAccount]).Value } catch { $dq.SecurityIdentifier.Value }
$warnMsg = "Potential effective-access overlap detected on '$DistinguishedName' for principal '$sidName' — review DACL before applying sort"
Write-Warning $warnMsg
$warnMsg = "Deny/Allow overlap on '$DistinguishedName' for principal '$sidName' — canonical reorder applied (effective access may change)."
if (-not $printedOverlapNotice) {
$ouLeaf = if ([string]::IsNullOrEmpty($DistinguishedName)) { $DistinguishedName } else { (($DistinguishedName -split ',')[0] -replace '^\w+=','') }
Write-Host "REMEDIATED: Canonical ACL overlap on OU: $ouLeaf" -ForegroundColor Green
Comment on lines +199 to +200
$printedOverlapNotice = $true
}
Comment on lines +198 to +202
$warnings.Add($warnMsg)
}
}
Expand Down
12 changes: 6 additions & 6 deletions tests/Unit.CanonicalAclRepair.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -319,15 +319,15 @@ Describe "Repair-TierModelCanonicalAcl — ByBytes path" -Tag 'Unit', 'Canonical
# -------------------------------------------------------------------------
Context "Deny/Allow overlap warning" {

It "Emits a warning when same SID has both Deny and Allow on overlapping rights" {
$result = Repair-TierModelCanonicalAcl -SecurityDescriptorBytes $script:OverlapInputBytes -WarningVariable warnVar 3>$null
$warnVar | Should -Not -BeNullOrEmpty
It "Records an overlap entry in Warnings when same SID has both Deny and Allow on overlapping rights" {
$result = Repair-TierModelCanonicalAcl -SecurityDescriptorBytes $script:OverlapInputBytes
$result.Warnings | Should -Not -BeNullOrEmpty
}

It "Warning message mentions the overlapping principal" {
$result = Repair-TierModelCanonicalAcl -SecurityDescriptorBytes $script:OverlapInputBytes -WarningVariable warnVar 3>$null
It "Warnings entry mentions the overlapping principal" {
$result = Repair-TierModelCanonicalAcl -SecurityDescriptorBytes $script:OverlapInputBytes
# au = Authenticated Users (S-1-5-11)
($warnVar -join ' ') | Should -Match 'overlap|S-1-5-11|Authenticated'
(($result.Warnings) -join ' ') | Should -Match 'overlap|S-1-5-11|Authenticated'
}

It "Still repairs (IsCanonical=true) despite the overlap warning" {
Expand Down