Skip to content

Commit

Permalink
symbols updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Davide Arcuri committed Feb 8, 2024
1 parent f59a430 commit f846cf4
Show file tree
Hide file tree
Showing 10 changed files with 265 additions and 43 deletions.
6 changes: 4 additions & 2 deletions orochi/static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ main {
.hex-index:hover,
.info-index:hover,
.edit-index:hover,
.open-index:hover {
.open-index:hover,
.symbols-index:hover {
background-color: transparent;
color: black;
}
Expand All @@ -148,7 +149,8 @@ main {
.hex-index,
.info-index,
.edit-index,
.open-index {
.open-index,
.symbols-index {
border: 0px;
}

Expand Down
17 changes: 16 additions & 1 deletion orochi/templates/website/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,23 @@ <h5 class="offcanvas-title" id="leftNoteLabel">History Log</h5>
});
});

// RELOAD SYMBOLS FROM BANNER FORM
$(document).on("click", ".symbols-reload", function () {
var btn = $(this);
$.ajax({
url: "{% url 'website:reload_symbols'%}",
data: { 'index': btn.data('index') },
type: 'get',
dataType: 'json',
success: function (data) {
console.log(data);
}
});
});


// DOWNLOAD SYMBOLS FROM BANNER FORM
$(document).on("click", ".symbols-index", function () {
$(document).on("click", ".symbols-download", function () {
var btn = $(this);
$.ajax({
url: "{% url 'website:banner_symbols'%}",
Expand Down
70 changes: 52 additions & 18 deletions orochi/templates/website/list_symbols.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@
<div class="card-header">
Manage Symbols
<button type="button" class="btn btn-sm btn-primary" id="upload-symbols">
<i class="fa fa-upload"></i> Upload
<i class="fa fa-upload"></i> Symbols
</button>
<button type="button" class="btn btn-sm btn-secondary" id="upload-packages">
<i class="fa fa-upload"></i> Linux Package
</button>
<button type="button" class="btn btn-sm btn-success" id="download-isf">
<i class="fa fa-download"></i> from ISF Server
</button>
</div>
<div class="card-body">
Expand Down Expand Up @@ -57,23 +63,50 @@
"bSort": false,
});

// CHANGE METHOD IN FORM UPLOAD SHOW/HIDE THINGS
$(document).on("change", "#id_method", function () {
var value = this.value;
// SHOW PATH ENABLE SUBMIT
if (value == 2) {
$("#div_id_symbols").show();
$("#div_id_packages").hide();
$("#btn_symbol_add").addClass('disabled');
// SHOW UPLOAD PACKAGE, DISABLE SUBMIT
} else if (value == 1) {
$("#div_id_symbols").hide();
$("#div_id_packages").show();
$("#btn_symbol_add").addClass('disabled');
// SHOW SYMBOLS PACKAGE, DISABLE SUBMIT
}
// DOWNLOAD FROM ISF FORM
$(document).on('click', '#download-isf', function () {
$.ajax({
url: "{% url 'website:download_isf' %}",
method: 'get',
dataType: 'json',
beforeSend: function () {
$("#modal-update .modal-dialog").removeClass('modal-xl');
$("#modal-update").modal("show");
},
success: function (data) {
$("#modal-update .modal-content").html(data.html_form);
}
});
});

// UPLOAD PACKAGE FORM
$(document).on('click', '#upload-packages', function () {
$.ajax({
url: "{% url 'website:upload_packages' %}",
method: 'get',
dataType: 'json',
beforeSend: function () {
$("#modal-update .modal-dialog").removeClass('modal-xl');
$("#modal-update").modal("show");
},
success: function (data) {
$("#modal-update .modal-content").html(data.html_form);
$("#btn_package_add").addClass('disabled')
initUploadFields(
document.getElementById("packages-upload-index"),
{
callbacks: {
onSuccess: upload => {
$("#btn_package_add").removeClass('disabled');
}
}
}
);
}
});
});


// UPLOAD SYMBOLS FORM
$(document).on('click', '#upload-symbols', function () {
$.ajax({
Expand All @@ -86,7 +119,6 @@
},
success: function (data) {
$("#modal-update .modal-content").html(data.html_form);
$("#div_id_packages").hide();
$("#btn_symbol_add").addClass('disabled')
initUploadFields(
document.getElementById("symbols-upload-index"),
Expand All @@ -103,8 +135,10 @@
});

// UPLOAD SYMBOLS FORM SUBMIT
$(document).on("submit", "#symbols-upload-index", function (e) {
$(document).on("submit", "#symbols-upload-index, #isf-download-index, #packages-upload-index", function (e) {
e.preventDefault();
$("#btn_isf_download").html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span><span class="sr-only">Loading...</span>');
$("#btn_isf_download").addClass('disabled');
var form = $(this);
$.ajax({
url: form.attr("action"),
Expand Down
25 changes: 21 additions & 4 deletions orochi/templates/website/partial_indices.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,27 @@
</button>
{% if missing_symbols %}
<!-- MISSING SYMBOLS -->
<button type="button" class="btn btn-outline-warning symbols-index btn-sm rounded"
data-index="{{index}}" data-toggle="tooltip" data-placement="top" title="Missing Symbols">
<i class="fas fa-sort-alpha-down-alt"></i>
</button>
<div class="dropdown">
<a class="btn btn-outline-secondary dropdown-toggle symbols-index btn-sm" href="#" role="button"
data-bs-toggle="dropdown" aria-expanded="false">
<i class="fas fa-sort-alpha-down-alt" data-toggle="tooltip" data-placement="top"
title="Missing Symbols"></i>
</a>

<ul class="dropdown-menu">
<li>
<a class="dropdown-item symbols-download" href="#" data-index="{{index}}">
<i class="fas fa-cloud-arrow-down"></i> Download
</a>
</li>
<li>
<a class="dropdown-item symbols-reload" href="#" data-index="{{index}}">
<i class="fas fa-arrows-rotate"></i> Reload
</a>
</li>
</ul>
</div>

{% elif status == 4 %}
<!-- ERROR -->
<button type="button" class="btn btn-outline-warning btn-sm error-index btn-log"
Expand Down
28 changes: 28 additions & 0 deletions orochi/templates/website/partial_isf_download.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{% load widget_tweaks %}

<form method="post" action="{% url 'website:download_isf' %}" id="isf-download-index">
{{ form.media }}
{% csrf_token %}
<div class="modal-header">
<h5 class="modal-title">Download symbols from ISF server</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
{% for field in form.visible_fields %}
<div class="form-group{% if field.errors %} has-error{% endif %}" id="div_{{field.id_for_label}}">
<label for="{{ field.id_for_label }}">{{ field.label }}</label>
{% render_field field class="form-control" %}
{% for error in field.errors %}
<p class="help-block">{{ error }}</p>
{% endfor %}
</div>
{% endfor %}
{% for hidden in form.hidden_fields %}
{{ hidden }}
{% endfor %}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary button-loader" id="btn_isf_download">Confirm</button>
</div>
</form>
28 changes: 28 additions & 0 deletions orochi/templates/website/partial_packages_upload.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{% load widget_tweaks %}

<form method="post" action="{% url 'website:upload_packages' %}" id="packages-upload-index">
{{ form.media }}
{% csrf_token %}
<div class="modal-header">
<h5 class="modal-title">Upload linux packages</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
{% for field in form.visible_fields %}
<div class="form-group{% if field.errors %} has-error{% endif %}" id="div_{{field.id_for_label}}">
<label for="{{ field.id_for_label }}">{{ field.label }}</label>
{% render_field field class="form-control" %}
{% for error in field.errors %}
<p class="help-block">{{ error }}</p>
{% endfor %}
</div>
{% endfor %}
{% for hidden in form.hidden_fields %}
{{ hidden }}
{% endfor %}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary button-loader" id="btn_package_add">Confirm</button>
</div>
</form>
11 changes: 2 additions & 9 deletions orochi/utils/download_symbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,10 @@


class Downloader:
def __init__(
self,
file_list: List[str] = None,
url_list: List[str] = None,
operating_system: str = None,
) -> None:
def __init__(self, file_list: List[str] = None, url_list: List[str] = None) -> None:
self.url_list = url_list if url_list is not None else []
self.file_list = file_list if file_list is not None else []
self.down_path = (
f"{settings.VOLATILITY_SYMBOL_PATH}/{operating_system.lower()}/"
)
self.down_path = f"{settings.VOLATILITY_SYMBOL_PATH}/added/"

def download_list(self):
processed_files = {}
Expand Down
8 changes: 6 additions & 2 deletions orochi/website/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,16 @@ def __init__(self, *args, **kwargs):
)


class SymbolISFForm(forms.Form):
path = forms.CharField(required=True)


class SymbolPackageForm(FileFormMixin, forms.Form):
packages = MultipleUploadedFileField(required=False)
packages = MultipleUploadedFileField(required=True)


class SymbolUploadForm(FileFormMixin, forms.Form):
symbols = MultipleUploadedFileField(required=False)
symbols = MultipleUploadedFileField(required=True)


class SymbolBannerForm(FileFormMixin, forms.ModelForm):
Expand Down
3 changes: 3 additions & 0 deletions orochi/website/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,11 @@ def to_url(self, value):
path("make_rule_default", views.make_rule_default, name="make_rule_default"),
path("download_rule/<int:pk>", views.download_rule, name="download_rule"),
# SYMBOLS
path("reload_symbols", views.reload_symbols, name="reload_symbols"),
path("banner_symbols", views.banner_symbols, name="banner_symbols"),
path("upload_symbols", views.upload_symbols, name="upload_symbols"),
path("upload_packages", views.upload_packages, name="upload_packages"),
path("download_isf", views.download_isf, name="download_isf"),
path("list_symbols", views.list_symbols, name="list_symbols"),
path("iterate_symbols", views.iterate_symbols, name="iterate_symbols"),
path("delete_symbol", views.delete_symbol, name="delete_symbol"),
Expand Down
Loading

0 comments on commit f846cf4

Please sign in to comment.