Skip to content

Commit

Permalink
Update PowerSTIG to successfully parse/apply MS SQL Server 2012 Insta…
Browse files Browse the repository at this point in the history
…nce Ver. 1 Rel. 20 (#642)

* updated sql 2012 Instance V1R20

* updated Get-SqlTechnologyRole

* removed tabs

* added a new line to the end of xccdf

* update build to use dscresource.test 0.13.1

* updated code based on feedback
  • Loading branch information
bcwilhite authored Jun 1, 2020
1 parent 9909e1f commit 6b4d7d4
Show file tree
Hide file tree
Showing 6 changed files with 5,737 additions and 5,728 deletions.
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']
}

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

0 comments on commit 6b4d7d4

Please sign in to comment.