assemblyline-v4-service 4.5.1.dev113__py3-none-any.whl → 4.5.1.dev115__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.

Potentially problematic release.


This version of assemblyline-v4-service might be problematic. Click here for more details.

@@ -1 +1 @@
1
- 4.5.1.dev113
1
+ 4.5.1.dev115
@@ -89,6 +89,7 @@ class Task:
89
89
  def _add_file(self, path: str, name: str, description: str,
90
90
  classification: Optional[Classification] = None,
91
91
  is_section_image: bool = False,
92
+ is_supplementary: bool = False,
92
93
  allow_dynamic_recursion: bool = False,
93
94
  parent_relation: str = PARENT_RELATION.EXTRACTED) -> Optional[Dict[str, str]]:
94
95
  # Reject empty files
@@ -113,6 +114,7 @@ class Task:
113
114
  classification=self._classification.max_classification(self.min_classification, classification),
114
115
  path=path,
115
116
  is_section_image=is_section_image,
117
+ is_supplementary=is_supplementary,
116
118
  allow_dynamic_recursion=allow_dynamic_recursion,
117
119
  parent_relation=parent_relation
118
120
  )
@@ -174,9 +176,8 @@ class Task:
174
176
  if not description:
175
177
  raise ValueError("Description cannot be empty")
176
178
 
177
- file = self._add_file(
178
- path, name, description, classification, is_section_image, parent_relation=parent_relation
179
- )
179
+ file = self._add_file(path, name, description, classification, is_section_image,
180
+ is_supplementary=True, parent_relation=parent_relation)
180
181
 
181
182
  if not file:
182
183
  return None
@@ -261,6 +261,7 @@ class RunPrivilegedService(ServerBase):
261
261
  file_info['classification'],
262
262
  task.ttl,
263
263
  file_info.get('is_section_image', False),
264
+ file_info.get('is_supplementary', False),
264
265
  expected_sha256=file_info['sha256']
265
266
  )
266
267
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: assemblyline-v4-service
3
- Version: 4.5.1.dev113
3
+ Version: 4.5.1.dev115
4
4
  Summary: Assemblyline 4 - Service base
5
5
  Home-page: https://github.com/CybercentreCanada/assemblyline-v4-service/
6
6
  Author: CCCS Assemblyline development team
@@ -1,8 +1,8 @@
1
- assemblyline_v4_service/VERSION,sha256=An3niOppfhriSM6loTtfIWhsXm3ZwrAKNBMNVh7mkXA,13
1
+ assemblyline_v4_service/VERSION,sha256=CiVxl_3WaAaw-Ltgv-KKY-JNT4YecspFdmL3zVkXfq0,13
2
2
  assemblyline_v4_service/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  assemblyline_v4_service/healthz.py,sha256=sS1cFkDLw8hUPMpj7tbHXFv8ZmHcazrwZ0l6oQDwwkQ,1575
4
4
  assemblyline_v4_service/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- assemblyline_v4_service/run_privileged_service.py,sha256=qd4DmHo5G_Tpv8tb0A96qNfCGuXBu5MlIKB205z5e5w,14514
5
+ assemblyline_v4_service/run_privileged_service.py,sha256=ipCjdB_PZXt85Hmu9r9q7QjKXI8Y6iF-w6Aa4PMn9S4,14576
6
6
  assemblyline_v4_service/run_service.py,sha256=NiFX52NfsbBQY6E3nrjoB3e2XxIlwFcQpYYY-rADIk4,5996
7
7
  assemblyline_v4_service/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  assemblyline_v4_service/common/api.py,sha256=Xzp8j4HCCfjPvNSGKiZl5ttH2_Itg47cjlH0NXNtth0,6849
@@ -12,7 +12,7 @@ assemblyline_v4_service/common/ocr.py,sha256=3fV0PyY3oui_ucAM9dkolP0VRYKACKJuGY4
12
12
  assemblyline_v4_service/common/ontology_helper.py,sha256=QpwerYoS5hXjWzpx3Pmwv6j2330PQVYqxYGamjcpW3I,7890
13
13
  assemblyline_v4_service/common/request.py,sha256=W7fqC2xQE3i5i2jlCDyUDp3ZqJQQqSshNW0mQfJMkFg,11792
14
14
  assemblyline_v4_service/common/result.py,sha256=9AqM6qCYiia_Bpyn_fBFhzNQMcqJbtFSiGjp57fXW2E,32713
15
- assemblyline_v4_service/common/task.py,sha256=-AhtT6qSMLndBB3IOqOF-MV5K8Xp_67yvcgMuzr1IT0,13720
15
+ assemblyline_v4_service/common/task.py,sha256=OIE_V-xyGq9vvuT-U_3DIoGdlY3F4oWV9WIc_jhWXsA,13848
16
16
  assemblyline_v4_service/common/utils.py,sha256=k2__d-V5LjB6o2IKbjVe7tJWKcKuUHto5TyT5oKhIa0,3890
