variables - New to XML and stuck -
good evening 1 , all. newer xml , have spent large chunk of today trying figure out code doing. spent lot of time testing/rewriting provided on free online xsl transformer (xslt) - freeformatter.com. officially stuck
we utilize tool can ingest xml feeds, albeit new xml can fix somethings work not tonight. have write translation translate xml xls file. xls stuck.
issues follow: have multiple reporthost , 1 report when run following code through transformer not of information host-ip, host-fqdn, system-type, operating-system in variable call outs. can see data in xml thats feeding not in output. , appreciated!
xls follows:
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns="http://www.archer-tech.com/"> <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes" /> <xsl:template match="nessusclientdata_v2"> <archerrecords> <xsl:apply-templates select="report" /> </archerrecords> </xsl:template> <xsl:template match="report"> <xsl:for-each select="reporthost"> <xsl:variable name="a" select="@name"/> <xsl:variable name="host" select="/nessusclientdata_v2/report/reporthost[@name=$a]"/> <xsl:variable name="x" select="host-ip"/> <xsl:variable name="y" select="host-fqdn"/> <xsl:variable name="z" select="system-type"/> <xsl:variable name="os" select="operating-system"/> <xsl:variable name="extract_ip" select="$host/hostproperties/tag[@name=$x]"/> <xsl:variable name="extract_netbios" select="$host/hostproperties/tag[@name=$y]"/> <xsl:variable name="extract_type" select="$host/hostproperties/tag[@name=$z]"/> <xsl:variable name="extract_operating-system" select="$host/hostproperties/tag[@name=$os]"/> <xsl:for-each select="reportitem"> <archerrecord> <ip><xsl:value-of select="$extract_ip/text()"/></ip> <device_name><xsl:value-of select="$extract_netbios/text()"/></device_name> <device_type><xsl:value-of select="$extract_type/text()"/></device_type> <operating_system><xsl:value-of select="$extract_operating-system/text()"/></operating_system> <port><xsl:value-of select="@port"/></port> <svc_name><xsl:value-of select="@svc_name"/></svc_name> <protocol><xsl:value-of select="@protocol"/></protocol> <raw_severity><xsl:value-of select="@severity"/></raw_severity> <pluginid><xsl:value-of select="@pluginid"/></pluginid> <pluginname><xsl:value-of select="@pluginname"/></pluginname> <pluginfamily><xsl:value-of select="@pluginfamily"/></pluginfamily> <xsl:variable name="extract_port" select="@port"/> <xsl:variable name="details" select="/nessusclientdata_v2/report/reporthost/reportitem[@port=$extract_port]"/> <solution><xsl:value-of select="$details/solution/text()"/></solution> <risk><xsl:value-of select="$details/risk_factor/text()"/></risk> <description><xsl:value-of select="$details/description/text()"/></description> <output><xsl:value-of select="$details/plugin_output/text()"/></output> <cvss_temporal_score><xsl:value-of select="$details/cvss_temporal_score/text()"/></cvss_temporal_score> <cvss_base_score><xsl:value-of select="$details/cvss_base_score/text()"/></cvss_base_score> <cpe><xsl:value-of select="$details/cpe/text()"/></cpe> <cve><xsl:value-of select="$details/cve/text()"/></cve> </archerrecord> </xsl:for-each> </xsl:for-each> </xsl:template> </xsl:stylesheet> snippet of xml
<nessusclientdata_v2> <report name="ccri network scan" xmlns:cm="http://www.nessus.org/cm"> <reporthost name="1328.1527.1142.128"> <hostproperties> <tag name="lastauthenticatedresults">1450111187</tag> <tag name="credentialed_scan">true</tag> <tag name="policy-used">b4c1a0418/fso scan policy</tag> <tag name="patch-summary-total-cves">2</tag> <tag name="cpe">cpe:/o:linux:linux_kernel</tag> <tag name="os">linux</tag> <tag name="smb-login-used">so</tag> <tag name="ssh-fingerprint">ssh-2.0-cisco-1.25 </tag> <tag name="cpe-0">cpe:/o:cisco:ios:15.1 -> cisco ios 15.1</tag> <tag name="mac-address">e0:129:82:d1 00:</tag> <tag name="system-type">router</tag> <tag name="operating-system">cisco ios 15.1(2)sg6</tag> <tag name="ssh-auth-meth">password</tag> <tag name="ssh-login-used">sagalliano</tag> <tag name="local-checks-proto">ssh</tag> <tag name="traceroute-hop-5">1338.13357.1342.138</tag> <tag name="traceroute-hop-4">1383.1357.1342.31</tag> <tag name="traceroute-hop-3">1338.1632.1356.2337</tag> <tag name="traceroute-hop-2">1538.3237.24.138</tag> <tag name="traceroute-hop-1">1358.2433.2333.252</tag> <tag name="traceroute-hop-0">1538.2433.331.1330</tag> <tag name="host_end">mon dec 14 16:39:47 2015</tag> <tag name="host-ip">14138.12457.12442.118</tag> <tag name="host_start">mon dec 14 16:36:31 2015</tag> </hostproperties> requested output
<archerrecord> <ip /> <device_name /> <device_type /> <operating_system /> <port>0</port> <svc_name>general</svc_name> <protocol>tcp</protocol> <raw_severity>0</raw_severity> <pluginid>47864</pluginid> <pluginname>cisco ios version</pluginname> <pluginfamily>cisco</pluginfamily> <solution>n/a</solution> <risk>none</risk> <description>the remote host running ios, operating system cisco routers.
Comments
Post a Comment