Skip to content

Commit

Permalink
#884 trustworthy
Browse files Browse the repository at this point in the history
  • Loading branch information
jpomfret committed Jun 5, 2022
1 parent 4f4759a commit e16925e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
12 changes: 11 additions & 1 deletion checks/Databasev5.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,20 @@ Describe "Auto Update Statistics" -Tag AutoUpdateStatistics, Low, Database -ForE

Describe "Auto Update Statistics Asynchronously" -Tag AutoUpdateStatisticsAsynchronously, Low, Database -ForEach $InstancesToTest {
$skip = Get-DbcConfigValue skip.database.autoupdatestatisticsasynchronously

Context "Testing Auto Update Statistics Asynchronously on <_.Name>" {
It "Database <_.Name> should have Auto Update Statistics Asynchronously set to <_.ConfigValues.autoupdatestatsasync> on <_.SqlInstance>" -Skip:$skip -ForEach $psitem.Databases.Where{ if ($Database) { $_.Name -in $Database } else { $psitem.ConfigValues.autoupdatestatsasyncexclude -notcontains $PsItem.Name } } {
$psitem.AutoUpdateStatisticsAsync | Should -Be $psitem.ConfigValues.autoupdatestatsasync -Because "This value is expected for autoupdate statistics asynchronously"
}
}
}

Describe "Trustworthy Option" -Tag Trustworthy, DISA, Varied, CIS, Database -ForEach $InstancesToTest {
$skip = Get-DbcConfigValue skip.database.trustworthy

Context "Testing database trustworthy option on <_.Name>" {
It "Database <_.Name> should have Trustworthy set to false on <_.SqlInstance>" -Skip:$skip -ForEach $psitem.Databases.Where{ if ($Database) { $_.Name -in $Database } else { $psitem.ConfigValues.trustworthyexclude -notcontains $PsItem.Name } } {
$psitem.Trustworthy | Should -BeFalse -Because "Trustworthy has security implications and may expose your SQL Server to additional risk"
}
}
}
5 changes: 5 additions & 0 deletions internal/functions/Get-AllDatabaseInfo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ function Get-AllDatabaseInfo {
$ConfigValues | Add-Member -MemberType NoteProperty -Name 'autoupdatestatsasync' -Value (Get-DbcConfigValue policy.database.autoupdatestatisticsasynchronously)
$ConfigValues | Add-Member -MemberType NoteProperty -Name 'autoupdatestatsasyncexclude' -Value (Get-DbcConfigValue policy.autoupdatestatisticsasynchronously.excludedb)
}
'Trustworthy' {
$trustworthy = $true
$ConfigValues | Add-Member -MemberType NoteProperty -Name 'trustworthyexclude' -Value (Get-DbcConfigValue policy.database.trustworthyexcludedb)
}
Default { }
}

Expand Down Expand Up @@ -139,6 +143,7 @@ function Get-AllDatabaseInfo {
AutoShrink = if ($autoshrink) { $psitem.AutoShrink}
VLF = if ($vlf) { ($psitem.Query("DBCC LOGINFO") | Measure-Object).Count }
LogFileCount = if ($logfilecount) { ($psitem.LogFiles | Measure-Object).Count }
Trustworthy = if ($trustworthy) { $psitem.Trustworthy }
}
}
}
Expand Down

0 comments on commit e16925e

Please sign in to comment.