17
17
  assemblyline_v4_service/dev/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
18
  assemblyline_v4_service/dev/run_service_once.py,sha256=4K3ljw0MnfPGw0-6lzc_vtUYg1EbntJbbsWvNU-ZM_A,10456
@@ -34,12 +34,12 @@ test/test_common/test_base.py,sha256=fuJSSlPxIDHq6HU1xbvaMFitw2z1spOZNHD2SJ4UUic
34
34
  test/test_common/test_helper.py,sha256=sO6YAiBhKTqaxlpLhFYDuy2ZdbuF2cg07Ylzo83ZzQs,2575
35
35
  test/test_common/test_ocr.py,sha256=mt_PgElgwQKJmNrp2nRVx9NjfMedVk40I6IV317vATI,1753
36
36
  test/test_common/test_ontology_helper.py,sha256=KhHEBg_ecJyQbDw79NMT4FzUyA4C1Aak3HEQCwBfM2s,7914
37
- test/test_common/test_request.py,sha256=PPhHfrwpwMdNZ33P1Z_0h1Zaz9ao9VFiDr_MJrBS3Lg,11492
37
+ test/test_common/test_request.py,sha256=Ceyds8BNO1O0f1kH1VEb84faJcaupvSjVKIrGdHexsc,11842
38
38
  test/test_common/test_result.py,sha256=0WK_Zfw7e6IJl5nTSUUt6LFTvbu6cVynaTOdpuYkBvg,42559
39
- test/test_common/test_task.py,sha256=jnfF68EgJIu30Pz_4jiJHkncfI-3XpGaut5r79KIXOA,18718
39
+ test/test_common/test_task.py,sha256=P44mNcSe-3tJgDk9ppN3KbM7oN4LBVIuhONG-Gveh74,19007
40
40
  test/test_common/test_utils.py,sha256=TbnBxqpS_ZC5ptXR9XJX3xtbItD0mTbtiBxxdyP8J5k,5904
41
- assemblyline_v4_service-4.5.1.dev113.dist-info/LICENCE.md,sha256=NSkYo9EH8h5oOkzg4VhjAHF4339MqPP2cQ8msTPgl-c,1396
42
- assemblyline_v4_service-4.5.1.dev113.dist-info/METADATA,sha256=K9OSRJy7y_iHZWW3682xX9G-7nqv0kkkKLJhGxl4B3k,9499
43
- assemblyline_v4_service-4.5.1.dev113.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
44
- assemblyline_v4_service-4.5.1.dev113.dist-info/top_level.txt,sha256=LpTOEaVCatkrvbVq3EZseMSIa2PQZU-2rhuO_FTpZgY,29
45
- assemblyline_v4_service-4.5.1.dev113.dist-info/RECORD,,
41
+ assemblyline_v4_service-4.5.1.dev115.dist-info/LICENCE.md,sha256=NSkYo9EH8h5oOkzg4VhjAHF4339MqPP2cQ8msTPgl-c,1396
42
+ assemblyline_v4_service-4.5.1.dev115.dist-info/METADATA,sha256=2mfPgv9gtIGZAFtoWkSbNK7iM9AHeaJp2uJpY0FEy9E,9499
43
+ assemblyline_v4_service-4.5.1.dev115.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
44
+ assemblyline_v4_service-4.5.1.dev115.dist-info/top_level.txt,sha256=LpTOEaVCatkrvbVq3EZseMSIa2PQZU-2rhuO_FTpZgY,29
45
+ assemblyline_v4_service-4.5.1.dev115.dist-info/RECORD,,
@@ -13,6 +13,7 @@ from assemblyline.odm.messages.task import Task as ServiceTask
13
13
  # Ensure service manifest is instantiated before importing from OCR submodule
14
14
  setup_module()
15
15
 
16
+
16
17
  @pytest.fixture
17
18
  def service_request():
18
19
  st = ServiceTask({
@@ -71,11 +72,12 @@ def test_add_extracted(service_request):
71
72
  'classification': 'TLP:C',
72
73
  'description': 'description',
73
74
  'is_section_image': False,
75
+ 'is_supplementary': False,
74
76
  'name': 'name',
75
77
  'parent_relation': 'EXTRACTED',
76
78
  'path': path,
77
79
  'sha256': '9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08'
78
- },
80
+ },
79
81
  ]
80
82
 
81
83
  # Raise MaxExtractedExceeded
@@ -97,17 +99,20 @@ def test_add_extracted(service_request):
97
99
  'classification': 'TLP:C',
98
100
  'description': 'description',
99
101
  'is_section_image': False,
