Skip to content

Commit e16925e

Browse files
committed
#884 trustworthy
1 parent 4f4759a commit e16925e

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

checks/Databasev5.Tests.ps1

+11-1
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,20 @@ Describe "Auto Update Statistics" -Tag AutoUpdateStatistics, Low, Database -ForE
163163

164164
Describe "Auto Update Statistics Asynchronously" -Tag AutoUpdateStatisticsAsynchronously, Low, Database -ForEach $InstancesToTest {
165165
$skip = Get-DbcConfigValue skip.database.autoupdatestatisticsasynchronously
166-
166+
167167
Context "Testing Auto Update Statistics Asynchronously on <_.Name>" {
168168
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 } } {
169169
$psitem.AutoUpdateStatisticsAsync | Should -Be $psitem.ConfigValues.autoupdatestatsasync -Because "This value is expected for autoupdate statistics asynchronously"
170170
}
171171
}
172+
}
173+
174+
Describe "Trustworthy Option" -Tag Trustworthy, DISA, Varied, CIS, Database -ForEach $InstancesToTest {
175+
$skip = Get-DbcConfigValue skip.database.trustworthy
176+
177+
Context "Testing database trustworthy option on <_.Name>" {
178+
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 } } {
179+
$psitem.Trustworthy | Should -BeFalse -Because "Trustworthy has security implications and may expose your SQL Server to additional risk"
180+
}
181+
}
172182
}

internal/functions/Get-AllDatabaseInfo.ps1

+5
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ function Get-AllDatabaseInfo {
112112
$ConfigValues | Add-Member -MemberType NoteProperty -Name 'autoupdatestatsasync' -Value (Get-DbcConfigValue policy.database.autoupdatestatisticsasynchronously)
113113
$ConfigValues | Add-Member -MemberType NoteProperty -Name 'autoupdatestatsasyncexclude' -Value (Get-DbcConfigValue policy.autoupdatestatisticsasynchronously.excludedb)
114114
}
115+
'Trustworthy' {
116+
$trustworthy = $true
117+
$ConfigValues | Add-Member -MemberType NoteProperty -Name 'trustworthyexclude' -Value (Get-DbcConfigValue policy.database.trustworthyexcludedb)
118+
}
115119
Default { }
116120
}
117121

@@ -139,6 +143,7 @@ function Get-AllDatabaseInfo {
139143
AutoShrink = if ($autoshrink) { $psitem.AutoShrink}
140144
VLF = if ($vlf) { ($psitem.Query("DBCC LOGINFO") | Measure-Object).Count }
141145
LogFileCount = if ($logfilecount) { ($psitem.LogFiles | Measure-Object).Count }
146+
Trustworthy = if ($trustworthy) { $psitem.Trustworthy }
142147
}
143148
}
144149
}

0 commit comments

Comments
 (0)