From f02a17742a858da824e12cbed3e990bfd7ce6b13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Stucke?= Date: Wed, 8 Nov 2023 14:08:11 +0100 Subject: [PATCH] SHS3: moved plugins from system health to their own page --- .../components/statistic_routes.py | 7 ++ src/web_interface/static/js/system_health.js | 42 +++++------ src/web_interface/templates/base.html | 1 + src/web_interface/templates/plugins.html | 72 ++++++++++++++++++ .../templates/system_health.html | 74 ++++--------------- 5 files changed, 113 insertions(+), 83 deletions(-) create mode 100644 src/web_interface/templates/plugins.html diff --git a/src/web_interface/components/statistic_routes.py b/src/web_interface/components/statistic_routes.py index d7a5afe2d..d7d2798bd 100644 --- a/src/web_interface/components/statistic_routes.py +++ b/src/web_interface/components/statistic_routes.py @@ -33,6 +33,13 @@ def show_system_health(self): plugin_dict.pop('unpacker') return render_template('system_health.html', analysis_plugin_info=plugin_dict) + @roles_accepted(*PRIVILEGES['status']) + @AppRoute('/plugins', GET) + def show_plugin_page(self): + plugin_dict = self.intercom.get_available_analysis_plugins() + plugin_dict.pop('unpacker') + return render_template('plugins.html', plugins=plugin_dict) + def _get_stats_from_db(self): with get_shared_session(self.db.stats_viewer) as stats_db: return { diff --git a/src/web_interface/static/js/system_health.js b/src/web_interface/static/js/system_health.js index 9de00898e..cd4de226d 100644 --- a/src/web_interface/static/js/system_health.js +++ b/src/web_interface/static/js/system_health.js @@ -106,39 +106,37 @@ function updatePluginCard(pluginName, pluginData) { } queueElement.innerText = pluginData.queue.toString(); outQueueElement.innerText = pluginData.out_queue.toString(); - if (pluginData.stats !== null) { - statsElement.innerHTML = ` - + statsElement.innerHTML = getPluginRuntimeStats(pluginData.stats); +} + +function getPluginRuntimeStats(stats) { + if (stats !== null) { + return ` +
- - - - - - - - - - - - - - + + + + - - + + + + - - + + + +
min${pluginData.stats.min}s
max${pluginData.stats.max}s
mean${pluginData.stats.mean}s
median${pluginData.stats.median}smin${stats.min}smax${stats.max}s
std.dev.${pluginData.stats.std_dev}smean${stats.mean}smedian${stats.median}s
count${pluginData.stats.count}std.dev.${stats.std_dev}scount${stats.count}
`; } else { - statsElement.innerHTML = `N/A`; + return `N/A`; } } diff --git a/src/web_interface/templates/base.html b/src/web_interface/templates/base.html index f3c830ddc..942489b9a 100644 --- a/src/web_interface/templates/base.html +++ b/src/web_interface/templates/base.html @@ -154,6 +154,7 @@ Statistics System + Plugins Rest API About diff --git a/src/web_interface/templates/plugins.html b/src/web_interface/templates/plugins.html new file mode 100644 index 000000000..e7d184fab --- /dev/null +++ b/src/web_interface/templates/plugins.html @@ -0,0 +1,72 @@ +{% extends "base.html" %} + +{% set active_page = "Info" %} + +{% block head %} + + +{% endblock %} + +{% macro icon_tooltip_desk(icon, tooltip, icon_class=None) %} + {% set icon_class = icon_class if icon_class else 'fas' %} + + + +{% endmacro %} + +{% macro plugin_card(plugin_name) %} + {% set description, _, __, version, dependencies, blacklist, whitelist, threads = plugins[plugin_name] %} +
+
+
{{ plugin_name }}
+
{{ version }}
+ +
+ + {{ description }} + + + + {{ icon_tooltip_desk('project-diagram', 'Plugin dependencies') }} + + + + {{ icon_tooltip_desk('flag', 'Blacklisted file types') }} + + + + {{ icon_tooltip_desk('flag', 'Whitelisted file types', icon_class='far') }} + + + +
{{ dependencies | list_group_collapse | safe}}
{{ blacklist | list_group_collapse | safe }}
{{ whitelist | list_group_collapse | safe }}
+
+ + {% set button_id = "bt-" + plugin_name %} + + +
+
+{% endmacro %} + +{% block body %} + +
+

Analysis Plugins

+
+{% if plugins %} +
+ {% for plugin_name in plugins | sort %} + {% if plugin_name != "unpacker" %} + {{ plugin_card(plugin_name) }} + {% endif %} + {% endfor %} +
+{% endif %} + +{% endblock %} diff --git a/src/web_interface/templates/system_health.html b/src/web_interface/templates/system_health.html index 162ba93ab..7179e120e 100644 --- a/src/web_interface/templates/system_health.html +++ b/src/web_interface/templates/system_health.html @@ -72,47 +72,6 @@
{% endmacro %} -{% macro plugin_card(plugin_name) %} - {% set description, _, __, version, dependencies, blacklist, whitelist, threads = analysis_plugin_info[plugin_name] %} -
-
-
{{ plugin_name }}
-
{{ version }}
- -
- - {{ description }} - - - - {{ icon_tooltip_desk('project-diagram', 'Plugin dependencies') }} - - - - {{ icon_tooltip_desk('flag', 'Blacklisted file types') }} - - - - {{ icon_tooltip_desk('flag', 'Whitelisted file types', icon_class='far') }} - - - - {{ icon_tooltip_desk('chart-bar', 'Analysis stats', icon_class='far') }} - - - -
{{ dependencies | list_group_collapse | safe}}
{{ blacklist | list_group_collapse | safe }}
{{ whitelist | list_group_collapse | safe }}
-
- - {% set button_id = "bt-" + plugin_name %} - - -
-
-{% endmacro %} - {% block body %}
@@ -122,9 +81,9 @@
{{ version }}
- {# anaylsis plugin status #} -
-
+ {# analysis plugin status #} +
+
Analysis Plugin Status
@@ -152,6 +111,14 @@
Analysis Plugin Status
+ + + + + + + {% endfor %} @@ -159,10 +126,10 @@
Analysis Plugin Status
-
+
-
+
Currently analyzed firmware
@@ -180,19 +147,4 @@
Currently analyzed firmware
-{% if analysis_plugin_info %} -
-
-
Analysis Plugins
-
-
-
- {% for plugin_name in analysis_plugin_info | sort %} - {% if plugin_name != "unpacker" %} - {{ plugin_card(plugin_name) }} - {% endif %} - {% endfor %} -
-{% endif %} - {% endblock %}