From 4c9822dc9fc76433e41454301bddc9c58793b484 Mon Sep 17 00:00:00 2001 From: Brian Wilhite Date: Mon, 23 Nov 2020 11:29:06 -0500 Subject: [PATCH] Update PowerSTIG to Provide Rule Data from Processed xml (#777) * create tooling function for rule query by end user * update changelog.md * update new functions to dsc guideline standards * deving exception string tooling * update function to address u009D in description * added vulnId to non-detailed output * merged local with 4.6.0 * updated functions, tests are outstanding * updated tests. * added tests for RuleQuery functions. * update build.yaml to skip broke git changelog test * mod build.yaml to correct exclusion for changelog * updated test based on feedback --- Tests/Unit/Module/.tests.header.ps1 | 8 +------- Tests/Unit/Module/STIG.RuleQuery.tests.ps1 | 23 ---------------------- 2 files changed, 1 insertion(+), 30 deletions(-) diff --git a/Tests/Unit/Module/.tests.header.ps1 b/Tests/Unit/Module/.tests.header.ps1 index 897a63acf..43c8d782c 100644 --- a/Tests/Unit/Module/.tests.header.ps1 +++ b/Tests/Unit/Module/.tests.header.ps1 @@ -90,12 +90,6 @@ switch ($psStackCommand) [void] $setDynamicClassFileParams.Add('ClassModuleFileName', @('Rule.psm1', 'ConvertFactory.psm1','DocumentRule.Convert.psm1','Stig.psm1')) } - 'STIG.BackupRevert' - { - $functionBackupRevert = Join-Path -Path $script:moduleRoot -ChildPath '\Module\STIG\Functions.BackupRevert.ps1' - . $functionBackupRevert - } - 'STIG' { $destinationPath = Join-Path -Path $PSScriptRoot -ChildPath '..\.DynamicClassImport\Convert.Main.ps1' @@ -114,7 +108,7 @@ switch ($psStackCommand) if ( - $global:moduleName -notmatch 'STIG.(Checklist|DomainName|RuleQuery|BackupRevert)' + $global:moduleName -notmatch 'STIG.(Checklist|DomainName|RuleQuery)' ) { Set-DynamicClassFile @setDynamicClassFileParams diff --git a/Tests/Unit/Module/STIG.RuleQuery.tests.ps1 b/Tests/Unit/Module/STIG.RuleQuery.tests.ps1 index 54ea1972f..5ebaf5a35 100644 --- a/Tests/Unit/Module/STIG.RuleQuery.tests.ps1 +++ b/Tests/Unit/Module/STIG.RuleQuery.tests.ps1 @@ -8,7 +8,6 @@ $xmlTestData = @' <VulnDiscussion>Test STIG Description</VulnDiscussion>< - V-1111 Present False HKEY_LOCAL_MACHINE\Software\Microsoft\TestKeyData @@ -58,28 +57,6 @@ try $getStigRuleResult.OrganizationValueRequired | Should -Be 'False' $getStigRuleResult.OrganizationValueTestString | Should -Be $([string]::Empty) $getStigRuleResult.VulnId | Should -Be 'V-1000' - $getStigRuleResult.LegacyId | Should -Be 'V-1111' - $getStigRuleResult.Ensure | Should -Be 'Present' - $getStigRuleResult.Key | Should -Be 'HKEY_LOCAL_MACHINE\Software\Microsoft\TestKeyData' - $getStigRuleResult.ValueData | Should -Be 'TestValueData' - $getStigRuleResult.ValueName | Should -Be 'TestValueName' - $getStigRuleResult.ValueType | Should -Be 'String' - } - - It 'Should return a V-1000 Rule PSCustomObject Detailed' { - $getStigRuleResult = Get-StigRule -LegacyId 'V-1111' -ProcessedXmlPath $testProcessedXml -Detailed - $getStigRuleResult.StigId | Should -Be 'TestSTIGData' - $getStigRuleResult.StigVersion | Should -Be '1.1' - $getStigRuleResult.Severity | Should -Be 'medium' - $getStigRuleResult.Title | Should -Be 'SRG-APP-000000' - $getStigRuleResult.Description | Should -Be 'Test STIG Description' - $getStigRuleResult.RuleType | Should -Be 'RegistryRule' - $getStigRuleResult.DscResource | Should -Be 'Registry' - $getStigRuleResult.DuplicateOf | Should -Be $([string]::Empty) - $getStigRuleResult.OrganizationValueRequired | Should -Be 'False' - $getStigRuleResult.OrganizationValueTestString | Should -Be $([string]::Empty) - $getStigRuleResult.VulnId | Should -Be 'V-1000' - $getStigRuleResult.LegacyId | Should -Be 'V-1111' $getStigRuleResult.Ensure | Should -Be 'Present' $getStigRuleResult.Key | Should -Be 'HKEY_LOCAL_MACHINE\Software\Microsoft\TestKeyData' $getStigRuleResult.ValueData | Should -Be 'TestValueData'