Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Correct FileObject import #1162

Merged
merged 1 commit into from
Feb 27, 2024
Merged

Conversation

baderj
Copy link
Contributor

@baderj baderj commented Feb 27, 2024

Commit 9853f23 erroneously moved the import of FileObject in pymisp/tools/create_misp_object.py to the TYPE_CHECKING conditional. This was later changed by 8fb34a2, however, the commit moved the import inside the try-except-block related to lief. As a consequence FileObject is not imported if lief is not available, but it is needed regardless, resulting in confusing exceptions unrelated to lief:

Traceback (most recent call last):
  File "/home/user/test.py", line 16, in <module>
    event.run_expansions()
  File "/home/user/.venv/lib/python3.10/site-packages/pymisp/mispevent.py", line 2029, in run_expansions
    file_object, bin_type_object, bin_section_objects = make_binary_objects(pseudofile=attribute.malware_binary, filename=attribute.malware_filename)
  File "/home/user/.venv/lib/python3.10/site-packages/pymisp/tools/create_misp_object.py", line 44, in make_binary_objects
    misp_file = FileObject(filepath=filepath, pseudofile=pseudofile, filename=filename,
NameError: name 'FileObject' is not defined

This pull request moves the import of FileObject outside the try-except block where it was before 9853f23.

The FileObject import has been moved outside the try-except-block
related to lief, as the import is needed regardless whether lief
is available or not.
@Rafiot
Copy link
Member

Rafiot commented Feb 27, 2024

woops, right, thanks!

@Rafiot Rafiot merged commit 98cc6e3 into MISP:main Feb 27, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants