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 successfully parse/apply MS SQL Server 2012 Instance Ver. 1 Rel. 20 #642

Merged
merged 11 commits into from
Jun 1, 2020
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [Unreleased]

* Update PowerSTIG to successfully parse/apply MS SQL Server 2012 Instance Ver. 1 Rel. 20: [#639](https://github.com/microsoft/PowerStig/issues/639)
* Update PowerSTIG to successfully parse/apply MS SQL Server 2016 Instance Ver. 1 Rel. 9: [#636](https://github.com/microsoft/PowerStig/issues/636)
* Update PowerSTIG to successfully parse/apply Windows Server 2012 DNS STIG - Ver 1, Rel 14: [#633](https://github.com/microsoft/PowerStig/issues/633)
* Update PowerSTIG to parse/convert the Vmware Vsphere 6.5 STIG V1R4: [#634](https://github.com/microsoft/PowerStig/issues/634)
Expand Down
28 changes: 14 additions & 14 deletions source/Module/Common/Functions.XccdfXml.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -375,15 +375,10 @@ function Split-BenchmarkId
{
{$PSItem -match "SQL_Server"}
{
# The metadata does not differentiate between the database and instance STIG so we have to get that from the file name.
$sqlRole = Get-SqlTechnologyRole -Path $FilePath
$returnId = $id -replace ($sqlServerVariations -join '|'), 'SqlServer'

# SQL 2012 Instance 1.17 has a different format which requires this line, can be removed when this STIG is no longer in archive
$returnId = $returnId -replace "_Database_Instance" + ""
# SQL 2012 Database 1.20 has a different format which requires this line.
$returnId = $returnId -replace "_Database" + ""
$returnId = '{0}_{1}' -f $returnId, $sqlRole
$sqlRole = Get-SqlTechnologyRole -Path $FilePath -Id $id
$id -match "(?<Version>\d{4})"
$sqlVersion = $Matches['Version']
$returnId = 'SqlServer_{0}_{1}' -f $sqlVersion, $sqlRole
continue
}
{$PSItem -match "_Firewall"}
Expand Down Expand Up @@ -519,6 +514,10 @@ function Get-SqlTechnologyRole
[OutputType([string])]
param
(
[Parameter(Mandatory = $true)]
[string]
$Id,

[Parameter(Mandatory=$true)]
[AllowEmptyString()]
[string]
Expand All @@ -528,6 +527,11 @@ function Get-SqlTechnologyRole
$split = $Path -split '_'
$stigIndex = $split.IndexOf('STIG')
$sqlRole = $split[$stigIndex -1]
if ($sqlRole -match '\w\d{1,}\w\d{1,}')
{
$null = $Id -match "(?<Type>Database|Instance)"
$sqlRole = $Matches['Type']
}
bcwilhite marked this conversation as resolved.
Show resolved Hide resolved

return $sqlRole
}
Expand Down Expand Up @@ -555,12 +559,8 @@ function Get-StigVersionNumber
)

# Extract the revision number from the xccdf
$revision = ( $StigDetails.Benchmark.'plain-text'.'#text' `
-split "(Release:)(.*?)(Benchmark)" )[2].trim()

$revision = ($StigDetails.Benchmark.'plain-text'.'#text' -split "(Release:)(.*?)(Benchmark)")[2].trim()
"$($StigDetails.Benchmark.version).$revision"

}

#endregion

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Each setting in this file is linked by STIG ID and the valid range is in an
associated comment.
-->
<OrganizationalSettings fullversion="1.17">
<OrganizationalSettings fullversion="1.20">
<!-- Ensure the correct path is specified and does NOT conflict with RuleId V-69169-->
<OrganizationalSetting id="V-40950" Path="" />
<!-- Ensure -->
Expand Down
Loading