-
Notifications
You must be signed in to change notification settings - Fork 3
/
Parse-STIGData.ps1
50 lines (42 loc) · 1.42 KB
/
Parse-STIGData.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<#
.SYNOPSIS
Inputs XML > Outputs Spreadsheet
.DESCRIPTION
Opens STIG XML data (or a checklist)
Searches for Elements that match criteria
Cleans/Exports data to a CSV file
.NOTES
File Name: Parse-STIGData.ps1
Author: Jay Berkovitz
Link: github.com/heuricane/InfoSecTools/blob/master/Parse-STIGData.ps1
.REQUIREMENTS
PS Version 5
Input STIG XML file
#>
# -- Preset the Variables -- #
$path = "C:\a\Checklist.xml"
$search = "Status"
$find = "Open"
$custList=@()
# -- Loads the contents as XML and searches -- #
$xml = [xml](Get-Content $path)
$list = $xml.CHECKLIST.STIGS.iSTIG.VULN | Where $search -eq $find
# -- Loop Through Findings -- #
0..($list.Count-1) | Foreach {
# -- Truncate Comments that Exceed the CSV Max Character Length -- #
$comment = $list[$_].COMMENTS.Trim()
If($comment.Length -gt 32767){$comment = $comment.Substring(0,32756)}
# -- Apply settings to object for Export -- #
$customObject = New-Object -TypeName PSObject -Property (@{
'VULN_IDs' = $list[$_].STIG_DATA.ATTRIBUTE_DATA[0].Trim();
'Statuses' = $list[$_].STATUS.Trim();
'Detailed' = $list[$_].FINDING_DETAILS.Trim();
'Comments' = $comment
})
$custList += $customObject
}
# -- Export -- #
$saveDate = (Get-Date).tostring("yyyyMMdd")
$output = "C:\a\" +$saveDate + "_Custom.csv"
$custList | Select VULN_IDs,Statuses,Detailed,Comments |
Export-CSV -Path $output -NoTypeInformation