assemblyline-v4-service 4.6.1.dev248__py3-none-any.whl → 4.7.0.dev31__py3-none-any.whl
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.
- assemblyline_v4_service/VERSION +1 -1
- assemblyline_v4_service/common/api.py +0 -47
- assemblyline_v4_service/common/base.py +2 -6
- assemblyline_v4_service/common/ontology_helper.py +2 -0
- assemblyline_v4_service/common/request.py +4 -5
- assemblyline_v4_service/common/result.py +257 -220
- assemblyline_v4_service/common/task.py +6 -6
- assemblyline_v4_service/dev/updater.py +7 -2
- assemblyline_v4_service/healthz.py +18 -19
- {assemblyline_v4_service-4.6.1.dev248.dist-info → assemblyline_v4_service-4.7.0.dev31.dist-info}/METADATA +1 -1
- {assemblyline_v4_service-4.6.1.dev248.dist-info → assemblyline_v4_service-4.7.0.dev31.dist-info}/RECORD +15 -16
- test/test_common/test_api.py +0 -24
- assemblyline_v4_service/run_privileged_service.py +0 -337
- {assemblyline_v4_service-4.6.1.dev248.dist-info → assemblyline_v4_service-4.7.0.dev31.dist-info}/WHEEL +0 -0
- {assemblyline_v4_service-4.6.1.dev248.dist-info → assemblyline_v4_service-4.7.0.dev31.dist-info}/licenses/LICENCE.md +0 -0
- {assemblyline_v4_service-4.6.1.dev248.dist-info → assemblyline_v4_service-4.7.0.dev31.dist-info}/top_level.txt +0 -0
assemblyline_v4_service/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
4.
|
|
1
|
+
4.7.0.dev31
|
|
@@ -2,8 +2,6 @@ import os
|
|
|
2
2
|
import time
|
|
3
3
|
|
|
4
4
|
import requests
|
|
5
|
-
from assemblyline_core.badlist_client import BadlistClient
|
|
6
|
-
from assemblyline_core.safelist_client import SafelistClient
|
|
7
5
|
from assemblyline_v4_service.common.utils import DEVELOPMENT_MODE
|
|
8
6
|
from assemblyline_v4_service.common.helper import get_service_manifest
|
|
9
7
|
|
|
@@ -129,48 +127,3 @@ class ServiceAPI:
|
|
|
129
127
|
return None
|
|
130
128
|
else:
|
|
131
129
|
raise
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
class PrivilegedServiceAPI:
|
|
135
|
-
def __init__(self, logger):
|
|
136
|
-
self.log = logger
|
|
137
|
-
self.badlist_client = BadlistClient()
|
|
138
|
-
self.safelist_client = SafelistClient()
|
|
139
|
-
|
|
140
|
-
def lookup_badlist_tags(self, tag_map):
|
|
141
|
-
if DEVELOPMENT_MODE or not tag_map:
|
|
142
|
-
return []
|
|
143
|
-
|
|
144
|
-
if not isinstance(tag_map, dict) and not all([isinstance(x, list) for x in tag_map.values()]):
|
|
145
|
-
raise ValueError("Parameter tag_list should be a dictionary tag_type mapping to a list of tag_values.")
|
|
146
|
-
|
|
147
|
-
return self.badlist_client.exists_tags(tag_map)
|
|
148
|
-
|
|
149
|
-
def lookup_badlist(self, qhash):
|
|
150
|
-
if DEVELOPMENT_MODE or qhash is None:
|
|
151
|
-
return None
|
|
152
|
-
return self.badlist_client.exists(qhash)
|
|
153
|
-
|
|
154
|
-
def lookup_badlist_ssdeep(self, ssdeep):
|
|
155
|
-
if DEVELOPMENT_MODE or ssdeep is None:
|
|
156
|
-
return []
|
|
157
|
-
return self.badlist_client.find_similar_ssdeep(ssdeep)
|
|
158
|
-
|
|
159
|
-
def lookup_badlist_tlsh(self, tlsh):
|
|
160
|
-
if DEVELOPMENT_MODE or tlsh is None:
|
|
161
|
-
return []
|
|
162
|
-
return self.badlist_client.find_similar_tlsh(tlsh)
|
|
163
|
-
|
|
164
|
-
def get_safelist(self, tag_list=None):
|
|
165
|
-
if DEVELOPMENT_MODE:
|
|
166
|
-
return {}
|
|
167
|
-
|
|
168
|
-
if tag_list and not isinstance(tag_list, list):
|
|
169
|
-
raise ValueError("Parameter tag_list should be a list of strings.")
|
|
170
|
-
|
|
171
|
-
return self.safelist_client.get_safelisted_tags(tag_list)
|
|
172
|
-
|
|
173
|
-
def lookup_safelist(self, qhash):
|
|
174
|
-
if DEVELOPMENT_MODE:
|
|
175
|
-
return None
|
|
176
|
-
return self.safelist_client.exists(qhash)
|
|
@@ -17,7 +17,7 @@ from assemblyline.common import exceptions, log, version
|
|
|
17
17
|
from assemblyline.common.digests import get_sha256_for_file
|
|
18
18
|
from assemblyline.odm.messages.task import Task as ServiceTask
|
|
19
19
|
from assemblyline_v4_service.common import helper
|
|
20
|
-
from assemblyline_v4_service.common.api import
|
|
20
|
+
from assemblyline_v4_service.common.api import ServiceAPI
|
|
21
21
|
from assemblyline_v4_service.common.ontology_helper import OntologyHelper
|
|
22
22
|
from assemblyline_v4_service.common.ocr import update_ocr_config
|
|
23
23
|
from assemblyline_v4_service.common.request import ServiceRequest
|
|
@@ -28,7 +28,6 @@ warnings.filterwarnings("ignore")
|
|
|
28
28
|
|
|
29
29
|
UPDATES_DIR = os.environ.get('UPDATES_DIR', '/updates')
|
|
30
30
|
UPDATES_CA = os.environ.get('UPDATES_CA', '/etc/assemblyline/ssl/al_root-ca.crt')
|
|
31
|
-
PRIVILEGED = os.environ.get('PRIVILEGED', 'false') == 'true'
|
|
32
31
|
MIN_SECONDS_BETWEEN_UPDATES = float(os.environ.get('MIN_SECONDS_BETWEEN_UPDATES', '10.0'))
|
|
33
32
|
SIGNATURES_META_FILENAME = "signatures_meta.json"
|
|
34
33
|
|
|
@@ -143,10 +142,7 @@ class ServiceBase:
|
|
|
143
142
|
|
|
144
143
|
def get_api_interface(self):
|
|
145
144
|
if not self._api_interface:
|
|
146
|
-
|
|
147
|
-
self._api_interface = PrivilegedServiceAPI(self.log)
|
|
148
|
-
else:
|
|
149
|
-
self._api_interface = ServiceAPI(self.service_attributes, self.log)
|
|
145
|
+
self._api_interface = ServiceAPI(self.service_attributes, self.log)
|
|
150
146
|
|
|
151
147
|
return self._api_interface
|
|
152
148
|
|
|
@@ -32,6 +32,7 @@ def validate_tags(tag_map: Dict[str, List[str]]) -> Dict[str, List[str]]:
|
|
|
32
32
|
tag_map = flatten(tag_map.as_primitives(strip_null=True))
|
|
33
33
|
return tag_map
|
|
34
34
|
|
|
35
|
+
|
|
35
36
|
# Merge tags
|
|
36
37
|
def merge_tags(tag_a: Dict[str, List[str]], tag_b: Dict[str, List[str]]) -> Dict[str, List[str]]:
|
|
37
38
|
if not tag_a:
|
|
@@ -43,6 +44,7 @@ def merge_tags(tag_a: Dict[str, List[str]], tag_b: Dict[str, List[str]]) -> Dict
|
|
|
43
44
|
all_keys = list(tag_a.keys()) + list(tag_b.keys())
|
|
44
45
|
return {key: list(set(tag_a.get(key, []) + tag_b.get(key, []))) for key in all_keys}
|
|
45
46
|
|
|
47
|
+
|
|
46
48
|
class OntologyHelper:
|
|
47
49
|
def __init__(self, logger, service_name) -> None:
|
|
48
50
|
self.log = logger
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import hashlib
|
|
2
2
|
import logging
|
|
3
3
|
import tempfile
|
|
4
|
-
from typing import Any, Dict, List, Optional, TextIO
|
|
4
|
+
from typing import Any, Dict, List, Optional, TextIO
|
|
5
5
|
|
|
6
|
-
from assemblyline_v4_service.common.api import
|
|
6
|
+
from assemblyline_v4_service.common.api import ServiceAPI
|
|
7
7
|
from assemblyline_v4_service.common.ocr import ocr_detections
|
|
8
8
|
from assemblyline_v4_service.common.result import Heuristic, Result, ResultKeyValueSection
|
|
9
9
|
from assemblyline_v4_service.common.task import PARENT_RELATION, MaxExtractedExceeded, Task
|
|
@@ -31,7 +31,7 @@ class ServiceRequest:
|
|
|
31
31
|
|
|
32
32
|
def add_extracted(self, path: str, name: str, description: str,
|
|
33
33
|
classification: Optional[Classification] = None,
|
|
34
|
-
safelist_interface: Optional[
|
|
34
|
+
safelist_interface: Optional[ServiceAPI] = None,
|
|
35
35
|
allow_dynamic_recursion: bool = False, parent_relation: str = PARENT_RELATION.EXTRACTED) -> bool:
|
|
36
36
|
"""
|
|
37
37
|
Add an extracted file for additional processing.
|
|
@@ -148,7 +148,7 @@ class ServiceRequest:
|
|
|
148
148
|
self, path: str, name: str, description: str,
|
|
149
149
|
classification: Optional[Classification] = None,
|
|
150
150
|
parent_relation: str = PARENT_RELATION.INFORMATION
|
|
151
|
-
|
|
151
|
+
) -> bool:
|
|
152
152
|
"""
|
|
153
153
|
Add a supplementary file.
|
|
154
154
|
|
|
@@ -159,7 +159,6 @@ class ServiceRequest:
|
|
|
159
159
|
:param parent_relation: File relation to parent, if any.
|
|
160
160
|
:return: None
|
|
161
161
|
"""
|
|
162
|
-
|
|
163
162
|
return self.task.add_supplementary(
|
|
164
163
|
path, name, description, classification, parent_relation=parent_relation
|
|
165
164
|
)
|