Skip to content

Commit

Permalink
Update PowerSTIG to Provide Rule Data from Processed xml (#777)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
bcwilhite authored and noyard committed Jan 27, 2022
1 parent 7743ae3 commit 4c9822d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 30 deletions.
8 changes: 1 addition & 7 deletions Tests/Unit/Module/.tests.header.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand Down
23 changes: 0 additions & 23 deletions Tests/Unit/Module/STIG.RuleQuery.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ $xmlTestData = @'
<Rule id="V-1000" severity="medium" conversionstatus="pass" title="SRG-APP-000000" dscresource="Registry">
<Description>&lt;VulnDiscussion&gt;Test STIG Description&lt;/VulnDiscussion&gt;&lt;</Description>
<DuplicateOf />
<LegacyId>V-1111</LegacyId>
<Ensure>Present</Ensure>
<IsNullOrEmpty>False</IsNullOrEmpty>
<Key>HKEY_LOCAL_MACHINE\Software\Microsoft\TestKeyData</Key>
Expand Down Expand Up @@ -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'
Expand Down

0 comments on commit 4c9822d

Please sign in to comment.