| 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 |
<xsl:stylesheet |
| 26 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
| 27 |
xmlns:xccdf_11="http://checklists.nist.gov/xccdf/1.1" |
| 28 |
xmlns:xccdf_12="http://checklists.nist.gov/xccdf/1.2" |
| 29 |
|
| 30 |
version="1.0"> |
| 31 |
|
| 32 |
<xsl:output method="xml" indent="yes"/> |
| 33 |
|
| 34 |
<xsl:param name="reverse_DNS"/> |
| 35 |
|
| 36 |
<xsl:key name="profiles" match="/xccdf_11:Benchmark/xccdf_11:Profile" use="@id"/> |
| 37 |
<xsl:key name="rules" match="/xccdf_11:Benchmark//xccdf_11:Rule" use="@id"/> |
| 38 |
<xsl:key name="groups" match="/xccdf_11:Benchmark//xccdf_11:Group" use="@id"/> |
| 39 |
<xsl:key name="values" match="/xccdf_11:Benchmark//xccdf_11:Value" use="@id"/> |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
<xsl:template match="@*|node()"> |
| 45 |
<xsl:copy> |
| 46 |
<xsl:apply-templates select="@*|node()"/> |
| 47 |
</xsl:copy> |
| 48 |
</xsl:template> |
| 49 |
|
| 50 |
|
| 51 |
<xsl:template match="xccdf_11:*"> |
| 52 |
<xsl:choose> |
| 53 |
|
| 54 |
<xsl:when test="local-name()='platform-definitions' or local-name()='Platform-Specification' or local-name()='cpe-list' or local-name()='impact-metric'"> |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
<xsl:text disable-output-escaping="yes"><--</xsl:text> |
| 59 |
This element has been deprecated and was removed from XCCDF 1.2! |
| 60 |
|
| 61 |
<xsl:element name="{local-name()}"> |
| 62 |
<xsl:apply-templates select="@*"/> |
| 63 |
<xsl:apply-templates/> |
| 64 |
</xsl:element> |
| 65 |
<xsl:text disable-output-escaping="yes">--></xsl:text> |
| 66 |
</xsl:when> |
| 67 |
<xsl:otherwise> |
| 68 |
<xsl:element name="{local-name()}" namespace="http://checklists.nist.gov/xccdf/1.2"> |
| 69 |
|
| 70 |
|
| 71 |
<xsl:apply-templates select="@*"/> |
| 72 |
<xsl:apply-templates/> |
| 73 |
</xsl:element> |
| 74 |
</xsl:otherwise> |
| 75 |
</xsl:choose> |
| 76 |
</xsl:template> |
| 77 |
|
| 78 |
|
| 79 |
<xsl:template match="@id[parent::xccdf_11:Benchmark]"> |
| 80 |
<xsl:variable name="old_id" select="."/> |
| 81 |
|
| 82 |
<xsl:attribute name="id"> |
| 83 |
<xsl:value-of select="concat('xccdf_', $reverse_DNS, '_benchmark_', $old_id)"/> |
| 84 |
</xsl:attribute> |
| 85 |
</xsl:template> |
| 86 |
|
| 87 |
|
| 88 |
<xsl:template match="@id[parent::xccdf_11:Profile]"> |
| 89 |
<xsl:variable name="old_id" select="."/> |
| 90 |
|
| 91 |
<xsl:attribute name="id"> |
| 92 |
<xsl:value-of select="concat('xccdf_', $reverse_DNS, '_profile_', $old_id)"/> |
| 93 |
</xsl:attribute> |
| 94 |
</xsl:template> |
| 95 |
|
| 96 |
|
| 97 |
<xsl:template match="@id[parent::xccdf_11:Rule]"> |
| 98 |
<xsl:variable name="old_id" select="."/> |
| 99 |
|
| 100 |
<xsl:attribute name="id"> |
| 101 |
<xsl:value-of select="concat('xccdf_', $reverse_DNS, '_rule_', $old_id)"/> |
| 102 |
</xsl:attribute> |
| 103 |
</xsl:template> |
| 104 |
|
| 105 |
|
| 106 |
<xsl:template match="@id[parent::xccdf_11:Group]"> |
| 107 |
<xsl:variable name="old_id" select="."/> |
| 108 |
|
| 109 |
<xsl:attribute name="id"> |
| 110 |
<xsl:value-of select="concat('xccdf_', $reverse_DNS, '_group_', $old_id)"/> |
| 111 |
</xsl:attribute> |
| 112 |
</xsl:template> |
| 113 |
|
| 114 |
|
| 115 |
<xsl:template match="@id[parent::xccdf_11:Value]"> |
| 116 |
<xsl:variable name="old_id" select="."/> |
| 117 |
|
| 118 |
<xsl:attribute name="id"> |
| 119 |
<xsl:value-of select="concat('xccdf_', $reverse_DNS, '_value_', $old_id)"/> |
| 120 |
</xsl:attribute> |
| 121 |
</xsl:template> |
| 122 |
|
| 123 |
|
| 124 |
<xsl:template match="@id[parent::xccdf_11:TestResult]"> |
| 125 |
<xsl:variable name="old_id" select="."/> |
| 126 |
|
| 127 |
<xsl:attribute name="id"> |
| 128 |
<xsl:value-of select="concat('xccdf_', $reverse_DNS, '_testresult_', $old_id)"/> |
| 129 |
</xsl:attribute> |
| 130 |
</xsl:template> |
| 131 |
|
| 132 |
|
| 133 |
<xsl:template match="@style[parent::xccdf_11:Benchmark][.='SCAP_1.1']"> |
| 134 |
<xsl:attribute name="style">SCAP_1.2</xsl:attribute> |
| 135 |
</xsl:template> |
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
<xsl:template match="@idref[parent::xccdf_11:*][not(parent::xccdf_11:platform)][not(parent::xccdf_11:requires)]"> |
| 140 |
<xsl:variable name="old_idref" select="."/> |
| 141 |
|
| 142 |
<xsl:attribute name="idref"> |
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
<xsl:choose> |
| 147 |
<xsl:when test="key('profiles', $old_idref)"> |
| 148 |
<xsl:value-of select="concat('xccdf_', $reverse_DNS, '_profile_', $old_idref)"/> |
| 149 |
</xsl:when> |
| 150 |
|
| 151 |
<xsl:when test="key('rules', $old_idref)"> |
| 152 |
<xsl:value-of select="concat('xccdf_', $reverse_DNS, '_rule_', $old_idref)"/> |
| 153 |
</xsl:when> |
| 154 |
|
| 155 |
<xsl:when test="key('groups', $old_idref)"> |
| 156 |
<xsl:value-of select="concat('xccdf_', $reverse_DNS, '_group_', $old_idref)"/> |
| 157 |
</xsl:when> |
| 158 |
|
| 159 |
<xsl:when test="key('values', $old_idref)"> |
| 160 |
<xsl:value-of select="concat('xccdf_', $reverse_DNS, '_value_', $old_idref)"/> |
| 161 |
</xsl:when> |
| 162 |
|
| 163 |
<xsl:otherwise> |
| 164 |
<xsl:value-of select="concat('dangling reference to ', $old_idref, '!')"/> |
| 165 |
</xsl:otherwise> |
| 166 |
</xsl:choose> |
| 167 |
</xsl:attribute> |
| 168 |
</xsl:template> |
| 169 |
|
| 170 |
<xsl:template name="migrate-requires"> |
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
<xsl:param name="string"/> |
| 175 |
<xsl:choose> |
| 176 |
|
| 177 |
<xsl:when test="$string=''"> |
| 178 |
|
| 179 |
</xsl:when> |
| 180 |
<xsl:otherwise> |
| 181 |
<xsl:choose> |
| 182 |
<xsl:when test="key('groups', substring-before($string, ' '))"> |
| 183 |
<xsl:value-of select="concat('xccdf_', $reverse_DNS, '_group_', substring-before($string, ' '))"/> |
| 184 |
</xsl:when> |
| 185 |
<xsl:when test="key('rules', substring-before($string, ' '))"> |
| 186 |
<xsl:value-of select="concat('xccdf_', $reverse_DNS, '_rule_', substring-before($string, ' '))"/> |
| 187 |
</xsl:when> |
| 188 |
<xsl:otherwise> |
| 189 |
<xsl:value-of select="concat('dangling reference to ', substring-before($string, ' '), '!')"/> |
| 190 |
</xsl:otherwise> |
| 191 |
</xsl:choose> |
| 192 |
|
| 193 |
|
| 194 |
<xsl:variable name="tail" select="substring-after($string, ' ')"/> |
| 195 |
<xsl:if test="$tail!=''"> |
| 196 |
<xsl:text> </xsl:text> |
| 197 |
<xsl:call-template name="migrate-requires"> |
| 198 |
<xsl:with-param name="string" select="$tail"/> |
| 199 |
</xsl:call-template> |
| 200 |
</xsl:if> |
| 201 |
</xsl:otherwise> |
| 202 |
</xsl:choose> |
| 203 |
</xsl:template> |
| 204 |
|
| 205 |
<xsl:template match="@idref[parent::xccdf_11:requires]"> |
| 206 |
|
| 207 |
<xsl:variable name="old_idref" select="."/> |
| 208 |
<xsl:attribute name="idref"><xsl:call-template name="migrate-requires"><xsl:with-param name="string" select="concat($old_idref, ' ')"/></xsl:call-template></xsl:attribute> |
| 209 |
</xsl:template> |
| 210 |
|
| 211 |
|
| 212 |
<xsl:template match="@value-id[parent::xccdf_11:*]"> |
| 213 |
<xsl:variable name="old_value_id" select="."/> |
| 214 |
|
| 215 |
<xsl:attribute name="value-id"> |
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
<xsl:choose> |
| 220 |
<xsl:when test="key('values', $old_value_id)"> |
| 221 |
<xsl:value-of select="concat('xccdf_', $reverse_DNS, '_value_', $old_value_id)"/> |
| 222 |
</xsl:when> |
| 223 |
|
| 224 |
<xsl:otherwise> |
| 225 |
<xsl:value-of select="concat('dangling reference to ', $old_value_id, '!')"/> |
| 226 |
</xsl:otherwise> |
| 227 |
</xsl:choose> |
| 228 |
</xsl:attribute> |
| 229 |
</xsl:template> |
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
<xsl:template match="@extends[parent::xccdf_11:Group]"> |
| 234 |
<xsl:variable name="old_extends" select="."/> |
| 235 |
|
| 236 |
<xsl:attribute name="extends"> |
| 237 |
<xsl:choose> |
| 238 |
<xsl:when test="key('groups', $old_extends)"> |
| 239 |
<xsl:value-of select="concat('xccdf_', $reverse_DNS, '_group_', $old_extends)"/> |
| 240 |
</xsl:when> |
| 241 |
<xsl:otherwise> |
| 242 |
<xsl:value-of select="concat('dangling reference to ', $old_extends, '!')"/> |
| 243 |
</xsl:otherwise> |
| 244 |
</xsl:choose> |
| 245 |
</xsl:attribute> |
| 246 |
</xsl:template> |
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
<xsl:template match="@extends[parent::xccdf_11:Rule]"> |
| 251 |
<xsl:variable name="old_extends" select="."/> |
| 252 |
|
| 253 |
<xsl:attribute name="extends"> |
| 254 |
<xsl:choose> |
| 255 |
<xsl:when test="key('rules', $old_extends)"> |
| 256 |
<xsl:value-of select="concat('xccdf_', $reverse_DNS, '_rule_', $old_extends)"/> |
| 257 |
</xsl:when> |
| 258 |
<xsl:otherwise> |
| 259 |
<xsl:value-of select="concat('dangling reference to ', $old_extends, '!')"/> |
| 260 |
</xsl:otherwise> |
| 261 |
</xsl:choose> |
| 262 |
</xsl:attribute> |
| 263 |
</xsl:template> |
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
<xsl:template match="@extends[parent::xccdf_11:Value]"> |
| 268 |
<xsl:variable name="old_extends" select="."/> |
| 269 |
|
| 270 |
<xsl:attribute name="extends"> |
| 271 |
<xsl:choose> |
| 272 |
<xsl:when test="key('values', $old_extends)"> |
| 273 |
<xsl:value-of select="concat('xccdf_', $reverse_DNS, '_value_', $old_extends)"/> |
| 274 |
</xsl:when> |
| 275 |
<xsl:otherwise> |
| 276 |
<xsl:value-of select="concat('dangling reference to ', $old_extends, '!')"/> |
| 277 |
</xsl:otherwise> |
| 278 |
</xsl:choose> |
| 279 |
</xsl:attribute> |
| 280 |
</xsl:template> |
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
<xsl:template match="@extends[parent::xccdf_11:Profile]"> |
| 285 |
<xsl:variable name="old_extends" select="."/> |
| 286 |
|
| 287 |
<xsl:attribute name="extends"> |
| 288 |
<xsl:choose> |
| 289 |
<xsl:when test="key('profiles', $old_extends)"> |
| 290 |
<xsl:value-of select="concat('xccdf_', $reverse_DNS, '_profile_', $old_extends)"/> |
| 291 |
</xsl:when> |
| 292 |
<xsl:otherwise> |
| 293 |
<xsl:value-of select="concat('dangling reference to ', $old_extends, '!')"/> |
| 294 |
</xsl:otherwise> |
| 295 |
</xsl:choose> |
| 296 |
</xsl:attribute> |
| 297 |
</xsl:template> |
| 298 |
|
| 299 |
|
| 300 |
<xsl:template match="xccdf_11:sub"> |
| 301 |
<xsl:element name="{local-name()}" namespace="http://checklists.nist.gov/xccdf/1.2"> |
| 302 |
<xsl:apply-templates select="@*"/> |
| 303 |
<xsl:apply-templates/> |
| 304 |
<xsl:attribute name="use">legacy</xsl:attribute> |
| 305 |
</xsl:element> |
| 306 |
</xsl:template> |
| 307 |
</xsl:stylesheet> |
| 308 |
|