Skip to content

Commit 6eeacba

Browse files
committed
fix: Call order & typo in magic call
1 parent b9f9b17 commit 6eeacba

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pymisp/tools/fileobject.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ def __init__(self, filepath: Path | str | None = None, # type: ignore[no-untype
5555
else:
5656
raise InvalidMISPObject('File buffer (BytesIO) or a path is required.')
5757
self.__data = self.__pseudofile.getvalue()
58+
if HAS_MAGIC:
59+
self.magic_db = MagicDb()
5860
self.generate_attributes()
59-
self.magic_bd = MagicDb()
6061

6162
def generate_attributes(self) -> None:
6263
self.add_attribute('filename', value=self.__filename)
@@ -69,7 +70,7 @@ def generate_attributes(self) -> None:
6970
self.add_attribute('sha512', value=sha512(self.__data).hexdigest())
7071
self.add_attribute('malware-sample', value=self.__filename, data=self.__pseudofile, disable_correlation=True)
7172
if HAS_MAGIC:
72-
magic = self.magic_bd.best_magic_buffer(self.__data)
73+
magic = self.magic_db.best_magic_buffer(self.__data)
7374
self.add_attribute('mimetype', value=magic.mime_type)
7475
if HAS_PYDEEP:
7576
self.add_attribute('ssdeep', value=pydeep.hash_buf(self.__data).decode())

0 commit comments

Comments
 (0)