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

Catch No Database Gracefully #12

Open
utkonos opened this issue Feb 22, 2025 · 0 comments
Open

Catch No Database Gracefully #12

utkonos opened this issue Feb 22, 2025 · 0 comments
Assignees
Labels

Comments

@utkonos
Copy link
Collaborator

utkonos commented Feb 22, 2025

The plugin requires that there be a binary ninja database. If the user attempts to use the plugin on a brand new file that they have not yet saved a database for, the plugin will raise an exception:

[Default] Traceback (most recent call last):
[Default]   File "/Applications/Binary Ninja.app/Contents/MacOS/plugins/../../Resources/python/binaryninja/plugin.py", line 127, in _default_action
[Default]     action(view_obj)
[Default]   File "/Users/username/Library/Application Support/Binary Ninja/repositories/community/plugins/x64dbg_x64dbgbinja/__init__.py", line 40, in export_db
[Default]     outpath = bv.file.database.globals.get('x64dbg_db_save_path', pathlib.Path(bv.file.filename).parent)
[Default] AttributeError: 'NoneType' object has no attribute 'globals'

A check for database existance should be made before the plugin even appears as an option in the various menus. An is_valid callback function that checks for the existance of the database needs to be added and it needs to be called by the register method:
https://api.binary.ninja/binaryninja.plugin-module.html#binaryninja.plugin.PluginCommand:~:text=as%20an%20argument-,is_valid,-(callback)%20%E2%80%93%20optional

This will prevent the plugin's menu entry from appearing at all until a database is available and the plugin would be able to function.

@utkonos utkonos added the bug label Feb 22, 2025
@utkonos utkonos self-assigned this Feb 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant