diff --git a/CHANGELOG.md b/CHANGELOG.md index 804cbbaab..dbff9e85f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ * Update PowerSTIG to successfully parse/apply Microsoft Windows Server 2016 STIG - Ver 2, Rel 1: [#782](https://github.com/microsoft/PowerStig/issues/782) * Update PowerSTIG to successfully parse/apply Microsoft Windows Server 2019 STIG - Ver 2, Rel 1 [#787](https://github.com/microsoft/PowerStig/issues/787) * Update PowerSTIG to include LegacyId to assist in determining Legacy Vuln Ids with the new DISA standard: [#788](https://github.com/microsoft/PowerStig/issues/788) +* Update PowerSTIG to include LegacyId query via Get-StigRule function: [#800](https://github.com/microsoft/PowerStig/issues/800) * Update PowerSTIG to fix LegacyId logic: [#791](https://github.com/microsoft/PowerStig/issues/791) ## [4.6.0] - 2020-12-01 diff --git a/Tests/Unit/Module/STIG.RuleQuery.tests.ps1 b/Tests/Unit/Module/STIG.RuleQuery.tests.ps1 index 5ebaf5a35..54ea1972f 100644 --- a/Tests/Unit/Module/STIG.RuleQuery.tests.ps1 +++ b/Tests/Unit/Module/STIG.RuleQuery.tests.ps1 @@ -8,6 +8,7 @@ $xmlTestData = @' <VulnDiscussion>Test STIG Description</VulnDiscussion>< + V-1111 Present False HKEY_LOCAL_MACHINE\Software\Microsoft\TestKeyData @@ -57,6 +58,28 @@ 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' diff --git a/source/Module/STIG/Functions.RuleQuery.ps1 b/source/Module/STIG/Functions.RuleQuery.ps1 index 14da9eb33..6788dd4bd 100644 --- a/source/Module/STIG/Functions.RuleQuery.ps1 +++ b/source/Module/STIG/Functions.RuleQuery.ps1 @@ -11,6 +11,10 @@ using module ..\Rule\Rule.psm1 VulnId within PowerSTIG is typically labled as the RuleId, which may not be consistent with DISA terminology. + .PARAMETER LegacyId + Specify the "previous" VulnId/RuleId, prior to DISA October 2020 Id + updates. + .PARAMETER ProcessedXmlPath Either the folder where the processed xml resides or a specific xml path. The default is .\StigData\Processed\*.xml @@ -27,12 +31,17 @@ function Get-StigRule [OutputType([PSCustomObject])] param ( - [Parameter(Mandatory = $true, Position = 0)] + [Parameter(Mandatory = $true, Position = 0, ParameterSetName = 'VulnId')] [ValidateScript({$_ -match '^V-\d{1,}(|\.[a-z])$'})] [Alias("RuleId")] [string[]] $VulnId, + [Parameter(Mandatory = $true, ParameterSetName = 'LegacyId')] + [ValidateScript({$_ -match '^V-\d{1,}(|\.[a-z])$'})] + [string[]] + $LegacyId, + [Parameter()] [ValidateScript({Test-Path -Path $_})] [string] @@ -43,7 +52,23 @@ function Get-StigRule $Detailed ) - $vulnIdPattern = '