smb-shares-size template

This commit is contained in:
Adrien MALINGREY 2024-10-22 17:55:31 +02:00
parent 1d5bb5446d
commit f2acc56ef7
6 changed files with 64 additions and 27 deletions

2
.gitignore vendored
View File

@ -1,4 +1,4 @@
scans/ scans/
scripts/smb-authentication.ini datadir/smb-authentication.ini
test.php test.php
server.php server.php

View File

@ -21,6 +21,7 @@ $presets = [
'-sV' => true, '-sV' => true,
'-T' => 5, '-T' => 5,
'--script' => "http-info,smb-shares-size", '--script' => "http-info,smb-shares-size",
'--script-args-file' => "smb-authentication.ini",
'--stylesheet' => "$BASEDIR/templates/hostScan.xsl", '--stylesheet' => "$BASEDIR/templates/hostScan.xsl",
'refreshPeriod' => 60, 'refreshPeriod' => 60,
'sudo' => true, 'sudo' => true,

View File

@ -1,3 +1,3 @@
smbdomain = smbdomain = auth.ad.e2.rie.gouv.fr
smbuser = smbuser = application.drieat
smbpassword = smbpassword = d+iFiWn4!cAzdr3KopiM>EA

View File

@ -58,6 +58,7 @@ main {
--used-percent: calc(100% - 100%*var(--free-ratio)); --used-percent: calc(100% - 100%*var(--free-ratio));
--color: hsl(calc(120*var(--free-ratio)) 100% 50%); --color: hsl(calc(120*var(--free-ratio)) 100% 50%);
background-image: linear-gradient(to right, var(--color) var(--used-percent), transparent var(--used-percent), transparent) !important; background-image: linear-gradient(to right, var(--color) var(--used-percent), transparent var(--used-percent), transparent) !important;
text-align: center !important;
} }
.compact .ui.icon.buttons .mini.button { .compact .ui.icon.buttons .mini.button {

View File

@ -118,6 +118,7 @@ $('.ui.dropdown').dropdown()
<th>Service</th> <th>Service</th>
<th>Produit</th> <th>Produit</th>
<th>Version</th> <th>Version</th>
<th>Infos</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -182,7 +183,21 @@ $('.ui.dropdown').dropdown()
<xsl:when test="$currentPort/state/@state='filtered'">orange</xsl:when> <xsl:when test="$currentPort/state/@state='filtered'">orange</xsl:when>
<xsl:otherwise>red</xsl:otherwise> <xsl:otherwise>red</xsl:otherwise>
</xsl:choose> </xsl:choose>
<xsl:if test="$currentPort/script[@id='smb-shares-size']/table"> dropdown share-size</xsl:if>
</xsl:attribute> </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:if test="service/@name='ftp' or service/@name='ssh' or service/@name='http' or service/@name='https'">
<xsl:attribute name="href"> <xsl:attribute name="href">
<xsl:choose> <xsl:choose>
@ -213,6 +228,14 @@ $('.ui.dropdown').dropdown()
</xsl:attribute> </xsl:attribute>
</xsl:if> </xsl:if>
<xsl:value-of select="service/@name"/> <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> </a>
</td> </td>
<td> <td>
@ -221,8 +244,18 @@ $('.ui.dropdown').dropdown()
<td> <td>
<xsl:value-of select="service/@version"/> <xsl:value-of select="service/@version"/>
</td> </td>
<td>
<xsl:value-of select="service/@extrainfo"/>
</td>
</tr> </tr>
</xsl:template> </xsl:template>
<xsl:template match="table">
<xsl:param name="hostAddress"/>
<a class="item share-size" href="file://///{$hostAddress}/{@key}" target="_blank" rel="noopener noreferrer" style="--free: {elem[@key='FreeSize']}; --total: {elem[@key='TotalSize']}">
<xsl:value-of select="@key"/>
</a>
</xsl:template>
</xsl:stylesheet> </xsl:stylesheet>

View File

@ -24,10 +24,23 @@
<xsl:otherwise>red</xsl:otherwise> <xsl:otherwise>red</xsl:otherwise>
</xsl:choose> </xsl:choose>
<xsl:choose> <xsl:choose>
<xsl:when test="(service/@name='microsoft-ds' or service/@name='netbios-ssn') and ../../hostscript/script[@id='smb-shares-size']/table"> mini dropdown button share-size</xsl:when> <xsl:when test="$currentPort/script[@id='smb-shares-size']/table"> mini dropdown button share-size</xsl:when>
<xsl:otherwise> small</xsl:otherwise> <xsl:otherwise> small</xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:attribute> </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:if test="service/@name='ftp' or service/@name='ssh' or service/@name='http' or service/@name='https'">
<xsl:attribute name="href"> <xsl:attribute name="href">
<xsl:value-of select="service/@name"/> <xsl:value-of select="service/@name"/>
@ -60,21 +73,10 @@
<xsl:value-of select="service/@name"/> <xsl:value-of select="service/@name"/>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
<xsl:if test="(service/@name='microsoft-ds' or service/@name='netbios-ssn') and ../../hostscript/script[@id='smb-shares-size']/table"> <xsl:if test="$currentPort/script[@id='smb-shares-size']/table">
<xsl:attribute name="style">
<xsl:for-each select="$currentHost/hostscript/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>
<i class="dropdown icon"></i> <i class="dropdown icon"></i>
<div class="menu"> <div class="menu">
<xsl:apply-templates select="$currentHost/hostscript/script[@id='smb-shares-size']/table"> <xsl:apply-templates select="$currentPort/script[@id='smb-shares-size']/table">
<xsl:with-param name="hostAddress" select="$hostAddress"/> <xsl:with-param name="hostAddress" select="$hostAddress"/>
</xsl:apply-templates> </xsl:apply-templates>
</div> </div>