-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Document: Adding initial module files (#72)
* 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
Showing
67 changed files
with
2,026 additions
and
412 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.