Skip to content

Commit 722dc85

Browse files
committed
Fixes at dump/load functions
1 parent 1cff1db commit 722dc85

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

common/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@
2222
I_SIZE = 4
2323
D_SIZE = 8
2424
C_SIZE = 1
25+
HASH_SIZE = 144

datalayer/node/winmodule_hash_node.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,20 @@ def as_dict(self):
5252

5353
return node_dict
5454

55-
56-
5755
def internal_serialize(self):
58-
return self.get_internal_page_id().to_bytes(I_SIZE, byteorder=BYTE_ORDER)
56+
id_bytes = self.get_id().encode('utf-8')
57+
if len(id_bytes) > HASH_SIZE:
58+
raise ValueError(f"ID too long - must be <= 144 bytes when encoded")
59+
return id_bytes.ljust(HASH_SIZE, b'\0')
5960

6061
@classmethod
6162
def internal_load(cls, f):
6263
bpage_id = f.read(I_SIZE)
6364
return bpage_id, int.from_bytes(bpage_id, byteorder=BYTE_ORDER)
6465

6566
@classmethod
66-
def create_node_from_DB(cls, db_manager, _id, hash_algorithm):
67-
new_node = db_manager.get_winmodule_data_by_pageid(page_id=_id, algorithm=hash_algorithm)
67+
def create_node_from_DB(cls, db_manager, hash_id, hash_algorithm):
68+
new_node = db_manager.get_winmodule_data_by_hash(hash_value=hash_id, algorithm=hash_algorithm)
6869
if hash_algorithm == TLSHHashAlgorithm:
6970
new_node._id = new_node._page.hashTLSH
7071
elif hash_algorithm == SSDEEPHashAlgorithm:

0 commit comments

Comments
 (0)