From: Roland Häder <roland@mxchange.org>
Date: Fri, 8 Dec 2023 03:56:26 +0000 (+0100)
Subject: Continued:
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=32c5ba74dbfcf62fbb8c841b8faa2a746d372587;p=fba.git

Continued:
- added list/scoreboard mode for column 'original_software'
---

diff --git a/daemon.py b/daemon.py
index cd91932..dc29823 100755
--- a/daemon.py
+++ b/daemon.py
@@ -77,6 +77,8 @@ def api_scoreboard(mode: str, amount: int):
         database.cursor.execute("SELECT blocker, COUNT(blocker) AS score FROM blocks GROUP BY blocker ORDER BY score DESC LIMIT ?", [amount])
     elif mode == "reference":
         database.cursor.execute("SELECT origin, COUNT(domain) AS score FROM instances WHERE origin IS NOT NULL GROUP BY origin ORDER BY score DESC LIMIT ?", [amount])
+    elif mode == "original_software":
+        database.cursor.execute("SELECT original_software, COUNT(domain) AS score FROM instances WHERE original_software IS NOT NULL GROUP BY original_software ORDER BY score DESC, original_software ASC LIMIT ?", [amount])
     elif mode == "software":
         database.cursor.execute("SELECT software, COUNT(domain) AS score FROM instances WHERE software IS NOT NULL GROUP BY software ORDER BY score DESC, software ASC LIMIT ?", [amount])
     elif mode == "command":
@@ -115,7 +117,7 @@ def api_list(request: Request, mode: str, value: str, amount: int):
     elif amount > config.get("api_limit"):
         raise HTTPException(status_code=500, detail=f"amount={amount} is to big")
 
-    if mode in ("detection_mode", "software", "command", "origin"):
+    if mode in ("detection_mode", "original_software", "software", "command", "origin"):
         database.cursor.execute(
             f"SELECT * \
 FROM instances \
diff --git a/templates/views/index.html b/templates/views/index.html
index 8660d39..d51b3ea 100644
--- a/templates/views/index.html
+++ b/templates/views/index.html
@@ -59,6 +59,7 @@
         <li><a href="scoreboard?mode=blocked&amp;amount=50">Defederated instances</a></li>
         <li><a href="scoreboard?mode=reference&amp;amount=50">Referencing instances</a></li>
         <li><a href="scoreboard?mode=software&amp;amount=50">Used software</a></li>
+        <li><a href="scoreboard?mode=original_software&amp;amount=50">... original</a></li>
         <li><a href="scoreboard?mode=command&amp;amount=20">Commands</a></li>
         <li><a href="scoreboard?mode=error_code&amp;amount=50">Error codes</a></li>
         <li><a href="scoreboard?mode=detection_mode&amp;amount=10">Detection modes</a></li>
diff --git a/templates/views/list.html b/templates/views/list.html
index 1e48ebd..101e926 100644
--- a/templates/views/list.html
+++ b/templates/views/list.html
@@ -2,6 +2,7 @@
 
 {% block title %}
     {% if mode == 'detection_mode' %} - Detection mode {{value}}
+    {% elif mode == 'original_software' %} - Original software {{value}}
     {% elif mode == 'software' %} - Used software {{value}}
     {% elif mode == 'command' %} - Command {{value}}
     {% elif mode == 'recently' %} - {{amount}} recently added instances
@@ -11,6 +12,8 @@
 {% block header %}
     {% if mode == 'detection_mode' %}
         <h1>Instances detected by method {{value}}</h1>
+    {% elif mode == 'original_software' %}
+        <h1>Original software name {{value}}</h1>
     {% elif mode == 'software' %}
         <h1>Instances using software {{value}}</h1>
     {% elif mode == 'command' %}
@@ -39,7 +42,8 @@
         <thead>
             <th>Domain</th>
             <th>Origin</th>
-            <th>Software</th>
+            <th title="Aliased software name">Software</th>
+            <th title="Original software name">Original</th>
             <th>Detection mode</th>
             <th>Command</th>
             <th>Total peers</th>
@@ -62,6 +66,11 @@
                     {% include "widgets/links.html" %}
                     {% endwith %}
                 </td>
+                <td>
+                    {% with mode='original_software', amount=amount, value=row['original_software'] %}
+                    {% include "widgets/list_links.html" %}
+                    {% endwith %}
+                </td>
                 <td>
                     {% with mode='software', amount=amount, value=row['software'] %}
                     {% include "widgets/list_links.html" %}
diff --git a/templates/views/scoreboard.html b/templates/views/scoreboard.html
index 2f76194..1cc68b7 100644
--- a/templates/views/scoreboard.html
+++ b/templates/views/scoreboard.html
@@ -2,7 +2,8 @@
 
 {% block title %}
     Scoreboard -
-    {% if mode == 'software' %}TOP {{amount}} used software
+    {% if mode == 'original_software' %}TOP {{amount}} original software
+    {% elif mode == 'software' %}TOP {{amount}} aliased software
     {% elif mode == 'detection_mode' %}Detection mode statistics
     {% elif mode == 'block_level' %}TOP {{amount}} block level statistics
     {% elif mode == 'obfuscation' %}Obfuscation statistics
@@ -24,8 +25,10 @@
         <h1>Top {{amount}} defederated instances</h1>
     {% elif mode == 'reference' %}
         <h1>Top {{amount}} referencing instances</h1>
+    {% elif mode == 'original_software' %}
+        <h1>Top {{amount}} original software names</h1>
     {% elif mode == 'software' %}
-        <h1>Top {{amount}} used software</h1>
+        <h1>Top {{amount}} aliased software</h1>
     {% elif mode == 'command' %}
         <h1>TOP {{amount}} commands</h1>
     {% elif mode == 'error_code' %}
@@ -53,7 +56,7 @@
             <thead>
                 <th>№</th>
                 <th>
-                    {% if mode in ('software', 'avg_peers', 'avg_blocks', 'obfuscator') %}Software
+                    {% if mode in ('original_software', 'software', 'avg_peers', 'avg_blocks', 'obfuscator') %}Software
                     {% elif mode == 'obfuscation' %}Obfuscation status
                     {% elif mode == 'detection_mode' %}Detection mode
                     {% elif mode == 'error_code' %}Error code
@@ -63,7 +66,7 @@
                 <th>
                     {% if mode == 'reference' %}References
                     {% elif mode in('avg_peers', 'avg_blocks') %}Average
-                    {% elif mode in('software', 'error_code', 'obfuscator', 'obfuscation', 'block_level', 'detection_mode', 'command') %}Total
+                    {% elif mode in('original_software', 'software', 'error_code', 'obfuscator', 'obfuscation', 'block_level', 'detection_mode', 'command') %}Total
                     {% else %}Blocks
                     {% endif %}
                 </th>
@@ -82,7 +85,7 @@
                             <a href="top?mode={{mode}}&amp;value={{entry['domain']}}&amp;amount=50">{{entry['domain']}}</a>
                         {% elif mode in ('avg_peers', 'avg_blocks', 'obfuscator') %}
                             <a href="list?mode=software&amp;value={{entry['domain']}}&amp;amount=50">{{entry['domain']}}</a>
-                        {% elif mode in ('software', 'detection_mode', 'command') %}
+                        {% elif mode in ('original_software', 'software', 'detection_mode', 'command') %}
                             <a href="list?mode={{mode}}&amp;value={{entry['domain']}}&amp;amount=50">{{entry['domain']}}</a>
                         {% else %}
                             {% with domain=entry['domain'] %}