assemblyline-v4-service 4.4.0.20__py3-none-any.whl → 4.4.0.22__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.4.0.20
1
+ 4.4.0.22
@@ -78,6 +78,7 @@ class ServiceBase:
78
78
  self.rules_directory: str = None
79
79
  self.rules_list: list = []
80
80
  self.update_time: int = None
81
+ self.update_hash: str = None
81
82
  self.update_check_time: float = 0.0
82
83
  self.rules_hash: str = None
83
84
 
@@ -258,7 +259,7 @@ class ServiceBase:
258
259
  resp = requests.get(url_base + 'status', verify=verify)
259
260
  resp.raise_for_status()
260
261
  status = resp.json()
261
- if self.update_time is not None and self.update_time >= status['local_update_time']:
262
+ if self.update_time is not None and self.update_time >= status['local_update_time'] and self.update_hash == status['local_update_hash']:
262
263
  self.log.info(f"There are no new signatures. ({self.update_time} >= {status['local_update_time']})")
263
264
  return
264
265
  if status['download_available']:
@@ -287,6 +288,7 @@ class ServiceBase:
287
288
  tar_handle = tarfile.open(buffer_name)
288
289
  tar_handle.extractall(temp_directory)
289
290
  self.update_time = status['local_update_time']
291
+ self.update_hash = status['local_update_hash']
290
292
  self.rules_directory, temp_directory = temp_directory, self.rules_directory
291
293
  # Try to load the rules into the service before declaring we're using these rules moving forward
292
294
  temp_hash = self._gen_rules_hash()
@@ -208,6 +208,7 @@ class SectionBody:
208
208
  def __init__(self, body_format, body=None):
209
209
  self._format = body_format
210
210
  self._data = body
211
+ self._config = {}
211
212
 
212
213
  @property
213
214
  def format(self):
@@ -222,6 +223,10 @@ class SectionBody:
222
223
  else:
223
224
  return self._data
224
225
 
226
+ @property
227
+ def config(self) -> dict:
228
+ return self._config
229
+
225
230
  def set_body(self, body):
226
231
  self._data = body
227
232
 
@@ -396,6 +401,11 @@ class TableSectionBody(SectionBody):
396
401
 
397
402
  def add_row(self, row: TableRow) -> None:
398
403
  self._data.append(row)
404
+ self.set_column_order(list(row.keys()))
405
+
406
+ def set_column_order(self, order: List[str]):
407
+ self._config = {'column_order': order}
408
+
399
409
 
400
410
 
401
411
  class ImageSectionBody(SectionBody):
@@ -418,7 +428,7 @@ class MultiSectionBody(SectionBody):
418
428
  super().__init__(BODY_FORMAT.MULTI, body=[])
419
429
 
420
430
  def add_section_body(self, section_body: SectionBody) -> None:
421
- self._data.append((section_body.format, section_body._data))
431
+ self._data.append((section_body.format, section_body._data, section_body._config))
422
432
 
423
433
 
424
434
  class DividerSectionBody(SectionBody):
@@ -461,10 +471,12 @@ class ResultSection:
461
471
  self._subsections: List[ResultSection] = []
462
472
  if isinstance(body, SectionBody):
463
473
  self._body_format = body.format
474
+ self._body_config = body.config
464
475
  self._body = body.body
465
476
  else:
466
477
  self._body_format = body_format
467
478
  self._body = body
479
+ self._body_config = {}
468
480
  self.classification: Classification = classification or SERVICE_ATTRIBUTES.default_result_classification
469
481
  self.depth: int = 0
470
482
  self._tags = tags or {}
@@ -497,6 +509,10 @@ class ResultSection:
497
509
  def body_format(self):
498
510
  return self._body_format
499
511
 
512
+ @property
513
+ def body_config(self):
514
+ return self._body_config
515
+
500
516
  @property
501
517
  def heuristic(self):
502
518
  return self._heuristic
@@ -629,6 +645,10 @@ class TypeSpecificResultSection(ResultSection):
629
645
  def body(self):
630
646
  return self.section_body.body
631
647
 
648
+ @property
649
+ def body_config(self):
650
+ return self.section_body.config
651
+
632
652
  def add_line(self, text: Union[str, List]) -> None:
633
653
  raise InvalidFunctionException("Do not use default add_line method in a type specific section.")
634
654
 
@@ -720,6 +740,10 @@ class ResultTableSection(TypeSpecificResultSection):
720
740
 
