| 1 |
<?xml version="1.0" encoding="utf-8" ?> |
| 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 |
<xsl:stylesheet version="1.1" |
| 27 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
| 28 |
xmlns:ovalres="http://oval.mitre.org/XMLSchema/oval-results-5" |
| 29 |
xmlns:ovalsys="http://oval.mitre.org/XMLSchema/oval-system-characteristics-5" |
| 30 |
xmlns:ovalunixsc="http://oval.mitre.org/XMLSchema/oval-system-characteristics-5#unix" |
| 31 |
xmlns:ovalindsc="http://oval.mitre.org/XMLSchema/oval-system-characteristics-5#independent" |
| 32 |
exclude-result-prefixes="xsl ovalres ovalsys ovalunixsc ovalindsc"> |
| 33 |
|
| 34 |
<xsl:key name='oval-definition' match='ovalres:definition' use='@definition_id' /> |
| 35 |
<xsl:key name='oval-test' match='ovalres:test' use='@test_id' /> |
| 36 |
<xsl:key name='oval-items' match='ovalsys:system_data/*' use='@id' /> |
| 37 |
|
| 38 |
<xsl:key name='oval-testdef' match='*[starts-with(namespace-uri(), "http://oval.mitre.org/XMLSchema/oval-definitions") and contains(local-name(), "_test")]' use='@id' /> |
| 39 |
<xsl:key name='oval-objectdef' match='*[starts-with(namespace-uri(), "http://oval.mitre.org/XMLSchema/oval-definitions") and contains(local-name(), "_object")]' use='@id' /> |
| 40 |
<xsl:key name='oval-statedef' match='*[starts-with(namespace-uri(), "http://oval.mitre.org/XMLSchema/oval-definitions") and contains(local-name(), "_state")]' use='@id' /> |
| 41 |
<xsl:key name='oval-variable' match='*[starts-with(namespace-uri(), "http://oval.mitre.org/XMLSchema/oval-results-5") and contains(local-name(), "tested_variable")]' use='@variable_id' /> |
| 42 |
<xsl:key name='ovalsys-object' match='*[starts-with(namespace-uri(), "http://oval.mitre.org/XMLSchema/oval-system-characteristics-5") and contains(local-name(), "object")]' use='@id' /> |
| 43 |
|
| 44 |
<xsl:template mode='brief' match='ovalres:oval_results'> |
| 45 |
<xsl:param name='definition-id' /> |
| 46 |
<xsl:apply-templates select='key("oval-definition", $definition-id)' mode='brief' /> |
| 47 |
</xsl:template> |
| 48 |
|
| 49 |
<xsl:template mode='brief' match='ovalres:extend_definition'> |
| 50 |
<xsl:apply-templates select='key("oval-definition", @definition_ref)' mode='brief' /> |
| 51 |
</xsl:template> |
| 52 |
|
| 53 |
<xsl:template mode='brief' match='ovalres:criterion'> |
| 54 |
<xsl:apply-templates select='key("oval-test", @test_ref)' mode='brief'> |
| 55 |
<xsl:with-param name='title' select='key("oval-testdef", @test_ref)/@comment'/> |
| 56 |
</xsl:apply-templates> |
| 57 |
</xsl:template> |
| 58 |
|
| 59 |
<xsl:template mode='brief' match='ovalres:criteria'> |
| 60 |
|
| 61 |
<xsl:apply-templates mode='brief' /> |
| 62 |
</xsl:template> |
| 63 |
|
| 64 |
<xsl:template mode='brief' match='ovalres:definition'> |
| 65 |
<xsl:apply-templates mode='brief' select="ovalres:criteria" /> |
| 66 |
</xsl:template> |
| 67 |
|
| 68 |
|
| 69 |
<xsl:template mode='brief' match='ovalres:test'> |
| 70 |
<xsl:param name='title'/> |
| 71 |
<xsl:variable name='items' select='ovalres:tested_item'/> |
| 72 |
<h4> |
| 73 |
<xsl:if test='$title'> |
| 74 |
<span class="label label-primary"> |
| 75 |
<xsl:value-of select='$title'/> |
| 76 |
</span>  |
| 77 |
</xsl:if> |
| 78 |
<span class="label label-default"> |
| 79 |
<xsl:value-of select='@test_id'/> |
| 80 |
</span>  |
| 81 |
<xsl:choose> |
| 82 |
<xsl:when test="@result='true'"> |
| 83 |
<span class="label label-success"> |
| 84 |
<xsl:value-of select="@result"/> |
| 85 |
</span> |
| 86 |
</xsl:when> |
| 87 |
<xsl:otherwise> |
| 88 |
<span class="label label-danger"> |
| 89 |
<xsl:value-of select="@result"/> |
| 90 |
</span> |
| 91 |
</xsl:otherwise> |
| 92 |
</xsl:choose> |
| 93 |
</h4> |
| 94 |
<xsl:choose> |
| 95 |
|
| 96 |
<xsl:when test='$items'> |
| 97 |
<h5>Following items have been found on the system:</h5> |
| 98 |
|
| 99 |
<table class="table table-striped table-bordered"> |
| 100 |
|
| 101 |
<thead> |
| 102 |
<xsl:apply-templates mode='item-head' select='key("oval-items", $items[1]/@item_id)'> |
| 103 |
<xsl:with-param name='resultColumn' select='"true"'/> |
| 104 |
</xsl:apply-templates> |
| 105 |
</thead> |
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
<tbody> |
| 110 |
<xsl:for-each select='$items'> |
| 111 |
<xsl:if test="not(position() > 100)"> |
| 112 |
<xsl:variable name="currentResult" select="@result" /> |
| 113 |
<xsl:for-each select='key("oval-items", @item_id)'> |
| 114 |
<xsl:apply-templates select='.' mode='item-body'> |
| 115 |
<xsl:with-param name="result" select="$currentResult"/> |
| 116 |
</xsl:apply-templates> |
| 117 |
</xsl:for-each> |
| 118 |
</xsl:if> |
| 119 |
</xsl:for-each> |
| 120 |
</tbody> |
| 121 |
</table> |
| 122 |
<xsl:if test="count($items) > 100"> |
| 123 |
... and <xsl:value-of select="count($items)-100"/> more items. |
| 124 |
</xsl:if> |
| 125 |
</xsl:when> |
| 126 |
<xsl:otherwise> |
| 127 |
|
| 128 |
|
| 129 |
<xsl:variable name='object_id' select='key("oval-testdef", @test_id)/*[local-name()="object"]/@object_ref'/> |
| 130 |
<xsl:variable name='object_info' select='key("oval-objectdef",$object_id)'/> |
| 131 |
<xsl:variable name='state_id' select='key("oval-testdef", @test_id)/*[local-name()="state"]/@state_ref'/> |
| 132 |
<xsl:variable name='comment' select='$object_info[1]/@comment'/> |
| 133 |
<xsl:if test="$object_info"> |
| 134 |
<h5>No items have been found conforming to the following objects:</h5> |
| 135 |
<h5>Object <strong><abbr> |
| 136 |
<xsl:if test='$comment'> |
| 137 |
<xsl:attribute name='title'> |
| 138 |
<xsl:value-of select='$object_info[1]/@comment'/> |
| 139 |
</xsl:attribute> |
| 140 |
</xsl:if> |
| 141 |
<xsl:value-of select='$object_id'/></abbr></strong> of type |
| 142 |
<strong><xsl:value-of select='local-name($object_info)'/></strong></h5> |
| 143 |
<table class="table table-striped table-bordered"> |
| 144 |
<thead> |
| 145 |
<xsl:apply-templates mode='item-head' select='$object_info[1]'/> |
| 146 |
</thead> |
| 147 |
<tbody> |
| 148 |
<tr> |
| 149 |
<xsl:apply-templates mode='object' select='$object_info[1]'> |
| 150 |
<xsl:with-param name="tested_var" select="ovalres:tested_variable"/> |
| 151 |
<xsl:with-param name="object_id" select="$object_id"/> |
| 152 |
</xsl:apply-templates> |
| 153 |
</tr> |
| 154 |
</tbody> |
| 155 |
</table> |
| 156 |
</xsl:if> |
| 157 |
</xsl:otherwise> |
| 158 |
</xsl:choose> |
| 159 |
</xsl:template> |
| 160 |
|
| 161 |
<xsl:template mode='normal' match='ovalres:tested_variable'> |
| 162 |
<xsl:if test='* or normalize-space()'> |
| 163 |
<xsl:value-of select='.'/> |
| 164 |
</xsl:if> |
| 165 |
</xsl:template> |
| 166 |
|
| 167 |
<xsl:template mode='tableintable' match='ovalres:tested_variable'> |
| 168 |
<xsl:if test='* or normalize-space()'> |
| 169 |
<tr> |
| 170 |
<td> |
| 171 |
<xsl:value-of select='.'/> |
| 172 |
</td> |
| 173 |
</tr> |
| 174 |
</xsl:if> |
| 175 |
</xsl:template> |
| 176 |
|
| 177 |
<xsl:template mode='object' match='*[starts-with(namespace-uri(), "http://oval.mitre.org/XMLSchema/oval-definitions") and contains(local-name(), "_object")]'> |
| 178 |
<xsl:param name="tested_var"/> |
| 179 |
<xsl:param name="object_id"/> |
| 180 |
|
| 181 |
<xsl:for-each select='*'> |
| 182 |
<td> |
| 183 |
<xsl:choose> |
| 184 |
<xsl:when test="@var_ref"> |
| 185 |
<xsl:variable name="matching_var" select="$tested_var[@variable_id = current()/@var_ref]"/> |
| 186 |
<xsl:choose> |
| 187 |
<xsl:when test="count($matching_var) > 1"> |
| 188 |
<table> |
| 189 |
<xsl:apply-templates mode='tableintable' select="$matching_var"/> |
| 190 |
</table> |
| 191 |
</xsl:when> |
| 192 |
<xsl:otherwise> |
| 193 |
<xsl:apply-templates mode='normal' select="$matching_var"/> |
| 194 |
</xsl:otherwise> |
| 195 |
</xsl:choose> |
| 196 |
<xsl:apply-templates mode='message' select='key("ovalsys-object", $object_id)'/> |
| 197 |
</xsl:when> |
| 198 |
|
| 199 |
<xsl:otherwise> |
| 200 |
<xsl:value-of select="."/> |
| 201 |
</xsl:otherwise> |
| 202 |
</xsl:choose> |
| 203 |
</td> |
| 204 |
</xsl:for-each> |
| 205 |
</xsl:template> |
| 206 |
|
| 207 |
<xsl:template mode='state' match='*[starts-with(namespace-uri(), "http://oval.mitre.org/XMLSchema/oval-definitions") and contains(local-name(), "_state")]'> |
| 208 |
<xsl:for-each select='*'> |
| 209 |
<xsl:if test='* or normalize-space()'> |
| 210 |
<td> |
| 211 |
<xsl:value-of select='.'/> |
| 212 |
</td> |
| 213 |
</xsl:if> |
| 214 |
</xsl:for-each> |
| 215 |
</xsl:template> |
| 216 |
|
| 217 |
<xsl:template mode='message' match='ovalsys:object'> |
| 218 |
<xsl:if test='ovalsys:message'> |
| 219 |
<xsl:value-of select='ovalsys:message'/> |
| 220 |
</xsl:if> |
| 221 |
</xsl:template> |
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
<xsl:template mode='item-head' match='node()' priority='-5'/> |
| 226 |
<xsl:template mode='item-body' match='node()' priority='-5'/> |
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
<xsl:template mode='item-head' match='*'> |
| 231 |
<xsl:param name="resultColumn" select="false"/> |
| 232 |
<tr> |
| 233 |
<xsl:if test='$resultColumn="true"'><th>Result of item-state comparison</th></xsl:if> |
| 234 |
<xsl:for-each select='*'> |
| 235 |
<xsl:variable name='label' select='translate(local-name(), "_", " ")'/> |
| 236 |
<xsl:variable name='first_letter' select='translate(substring($label,1,1), "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ")'/> |
| 237 |
<xsl:variable name='rest' select='substring($label,2)'/> |
| 238 |
<th><xsl:value-of select='concat($first_letter, $rest)'/></th> |
| 239 |
</xsl:for-each> |
| 240 |
</tr> |
| 241 |
</xsl:template> |
| 242 |
|
| 243 |
<xsl:template mode='item-body' match='*'> |
| 244 |
<xsl:param name="result"/> |
| 245 |
<tr> |
| 246 |
<td> |
| 247 |
<xsl:choose> |
| 248 |
<xsl:when test="$result='true'"> |
| 249 |
<span class="label label-success"> |
| 250 |
<xsl:value-of select="$result"/> |
| 251 |
</span> |
| 252 |
</xsl:when> |
| 253 |
<xsl:otherwise> |
| 254 |
<span class="label label-danger"> |
| 255 |
<xsl:value-of select="$result"/> |
| 256 |
</span> |
| 257 |
</xsl:otherwise> |
| 258 |
</xsl:choose> |
| 259 |
</td> |
| 260 |
<xsl:for-each select='*'> |
| 261 |
<td> |
| 262 |
<xsl:if test='@datatype="int" or @datatype="boolean"'><xsl:attribute name='role'>num</xsl:attribute></xsl:if> |
| 263 |
<xsl:value-of select='.'/> |
| 264 |
</td> |
| 265 |
</xsl:for-each> |
| 266 |
</tr> |
| 267 |
</xsl:template> |
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
<xsl:template mode='item-head' match='ovalunixsc:file_item'> |
| 272 |
<tr><th>Result of item-state comparison</th><th>Path</th><th>Type</th><th>UID</th><th>GID</th><th>Size (B)</th><th>Permissions</th></tr> |
| 273 |
</xsl:template> |
| 274 |
|
| 275 |
<xsl:template mode='item-body' match='ovalunixsc:file_item'> |
| 276 |
<xsl:param name="result"/> |
| 277 |
<xsl:variable name='path' select='concat(ovalunixsc:path, "/", ovalunixsc:filename)'/> |
| 278 |
<tr> |
| 279 |
<td> |
| 280 |
<xsl:choose> |
| 281 |
<xsl:when test="$result='true'"> |
| 282 |
<span class="label label-success"> |
| 283 |
<xsl:value-of select="$result"/> |
| 284 |
</span> |
| 285 |
</xsl:when> |
| 286 |
<xsl:otherwise> |
| 287 |
<span class="label label-danger"> |
| 288 |
<xsl:value-of select="$result"/> |
| 289 |
</span> |
| 290 |
</xsl:otherwise> |
| 291 |
</xsl:choose> |
| 292 |
</td> |
| 293 |
<td><xsl:value-of select='$path'/></td> |
| 294 |
<td><xsl:value-of select='ovalunixsc:type'/></td> |
| 295 |
<td><xsl:value-of select='ovalunixsc:user_id'/></td> |
| 296 |
<td><xsl:value-of select='ovalunixsc:group_id'/></td> |
| 297 |
<td><xsl:value-of select='ovalunixsc:size'/></td> |
| 298 |
|
| 299 |
<td> |
| 300 |
<code> |
| 301 |
<xsl:apply-templates mode='permission' select='ovalunixsc:uread'/> |
| 302 |
<xsl:apply-templates mode='permission' select='ovalunixsc:uwrite'/> |
| 303 |
<xsl:choose> |
| 304 |
<xsl:when test='string(ovalunixsc:suid)="true"'>s</xsl:when> |
| 305 |
<xsl:otherwise><xsl:apply-templates mode='permission' select='ovalunixsc:uexec'/></xsl:otherwise> |
| 306 |
</xsl:choose> |
| 307 |
<xsl:apply-templates mode='permission' select='ovalunixsc:gread'/> |
| 308 |
<xsl:apply-templates mode='permission' select='ovalunixsc:gwrite'/> |
| 309 |
<xsl:choose> |
| 310 |
<xsl:when test='string(ovalunixsc:sgid)="true"'>s</xsl:when> |
| 311 |
<xsl:otherwise><xsl:apply-templates mode='permission' select='ovalunixsc:gexec'/></xsl:otherwise> |
| 312 |
</xsl:choose> |
| 313 |
<xsl:apply-templates mode='permission' select='ovalunixsc:oread'/> |
| 314 |
<xsl:apply-templates mode='permission' select='ovalunixsc:owrite'/> |
| 315 |
<xsl:apply-templates mode='permission' select='ovalunixsc:oexec'/> |
| 316 |
<xsl:choose> |
| 317 |
<xsl:when test='string(ovalunixsc:sticky)="true"'>t</xsl:when> |
| 318 |
<xsl:otherwise><xsl:text> </xsl:text></xsl:otherwise> |
| 319 |
</xsl:choose> |
| 320 |
</code> |
| 321 |
</td> |
| 322 |
</tr> |
| 323 |
</xsl:template> |
| 324 |
|
| 325 |
<xsl:template mode='permission' match='*'> |
| 326 |
<xsl:choose> |
| 327 |
<xsl:when test='string(.)="true"'><xsl:value-of select='translate(substring(local-name(),2,1), "e", "x")'/></xsl:when> |
| 328 |
<xsl:otherwise>-</xsl:otherwise> |
| 329 |
</xsl:choose> |
| 330 |
</xsl:template> |
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
<xsl:template mode='item-head' match='ovalindsc:textfilecontent_item'> |
| 335 |
<tr><th>Result of item-state comparison</th><th>Path</th><th>Content</th></tr> |
| 336 |
</xsl:template> |
| 337 |
|
| 338 |
<xsl:template mode='item-body' match='ovalindsc:textfilecontent_item'> |
| 339 |
<xsl:param name="result"/> |
| 340 |
<xsl:variable name='path' select='concat(ovalindsc:path, "/", ovalindsc:filename)'/> |
| 341 |
<tr> |
| 342 |
<td> |
| 343 |
<xsl:choose> |
| 344 |
<xsl:when test="$result='true'"> |
| 345 |
<span class="label label-success"> |
| 346 |
<xsl:value-of select="$result"/> |
| 347 |
</span> |
| 348 |
</xsl:when> |
| 349 |
<xsl:otherwise> |
| 350 |
<span class="label label-danger"> |
| 351 |
<xsl:value-of select="$result"/> |
| 352 |
</span> |
| 353 |
</xsl:otherwise> |
| 354 |
</xsl:choose> |
| 355 |
</td> |
| 356 |
<td><xsl:value-of select='$path'/></td><td><xsl:value-of select='ovalindsc:text'/></td> |
| 357 |
</tr> |
| 358 |
</xsl:template> |
| 359 |
|
| 360 |
</xsl:stylesheet> |