assemblyline-core 4.5.1.dev171__tar.gz → 4.5.1.dev173__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of assemblyline-core might be problematic. Click here for more details.
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/PKG-INFO +1 -1
- assemblyline-core-4.5.1.dev173/assemblyline_core/VERSION +1 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/replay/client.py +24 -5
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/replay/creator/run.py +7 -22
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/replay/creator/run_worker.py +11 -23
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/replay/replay.py +1 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/updater/helper.py +1 -1
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core.egg-info/PKG-INFO +1 -1
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/test/test_replay.py +18 -5
- assemblyline-core-4.5.1.dev171/assemblyline_core/VERSION +0 -1
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/LICENCE.md +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/README.md +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/__init__.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/alerter/__init__.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/alerter/processing.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/alerter/run_alerter.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/archiver/__init__.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/archiver/run_archiver.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/badlist_client.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/dispatching/__init__.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/dispatching/__main__.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/dispatching/client.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/dispatching/dispatcher.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/dispatching/schedules.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/dispatching/timeout.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/expiry/__init__.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/expiry/run_expiry.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/ingester/__init__.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/ingester/__main__.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/ingester/constants.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/ingester/ingester.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/metrics/__init__.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/metrics/es_metrics.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/metrics/heartbeat_formatter.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/metrics/helper.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/metrics/metrics_server.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/metrics/run_heartbeat_manager.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/metrics/run_metrics_aggregator.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/metrics/run_statistics_aggregator.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/plumber/__init__.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/plumber/run_plumber.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/replay/__init__.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/replay/creator/__init__.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/replay/loader/__init__.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/replay/loader/run.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/replay/loader/run_worker.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/safelist_client.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/scaler/__init__.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/scaler/collection.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/scaler/controllers/__init__.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/scaler/controllers/docker_ctl.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/scaler/controllers/interface.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/scaler/controllers/kubernetes_ctl.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/scaler/run_scaler.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/scaler/scaler_server.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/server_base.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/signature_client.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/submission_client.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/tasking_client.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/updater/__init__.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/updater/run_updater.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/vacuum/__init__.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/vacuum/crawler.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/vacuum/department_map.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/vacuum/safelist.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/vacuum/stream_map.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/vacuum/worker.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/workflow/__init__.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/workflow/run_workflow.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core.egg-info/SOURCES.txt +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core.egg-info/dependency_links.txt +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core.egg-info/requires.txt +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core.egg-info/top_level.txt +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/setup.cfg +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/setup.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/test/test_alerter.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/test/test_badlist_client.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/test/test_dispatcher.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/test/test_expiry.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/test/test_plumber.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/test/test_safelist_client.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/test/test_scaler.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/test/test_scheduler.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/test/test_signature_client.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/test/test_simulation.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/test/test_vacuum.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/test/test_worker_ingest.py +0 -0
- {assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/test/test_worker_submit.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
4.5.1.dev173
|
{assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/replay/client.py
RENAMED
|
@@ -7,8 +7,10 @@ from assemblyline.common.bundling import create_bundle, import_bundle
|
|
|
7
7
|
from assemblyline.odm import Model
|
|
8
8
|
from assemblyline.remote.datatypes.queues.named import NamedQueue
|
|
9
9
|
from assemblyline.remote.datatypes.hash import Hash
|
|
10
|
+
from assemblyline_core.replay.replay import INPUT_TYPES
|
|
10
11
|
from assemblyline_core.badlist_client import BadlistClient
|
|
11
12
|
from assemblyline_core.safelist_client import SafelistClient
|
|
13
|
+
from assemblyline_core.signature_client import SignatureClient
|
|
12
14
|
|
|
13
15
|
EMPTY_WAIT_TIME = int(os.environ.get('EMPTY_WAIT_TIME', '30'))
|
|
14
16
|
REPLAY_REQUESTED = 'requested'
|
|
@@ -18,7 +20,7 @@ REPLAY_DONE = 'done'
|
|
|
18
20
|
|
|
19
21
|
class ClientBase(object):
|
|
20
22
|
def __init__(self, log, lookback_time='*',
|
|
21
|
-
alert_fqs=None, badlist_fqs=None, safelist_fqs=None, submission_fqs=None, workflow_fqs=None):
|
|
23
|
+
alert_fqs=None, badlist_fqs=None, safelist_fqs=None, signature_fqs=None, submission_fqs=None, workflow_fqs=None):
|
|
22
24
|
# Set logger
|
|
23
25
|
self.log = log
|
|
24
26
|
|
|
@@ -31,6 +33,7 @@ class ClientBase(object):
|
|
|
31
33
|
self.alert_fqs = alert_fqs or []
|
|
32
34
|
self.badlist_fqs = badlist_fqs or []
|
|
33
35
|
self.safelist_fqs = safelist_fqs or []
|
|
36
|
+
self.signature_fqs = signature_fqs or []
|
|
34
37
|
self.submission_fqs = submission_fqs or []
|
|
35
38
|
self.workflow_fqs = workflow_fqs or []
|
|
36
39
|
|
|
@@ -202,15 +205,18 @@ class ClientBase(object):
|
|
|
202
205
|
if once:
|
|
203
206
|
break
|
|
204
207
|
|
|
205
|
-
def setup_workflow_input_queue(self, once=False):
|
|
206
|
-
self._setup_checkpoint_based_input_queue("workflow", "workflow_id", "last_edit", once)
|
|
207
|
-
|
|
208
208
|
def setup_badlist_input_queue(self, once=False):
|
|
209
209
|
self._setup_checkpoint_based_input_queue("badlist", "id", "updated", once)
|
|
210
210
|
|
|
211
211
|
def setup_safelist_input_queue(self, once=False):
|
|
212
212
|
self._setup_checkpoint_based_input_queue("safelist", "id", "updated", once)
|
|
213
213
|
|
|
214
|
+
def setup_signature_input_queue(self, once=False):
|
|
215
|
+
self._setup_checkpoint_based_input_queue("signature", "id", "last_modified", once)
|
|
216
|
+
|
|
217
|
+
def setup_workflow_input_queue(self, once=False):
|
|
218
|
+
self._setup_checkpoint_based_input_queue("workflow", "workflow_id", "last_edit", once)
|
|
219
|
+
|
|
214
220
|
def _query(self, collection, query, filter_queries=[], rows=None, track_total_hits=False):
|
|
215
221
|
raise NotImplementedError()
|
|
216
222
|
|
|
@@ -232,6 +238,9 @@ class ClientBase(object):
|
|
|
232
238
|
def get_next_safelist(self):
|
|
233
239
|
return self.get_next_message("safelist")
|
|
234
240
|
|
|
241
|
+
def get_next_signature(self):
|
|
242
|
+
return self.get_next_message("signature")
|
|
243
|
+
|
|
235
244
|
def get_next_submission(self):
|
|
236
245
|
return self.get_next_message("submission")
|
|
237
246
|
|
|
@@ -321,6 +330,9 @@ class APIClient(ClientBase):
|
|
|
321
330
|
elif collection == "safelist":
|
|
322
331
|
data['enabled'] = obj["enabled"]
|
|
323
332
|
self.al_client.safelist.add_update(data)
|
|
333
|
+
elif collection == "signature":
|
|
334
|
+
data['status'] = obj["status"]
|
|
335
|
+
self.al_client.signature.add_update(data)
|
|
324
336
|
except ClientError as e:
|
|
325
337
|
if e.status_code == 404:
|
|
326
338
|
# The document doesn't exist in the system, therefore create it
|
|
@@ -330,6 +342,8 @@ class APIClient(ClientBase):
|
|
|
330
342
|
self.al_client.badlist.add_update(data)
|
|
331
343
|
elif collection == "safelist":
|
|
332
344
|
self.al_client.safelist.add_update(data)
|
|
345
|
+
elif collection == "signature":
|
|
346
|
+
self.al_client.signature.add_update(data)
|
|
333
347
|
return
|
|
334
348
|
raise
|
|
335
349
|
|
|
@@ -363,7 +377,7 @@ class DirectClient(ClientBase):
|
|
|
363
377
|
self.datastore = forge.get_datastore(config=config)
|
|
364
378
|
self.queues = {
|
|
365
379
|
queue_type: NamedQueue(f"replay_{queue_type}", host=redis)
|
|
366
|
-
for queue_type in ['
|
|
380
|
+
for queue_type in INPUT_TYPES + ['file']
|
|
367
381
|
}
|
|
368
382
|
self.checkpoint_hash = Hash('replay_checkpoints', redis_persist)
|
|
369
383
|
|
|
@@ -431,6 +445,11 @@ class DirectClient(ClientBase):
|
|
|
431
445
|
# Preserve the system's enabled state of the item
|
|
432
446
|
data['enabled'] = obj["enabled"]
|
|
433
447
|
es_collection.save(id, SafelistClient._merge_hashes(data, obj))
|
|
448
|
+
elif collection == "signature":
|
|
449
|
+
if obj:
|
|
450
|
+
# Preserve the system's status state of the item
|
|
451
|
+
data['status'] = obj["status"]
|
|
452
|
+
es_collection.save(id, data)
|
|
434
453
|
es_collection.commit()
|
|
435
454
|
|
|
436
455
|
def set_single_object_complete(self, collection, id):
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import os
|
|
2
2
|
|
|
3
3
|
from assemblyline_core.replay.client import APIClient, DirectClient
|
|
4
|
-
from assemblyline_core.replay.replay import ReplayBase
|
|
5
|
-
|
|
4
|
+
from assemblyline_core.replay.replay import ReplayBase, INPUT_TYPES
|
|
6
5
|
|
|
7
6
|
class ReplayCreator(ReplayBase):
|
|
8
7
|
def __init__(self):
|
|
@@ -16,12 +15,9 @@ class ReplayCreator(ReplayBase):
|
|
|
16
15
|
os.makedirs(self.replay_config.creator.working_directory, exist_ok=True)
|
|
17
16
|
|
|
18
17
|
# Load client
|
|
19
|
-
client_config =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
safelist_fqs=self.replay_config.creator.safelist_input.filter_queries,
|
|
23
|
-
submission_fqs=self.replay_config.creator.submission_input.filter_queries,
|
|
24
|
-
workflow_fqs=self.replay_config.creator.workflow_input.filter_queries)
|
|
18
|
+
client_config = {f'{input_type}_fqs': getattr(self.replay_config.creator, f'{input_type}_input').filter_queries
|
|
19
|
+
for input_type in INPUT_TYPES}
|
|
20
|
+
client_config['lookback_time'] = self.replay_config.creator.lookback_time
|
|
25
21
|
|
|
26
22
|
if self.replay_config.creator.client.type == 'direct':
|
|
27
23
|
self.log.info("Using direct database access client")
|
|
@@ -36,20 +32,9 @@ class ReplayCreator(ReplayBase):
|
|
|
36
32
|
|
|
37
33
|
def try_run(self):
|
|
38
34
|
threads = {}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if self.replay_config.creator.badlist_input.enabled:
|
|
43
|
-
threads['Load Badlist Items'] = self.client.setup_badlist_input_queue
|
|
44
|
-
|
|
45
|
-
if self.replay_config.creator.safelist_input.enabled:
|
|
46
|
-
threads['Load Safelist Items'] = self.client.setup_safelist_input_queue
|
|
47
|
-
|
|
48
|
-
if self.replay_config.creator.submission_input.enabled:
|
|
49
|
-
threads['Load Submissions'] = self.client.setup_submission_input_queue
|
|
50
|
-
|
|
51
|
-
if self.replay_config.creator.workflow_input.enabled:
|
|
52
|
-
threads['Load Workflows'] = self.client.setup_workflow_input_queue
|
|
35
|
+
for input_type in INPUT_TYPES:
|
|
36
|
+
if getattr(self.replay_config.creator, f'{input_type}_input').enabled:
|
|
37
|
+
threads[f'Load {input_type.capitalize()}s'] = getattr(self.client, f'setup_{input_type}_input_queue')
|
|
53
38
|
|
|
54
39
|
if threads:
|
|
55
40
|
self.maintain_threads(threads)
|
|
@@ -4,7 +4,7 @@ import os
|
|
|
4
4
|
from assemblyline.filestore import FileStore
|
|
5
5
|
from assemblyline.common.isotime import now_as_iso
|
|
6
6
|
from assemblyline_core.replay.client import APIClient, DirectClient
|
|
7
|
-
from assemblyline_core.replay.replay import ReplayBase
|
|
7
|
+
from assemblyline_core.replay.replay import ReplayBase, INPUT_TYPES
|
|
8
8
|
|
|
9
9
|
REPLAY_BATCH_SIZE = int(os.environ.get("REPLAY_BATCH_SIZE", "1000"))
|
|
10
10
|
|
|
@@ -39,7 +39,7 @@ class ReplayCreatorWorker(ReplayBase):
|
|
|
39
39
|
raise ValueError(f'Invalid client type ({self.replay_config.creator.client.type}). '
|
|
40
40
|
'Must be either \'api\' or \'direct\'.')
|
|
41
41
|
|
|
42
|
-
def
|
|
42
|
+
def process_alert(self, once=False):
|
|
43
43
|
while self.running:
|
|
44
44
|
# Process alerts found
|
|
45
45
|
alert = self.client.get_next_alert()
|
|
@@ -67,7 +67,7 @@ class ReplayCreatorWorker(ReplayBase):
|
|
|
67
67
|
if once:
|
|
68
68
|
break
|
|
69
69
|
|
|
70
|
-
def
|
|
70
|
+
def process_submission(self, once=False):
|
|
71
71
|
while self.running:
|
|
72
72
|
# Process submissions found
|
|
73
73
|
submission = self.client.get_next_submission()
|
|
@@ -151,31 +151,19 @@ class ReplayCreatorWorker(ReplayBase):
|
|
|
151
151
|
def process_safelist(self, once=False):
|
|
152
152
|
self._process_json_exports("safelist", "id", "updated", once)
|
|
153
153
|
|
|
154
|
+
def process_signature(self, once=False):
|
|
155
|
+
self._process_json_exports("signature", "id", "last_modified", once)
|
|
156
|
+
|
|
154
157
|
def process_workflow(self, once=False):
|
|
155
158
|
self._process_json_exports("workflow", "id", "last_edit", once)
|
|
156
159
|
|
|
157
160
|
def try_run(self):
|
|
158
161
|
threads = {}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
for ii in range(self.replay_config.creator.badlist_input.threads):
|
|
165
|
-
threads[f'Badlist process thread #{ii}'] = self.process_badlist
|
|
166
|
-
|
|
167
|
-
if self.replay_config.creator.safelist_input.enabled:
|
|
168
|
-
for ii in range(self.replay_config.creator.safelist_input.threads):
|
|
169
|
-
threads[f'Safelist process thread #{ii}'] = self.process_safelist
|
|
170
|
-
|
|
171
|
-
if self.replay_config.creator.submission_input.enabled:
|
|
172
|
-
for ii in range(self.replay_config.creator.submission_input.threads):
|
|
173
|
-
threads[f'Submission process thread #{ii}'] = self.process_submissions
|
|
174
|
-
|
|
175
|
-
if self.replay_config.creator.workflow_input.enabled:
|
|
176
|
-
for ii in range(self.replay_config.creator.workflow_input.threads):
|
|
177
|
-
threads[f'Workflow process thread #{ii}'] = self.process_workflow
|
|
178
|
-
|
|
162
|
+
for input_type in INPUT_TYPES:
|
|
163
|
+
input_config = getattr(self.replay_config.creator, f"{input_type}_input")
|
|
164
|
+
if input_config.enabled:
|
|
165
|
+
for ii in range(input_config.threads):
|
|
166
|
+
threads[f"{input_type.capitalize()} process thread #{ii}"] = getattr(self, f"process_{input_type}")
|
|
179
167
|
if threads:
|
|
180
168
|
self.maintain_threads(threads)
|
|
181
169
|
else:
|
{assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/replay/replay.py
RENAMED
|
@@ -11,6 +11,7 @@ from assemblyline.odm.models.replay import ReplayConfig
|
|
|
11
11
|
from assemblyline_core.server_base import ServerBase
|
|
12
12
|
|
|
13
13
|
CONFIG_PATH = os.environ.get('REPLAY_CONFIG_PATH', '/etc/assemblyline/replay.yml')
|
|
14
|
+
INPUT_TYPES = ['alert', 'badlist', 'safelist', 'signature', 'submission', 'workflow']
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
class ReplayBase(ServerBase):
|
|
@@ -227,7 +227,7 @@ def _get_dockerhub_tags(image_name, update_channel, proxies=None):
|
|
|
227
227
|
elif resp.status_code == 429:
|
|
228
228
|
# Based on https://docs.docker.com/docker-hub/api/latest/#tag/rate-limiting
|
|
229
229
|
# We've hit the rate limit so we have to wait and try again later
|
|
230
|
-
time.sleep(int(
|
|
230
|
+
time.sleep(int(resp.headers['retry-after']) - int(time.time()))
|
|
231
231
|
else:
|
|
232
232
|
break
|
|
233
233
|
|
|
@@ -2,11 +2,12 @@ import collections
|
|
|
2
2
|
import json
|
|
3
3
|
import os
|
|
4
4
|
import random
|
|
5
|
+
import time
|
|
5
6
|
|
|
6
7
|
import pytest
|
|
7
8
|
|
|
8
9
|
from assemblyline.common import forge
|
|
9
|
-
from assemblyline.odm.random_data import create_alerts, wipe_alerts, wipe_submissions, create_submission, create_badlists, create_safelists, create_workflows, wipe_badlist, wipe_safelist, wipe_workflows
|
|
10
|
+
from assemblyline.odm.random_data import create_alerts, wipe_alerts, wipe_submissions, create_submission, create_badlists, create_safelists, create_workflows, wipe_badlist, wipe_safelist, wipe_workflows, create_signatures, wipe_signatures
|
|
10
11
|
from assemblyline_core.replay.creator.run import ReplayCreator
|
|
11
12
|
from assemblyline_core.replay.creator.run_worker import ReplayCreatorWorker
|
|
12
13
|
from assemblyline_core.replay.loader.run import ReplayLoader
|
|
@@ -15,6 +16,7 @@ from assemblyline_core.replay.loader.run_worker import ReplayLoaderWorker
|
|
|
15
16
|
NUM_ALERTS = 1
|
|
16
17
|
NUM_BADLIST_ITEMS = 1
|
|
17
18
|
NUM_SAFELIST_ITEMS = 1
|
|
19
|
+
NUM_SIGNATURES = 1
|
|
18
20
|
NUM_SUBMISSIONS = 1
|
|
19
21
|
NUM_WORKFLOWS = 1
|
|
20
22
|
|
|
@@ -48,14 +50,24 @@ def datastore(request, datastore_connection, fs):
|
|
|
48
50
|
wipe_badlist(datastore_connection)
|
|
49
51
|
wipe_safelist(datastore_connection)
|
|
50
52
|
wipe_submissions(datastore_connection, fs)
|
|
53
|
+
wipe_signatures(datastore_connection)
|
|
51
54
|
wipe_workflows(datastore_connection)
|
|
52
55
|
|
|
53
56
|
for _ in range(NUM_SUBMISSIONS):
|
|
54
57
|
all_submissions.append(create_submission(datastore_connection, fs))
|
|
55
58
|
create_alerts(datastore_connection, alert_count=NUM_ALERTS,
|
|
56
59
|
submission_list=all_submissions)
|
|
57
|
-
create_safelists(datastore_connection, count=NUM_SAFELIST_ITEMS)
|
|
58
60
|
create_badlists(datastore_connection, count=NUM_BADLIST_ITEMS)
|
|
61
|
+
|
|
62
|
+
# Generate all signatures from testing set, but only keep what's being asked to limit to
|
|
63
|
+
create_signatures(datastore_connection)
|
|
64
|
+
data_collections["signature"] = \
|
|
65
|
+
datastore_connection.signature.search("*", rows=NUM_SIGNATURES, fl="id,*")['items']
|
|
66
|
+
wipe_signatures(datastore_connection)
|
|
67
|
+
for sig in data_collections["signature"]:
|
|
68
|
+
datastore_connection.signature.save(sig.id, sig)
|
|
69
|
+
|
|
70
|
+
create_safelists(datastore_connection, count=NUM_SAFELIST_ITEMS)
|
|
59
71
|
create_workflows(datastore_connection, count=NUM_WORKFLOWS)
|
|
60
72
|
for alert in datastore_connection.alert.stream_search("id:*", fl="*"):
|
|
61
73
|
all_alerts.append(alert)
|
|
@@ -70,6 +82,7 @@ def datastore(request, datastore_connection, fs):
|
|
|
70
82
|
wipe_alerts(datastore_connection)
|
|
71
83
|
wipe_badlist(datastore_connection)
|
|
72
84
|
wipe_safelist(datastore_connection)
|
|
85
|
+
wipe_signatures(datastore_connection)
|
|
73
86
|
wipe_submissions(datastore_connection, fs)
|
|
74
87
|
wipe_workflows(datastore_connection)
|
|
75
88
|
|
|
@@ -141,7 +154,7 @@ def test_replay_single_alert(config, datastore, creator, creator_worker, loader,
|
|
|
141
154
|
'alert_id'] == alert.alert_id
|
|
142
155
|
|
|
143
156
|
# Test replay creator worker
|
|
144
|
-
creator_worker.
|
|
157
|
+
creator_worker.process_alert(once=True)
|
|
145
158
|
datastore.alert.commit()
|
|
146
159
|
assert creator_worker.client.queues['alert'].length() == 0
|
|
147
160
|
assert datastore.alert.get(alert.alert_id, as_obj=False)['metadata']['replay'] == 'done'
|
|
@@ -190,7 +203,7 @@ def test_replay_single_submission(config, datastore, creator, creator_worker, lo
|
|
|
190
203
|
assert creator.client.queues['submission'].peek_next()['sid'] == sub['sid']
|
|
191
204
|
|
|
192
205
|
# Test replay creator worker
|
|
193
|
-
creator_worker.
|
|
206
|
+
creator_worker.process_submission(once=True)
|
|
194
207
|
datastore.submission.commit()
|
|
195
208
|
assert creator_worker.client.queues['submission'].length() == 0
|
|
196
209
|
assert datastore.submission.get(sub['sid'], as_obj=False)['metadata']['replay'] == 'done'
|
|
@@ -222,7 +235,7 @@ def test_replay_single_submission(config, datastore, creator, creator_worker, lo
|
|
|
222
235
|
assert 'replay' not in loaded_submission['metadata']
|
|
223
236
|
|
|
224
237
|
|
|
225
|
-
@pytest.mark.parametrize("collection", ["badlist", "safelist", "workflow"])
|
|
238
|
+
@pytest.mark.parametrize("collection", ["badlist", "safelist", "signature", "workflow"])
|
|
226
239
|
def test_replay_single_data_collection(datastore, creator, creator_worker, loader, loader_worker, collection):
|
|
227
240
|
output_dir = creator.replay_config.creator.output_filestore.replace('file://', '')
|
|
228
241
|
input_dir = loader.replay_config.loader.input_directory
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
4.5.1.dev171
|
|
File without changes
|
|
File without changes
|
{assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/server_base.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/assemblyline_core/vacuum/worker.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/test/test_badlist_client.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/test/test_safelist_client.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/test/test_signature_client.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/test/test_worker_ingest.py
RENAMED
|
File without changes
|
{assemblyline-core-4.5.1.dev171 → assemblyline-core-4.5.1.dev173}/test/test_worker_submit.py
RENAMED
|
File without changes
|