@@ -42,15 +42,25 @@ function New-StigCheckList
42
42
$XccdfPath ,
43
43
44
44
[Parameter (Mandatory = $true )]
45
- [string ]
45
+ [System.IO.FileInfo ]
46
46
$OutputPath
47
47
)
48
48
49
+ if (-not (Test-Path - Path $OutputPath.DirectoryName ))
50
+ {
51
+ throw " $ ( $OutputPath.DirectoryName ) is not a valid directory. Please provide a valid directory."
52
+ }
53
+
54
+ if ($OutputPath.Extension -ne ' .ckl' )
55
+ {
56
+ throw " $ ( $OutputPath.FullName ) is not a valid checklist extension. Please provide a full valid path ending in .ckl"
57
+ }
58
+
49
59
$xmlWriterSettings = [System.Xml.XmlWriterSettings ]::new()
50
60
$xmlWriterSettings.Indent = $true
51
61
$xmlWriterSettings.IndentChars = " `t "
52
62
$xmlWriterSettings.NewLineChars = " `n "
53
- $writer = [System.Xml.XmlWriter ]::Create($outputPath , $xmlWriterSettings )
63
+ $writer = [System.Xml.XmlWriter ]::Create($OutputPath .FullName , $xmlWriterSettings )
54
64
55
65
$writer.WriteStartElement (' CHECKLIST' )
56
66
@@ -94,17 +104,17 @@ function New-StigCheckList
94
104
$xccdfBenchmarkContent = Get-StigXccdfBenchmarkContent - Path $xccdfPath
95
105
96
106
$stigInfoElements = [ordered ] @ {
97
- ' version' = $xccdfBenchmarkContent.version
107
+ ' version' = $xccdfBenchmarkContent.version
98
108
' classification' = ' UNCLASSIFIED'
99
- ' customname' = ' '
100
- ' stigid' = $xccdfBenchmarkContent.id
101
- ' description' = $xccdfBenchmarkContent.description
102
- ' filename' = Split-Path - Path $xccdfPath - Leaf
103
- ' releaseinfo' = $xccdfBenchmarkContent .' plain-text' .InnerText
104
- ' title' = $xccdfBenchmarkContent.title
105
- ' uuid' = (New-Guid ).Guid
106
- ' notice' = $xccdfBenchmarkContent.notice.InnerText
107
- ' source' = $xccdfBenchmarkContent.reference.source
109
+ ' customname' = ' '
110
+ ' stigid' = $xccdfBenchmarkContent.id
111
+ ' description' = $xccdfBenchmarkContent.description
112
+ ' filename' = Split-Path - Path $xccdfPath - Leaf
113
+ ' releaseinfo' = $xccdfBenchmarkContent .' plain-text' .InnerText
114
+ ' title' = $xccdfBenchmarkContent.title
115
+ ' uuid' = (New-Guid ).Guid
116
+ ' notice' = $xccdfBenchmarkContent.notice.InnerText
117
+ ' source' = $xccdfBenchmarkContent.reference.source
108
118
}
109
119
110
120
foreach ($StigInfoElement in $stigInfoElements.GetEnumerator ())
@@ -134,7 +144,7 @@ function New-StigCheckList
134
144
135
145
foreach ($attribute in $vulnerability.GetEnumerator ())
136
146
{
137
- $status = $null
147
+ $status = $null
138
148
$comments = $null
139
149
140
150
if ($attribute.Name -eq ' Vuln_Num' )
0 commit comments