Skip to content

Commit

Permalink
[Bugfinder] change deprecated method of loading binaryview from file (#…
Browse files Browse the repository at this point in the history
…347)

Co-authored-by: mm4rks <[email protected]>
Co-authored-by: Marvin Marks <[email protected]>
  • Loading branch information
3 people authored Oct 5, 2023
1 parent 1e818ad commit 45ef92b
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions decompiler/util/bugfinder/bugfinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,18 @@
# Add project root to path (script located in dewolf/decompiler/util/bugfinder/)
project_root = Path(__file__).resolve().parents[3]
sys.path.append(str(project_root))
from binaryninja import BinaryViewType, Function, core_version
from binaryninja import Function, core_version

# use binaryninja.load for BN 3.5 up
version_numbers = core_version().split(".")
major, minor = int(version_numbers[0]), int(version_numbers[1])
if major >= 3 and minor >= 5:
from binaryninja import load
else:
from binaryninja import BinaryViewType

load = BinaryViewType.get_view_of_file

from decompile import Decompiler
from decompiler.frontend import BinaryninjaFrontend
from decompiler.logger import configure_logging
Expand Down Expand Up @@ -124,7 +135,7 @@ def get_function_info(function: Function) -> dict:
"function_size": function.highest_address - function.start,
"function_arch": str(function.arch),
"function_platform": str(function.platform),
"timestamp": datetime.now()
"timestamp": datetime.now(),
}

@staticmethod
Expand Down Expand Up @@ -198,7 +209,7 @@ def iter_function_reports(self, sample) -> Iterator[dict]:
def store_reports_from_sample(sample: Path, db_reports: DBConnector, max_size: int):
"""Store all reports from sample into database"""
logging.info(f"processing {sample}")
if not (binary_view := BinaryViewType.get_view_of_file(sample)):
if not (binary_view := load(sample)):
logging.warning(f"Could not get BinaryView '{sample}'")
return
try:
Expand Down

0 comments on commit 45ef92b

Please sign in to comment.