102
+ 'is_supplementary': False,
100
103
  'name': 'name',
101
104
  'parent_relation': 'DYNAMIC',
102
105
  'path': path,
103
106
  'sha256': '9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08'
104
- },
107
+ },
105
108
  ]
106
109
 
107
110
 
108
111
  @pytest.mark.skipif(len(TESSERACT_LIST) < 1, reason="Requires tesseract-ocr apt package")
109
112
  def test_add_image(service_request):
110
- image_path = os.path.join(os.path.dirname(__file__), "b32969aa664e3905c20f865cdd7b921f922678f5c3850c78e4c803fbc1757a8e")
113
+ image_path = os.path.join(
114
+ os.path.dirname(__file__),
115
+ "b32969aa664e3905c20f865cdd7b921f922678f5c3850c78e4c803fbc1757a8e")
111
116
 
112
117
  # Basic
113
118
  assert service_request.add_image(image_path, "image_name", "description of image") == {
@@ -131,6 +136,7 @@ def test_add_image(service_request):
131
136
  'classification': 'TLP:C',
132
137
  'description': 'description of image',
133
138
  'is_section_image': True,
139
+ 'is_supplementary': True,
134
140
  'name': 'image_name',
135
141
  'parent_relation': 'INFORMATION',
136
142
  'sha256': '09bf99ab5431af13b701a06dc2b04520aea9fd346584fa2a034d6d4af0c57329'
@@ -140,6 +146,7 @@ def test_add_image(service_request):
140
146
  'classification': 'TLP:C',
141
147
  'description': 'description of image (thumbnail)',
142
148
  'is_section_image': True,
149
+ 'is_supplementary': True,
143
150
  'name': 'image_name.thumb',
144
151
  'parent_relation': 'INFORMATION',
145
152
  'sha256': '1af0e0d99845493b64cf402b3704170f17ecf15001714016e48f9d4854218901'
@@ -152,7 +159,8 @@ def test_add_image(service_request):
152
159
  ocr_heuristic_id = 1
153
160
  _, path = tempfile.mkstemp()
154
161
  ocr_io = open(path, "w")
155
- data = service_request.add_image(image_path, "image_name", "description of image", "TLP:A", ocr_heuristic_id, ocr_io)
162
+ data = service_request.add_image(image_path, "image_name", "description of image",
163
+ "TLP:A", ocr_heuristic_id, ocr_io)
156
164
  assert data["img"] == {
157
165
  'description': 'description of image',
158
166
  'name': 'image_name',
@@ -188,17 +196,23 @@ def test_add_image(service_request):
188
196
 
189
197
  heur_dict = get_heuristic_primitives(data["ocr_section"].__dict__["_heuristic"])
190
198
 
191
- assert heur_dict == {'heur_id': 1, 'score': 1200, 'attack_ids': ['T1005'], 'signatures': {'ransomware_strings': 8}, 'frequency': 0, 'score_map': {}}
199
+ assert heur_dict == {
200
+ 'heur_id': 1, 'score': 1200, 'attack_ids': ['T1005'],
201
+ 'signatures': {'ransomware_strings': 8},
202
+ 'frequency': 0, 'score_map': {}}
192
203
 
193
204
  assert service_request.temp_submission_data == {}
194
205
 
195
206
  service_request.task.supplementary.clear()
196
207
 
197
208
  # Classification, OCR heuristic, OCR_IO, image with password
198
- image_path = os.path.join(os.path.dirname(__file__), "4031ed8786439eee24b87f84901e38038a76b8c55e9d87dd5a7d88df2806c1cf")
209
+ image_path = os.path.join(
210
+ os.path.dirname(__file__),
211
+ "4031ed8786439eee24b87f84901e38038a76b8c55e9d87dd5a7d88df2806c1cf")
199
212
  _, path = tempfile.mkstemp()
200
213
  ocr_io = open(path, "w")
201
- data = service_request.add_image(image_path, "image_name", "description of image", "TLP:A", ocr_heuristic_id, ocr_io)
214
+ data = service_request.add_image(image_path, "image_name", "description of image",
215
+ "TLP:A", ocr_heuristic_id, ocr_io)
202
216
  assert data["img"] == {
203
217
  'description': 'description of image',
204
218
  'name': 'image_name',
@@ -217,9 +231,12 @@ def test_add_image(service_request):
217
231
 
218
232
  heur_dict = get_heuristic_primitives(data["ocr_section"].__dict__["_heuristic"])
219
233
 
220
- assert heur_dict == {'heur_id': 1, 'score': 250, 'attack_ids': ['T1005'], 'signatures': {'password_strings': 1}, 'frequency': 0, 'score_map': {}}
234
+ assert heur_dict == {
235
+ 'heur_id': 1, 'score': 250, 'attack_ids': ['T1005'],
236
+ 'signatures': {'password_strings': 1},
237
+ 'frequency': 0, 'score_map': {}}
221
238
 
222
- assert service_request.temp_submission_data == {'passwords':[' 975', '975', 'DOCUMENT', 'PASSWORD', 'PASSWORD:']}
239
+ assert service_request.temp_submission_data == {'passwords': [' 975', '975', 'DOCUMENT', 'PASSWORD', 'PASSWORD:']}
223
240
 
224
241
 
225
242
  def test_add_supplementary(service_request):
@@ -239,11 +256,12 @@ def test_add_supplementary(service_request):
239
256
  'classification': 'TLP:C',
240
257
  'description': 'description',
241
258
  'is_section_image': False,
259
+ 'is_supplementary': True,
242
260
  'name': 'name',
243
261
  'parent_relation': 'INFORMATION',
244
262
  'path': path,
245
263
  'sha256': '9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08'
246
- },
264
+ },
247
265
  ]
