Skip to content
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

Update PowerSTIG to include LegacyId to assist in determining Legacy Vuln Ids with the new DISA standard. #789

Merged
merged 4 commits into from
Dec 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## [Unreleased]

* 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)

## [4.6.0] - 2020-12-01

* Provide Method to install DoD Root Certs for Server OS and Client OS: [#755](https://github.com/microsoft/PowerStig/issues/755)
Expand Down
3 changes: 3 additions & 0 deletions Tests/Unit/Module/Rule.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ try
It 'Should return the rule Id' {
$stig.id | Should Be 'V-1000'
}
It 'Should return the legacy Id' {
$stig.legacyid | Should Be 'V-1111'
}
It 'Should return the Severity' {
$stig.severity | Should Be 'medium'
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/Unit/Module/STIG.PowerStigXml.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ Describe 'Compare-PowerStigXml' {

Describe 'Get-BaseRulePropertyName' {

It 'Should return 11 base rule types' {
It 'Should return 12 base rule types' {
$baseRulePropertyName = Get-BaseRulePropertyName
$baseRulePropertyName.Count | Should -Be 11
$baseRulePropertyName.Count | Should -Be 12
}
}

Expand Down
1 change: 1 addition & 0 deletions Tools/TestHelper/Data/samplegroup.xml.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<dc:subject>Technology</dc:subject>
<dc:identifier>2350</dc:identifier>
</reference>
<ident system="http://cyber.mil/legacy">{6}</ident>
<ident system="http://cce.mitre.org">CCE--12345-6</ident>
<ident system="http://iase.disa.mil/cci">CCI-123456</ident>
<fixtext fixref="F-12345r1_fix">{4}</fixtext>
Expand Down
6 changes: 5 additions & 1 deletion Tools/TestHelper/TestHelper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ function Get-TestStigRule
[string]
$FixText = 'This is a string of text that tells an admin how to fix an item if it is not currently configured properly and ignored by the parser',

[Parameter(Parametersetname = 'UseExisting')]
[string]
$LegacyId = 'V-1111',

[Parameter(Parametersetname = 'UseExisting')]
[Parameter(Parametersetname = 'FileProvided')]
[switch]
Expand All @@ -162,7 +166,7 @@ function Get-TestStigRule
{
# Get the samplegroup element text and merge in the parameter strings
$groupElement = Get-Content -Path "$PSScriptRoot\data\sampleGroup.xml.txt" -Encoding UTF8 -Raw
$groupElement = $groupElement -f $GroupId, $GroupTitle, $RuleTitle, $RuleDescription, $FixText, $CheckContent
$groupElement = $groupElement -f $GroupId, $GroupTitle, $RuleTitle, $RuleDescription, $FixText, $CheckContent, $LegacyId
}

# Get and merge the group element data into the xccdf xml document and create an xml object to return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ class HardCodedRuleConvert
#>
[object] SetRule ([xml.xmlelement] $XccdfRule, [string] $TypeName)
{
# Support for HardCodedRule Split rule with Legacy Id present
$legacyId = ($XccdfRule.rule.ident | Where-Object -FilterScript {$PSItem.'#text' -match "^V-.*"}).'#text'
if ($XccdfRule.id -match '^V-.*\.[a-z]$' -and [string]::IsNullOrEmpty($legacyId) -eq $false)
{
$legacyId = '{0}.{1}' -f $legacyId, $XccdfRule.id.Split('.')[1]
}

$newRule = New-Object -TypeName $TypeName -ArgumentList $XccdfRule
$propertyHashtable = Get-HardCodedRuleProperty -CheckContent $XccdfRule.Rule.Check.'check-content'
foreach ($property in $propertyHashtable.Keys)
Expand All @@ -85,6 +92,7 @@ class HardCodedRuleConvert
{
$newRule.set_OrganizationValueRequired($true)
}
$newRule.set_LegacyId($legacyId)
$newRule.set_Severity($XccdfRule.rule.severity)
$newRule.set_Description($XccdfRule.rule.description)
$newRule.set_RawString($XccdfRule.Rule.check.'check-content')
Expand Down
4 changes: 4 additions & 0 deletions source/Module/Rule/Convert/ConvertFactory.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@ class ConvertFactory
foreach ($convertedrule in $ruleTypeList)
{
$convertedrule.id = "$($Rule.id).$([CHAR][BYTE]$byte)"
if ([string]::IsNullOrEmpty($convertedrule.LegacyId) -eq $false)
{
$convertedrule.LegacyId = "$($convertedrule.LegacyId).$([CHAR][BYTE]$byte)"
}
$byte ++
}
}
Expand Down
2 changes: 2 additions & 0 deletions source/Module/Rule/Rule.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ foreach ($supportFile in $supportFileList)
class Rule : ICloneable
{
[string] $Id
[string] $LegacyId
[string] $Title
[severity] $Severity
[status] $ConversionStatus
Expand Down Expand Up @@ -102,6 +103,7 @@ class Rule : ICloneable
{
# This relaces the current Invokeclass method
$this.Id = $Rule.Id
$this.LegacyId = ($rule.Rule.ident | Where-Object -FilterScript {$PSItem.'#text' -match "^V-.*"}).'#text'
$this.Title = $Rule.Title
$this.Severity = $Rule.rule.severity
$this.Description = $Rule.rule.description
Expand Down
62 changes: 61 additions & 1 deletion source/StigData/Processed/IISServer-10.0-2.1.xml

Large diffs are not rendered by default.

61 changes: 60 additions & 1 deletion source/StigData/Processed/IISServer-8.5-2.1.xml

Large diffs are not rendered by default.

Loading