Skip to content

Commit

Permalink
Document: Adding initial module files (#72)
Browse files Browse the repository at this point in the history
* initial files

* formatting

* added files

* renamed file

* moved functions

* added tests

* rem duplicate module call

* added PR feedback

* fixed typo

* added document module

* fixed casing
  • Loading branch information
athaynes authored Aug 17, 2018
1 parent 3395168 commit ea6f0f2
Show file tree
Hide file tree
Showing 67 changed files with 2,026 additions and 412 deletions.
8 changes: 8 additions & 0 deletions .NuspecFileList.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"src": "PowerStig.psm1",
"target": ""
},
{
"src": "PowerStig.Document.psm1",
"target": ""
},
{
"src": "README.md",
"target": ""
Expand All @@ -30,5 +34,9 @@
{
"src": "Module\\Stig*\\**",
"target": "Module"
},
{
"src": "Module\\Document*\\**",
"target": "Module"
}
]
2 changes: 1 addition & 1 deletion DSCResources/Browser/Browser.schema.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ using module ..\..\PowerStig.psm1
Configuration Browser
{
[CmdletBinding()]
Param
param
(
[Parameter(Mandatory = $true)]
[ValidateSet('IE11')]
Expand Down
2 changes: 1 addition & 1 deletion DSCResources/DotNetFramework/DotNetFramework.schema.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ using module ..\..\PowerStig.psm1
Configuration DotNetFramework
{
[CmdletBinding()]
Param
param
(
[Parameter(Mandatory = $true)]
[ValidateSet('DotNet4')]
Expand Down
2 changes: 1 addition & 1 deletion DSCResources/SqlServer/SqlServer.schema.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ using module ..\..\PowerStig.psm1
Configuration SqlServer
{
[CmdletBinding()]
Param
param
(
[Parameter(Mandatory = $true)]
[ValidateSet('2012')]
Expand Down
2 changes: 1 addition & 1 deletion DSCResources/WindowsDnsServer/WindowsDnsServer.schema.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ using module ..\..\PowerStig.psm1
Configuration WindowsDnsServer
{
[CmdletBinding()]
Param
param
(
[Parameter(Mandatory = $true)]
[ValidateSet('2012R2')]
Expand Down
2 changes: 1 addition & 1 deletion DSCResources/WindowsFirewall/WindowsFirewall.schema.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ using module ..\..\PowerStig.psm1
Configuration WindowsFirewall
{
[CmdletBinding()]
Param
param
(
[Parameter()]
[ValidateSet('1.6')]
Expand Down
2 changes: 1 addition & 1 deletion DSCResources/WindowsServer/WindowsServer.schema.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ using module ..\..\PowerStig.psm1
Configuration WindowsServer
{
[CmdletBinding()]
Param
param
(
[Parameter(Mandatory = $true)]
[ValidateSet('2012R2', '2016')]
Expand Down
5 changes: 1 addition & 4 deletions Module/Common/Function.Helper.ps1
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#region Header
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
#endregion
#region Support Functions

<#
.SYNOPSIS
Appends the next letter in the alphabet to the ID to handle rules that enforce multiple settings
Expand Down Expand Up @@ -35,4 +33,3 @@ function Get-AvailableId
return "$Id.$([char]$appendLetterInt)"
}
}
#endregion
52 changes: 26 additions & 26 deletions Module/Common/Function.RangeConversion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function Get-OrganizationValueTestString
[OutputType([string])]
param
(
[parameter(Mandatory = $true)]
[Parameter(Mandatory = $true)]
[string]
$String
)
Expand Down Expand Up @@ -67,7 +67,7 @@ function Get-TestStringTokenNumbers
[OutputType([string[]])]
param
(
[parameter(Mandatory = $true)]
[Parameter(Mandatory = $true)]
[string]
$String
)
Expand All @@ -86,7 +86,7 @@ function Get-TestStringTokenNumbers
{
$number[1, 2]
}
else
else
{
[convert]::ToInt32($match,16)
}
Expand All @@ -108,15 +108,15 @@ function Get-TestStringTokenList
[OutputType([string])]
param
(
[parameter(Mandatory = $true)]
[Parameter(Mandatory = $true)]
[string]
$String,

[parameter(ParameterSetName = 'CommandTokens')]
[Parameter(ParameterSetName = 'CommandTokens')]
[switch]
$CommandTokens,

[parameter(ParameterSetName = 'StringTokens')]
[Parameter(ParameterSetName = 'StringTokens')]
[switch]
$StringTokens
)
Expand All @@ -141,7 +141,7 @@ function ConvertTo-TestString
[OutputType([string])]
param
(
[parameter(Mandatory = $true)]
[Parameter(Mandatory = $true)]
[string]
$String
)
Expand Down Expand Up @@ -236,7 +236,7 @@ function ConvertTo-HashTable
This example returns $false
Test-StringIsNegativeOr -String "1 or 2 = is not a Finding"
.NOTES
Tests if a string such as '1 or 2 = a Finding' is a negative or test.
#>
Expand All @@ -246,7 +246,7 @@ function Test-StringIsNegativeOr
[OutputType([bool])]
param
(
[parameter(Mandatory = $true)]
[Parameter(Mandatory = $true)]
[string]
$String
)
Expand Down Expand Up @@ -282,7 +282,7 @@ function Test-StringIsPositiveOr
[OutputType([bool])]
param
(
[parameter(Mandatory = $true)]
[Parameter(Mandatory = $true)]
[string]
$string
)
Expand Down Expand Up @@ -346,7 +346,7 @@ function ConvertTo-OrTestString
[OutputType([string])]
param
(
[parameter(Mandatory = $true)]
[Parameter(Mandatory = $true)]
[string]
$String,

Expand Down Expand Up @@ -397,7 +397,7 @@ function Test-StringIsGreaterThan
[OutputType([bool])]
param
(
[parameter(Mandatory = $true)]
[Parameter(Mandatory = $true)]
[string]
$String
)
Expand Down Expand Up @@ -434,7 +434,7 @@ function Test-StringIsGreaterThanOrEqual
[OutputType([bool])]
param
(
[parameter(Mandatory = $true)]
[Parameter(Mandatory = $true)]
[string]
$String
)
Expand Down Expand Up @@ -471,7 +471,7 @@ function Test-StringIsGreaterThanButNot
[OutputType([bool])]
param
(
[parameter(Mandatory = $true)]
[Parameter(Mandatory = $true)]
[string]
$String
)
Expand Down Expand Up @@ -508,7 +508,7 @@ function Test-StringIsGreaterThanOrEqualButNot
[OutputType([bool])]
param
(
[parameter(Mandatory = $true)]
[Parameter(Mandatory = $true)]
[string]
$String
)
Expand Down Expand Up @@ -543,7 +543,7 @@ function Test-StringIsLessThan
[OutputType([bool])]
param
(
[parameter(Mandatory = $true)]
[Parameter(Mandatory = $true)]
[string]
$String
)
Expand Down Expand Up @@ -577,7 +577,7 @@ function Test-StringIsLessThanOrEqual
[OutputType([bool])]
param
(
[parameter(Mandatory = $true)]
[Parameter(Mandatory = $true)]
[string]
$String
)
Expand Down Expand Up @@ -614,7 +614,7 @@ function Test-StringIsLessThanButNot
[OutputType([bool])]
param
(
[parameter(Mandatory = $true)]
[Parameter(Mandatory = $true)]
[string]
$String
)
Expand Down Expand Up @@ -659,7 +659,7 @@ function Test-StringIsLessThanOrEqualButNot
[OutputType([bool])]
param
(
[parameter(Mandatory = $true)]
[Parameter(Mandatory = $true)]
[string]
$String
)
Expand Down Expand Up @@ -696,7 +696,7 @@ function Test-StringIsLessThanOrEqualExcluding
[OutputType([bool])]
param
(
[parameter(Mandatory = $true)]
[Parameter(Mandatory = $true)]
[string]
$String
)
Expand Down Expand Up @@ -730,7 +730,7 @@ function Test-StringIsMultipleValue
[OutputType([bool])]
param
(
[parameter(Mandatory = $true)]
[Parameter(Mandatory = $true)]
[string]
$String
)
Expand Down Expand Up @@ -761,9 +761,9 @@ function ConvertTo-MultipleValue
{
[CmdletBinding()]
[OutputType([string])]
Param
param
(
[parameter(Mandatory)]
[Parameter(Mandatory)]
[string[]] $String
)

Expand All @@ -786,7 +786,7 @@ function Get-SecurityPolicyString
[OutputType([string])]
param
(
[parameter(Mandatory = $true)]
[Parameter(Mandatory = $true)]
[AllowEmptyString()]
[string[]]
$CheckContent
Expand All @@ -813,7 +813,7 @@ function Test-SecurityPolicyContainsRange
[OutputType([bool])]
param
(
[parameter(Mandatory = $true)]
[Parameter(Mandatory = $true)]
[AllowEmptyString()]
[string[]]
$CheckContent
Expand Down Expand Up @@ -842,7 +842,7 @@ function Get-SecurityPolicyOrganizationValueTestString
[CmdletBinding()]
param
(
[parameter(Mandatory = $true)]
[Parameter(Mandatory = $true)]
[AllowEmptyString()]
[string[]]
$CheckContent
Expand Down
74 changes: 74 additions & 0 deletions Module/Common/Function.Xccdf.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

<#
.SYNOPSIS
Returns the benchmark element from the xccdf xml document.
.PARAMETER Path
The literal path to the the zip file that contain the xccdf or the specifc xccdf file.
#>
function Get-StigXccdfBenchmarkContent
{
[CmdletBinding()]
[OutputType([xml])]
param
(
[Parameter(Mandatory = $true)]
[string]
$Path
)

if (-not (Test-Path -Path $Path))
{
Throw "The file $Path was not found"
}

if ($Path -like "*.zip")
{
[xml] $xccdfXmlContent = Get-StigContentFromZip -Path $Path
}
else
{
[xml] $xccdfXmlContent = Get-Content -Path $Path -Encoding UTF8
}

$xccdfXmlContent.Benchmark
}

<#
.SYNOPSIS
Extracts the xccdf file from the zip file provided from the DISA website.
.PARAMETER Path
The literal path to the zip file.
#>
function Get-StigContentFromZip
{
[CmdletBinding()]
[OutputType([xml])]
param
(
[Parameter(Mandatory = $true)]
[string]
$Path
)

# Create a unique path in the users temp directory to expand the files to.
$zipDestinationPath = "$((Split-Path -Path $Path -Leaf) -replace '.zip','').$((Get-Date).Ticks)"
Expand-Archive -LiteralPath $Path -DestinationPath $zipDestinationPath
# Get the full path to the extracted xccdf file.
$getChildItem = @{
Path = $zipDestinationPath
Filter = "*Manual-xccdf.xml"
Recurse = $true
}

$xccdfPath = (Get-ChildItem @getChildItem).fullName
# Get the xccdf content before removing the content from disk.
$xccdfContent = Get-Content -Path $xccdfPath
# Cleanup to temp folder
Remove-Item $zipDestinationPath -Recurse -Force

$xccdfContent
}
4 changes: 2 additions & 2 deletions Module/Convert.AccountPolicyRule/Functions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ function ConvertTo-AccountPolicyRule
{
[CmdletBinding()]
[OutputType([AccountPolicyRule])]
Param
param
(
[parameter(Mandatory = $true)]
[Parameter(Mandatory = $true)]
[xml.xmlelement]
$StigRule
)
Expand Down
Loading

0 comments on commit ea6f0f2

Please sign in to comment.