use service template

This commit is contained in:
Adrien MALINGREY 2024-10-22 23:24:08 +02:00
parent 2ef0421078
commit 154d731e55
6 changed files with 31 additions and 77 deletions

View File

@ -61,15 +61,21 @@ svg {
text-align: center !important; text-align: center !important;
} }
.compact .ui.icon.buttons .mini.button {
padding: 0.5em;
}
.compact { .compact {
overflow-x: scroll; position: static !important;
overflow-x: auto;
} }
.compact > input { .compact > input {
min-width: 10em; min-width: 10em;
padding-right: 0.1em; padding-right: 0.1em;
} }
.compact .ui.icon.buttons .mini.button {
padding: 0.5em;
position: static;
}
.compact .ui.dropdown.button:not(.pointing):not(.floating).active {
border-radius: 0;
}

View File

@ -6,7 +6,7 @@
<xsl:import href="lib/head.xsl"/> <xsl:import href="lib/head.xsl"/>
<xsl:import href="lib/nav.xsl"/> <xsl:import href="lib/nav.xsl"/>
<xsl:import href="lib/serviceLabel.xsl"/> <xsl:import href="lib/service.xsl"/>
<xsl:import href="lib/toast.xsl"/> <xsl:import href="lib/toast.xsl"/>
<xsl:output method="html" encoding="UTF-8"/> <xsl:output method="html" encoding="UTF-8"/>
@ -152,10 +152,11 @@ function hostScanning(link) {
</xsl:if> </xsl:if>
</div> </div>
<div class="description"> <div class="description">
<xsl:apply-templates select="$currentHost/ports/port | $initHost/ports/port[not(@portid=$currentHost/ports/port/@portid)][not(state/@state='closed')]"> <xsl:apply-templates select="$currentHost/ports/port | $initHost/ports/port[not(@portid=$currentHost/ports/port/@portid)][not(state/@state='closed')]" mode="service">
<xsl:with-param name="initHost" select="$initHost"/> <xsl:with-param name="initHost" select="$initHost"/>
<xsl:with-param name="currentHost" select="$currentHost"/> <xsl:with-param name="currentHost" select="$currentHost"/>
<xsl:with-param name="hostAddress" select="$hostAddress"/> <xsl:with-param name="hostAddress" select="$hostAddress"/>
<xsl:with-param name="class" select="'ui label'"/>
<xsl:sort select="number(@portid)" order="ascending"/> <xsl:sort select="number(@portid)" order="ascending"/>
</xsl:apply-templates> </xsl:apply-templates>
</div> </div>

View File

@ -6,6 +6,7 @@
<xsl:import href="lib/head.xsl"/> <xsl:import href="lib/head.xsl"/>
<xsl:import href="lib/nav.xsl"/> <xsl:import href="lib/nav.xsl"/>
<xsl:import href="lib/service.xsl"/>
<xsl:import href="lib/toast.xsl"/> <xsl:import href="lib/toast.xsl"/>
<xsl:output method="html" encoding="UTF-8"/> <xsl:output method="html" encoding="UTF-8"/>
@ -104,10 +105,11 @@ $('.ui.dropdown').dropdown()
title="{$currentHost/hostnames/hostname/@name} ({address/@addr})" title="{$currentHost/hostnames/hostname/@name} ({address/@addr})"
onfocus="this.value='{hostnames/hostname/@name}'; this.select()" onblur="this.value='{substring-before(hostnames/hostname/@name, '.')}'" onfocus="this.value='{hostnames/hostname/@name}'; this.select()" onblur="this.value='{substring-before(hostnames/hostname/@name, '.')}'"
/> />
<xsl:apply-templates select="$currentHost/ports/port | $initHost/ports/port[not(@portid=$currentHost/ports/port/@portid)][not(state/@state='closed')]"> <xsl:apply-templates select="$initHost/ports/port[not(@portid=$currentHost/ports/port/@portid)][not(state/@state='closed')] | $currentHost/ports/port" mode="service">
<xsl:with-param name="initHost" select="$initHost"/> <xsl:with-param name="initHost" select="$initHost"/>
<xsl:with-param name="currentHost" select="$currentHost"/> <xsl:with-param name="currentHost" select="$currentHost"/>
<xsl:with-param name="hostAddress" select="$hostAddress"/> <xsl:with-param name="hostAddress" select="$hostAddress"/>
<xsl:with-param name="class" select="'ui mini button'"/>
<xsl:sort select="number(@portid)" order="ascending"/> <xsl:sort select="number(@portid)" order="ascending"/>
</xsl:apply-templates> </xsl:apply-templates>
</div> </div>

View File

@ -6,6 +6,7 @@
<xsl:import href="lib/head.xsl"/> <xsl:import href="lib/head.xsl"/>
<xsl:import href="lib/nav.xsl"/> <xsl:import href="lib/nav.xsl"/>
<xsl:import href="lib/service.xsl"/>
<xsl:import href="lib/toast.xsl"/> <xsl:import href="lib/toast.xsl"/>
<xsl:output method="html" encoding="UTF-8"/> <xsl:output method="html" encoding="UTF-8"/>
@ -172,71 +173,12 @@ $('.ui.dropdown').dropdown()
<xsl:value-of select="@portid"/> <xsl:value-of select="@portid"/>
</td> </td>
<td> <td>
<a> <xsl:apply-templates select="." mode="service">
<xsl:attribute name="class"> <xsl:with-param name="initHost" select="$initHost"/>
<xsl:text>ui mini fluid button </xsl:text> <xsl:with-param name="currentHost" select="$currentHost"/>
<xsl:choose> <xsl:with-param name="hostAddress" select="$hostAddress"/>
<xsl:when test="$currentPort/script[@id='http-info']/elem[@key='status']>=500">red</xsl:when> <xsl:with-param name="class" select="'ui mini fluid button'"/>
<xsl:when test="$currentPort/script[@id='http-info']/elem[@key='status']>=400">orange</xsl:when> </xsl:apply-templates>
<xsl:when test="$currentPort/script[@id='http-info']/elem[@key='status']>=200">green</xsl:when>
<xsl:when test="$currentPort/state/@state='open'">green</xsl:when>
<xsl:when test="$currentPort/state/@state='filtered'">orange</xsl:when>
<xsl:otherwise>red</xsl:otherwise>
</xsl:choose>
<xsl:if test="$currentPort/script[@id='smb-shares-size']/table"> dropdown share-size</xsl:if>
</xsl:attribute>
<xsl:if test="$currentPort/script[@id='smb-shares-size']/table">
<xsl:attribute name="style">
<xsl:for-each select="$currentPort/script[@id='smb-shares-size']/table">
<xsl:sort select="elem[@key='FreeSize'] div elem[@key='TotalSize']" order="ascending"/>
<xsl:if test="position()=1">
<xsl:text>--free: </xsl:text>
<xsl:value-of select="elem[@key='FreeSize']"/>
<xsl:text>; --total: </xsl:text>
<xsl:value-of select="elem[@key='TotalSize']"/>
</xsl:if>
</xsl:for-each>
</xsl:attribute>
</xsl:if>
<xsl:if test="service/@name='ftp' or service/@name='ssh' or service/@name='http' or service/@name='https'">
<xsl:attribute name="href">
<xsl:choose>
<xsl:when test="service/@name='http' and service/@tunnel='ssl'">
<xsl:text>https</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="service/@name"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>://</xsl:text>
<xsl:value-of select="$hostAddress"/>
<xsl:text>:</xsl:text>
<xsl:value-of select="@portid"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="service/@name='ms-wbt-server'">
<xsl:attribute name="href">
<xsl:text>rdp.php?v=</xsl:text>
<xsl:value-of select="$hostAddress"/>
<xsl:text>&amp;p=</xsl:text>
<xsl:value-of select="@portid"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="script[@id='http-info']/elem[@key='title']">
<xsl:attribute name="title">
<xsl:value-of select="script[@id='http-info']/elem[@key='title']"/>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="service/@name"/>
<xsl:if test="$currentPort/script[@id='smb-shares-size']/table">
<i class="dropdown icon"></i>
<div class="menu">
<xsl:apply-templates select="$currentPort/script[@id='smb-shares-size']/table">
<xsl:with-param name="hostAddress" select="$hostAddress"/>
</xsl:apply-templates>
</div>
</xsl:if>
</a>
</td> </td>
<td> <td>
<xsl:value-of select="service/@product"/> <xsl:value-of select="service/@product"/>

View File

@ -6,7 +6,7 @@
<xsl:import href="lib/head.xsl"/> <xsl:import href="lib/head.xsl"/>
<xsl:import href="lib/nav.xsl"/> <xsl:import href="lib/nav.xsl"/>
<xsl:import href="lib/serviceLabel.xsl"/> <xsl:import href="lib/service.xsl"/>
<xsl:import href="lib/toast.xsl"/> <xsl:import href="lib/toast.xsl"/>
<xsl:output method="html" encoding="UTF-8"/> <xsl:output method="html" encoding="UTF-8"/>
@ -163,10 +163,11 @@ function hostScanning(link) {
<xsl:value-of select="address[@addrtype='mac']/@vendor"/> <xsl:value-of select="address[@addrtype='mac']/@vendor"/>
</td> </td>
<td> <td>
<xsl:apply-templates select="$initHost/ports/port[not(@portid=$currentHost/ports/port/@portid)][not(state/@state='closed')] | $currentHost/ports/port"> <xsl:apply-templates select="$initHost/ports/port[not(@portid=$currentHost/ports/port/@portid)][not(state/@state='closed')] | $currentHost/ports/port" mode="service">
<xsl:with-param name="initHost" select="$initHost"/> <xsl:with-param name="initHost" select="$initHost"/>
<xsl:with-param name="currentHost" select="$currentHost"/> <xsl:with-param name="currentHost" select="$currentHost"/>
<xsl:with-param name="hostAddress" select="$hostAddress"/> <xsl:with-param name="hostAddress" select="$hostAddress"/>
<xsl:with-param name="class" select="'ui label'"/>
<xsl:sort select="number(@portid)" order="ascending"/> <xsl:sort select="number(@portid)" order="ascending"/>
</xsl:apply-templates> </xsl:apply-templates>
</td> </td>

View File

@ -4,17 +4,19 @@
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="1.1"> version="1.1">
<xsl:template match="port"> <xsl:template match="port" mode="service">
<xsl:param name="hostAddress"/> <xsl:param name="hostAddress"/>
<xsl:param name="initHost"/> <xsl:param name="initHost"/>
<xsl:param name="currentHost"/> <xsl:param name="currentHost"/>
<xsl:param name="class"/>
<xsl:variable name="portid" select="@portid"/> <xsl:variable name="portid" select="@portid"/>
<xsl:variable name="initPort" select="$initHost/ports/port[@portid=$portid]"/> <xsl:variable name="initPort" select="$initHost/ports/port[@portid=$portid]"/>
<xsl:variable name="currentPort" select="$currentHost/ports/port[@portid=$portid]"/> <xsl:variable name="currentPort" select="$currentHost/ports/port[@portid=$portid]"/>
<a target="_blank"> <a target="_blank">
<xsl:attribute name="class"> <xsl:attribute name="class">
<xsl:text>ui label </xsl:text> <xsl:value-of select="$class"/>
<xsl:text> </xsl:text>
<xsl:choose> <xsl:choose>
<xsl:when test="$currentPort/script[@id='http-info']/elem[@key='status']>=500">red</xsl:when> <xsl:when test="$currentPort/script[@id='http-info']/elem[@key='status']>=500">red</xsl:when>
<xsl:when test="$currentPort/script[@id='http-info']/elem[@key='status']>=400">orange</xsl:when> <xsl:when test="$currentPort/script[@id='http-info']/elem[@key='status']>=400">orange</xsl:when>