721
741
  def add_row(self, row: TableRow) -> None:
722
742
  self.section_body.add_row(row)
743
+ self.set_column_order(list(row.keys()))
744
+
745
+ def set_column_order(self, order: List[str]):
746
+ self.section_body.set_column_order(order)
723
747
 
724
748
 
725
749
  class ResultImageSection(TypeSpecificResultSection):
@@ -772,6 +796,7 @@ class Result:
772
796
  body=section.body,
773
797
  classification=section.classification,
774
798
  body_format=section.body_format,
799
+ body_config=section.body_config,
775
800
  depth=section.depth,
776
801
  heuristic=get_heuristic_primitives(section.heuristic),
777
802
  tags=unflatten(section.tags),
@@ -27,6 +27,7 @@ if os.path.exists(AL_ROOT_CA):
27
27
  status_last_read_time = 0
28
28
  NO_STATUS = {
29
29
  'local_update_time': 0,
30
+ 'local_update_hash': None,
30
31
  'download_available': False,
31
32
  '_directory': None,
32
33
  '_tar': None,
@@ -13,6 +13,7 @@ import tarfile
13
13
  import threading
14
14
  import subprocess
15
15
  from contextlib import contextmanager
16
+ from hashlib import sha256
16
17
  from passlib.hash import bcrypt
17
18
  from zipfile import ZipFile, BadZipFile
18
19
 
@@ -179,9 +180,13 @@ class ServiceUpdater(ThreadedCoreBase):
179
180
  return os.path.getctime(self._time_keeper)
180
181
  return 0
181
182
 
183
+ def get_local_update_hash(self) -> str:
184
+ return sha256(open(self._update_tar, "rb").read()).hexdigest()
185
+
182
186
  def status(self):
183
187
  return {
184
188
  'local_update_time': self.get_local_update_time(),
189
+ 'local_update_hash': self.get_local_update_hash(),
185
190
  'download_available': self._update_dir is not None,
186
191
  '_directory': self._update_dir,
187
192
  '_tar': self._update_tar,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: assemblyline-v4-service
3
- Version: 4.4.0.20
3
+ Version: 4.4.0.22
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,18 +1,18 @@
1
- assemblyline_v4_service/VERSION,sha256=giHEQa3NiiRW28QBvDs-2fjN8cmLET_ZL4sLibZtgfU,9
1
+ assemblyline_v4_service/VERSION,sha256=P6RL_rWI59Yat6kK-jNcLoDZGq_Fd53Vo7ZZYlfA95w,9
2
2
  assemblyline_v4_service/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  assemblyline_v4_service/healthz.py,sha256=3QGBg0EZuXC6UN411HFwpLNEop9UvS9feFhvBUTP-k4,1576
4
4
  assemblyline_v4_service/run_privileged_service.py,sha256=9uTfHetXR5G-EDKMDrgfWUOw34yr64-cj6Cm9eZaCbQ,14547
5
5
  assemblyline_v4_service/run_service.py,sha256=RCqxdm-OAwJhl15BnKFkuavpQ5k6eTX3ZGeSna5JJBw,5557
6
6
  assemblyline_v4_service/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
7
  assemblyline_v4_service/common/api.py,sha256=U908p3wlW9fEydx77GgI2E-6wW6T8Nc3R91nNOKU0H0,4453
8
- assemblyline_v4_service/common/base.py,sha256=STzfZ9dwqvbgbKiFs-aLk05pdhyK6Psz4hZ3_fOmQYM,13039
8
+ assemblyline_v4_service/common/base.py,sha256=qKhNpcD-FwV0R-5EWDWWXgr2Y-2dciVY6IIQsprenQ0,13187
9
9
  assemblyline_v4_service/common/dynamic_service_helper.py,sha256=OhxSnSOjUB_iSkMahHbPQEll9sl5wLuCFwwykvV-Kno,147461
10
10
  assemblyline_v4_service/common/helper.py,sha256=Fgimk8DhnS23aijTGewA1HwvPoAM61UUbHlrGBnSzL0,3290
11
11
  assemblyline_v4_service/common/icap.py,sha256=phT3CT5uII3Qm90Nzi4O-eDkQ2jmr3zHcVVra4sqYSc,5376
12
12
  assemblyline_v4_service/common/keytool_parse.py,sha256=e829hrNNG5LFw1kjLsYVZsafCm2S3NpgM6jBc6JKawY,2219
13
13
  assemblyline_v4_service/common/ontology_helper.py,sha256=uiwc5cfPDAesEDYKk7etzCMTGQNVwhNrO3mWLdB2520,7793
14
14
  assemblyline_v4_service/common/request.py,sha256=p8A9boDZ6KuVxl3EdhvaU1D_5K6_gAVoIbJYDz8TzjA,9711
15
- assemblyline_v4_service/common/result.py,sha256=0_ybxAQ_0W0pYo35Kr2EUgBMujQeGsgHbbbdfiLud88,29651
15
+ assemblyline_v4_service/common/result.py,sha256=9OGfWTCnBtow31Ft03us9Ew_2pXyDydUTP4iio9Qg8Q,30349
16
16
  assemblyline_v4_service/common/safelist_helper.py,sha256=QHTuG8q52o3U307AADPgrIgug7aYFK2uQE4-EtWG3yQ,3037
17
17
  assemblyline_v4_service/common/section_reducer.py,sha256=JJOT7eFfBn4hFJKHY9UeVEbHS-E8FpmQ_dPZC-dWla0,1513
18
18
  assemblyline_v4_service/common/tag_helper.py,sha256=om3TVPY_XDeFDqVW2iUA349xbljSAy5tv667jCiA7JI,4186
@@ -42,12 +42,12 @@ assemblyline_v4_service/testing/helper.py,sha256=f0-qBtgR0vWZBpEV9sPfcworLtdh4h_
42
42
  assemblyline_v4_service/testing/regenerate_results.py,sha256=Cbp2CMAxbF3kz5vxEPPCxrgUp1Vl3Tz6e46aUhg_I4U,1101
43
43
  assemblyline_v4_service/updater/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
44
44
  assemblyline_v4_service/updater/__main__.py,sha256=9Os-u8Tf7MD73JSrUSPmOaErTgfvesNLiEeszU4ujXA,133
45
- assemblyline_v4_service/updater/app.py,sha256=Ass5DZtOCr0tdoRbLo7Qn8Ujlw8T8mUDroAaHxx2oMo,3198
45
+ assemblyline_v4_service/updater/app.py,sha256=OF-G7J8IYwTjdGw_BI9numBicZBN5lspm8Eqb3qbIl8,3229
46
46
  assemblyline_v4_service/updater/gunicorn_config.py,sha256=p3j2KPBeD5jvMw9O5i7vAtlRgPSVVxIG9AO0DfN82J8,1247
47
47
  assemblyline_v4_service/updater/helper.py,sha256=JD0gX3KHY-wvsFjTbWkT83F0d5Up3OfubMPinuNzbTQ,9069
48
- assemblyline_v4_service/updater/updater.py,sha256=AQ3aTm5nhb-RXWjm5w1RIZM3j3UQJ4Vr4bVJ6Z2rX8A,29322
49
- assemblyline_v4_service-4.4.0.20.dist-info/LICENCE.md,sha256=NSkYo9EH8h5oOkzg4VhjAHF4339MqPP2cQ8msTPgl-c,1396
50
- assemblyline_v4_service-4.4.0.20.dist-info/METADATA,sha256=HFxr9HMIKSHdHzCCiXDVbJnjWsllina0A4rbSv4oW3Y,9328
51
- assemblyline_v4_service-4.4.0.20.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
52
- assemblyline_v4_service-4.4.0.20.dist-info/top_level.txt,sha256=Ut5IqePObcxlJ8rv2--dOAzYbxzqlllfiV_51cbqjbA,24
53
- assemblyline_v4_service-4.4.0.20.dist-info/RECORD,,
48
+ assemblyline_v4_service/updater/updater.py,sha256=gTFNN8Xow1HnlUcftWG30-ULXK5_FfJynZBnf7i4aIQ,29528
49
+ assemblyline_v4_service-4.4.0.22.dist-info/LICENCE.md,sha256=NSkYo9EH8h5oOkzg4VhjAHF4339MqPP2cQ8msTPgl-c,1396
50
+ assemblyline_v4_service-4.4.0.22.dist-info/METADATA,sha256=Pf_pRHiAVBk1lxIbhkHvBAYSociMGcZStBE82DIUERc,9328
51
+ assemblyline_v4_service-4.4.0.22.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
52
+ assemblyline_v4_service-4.4.0.22.dist-info/top_level.txt,sha256=Ut5IqePObcxlJ8rv2--dOAzYbxzqlllfiV_51cbqjbA,24
53
+ assemblyline_v4_service-4.4.0.22.dist-info/RECORD,,