From 65f4f203f87e526c8f6b0fd578dfb8419a954986 Mon Sep 17 00:00:00 2001 From: tpo-anssi Date: Mon, 2 Jan 2017 18:32:50 +0100 Subject: [PATCH 1/3] This commit has broken sample upload from Skelenox. This reverts commit 80fa2b684d74831a9ec359b20f15def502ba6140. --- poli/views/apiview.py | 3 +-- poli/views/webui.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/poli/views/apiview.py b/poli/views/apiview.py index 008500a..44ff95a 100644 --- a/poli/views/apiview.py +++ b/poli/views/apiview.py @@ -292,8 +292,7 @@ def api_get_sample_id_from_hash(shash): abort(400, "Invalid hash length") if sample is not None: return jsonify({'sample_id': sample.id}) - else: - abort(404) + return jsonify({'sample_id': None}) @apiview.route('/samples//download/') diff --git a/poli/views/webui.py b/poli/views/webui.py index b830cc3..de4e3f5 100644 --- a/poli/views/webui.py +++ b/poli/views/webui.py @@ -65,7 +65,7 @@ def before_request(): Affects global variables for each request """ g.user = current_user - g.samples = Sample.query.order_by(Sample.id).limit(15).all() + g.samples = Sample.query.all() """ From 8a59481687ed5c2d48fda11b73f0818fbd688bf9 Mon Sep 17 00:00:00 2001 From: tpo-anssi Date: Mon, 2 Jan 2017 18:36:03 +0100 Subject: [PATCH 2/3] Limit the results for last samples in the index --- poli/views/webui.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/poli/views/webui.py b/poli/views/webui.py index de4e3f5..0596207 100644 --- a/poli/views/webui.py +++ b/poli/views/webui.py @@ -65,7 +65,8 @@ def before_request(): Affects global variables for each request """ g.user = current_user - g.samples = Sample.query.all() + # Query the last 15 samples for displaying in the index page + g.samples = Sample.query.order_by(Sample.id.desc()).limit(15).all() """ From ab8c4886bb6c8bf474dee28ee9c3e04aee40b307 Mon Sep 17 00:00:00 2001 From: Cyril Moreau Date: Mon, 6 Feb 2017 19:37:19 +0100 Subject: [PATCH 3/3] Add connection optional parameters to SampleModule, FamilyModule and YaraModule --- poliapi/mainapi.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/poliapi/mainapi.py b/poliapi/mainapi.py index 3fd9151..8e79145 100644 --- a/poliapi/mainapi.py +++ b/poliapi/mainapi.py @@ -105,8 +105,9 @@ class SampleModule(MainModule): Uses the sample endpoint """ - def __init__(self): - super(SampleModule, self).__init__() + def __init__(self, server="127.0.0.1", server_port=5000, + base_uri='/api/1.0/'): + super(SampleModule, self).__init__(server, server_port, base_uri) def send_sample(self, filename, tlp): """ @@ -178,8 +179,9 @@ class FamilyModule(MainModule): Utilities to manage families """ - def __init__(self): - super(FamilyModule, self).__init__() + def __init__(self, server="127.0.0.1", server_port=5000, + base_uri='/api/1.0/'): + super(FamilyModule, self).__init__(server, server_port, base_uri) def create_family(self, name, parent=None, tlp_level=3): """ @@ -229,8 +231,9 @@ class YaraModule(MainModule): Manage yara rules """ - def __init__(self): - super(YaraModule, self).__init__() + def __init__(self, server="127.0.0.1", server_port=5000, + base_uri='/api/1.0/'): + super(YaraModule, self).__init__(server, server_port, base_uri) def create_yara(self, name, rule, tlp_level=2): """