Skip to content

Commit

Permalink
Always set the BV in Binja (#18)
Browse files Browse the repository at this point in the history
* Always set the BV

* bump
  • Loading branch information
mahaloz authored Sep 16, 2023
1 parent 92e67f9 commit d0a4f5f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dailalib/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.2.1"
__version__ = "1.2.2"
2 changes: 1 addition & 1 deletion dailalib/interfaces/openai_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def query_for_cmd(self, cmd, func_addr=None, decompilation=None, edit_dec=False,
if cmd not in self.AI_COMMANDS:
raise ValueError(f"Command {cmd} is not supported")

kwargs = self.AI_COMMANDS[cmd]
kwargs.update(self.AI_COMMANDS[cmd])
if func_addr is None and decompilation is None:
raise Exception(f"You must provide either a function address or decompilation!")

Expand Down
40 changes: 34 additions & 6 deletions plugins/daila_binja.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ def _current_function_addr(self, **kwargs):
return addr

def _decompile(self, func_addr: int, **kwargs):
bv = kwargs.get("bv", None)
bv = self.bv
if bv is None:
return None
print("[DAILA] Warning: was unable to collect the current BinaryView. Please report this issue.")
return

func = DAILAPlugin.get_func(bv, func_addr)
if func is None:
Expand Down Expand Up @@ -81,7 +82,7 @@ def _decompile(self, func_addr: int, **kwargs):
return decomp

def _cmt_func(self, func_addr: int, comment: str, **kwargs):
bv = kwargs.get("bv", None)
bv = self.bv
if bv is None:
return None

Expand Down Expand Up @@ -110,19 +111,46 @@ def ask_api_key(self, *args, **kwargs):
@addr_ctx_when_none
def find_source_of_function(self, *args, **kwargs) -> str:
bv, address = args[0:2]
return super().find_source_of_function(func_addr=address, bv=bv)
self.bv = bv
return super().find_source_of_function(func_addr=address, bv=bv, edit_dec=True)

@with_loading_popup
@addr_ctx_when_none
def summarize_function(self, *args, **kwargs) -> str:
bv, address = args[0:2]
return super().summarize_function(func_addr=address, bv=bv)
self.bv = bv
return super().summarize_function(func_addr=address, bv=bv, edit_dec=True)

@with_loading_popup
@addr_ctx_when_none
def find_vulnerability_in_function(self, *args, **kwargs) -> str:
bv, address = args[0:2]
return super().find_vulnerability_in_function(func_addr=address, bv=bv)
self.bv = bv
return super().find_vulnerability_in_function(func_addr=address, bv=bv, edit_dec=True)

@with_loading_popup
@addr_ctx_when_none
def answer_questions(self, *args, func_addr=None, decompilation=None, edit_dec=False, **kwargs):
bv, address = args[0:2]
self.bv = bv
return super().answer_questions(func_addr=address, bv=bv, edit_dec=True)

@with_loading_popup
@addr_ctx_when_none
def rename_functions_in_function(self, *args, func_addr=None, decompilation=None, edit_dec=False, **kwargs):
bv, address = args[0:2]
self.bv = bv
return super().rename_functions_in_function(func_addr=address, bv=bv, edit_dec=True)

@with_loading_popup
@addr_ctx_when_none
def rename_variables_in_function(self, *args, func_addr=None, decompilation=None, edit_dec=False, **kwargs):
bv, address = args[0:2]
self.bv = bv
return super().rename_variables_in_function(func_addr=address, bv=bv, edit_dec=True)





class DAILAPlugin:
Expand Down

0 comments on commit d0a4f5f

Please sign in to comment.