Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Davide Arcuri committed Feb 7, 2024
1 parent 584cf23 commit d1555c4
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 19 deletions.
2 changes: 1 addition & 1 deletion orochi/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
$("#tasks_running").html(data.running);
}
)
}, 30000);
}, 5000);

// ABOUT
$(document).on("click", "#about", function () {
Expand Down
7 changes: 4 additions & 3 deletions orochi/templates/website/partial_plugins.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{% for plugin in results %}
{% for plugin, comment in results %}
<li class="nav-item">
<label class="radio_container" data-plugin="{{plugin}}">
<label class="radio_container" data-plugin="{{plugin}}" data-toggle="tooltip" data-placement="top"
title="{{comment}}">
{{plugin}}
<input type="radio" name="radio"><span class="checkmark"></span>
</label>
</li>
{% endfor %}
{% endfor %}
2 changes: 1 addition & 1 deletion orochi/website/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class PluginAdmin(FileFormAdmin):
form = PluginEditAdminForm
add_form = PluginCreateAdminForm

list_display = ("name", "operating_system", "disabled")
list_display = ("name", "comment", "operating_system", "disabled")
list_filter = (
"disabled",
"operating_system",
Expand Down
2 changes: 2 additions & 0 deletions orochi/website/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ class Meta:
model = Plugin
fields = [
"plugin",
"comment",
"operating_system",
"disabled",
"local_dump",
Expand All @@ -173,6 +174,7 @@ class Meta:
model = Plugin
fields = [
"disabled",
"comment",
"local_dump",
"vt_check",
"clamav_check",
Expand Down
10 changes: 7 additions & 3 deletions orochi/website/management/commands/plugins_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from volatility3.framework import contexts

from orochi.website.models import (
RESULT_STATUS_DISABLED,
RESULT_STATUS_NOT_STARTED,
Dump,
Plugin,
Result,
Expand Down Expand Up @@ -47,7 +47,7 @@ def handle(self, *args, **kwargs):
)

# Create new plugin, take os from name
for plugin in available_plugins:
for plugin, plugin_class in available_plugins.items():
if plugin not in installed_plugins:
if plugin.startswith("linux"):
plugin = Plugin(name=plugin, operating_system="Linux")
Expand All @@ -57,6 +57,7 @@ def handle(self, *args, **kwargs):
plugin = Plugin(name=plugin, operating_system="Mac")
else:
plugin = Plugin(name=plugin, operating_system="Other")
plugin.comment = plugin_class.__doc__
plugin.save()
self.stdout.write(self.style.SUCCESS("Plugin {} added!".format(plugin)))

Expand All @@ -67,14 +68,17 @@ def handle(self, *args, **kwargs):
dump=dump, plugin=plugin
)
if created:
up.result = RESULT_STATUS_DISABLED
up.result = RESULT_STATUS_NOT_STARTED
up.save()
self.stdout.write(
self.style.SUCCESS("Plugin {} added to old dumps!".format(plugin))
)

else:
plugin = Plugin.objects.get(name=plugin)
if not plugin.comment:
plugin.comment = plugin_class.__doc__
plugin.save()

# Add new plugin to user
for user in get_user_model().objects.all():
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Generated by Django 5.0.2 on 2024-02-07 13:39

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("website", "0048_dump_description"),
]

operations = [
migrations.AddField(
model_name="plugin",
name="comment",
field=models.TextField(blank=True, null=True),
),
migrations.AlterField(
model_name="result",
name="result",
field=models.PositiveSmallIntegerField(
choices=[
(0, "Not Started"),
(1, "Running"),
(2, "Empty"),
(3, "Success"),
(4, "Unsatisfied"),
(5, "Error"),
(6, "Disabled"),
],
default=0,
),
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def generate_superuser(app, schema_editor):

class Migration(migrations.Migration):
dependencies = [
("website", "0048_dump_description"),
("website", "0049_plugin_comment_alter_result_result"),
("ya", "0005_auto_20210618_0947"),
]

Expand Down
17 changes: 10 additions & 7 deletions orochi/website/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@
(DUMP_STATUS_ERROR, "Error"),
)

RESULT_STATUS_RUNNING = 0
RESULT_STATUS_EMPTY = 1
RESULT_STATUS_SUCCESS = 2
RESULT_STATUS_UNSATISFIED = 3
RESULT_STATUS_ERROR = 4
RESULT_STATUS_DISABLED = 5
RESULT_STATUS_NOT_STARTED = 0
RESULT_STATUS_RUNNING = 1
RESULT_STATUS_EMPTY = 2
RESULT_STATUS_SUCCESS = 3
RESULT_STATUS_UNSATISFIED = 4
RESULT_STATUS_ERROR = 5
RESULT_STATUS_DISABLED = 6
RESULT = (
(RESULT_STATUS_NOT_STARTED, "Not Started"),
(RESULT_STATUS_RUNNING, "Running"),
(RESULT_STATUS_EMPTY, "Empty"),
(RESULT_STATUS_SUCCESS, "Success"),
Expand Down Expand Up @@ -172,6 +174,7 @@ class Plugin(models.Model):
choices=OPERATING_SYSTEM, default="Linux", max_length=10
)
disabled = models.BooleanField(default=False)
comment = models.TextField(blank=True, null=True)
local_dump = models.BooleanField(default=False)
vt_check = models.BooleanField(default=False)
clamav_check = models.BooleanField(default=False)
Expand Down Expand Up @@ -330,7 +333,7 @@ def new_plugin(sender, instance, created, **kwargs):
for dump in Dump.objects.all():
if instance.operating_system in [dump.operating_system, "Other"]:
up, created = Result.objects.get_or_create(dump=dump, plugin=instance)
up.result = RESULT_STATUS_DISABLED
up.result = RESULT_STATUS_NOT_STARTED
up.save()

# Add new plugin to user
Expand Down
9 changes: 6 additions & 3 deletions orochi/website/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
from orochi.website.models import (
RESULT_STATUS_DISABLED,
RESULT_STATUS_EMPTY,
RESULT_STATUS_NOT_STARTED,
RESULT_STATUS_RUNNING,
RESULT_STATUS_SUCCESS,
SERVICE_MISP,
Expand Down Expand Up @@ -144,7 +145,7 @@ def plugins(request):
Result.objects.filter(dump__index__in=indexes)
.order_by("plugin__name")
.distinct()
.values_list("plugin__name", flat=True)
.values_list("plugin__name", "plugin__comment")
)
return render(request, "website/partial_plugins.html", {"results": results})
raise Http404("404")
Expand Down Expand Up @@ -464,7 +465,9 @@ def analysis(request):
if plugin.name.lower() not in PLUGIN_WITH_CHILDREN:
columns = []
for res in results:
if res.result == RESULT_STATUS_RUNNING and columns == []:
if res.result == RESULT_STATUS_NOT_STARTED and columns == []:
columns = ["Not started"]
elif res.result == RESULT_STATUS_RUNNING and columns == []:
columns = ["Loading"]
elif res.result == RESULT_STATUS_EMPTY and columns == []:
columns = ["Empty"]
Expand All @@ -486,7 +489,7 @@ def analysis(request):
except elasticsearch.NotFoundError:
continue
elif res.result != RESULT_STATUS_DISABLED and columns == []:
columns = ["Error"]
columns = ["Disabled"]
return render(
request,
"website/partial_analysis.html",
Expand Down

0 comments on commit d1555c4

Please sign in to comment.