248
266
 
249
267
 
@@ -280,7 +298,7 @@ def test_get_param(service_request):
280
298
  service_request.get_param("blah")
281
299
 
282
300
  # Submission parameter exists
283
- service_request.task.service_config = {"blah":"blah"}
301
+ service_request.task.service_config = {"blah": "blah"}
284
302
  assert service_request.get_param("blah") == "blah"
285
303
 
286
304
 
@@ -6,7 +6,7 @@ from logging import Logger
6
6
  import pytest
7
7
  from assemblyline_v4_service.common import helper
8
8
  from assemblyline_v4_service.common.result import ResultSection
9
- from assemblyline_v4_service.common.task import *
9
+ from assemblyline_v4_service.common.task import Task, Classification, MaxExtractedExceeded, ServiceAPI, Result
10
10
 
11
11
  from assemblyline.odm.messages.task import DataItem, TagItem
12
12
  from assemblyline.odm.messages.task import Task as ServiceTask
@@ -159,6 +159,7 @@ def test_task_add_file(servicetask):
159
159
  "classification": "TLP:C",
160
160
  "path": path,
161
161
  "is_section_image": False,
162
+ 'is_supplementary': False,
162
163
  "allow_dynamic_recursion": False,
163
164
  "parent_relation": "EXTRACTED",
164
165
  }
@@ -173,6 +174,7 @@ def test_task_add_file(servicetask):
173
174
  "classification": "TLP:C",
174
175
  "path": path,
175
176
  "is_section_image": False,
177
+ 'is_supplementary': False,
176
178
  "allow_dynamic_recursion": True,
177
179
  "parent_relation": "DYNAMIC",
178
180
  }
@@ -210,7 +212,7 @@ def test_task_add_extracted(servicetask, mocker):
210
212
  # Safelisted file hash
211
213
  service_attributes = helper.get_service_attributes()
212
214
  sa = ServiceAPI(service_attributes, None)
213
- with mocker.patch.object(sa, "lookup_safelist", return_value={"enabled": True, "type": "file"}) as m:
215
+ with mocker.patch.object(sa, "lookup_safelist", return_value={"enabled": True, "type": "file"}) as _:
214
216
  t.safelist_config.enabled = True
215
217
  assert t.add_extracted(path, "name", "description", safelist_interface=sa) is False
216
218
 
@@ -224,6 +226,7 @@ def test_task_add_extracted(servicetask, mocker):
224
226
  "classification": "TLP:C",
225
227
  "path": path,
226
228
  "is_section_image": False,
229
+ 'is_supplementary': False,
227
230
  "allow_dynamic_recursion": False,
228
231
  "parent_relation": "EXTRACTED",
229
232
  }
@@ -259,6 +262,7 @@ def test_task_add_supplementary(servicetask):
259
262
  "classification": "TLP:C",
260
263
  "path": path,
261
264
  "is_section_image": False,
265
+ 'is_supplementary': True,
262
266
  "allow_dynamic_recursion": False,
263
267
  "parent_relation": "INFORMATION",
264
268
  }
@@ -270,6 +274,7 @@ def test_task_add_supplementary(servicetask):
270
274
  "classification": "TLP:C",
271
275
  "path": path,
272
276
  "is_section_image": False,
277
+ 'is_supplementary': True,
273
278
  "allow_dynamic_recursion": False,
274
279
  "parent_relation": "INFORMATION",
275
280
  }
@@ -405,6 +410,7 @@ def test_task_get_service_result(servicetask):
405
410
  "classification": "TLP:C",
406
411
  "description": "description",
407
412
  "is_section_image": False,
413
+ "is_supplementary": False,
408
414
  "name": "name",
409
415
  "parent_relation": "EXTRACTED",
410
416
  "path": path,