Skip to content

Commit 3c1c825

Browse files
author
dreizehnutters
committed
improvments
1 parent 21fde35 commit 3c1c825

8 files changed

Lines changed: 1495 additions & 779 deletions

File tree

samples/report.html

Lines changed: 578 additions & 292 deletions
Large diffs are not rendered by default.

xsl/helpers.xsl

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,19 @@
7979
<xsl:param name="primary"/>
8080
<xsl:param name="secondary" select="''"/>
8181
<xsl:if test="string($primary) != '' or string($secondary) != ''">
82-
<tr>
83-
<td>
82+
<div class="certificate-row">
83+
<span class="certificate-label">
8484
<xsl:value-of select="$label"/>
85-
</td>
86-
<td>
87-
<i>
88-
<xsl:value-of select="$primary"/>
89-
<xsl:if test="string($secondary) != ''">
90-
<xsl:text> – </xsl:text>
91-
<xsl:value-of select="$secondary"/>
92-
</xsl:if>
93-
</i>
94-
</td>
95-
</tr>
85+
<xsl:text>: </xsl:text>
86+
</span>
87+
<i class="certificate-value">
88+
<xsl:value-of select="$primary"/>
89+
<xsl:if test="string($secondary) != ''">
90+
<xsl:text> – </xsl:text>
91+
<xsl:value-of select="$secondary"/>
92+
</xsl:if>
93+
</i>
94+
</div>
9695
</xsl:if>
9796
</xsl:template>
9897

@@ -143,4 +142,11 @@
143142
</ul>
144143
</xsl:if>
145144
</xsl:template>
145+
146+
<xsl:template name="render-empty-state">
147+
<xsl:param name="message"/>
148+
<p class="text-muted fst-italic mb-3">
149+
<xsl:value-of select="$message"/>
150+
</p>
151+
</xsl:template>
146152
</xsl:stylesheet>

xsl/hosts.xsl

Lines changed: 100 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,99 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
33
<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) &gt; 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>
5969
</xsl:template>
6070
<xsl:template name="render-online-hosts">
6171
<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']) &gt; 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">
8697
<xsl:if test="count(hostnames/hostname) &gt; 0">
8798
<h4 class="fs-6">Hostnames</h4>
8899
<ul>
@@ -168,10 +179,16 @@
168179
</xsl:for-each>
169180
</xsl:for-each>
170181
</xsl:if>
171-
</div>
172-
</div>
182+
</div>
183+
</details>
184+
</xsl:for-each>
173185
</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>
176193
</xsl:template>
177194
</xsl:stylesheet>

0 commit comments

Comments
 (0)