dataplat / dbachecks

✔ SQL Server Environmental Validation
https://dbachecks.readthedocs.io/en/latest/
MIT License
461 stars 141 forks source link

Sym & Asym Keys not excluding the excluded database list #780

Closed Ant-Green closed 3 years ago

Ant-Green commented 4 years ago

Bug Report

General Troubleshooting steps

Does (Find-Module dbachecks).Version match (Get-Module dbachecks).Version.ToString()

DBAChecks 2.0.3 DBATools 1.0.114 Pester 4.10.1 PSFramework 1.1.59

Version Information

Steps to Reproduce

<--
Set the command.invokedbccheck.excludeddatabases to be an array or values

Invoke the check for Sym or Asym keys, the excluded databases are still checked for compliance.

Looking at the database.tests.ps1 it seems to be appending the $ExcludedDatabases parameters correctly, when it is passed to SMO it doesn't seem to be filtering them out.

-->

Description of Bug

<--
When checking for symmetric or asymmetric key compliance, the excluded databases are still checked. Adding these to the default command.invokedbcchecks.excludeddatabases config value doesn't filter them out from being checked.

Also believe the assertions file is incorrect, but maybe my lack of knowledge on this.

function assert-asymmetrickeysize is -eg "Symmetric Key" function asset-symmetrickeysize if -eg "Asymmetric Key" -->

Ant-Green commented 4 years ago

Not sure why the $ExcludedDatabases += "master", "tempdb", "msdb" piece doesn't work, but changing line 1036 of the database.tests.ps1 to $ExcludedDatabases = $ExcludedDatabases + "master", "tempdb", "msdb" now seems to excluded the correct list of databases

tboggiano commented 4 years ago

@Ant-Green are you going to put in PR, if not I will later today?

Ant-Green commented 4 years ago

@tboggiano I'm very much a GIT noob, so unsure how to do a PR.

After further investigation I believe the fix needs applying to lines 1012 for the Guest User check 1035 for Asym 1056 for Sym

If you're happy to do this I salute you, however if you got a quick guide on how to do a PR for this sort of stuff I will by all means give it a go.

tboggiano commented 4 years ago

@Ant-Green if you made the changes to the code, if you commit the changes, say using Github Desktop, and Push it will pop up with a button to create PR, and then you can just fill in the details. If you need further help maybe if you are in the SQLCommunity Slack hit me up there and we can work through, maybe a Zoom meeting to walk through it. Be more than happy to get you started contributing code.