|
1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | 2 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> |
3 | 3 | <xsl:template name="render-scanned-hosts"> |
4 | | - <h2 id="scannedhosts" class="fs-4 mt-5 mb-3 bg-light p-3 rounded">Scanned Hosts</h2> |
5 | | - <div class="table-responsive"> |
6 | | - <table id="table-overview" class="table table-striped table-hover align-middle" role="grid"> |
7 | | - <thead class="table-light"> |
8 | | - <tr> |
9 | | - <th scope="col">State</th> |
10 | | - <th scope="col">Mac</th> |
11 | | - <th scope="col">Vendor</th> |
12 | | - <th scope="col">OS</th> |
13 | | - <th scope="col">Address</th> |
14 | | - <th scope="col">Hostname</th> |
15 | | - <th scope="col">Open TCP Ports</th> |
16 | | - <th scope="col">Open UDP Ports</th> |
17 | | - </tr> |
18 | | - </thead> |
19 | | - <tbody> |
20 | | - <xsl:for-each select="/nmaprun/host"> |
21 | | - <tr> |
22 | | - <td> |
23 | | - <span class="badge bg-warning"> |
24 | | - <xsl:if test="status/@state='up'"> |
25 | | - <xsl:attribute name="class">badge bg-success</xsl:attribute> |
26 | | - </xsl:if> |
27 | | - <xsl:value-of select="status/@state"/> |
28 | | - </span> |
29 | | - </td> |
30 | | - <td> |
31 | | - <xsl:value-of select="address[@addrtype='mac']/@addr"/> |
32 | | - </td> |
33 | | - <td> |
34 | | - <xsl:value-of select="address[@addrtype='mac']/@vendor"/> |
35 | | - </td> |
36 | | - <td> |
37 | | - <xsl:value-of select="os/osmatch[1]/@name"/> |
38 | | - </td> |
39 | | - <td> |
40 | | - <xsl:variable name="ip" select="address[not(@addrtype='mac')][1]/@addr"/> |
41 | | - <xsl:call-template name="render-onlinehosts-link"> |
42 | | - <xsl:with-param name="address" select="$ip"/> |
43 | | - </xsl:call-template> |
44 | | - </td> |
45 | | - <td> |
46 | | - <xsl:value-of select="hostnames/hostname/@name"/> |
47 | | - </td> |
48 | | - <td> |
49 | | - <xsl:value-of select="count(ports/port[state/@state='open' and @protocol='tcp'])"/> |
50 | | - </td> |
51 | | - <td> |
52 | | - <xsl:value-of select="count(ports/port[state/@state='open' and @protocol='udp'])"/> |
53 | | - </td> |
54 | | - </tr> |
55 | | - </xsl:for-each> |
56 | | - </tbody> |
57 | | - </table> |
58 | | - </div> |
| 4 | + <h2 id="scannedhosts" class="fs-4 mt-5 mb-3 bg-light p-3 rounded">Host Overview</h2> |
| 5 | + <xsl:choose> |
| 6 | + <xsl:when test="count(/nmaprun/host) > 0"> |
| 7 | + <xsl:call-template name="render-service-distribution"/> |
| 8 | + <div class="table-responsive"> |
| 9 | + <table id="table-overview" class="table table-striped table-hover align-middle" role="grid"> |
| 10 | + <thead class="table-light"> |
| 11 | + <tr> |
| 12 | + <th scope="col">State</th> |
| 13 | + <th scope="col">Mac</th> |
| 14 | + <th scope="col">Vendor</th> |
| 15 | + <th scope="col">OS</th> |
| 16 | + <th scope="col">Address</th> |
| 17 | + <th scope="col">Hostname</th> |
| 18 | + <th scope="col">Open TCP Ports</th> |
| 19 | + <th scope="col">Open UDP Ports</th> |
| 20 | + </tr> |
| 21 | + </thead> |
| 22 | + <tbody> |
| 23 | + <xsl:for-each select="/nmaprun/host"> |
| 24 | + <tr> |
| 25 | + <td> |
| 26 | + <span class="badge bg-warning"> |
| 27 | + <xsl:if test="status/@state='up'"> |
| 28 | + <xsl:attribute name="class">badge bg-success</xsl:attribute> |
| 29 | + </xsl:if> |
| 30 | + <xsl:value-of select="status/@state"/> |
| 31 | + </span> |
| 32 | + </td> |
| 33 | + <td> |
| 34 | + <xsl:value-of select="address[@addrtype='mac']/@addr"/> |
| 35 | + </td> |
| 36 | + <td> |
| 37 | + <xsl:value-of select="address[@addrtype='mac']/@vendor"/> |
| 38 | + </td> |
| 39 | + <td> |
| 40 | + <xsl:value-of select="os/osmatch[1]/@name"/> |
| 41 | + </td> |
| 42 | + <td> |
| 43 | + <xsl:variable name="ip" select="address[not(@addrtype='mac')][1]/@addr"/> |
| 44 | + <xsl:call-template name="render-onlinehosts-link"> |
| 45 | + <xsl:with-param name="address" select="$ip"/> |
| 46 | + </xsl:call-template> |
| 47 | + </td> |
| 48 | + <td> |
| 49 | + <xsl:value-of select="hostnames/hostname/@name"/> |
| 50 | + </td> |
| 51 | + <td> |
| 52 | + <xsl:value-of select="count(ports/port[state/@state='open' and @protocol='tcp'])"/> |
| 53 | + </td> |
| 54 | + <td> |
| 55 | + <xsl:value-of select="count(ports/port[state/@state='open' and @protocol='udp'])"/> |
| 56 | + </td> |
| 57 | + </tr> |
| 58 | + </xsl:for-each> |
| 59 | + </tbody> |
| 60 | + </table> |
| 61 | + </div> |
| 62 | + </xsl:when> |
| 63 | + <xsl:otherwise> |
| 64 | + <xsl:call-template name="render-empty-state"> |
| 65 | + <xsl:with-param name="message" select="'No hosts were recorded in this scan.'"/> |
| 66 | + </xsl:call-template> |
| 67 | + </xsl:otherwise> |
| 68 | + </xsl:choose> |
59 | 69 | </xsl:template> |
60 | 70 | <xsl:template name="render-online-hosts"> |
61 | 71 | <hr class="my-4"/> |
62 | | - <h2 id="onlinehosts" class="fs-4 mt-5 mb-3 bg-light p-3 rounded">Online Hosts</h2> |
63 | | - <div class="accordion" id="accordionOnlineHosts"> |
64 | | - <xsl:for-each select="/nmaprun/host[status/@state='up']"> |
65 | | - <div class="accordion-item"> |
66 | | - <h2 class="accordion-header"> |
67 | | - <xsl:attribute name="id">heading-<xsl:value-of select="translate(address/@addr, '.:', '--')"/></xsl:attribute> |
68 | | - <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse"> |
69 | | - <xsl:attribute name="id">onlinehosts-<xsl:value-of select="translate(address/@addr, '.:', '--')"/></xsl:attribute> |
70 | | - <xsl:attribute name="data-bs-target">#collapse-<xsl:value-of select="translate(address/@addr, '.:', '--')"/></xsl:attribute> |
71 | | - <xsl:attribute name="aria-controls">collapse-<xsl:value-of select="translate(address/@addr, '.:', '--')"/></xsl:attribute> |
72 | | - <xsl:call-template name="render-host-header-label"> |
73 | | - <xsl:with-param name="address" select="address/@addr"/> |
74 | | - <xsl:with-param name="mac" select="address[@addrtype='mac']/@addr"/> |
75 | | - <xsl:with-param name="vendor" select="address[@addrtype='mac']/@vendor"/> |
76 | | - <xsl:with-param name="hostname" select="hostnames/hostname/@name"/> |
77 | | - </xsl:call-template> |
78 | | - </button> |
79 | | - </h2> |
80 | | - <div> |
81 | | - <xsl:attribute name="id">collapse-<xsl:value-of select="translate(address/@addr, '.:', '--')"/></xsl:attribute> |
82 | | - <xsl:attribute name="class">accordion-collapse collapse</xsl:attribute> |
83 | | - <xsl:attribute name="aria-labelledby">heading-<xsl:value-of select="translate(address/@addr, '.:', '--')"/></xsl:attribute> |
84 | | - <xsl:attribute name="data-bs-parent">#accordionOnlineHosts</xsl:attribute> |
85 | | - <div class="accordion-body"> |
| 72 | + <h2 id="onlinehosts" class="fs-4 mt-5 mb-3 bg-light p-3 rounded">Host Details</h2> |
| 73 | + <xsl:choose> |
| 74 | + <xsl:when test="count(/nmaprun/host[status/@state='up']) > 0"> |
| 75 | + <div class="host-controls mb-3"> |
| 76 | + <button type="button" class="btn btn-outline-secondary btn-sm" id="toggle-all-hosts" aria-controls="onlinehosts-list" aria-expanded="false">Expand all</button> |
| 77 | + </div> |
| 78 | + <div class="host-list" id="onlinehosts-list"> |
| 79 | + <xsl:for-each select="/nmaprun/host[status/@state='up']"> |
| 80 | + <xsl:variable name="host-id" select="translate(address/@addr, '.:', '--')"/> |
| 81 | + <details class="host-entry"> |
| 82 | + <xsl:attribute name="id">host-entry-<xsl:value-of select="$host-id"/></xsl:attribute> |
| 83 | + <summary class="host-entry-summary"> |
| 84 | + <span class="host-entry-anchor"> |
| 85 | + <xsl:attribute name="id">onlinehosts-<xsl:value-of select="$host-id"/></xsl:attribute> |
| 86 | + </span> |
| 87 | + <span class="host-entry-label"> |
| 88 | + <xsl:call-template name="render-host-header-label"> |
| 89 | + <xsl:with-param name="address" select="address/@addr"/> |
| 90 | + <xsl:with-param name="mac" select="address[@addrtype='mac']/@addr"/> |
| 91 | + <xsl:with-param name="vendor" select="address[@addrtype='mac']/@vendor"/> |
| 92 | + <xsl:with-param name="hostname" select="hostnames/hostname/@name"/> |
| 93 | + </xsl:call-template> |
| 94 | + </span> |
| 95 | + </summary> |
| 96 | + <div class="host-entry-body"> |
86 | 97 | <xsl:if test="count(hostnames/hostname) > 0"> |
87 | 98 | <h4 class="fs-6">Hostnames</h4> |
88 | 99 | <ul> |
|
168 | 179 | </xsl:for-each> |
169 | 180 | </xsl:for-each> |
170 | 181 | </xsl:if> |
171 | | - </div> |
172 | | - </div> |
| 182 | + </div> |
| 183 | + </details> |
| 184 | + </xsl:for-each> |
173 | 185 | </div> |
174 | | - </xsl:for-each> |
175 | | - </div> |
| 186 | + </xsl:when> |
| 187 | + <xsl:otherwise> |
| 188 | + <xsl:call-template name="render-empty-state"> |
| 189 | + <xsl:with-param name="message" select="'No hosts are marked as up in this scan.'"/> |
| 190 | + </xsl:call-template> |
| 191 | + </xsl:otherwise> |
| 192 | + </xsl:choose> |
176 | 193 | </xsl:template> |
177 | 194 | </xsl:stylesheet> |
0 commit comments