-
-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running CIS Tests fails but passes when in single test alone #1034
Comments
ok The problem is that hideinstance check requires elevation. And even if i disable the check with |
ok, indeed, Skip the hideinstance check does not prevent from checking it.... I'm looking for a way to really prevent to execute this check.... |
It seems that the Get-CheckInformation function does return "HideInstance" even if you pass it as the parameter "$ExcludeCheck" eg. ->The tags returned from Get-CheckInformation does include "Hideinstance" tag also. So that is the reason the check is also executed. Should i make a bug report? |
I just changed the Get-CheckInformation function and i have added this line at the bottom (Just before"Return $CheckInfo" $CheckInfo = $CheckInfo |Where-Object {$item = $; -not $ExcludeCheck.Where({$item -like "${}*"}, 'First')} ->That removes from the $Checkinfo array all the items in the $ExcludeCheck Array ->This works for me now. I hope you can update the Get-CheckInformation function |
General Troubleshooting steps
Version Information
Steps to Reproduce
Running the following with an SQL Service Account (Without local Admin permissions):
->Single Check EngineServiceAdmin has passed without error:
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Key Value
Tag {EngineServiceAdmin}
ExcludeTag
Script C:\Program Files\WindowsPowerShell\Modules\dbachecks\3.1.0\checks\Instance.Tests.ps1
PassThru True
Strict True
Pester v4.10.1
Executing all tests in 'C:\Program Files\WindowsPowerShell\Modules\dbachecks\3.1.0\checks\Instance.Tests.ps1' with Tags EngineServiceAdmin
Executing script C:\Program Files\WindowsPowerShell\Modules\dbachecks\3.1.0\checks\Instance.Tests.ps1
Describing SQL Engine Service Admin
Tests completed in 1.23s
Tests Passed: 1, Failed: 0, Skipped: 0, Pending: 0, Inconclusive: 0
TagFilter : {EngineServiceAdmin}
ExcludeTagFilter :
TestNameFilter :
ScriptBlockFilter :
TotalCount : 1
PassedCount : 1
FailedCount : 0
SkippedCount : 0
PendingCount : 0
InconclusiveCount : 0
Time : 00:00:01.2285526
TestResult : {@{ErrorRecord=; ParameterizedSuiteName=; Describe=SQL Engine Service Admin;
Parameters=System.Collections.Specialized.OrderedDictionary; Passed=True;
Show=All; FailureMessage=; Time=00:00:00.0078503; Name=The SQL Engine service
account should not be a local administrator on XXXXX; Result=Passed;
Context=Testing whether SQL Engine account is a local administrator on
XXXXX; StackTrace=}}
XXXXXXXXXXXXXXXXXXXXXXXX
Command:
Invoke-DbcCheck -Check CIS -ExcludeCheck LoginAuditSuccessful,NonStandardPort,SQLMailXPsDisabled,LoginMustChange,ContainedDBSQLAuth -ComputerName $srv -SqlInstance $srv -PassThru -Strict
Error Message:
Describing SQL Engine Service Admin
Result:
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx
Key Value
ExcludeTag {LoginAuditSuccessful, NonStandardPort, SQLMailXPsDisabled, LoginMustChange...}
Tag {CIS}
Script {C:\Program Files\WindowsPowerShell\Modules\dbachecks\3.1.0\checks\Agent.Tests.ps1, C...
PassThru True
Strict True
Pester v4.10.1
Executing all tests in 'C:\Program Files\WindowsPowerShell\Modules\dbachecks\3.1.0\checks\Agent.Tests.ps1', 'C:\Program Files\WindowsPowerShell\Modules\dbachecks\3.1.0\checks\Database.Tests.ps1', 'C:\Program Files\WindowsPowerShell\Modules\dbachecks\3.1.0\checks\Instance.Tests.ps1', 'C:\Program Files\WindowsPowerShell\Modules\dbachecks\3.1.0\checks\Server.Tests.ps1' with Tags CIS
Executing script C:\Program Files\WindowsPowerShell\Modules\dbachecks\3.1.0\checks\Agent.Tests.ps1
Describing Database Mail XPs
Executing script C:\Program Files\WindowsPowerShell\Modules\dbachecks\3.1.0\checks\Database.Tests.ps1
Describing Trustworthy Option
Describing Database Orphaned User
Describing Contained Database Auto Close
Describing CLR Assemblies SAFE_ACCESS
Describing Guest User
Describing AsymmetricKeySize
Describing SymmetricKeyEncryptionLevel
Executing script C:\Program Files\WindowsPowerShell\Modules\dbachecks\3.1.0\checks\Instance.Tests.ps1
Describing Dedicated Administrator Connection
Describing SA Login Renamed
Describing SA Login Disabled
Describing Login SA cannot exist
Describing OLE Automation
Describing Error Log Count
Describing CLR Enabled
Describing Cross Database Ownership Chaining
Describing Ad Hoc Distributed Queries
Describing XP CmdShell
Describing Scan For Startup Procedures
Describing Default Trace
Describing OLE Automation Procedures Disabled
Describing Remote Access Disabled
Describing Latest Build
Describing Login BUILTIN Administrators cannot exist
Describing Local Windows Groups Not Have SQL Logins
Describing Failed Login Auditing
Describing SqlAgentProxiesNoPublicRole
Describing Hide Instance
Describing SQL Engine Service Admin
Describing SQL Agent Service Admin
Describing SQL Full Text Service Admin
Describing Login Check Policy
Describing Login Password Expiration
Describing Public Role Permissions
Describing SQL Browser Service
Executing script C:\Program Files\WindowsPowerShell\Modules\dbachecks\3.1.0\checks\Server.Tests.ps1
Describing Server Protocols
Tests completed in 25.15s
Tests Passed: 70, Failed: 5, Skipped: 0, Pending: 0, Inconclusive: 0
TagFilter : {CIS}
ExcludeTagFilter : {LoginAuditSuccessful, NonStandardPort, SQLMailXPsDisabled, LoginMustChange...}
TestNameFilter :
ScriptBlockFilter :
TotalCount : 75
PassedCount : 70
FailedCount : 5
SkippedCount : 0
PendingCount : 0
InconclusiveCount : 0
Time : 00:00:25.1458317
TestResult : {@{ErrorRecord=; ParameterizedSuiteName=; Describe=Database Mail XPs;
Parameters=System.Collections.Specialized.OrderedDictionary; Passed=True;
Show=All; FailureMessage=; Time=00:00:01.6595378; Name=Testing Database Mail
XPs is set to True on XXXXX; Result=Passed; Context=Testing Database
Mail XPs on XXXXX; StackTrace=}, @{ErrorRecord=;
ParameterizedSuiteName=; Describe=Trustworthy Option;
Parameters=System.Collections.Specialized.OrderedDictionary; Passed=True;
Show=All; FailureMessage=; Time=00:00:00.0860918; Name=Database AdminDB should
have Trustworthy set to false on XXXXX; Result=Passed; Context=Testing
database trustworthy option on XXXXX; StackTrace=}, @{ErrorRecord=;
ParameterizedSuiteName=; Describe=Trustworthy Option;
Parameters=System.Collections.Specialized.OrderedDictionary; Passed=True;
Show=All; FailureMessage=; Time=00:00:00.0020350; Name=Database master should
have Trustworthy set to false on XXXXX; Result=Passed; Context=Testing
database trustworthy option on XXXXX; StackTrace=}, @{ErrorRecord=;
ParameterizedSuiteName=; Describe=Trustworthy Option;
Parameters=System.Collections.Specialized.OrderedDictionary; Passed=True;
Show=All; FailureMessage=; Time=00:00:00.0018695; Name=Database model should
have Trustworthy set to false on XXXXX; Result=Passed; Context=Testing
database trustworthy option on XXXXX; StackTrace=}...}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx
The text was updated successfully, but these errors were encountered: