Skip to content

Commit b4e76a5

Browse files
so that we c nca check login check policy #882
1 parent 30e05cc commit b4e76a5

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

source/checks/Instancev5.Tests.ps1

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,15 @@ Describe "Successful Login Auditing" -Tag LoginAuditSuccessful, Security, CIS, M
218218
}
219219
}
220220

221+
Describe "Login Check Policy" -Tag LoginCheckPolicy, Security, CIS, Medium, Instance -ForEach $InstancesToTest {
222+
$skip = ($__dbcconfig | Where-Object { $_.Name -eq 'skip.security.LoginCheckPolicy' }).Value
223+
Context "Testing if the CHECK_POLICY is enabled on all logins on $psitem" {
224+
It "All logins should have the CHECK_POLICY option set to ON on $psitem" -Skip:$skip {
225+
($psitem.logins | Where-Object { $_.LoginType -eq 'SqlLogin' -and $_.PasswordPolicyEnforced -eq $false -and $_.IsDisabled -eq $false }).Count | Should -Be 0 -Because "We expected the CHECK_POLICY for the all logins to be enabled"
226+
}
227+
}
228+
}
229+
221230
Describe "Instance MaxDop" -Tag MaxDopInstance, MaxDop, Medium, Instance -ForEach ($InstancesToTest | Where-Object { $psitem.Name -notin $psitem.ConfigValues.ExcludeInstanceMaxDop }) {
222231
$skip = ($__dbcconfig | Where-Object { $_.Name -eq 'skip.instance.MaxDopInstance' }).Value
223232
Context "Testing Instance MaxDop Value on <_.Name>" {

source/internal/functions/NewGet-AllInstanceInfo.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,12 @@ function NewGet-AllInstanceInfo {
410410
$Instance.SetDefaultInitFields([Microsoft.SqlServer.Management.Smo.Settings], $SettingsInitFields)
411411
}
412412

413+
'LoginCheckPolicy' {
414+
$LoginInitFields.Add("IsDisabled") | Out-Null # so we can check login check policy
415+
$LoginInitFields.Add("PasswordPolicyEnforced") | Out-Null # so we can check login check policy
416+
$Instance.SetDefaultInitFields([Microsoft.SqlServer.Management.Smo.Settings], $LoginInitFields)
417+
}
418+
413419
Default { }
414420
}
415421

0 commit comments

Comments
 (0)