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

Add support for Python3 and IDA 7.x #12

Merged
merged 11 commits into from
Jul 2, 2020

Conversation

nazywam
Copy link
Contributor

@nazywam nazywam commented Jun 29, 2020

Changelog:

  • Migrated codebase to python3
  • Migrated idaapi from 6.x to 7.x
  • Removed wildcard imports in favour of explicit ones
  • Added type hints for some functions
  • Fixed codebase to be pep8-compliant
  • Commented out unused variables (they can probably be safely deleted in a future refactor)

Flake8 output:

➜  ida_ifl git:(feature/python3) flake8 ifl.py --max-line-length=256                                                                                                                                                                                                              18:23:20
ifl.py:19:1: E402 module level import not at top of file
ifl.py:20:1: E402 module level import not at top of file
ifl.py:22:1: E402 module level import not at top of file
ifl.py:24:1: E402 module level import not at top of file
ifl.py:28:1: E402 module level import not at top of file
ifl.py:31:1: E402 module level import not at top of file
ifl.py:32:1: E402 module level import not at top of file
ifl.py:33:1: E402 module level import not at top of file
ifl.py:35:1: E402 module level import not at top of file

Mypy output (ran inside an IDA instance) - still not perfect:

Python>from mypy import api
Python>for p in api.run(["/home/michal/work/ida_ifl/ifl.py"]):
Python>     print(p)
Python>
/home/michal/work/ida_ifl/ifl.py:63: error: Need type annotation for 'local_variables'
/home/michal/work/ida_ifl/ifl.py:64: error: Need type annotation for 'arguments'
/home/michal/work/ida_ifl/ifl.py:365: error: Name 'g_DataManager' is not defined
/home/michal/work/ida_ifl/ifl.py:499: error: Need type annotation for 'refs_list'
/home/michal/work/ida_ifl/ifl.py:706: error: Need type annotation for '_importsSet'
/home/michal/work/ida_ifl/ifl.py:707: error: Need type annotation for '_importNamesSet'
/home/michal/work/ida_ifl/ifl.py:809: error: Need type annotation for '_functionsMap'
/home/michal/work/ida_ifl/ifl.py:810: error: Need type annotation for 'funcList'
/home/michal/work/ida_ifl/ifl.py:890: error: Cannot determine type of 'subDataManager'
/home/michal/work/ida_ifl/ifl.py:936: error: Cannot determine type of 'refs_label'
/home/michal/work/ida_ifl/ifl.py:950: error: Cannot determine type of 'refs_tabs'
/home/michal/work/ida_ifl/ifl.py:951: error: Cannot determine type of 'refs_tabs'
/home/michal/work/ida_ifl/ifl.py:957: error: Cannot determine type of 'addr_view'
/home/michal/work/ida_ifl/ifl.py:958: error: Cannot determine type of 'addr_view'
/home/michal/work/ida_ifl/ifl.py:959: error: Cannot determine type of 'addr_view'
/home/michal/work/ida_ifl/ifl.py:961: error: Cannot determine type of 'addr_view'
/home/michal/work/ida_ifl/ifl.py:962: error: Cannot determine type of 'addr_view'
/home/michal/work/ida_ifl/ifl.py:963: error: Cannot determine type of 'addr_view'
/home/michal/work/ida_ifl/ifl.py:972: error: Name 'g_DataManager' is not defined
/home/michal/work/ida_ifl/ifl.py:981: error: Cannot determine type of 'refs_view'
/home/michal/work/ida_ifl/ifl.py:981: error: Cannot determine type of 'refsto_model'
/home/michal/work/ida_ifl/ifl.py:982: error: Cannot determine type of 'refsfrom_view'
/home/michal/work/ida_ifl/ifl.py:982: error: Cannot determine type of 'refsfrom_model'
/home/michal/work/ida_ifl/ifl.py:992: error: Cannot determine type of 'criterium_id'
/home/michal/work/ida_ifl/ifl.py:994: error: Cannot determine type of 'addr_sorted_model'
/home/michal/work/ida_ifl/ifl.py:995: error: Cannot determine type of 'addr_sorted_model'
/home/michal/work/ida_ifl/ifl.py:1001: error: Cannot determine type of 'filter_combo'
/home/michal/work/ida_ifl/ifl.py:1001: error: Cannot determine type of 'filter_edit'
/home/michal/work/ida_ifl/ifl.py:1005: error: Cannot determine type of 'filter_edit'
/home/michal/work/ida_ifl/ifl.py:1006: error: Cannot determine type of 'is_livefilter'
/home/michal/work/ida_ifl/ifl.py:1014: error: Cannot determine type of 'criterium_combo'
/home/michal/work/ida_ifl/ifl.py:1016: error: Cannot determine type of 'filter_edit'
/home/michal/work/ida_ifl/ifl.py:1018: error: Cannot determine type of 'filter_edit'
/home/michal/work/ida_ifl/ifl.py:1022: error: Cannot determine type of 'livefilter_box'
/home/michal/work/ida_ifl/ifl.py:1024: error: Cannot determine type of 'filter_combo'
/home/michal/work/ida_ifl/ifl.py:1024: error: Cannot determine type of 'filter_edit'
/home/michal/work/ida_ifl/ifl.py:1046: error: Name 'g_DataManager' is not defined
/home/michal/work/ida_ifl/ifl.py:1087: error: Name 'g_DataManager' is not defined
/home/michal/work/ida_ifl/ifl.py:1246: error: Name 'g_DataManager' is not defined
/home/michal/work/ida_ifl/ifl.py:1248: error: Name 'g_DataManager' is not defined
/home/michal/work/ida_ifl/ifl.py:1251: error: Name 'm_functionInfoForm' is not defined
/home/michal/work/ida_ifl/ifl.py:1254: error: Name 'm_functionInfoForm' is not defined
/home/michal/work/ida_ifl/ifl.py:1256: error: Name 'm_functionInfoForm' is not defined

Test plan:
Try using the script on various compatible IDA versions.

Closes #9

@hasherezade hasherezade merged commit 6083636 into hasherezade:master Jul 2, 2020
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.

Switch to python 3
2 participants