{"id":13755075,"url":"https://github.com/nirizr/pytest-idapro","last_synced_at":"2025-07-14T03:09:28.313Z","repository":{"id":62584094,"uuid":"87057425","full_name":"nirizr/pytest-idapro","owner":"nirizr","description":"A pytest module for The Interactive Disassembler and IDAPython; Record and Replay IDAPython API, execute inside IDA or use mockups of IDAPython API.","archived":false,"fork":false,"pushed_at":"2018-11-03T01:10:38.000Z","size":217,"stargazers_count":47,"open_issues_count":5,"forks_count":8,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-06-23T09:06:06.761Z","etag":null,"topics":["ida-plugin","ida-pro","idapython","pytest","pytest-idapro","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nirizr.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-03T09:22:15.000Z","updated_at":"2022-07-11T04:41:07.000Z","dependencies_parsed_at":"2022-11-03T21:46:48.982Z","dependency_job_id":null,"html_url":"https://github.com/nirizr/pytest-idapro","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nirizr/pytest-idapro","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nirizr%2Fpytest-idapro","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nirizr%2Fpytest-idapro/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nirizr%2Fpytest-idapro/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nirizr%2Fpytest-idapro/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nirizr","download_url":"https://codeload.github.com/nirizr/pytest-idapro/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nirizr%2Fpytest-idapro/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265236958,"owners_count":23732504,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ida-plugin","ida-pro","idapython","pytest","pytest-idapro","python"],"created_at":"2024-08-03T10:00:43.745Z","updated_at":"2025-07-14T03:09:28.286Z","avatar_url":"https://github.com/nirizr.png","language":"Python","readme":"|Build Status| |PyPI|\n\npytest-idapro\n=============\n\nA pytest module for The Interactive Disassembler and IDAPython, by executing an\ninternal pytest runner inside IDA or mocking IDAPython functionality outside of\nIDA.\n\nMotivation\n----------\n\nAs the avarage IDAPython plugin size increases, the need of proper unitests\nbecomes more evident. The purpose of this pytest plugin is to ease unittesting\nIDAPython plugins and scripts and mitigate the gap between Continuous Integration\nservices and the IDA executable (which we are unable to execute in a CI).\n\nBasic usage\n-----------\n\nThe pytest-idapro plugin adds new command line flags to the pytest executable.\nAll pytest-idapro flags start with :code:`--ida` and exist under the\n\"interactive disassembler testing facilities\" category.\n\nThe most basic pytest-idapro usage will be using :code:`--ida` to execute a\npyteset session within IDA, and the optional :code:`--ida-file` flag:\n\n.. code-block:: console\n\n   $ pytest --ida \u003cPATH TO IDA EXEUTABLE\u003e --ida-file \u003cPATH TO IDB OR SUPPORTED FILE\u003e ;\n\nRunning the above command will run all tests detected by pytest in the current\ndirectory inside an IDA instance with a given IDA supported file (IDB, EXE, SO,\netc).\n\nRecord and Replay\n-----------------\n\nSince version 0.3.5, pytest-idapro has shifted from a mock-up focus to\nrecord-and-replay focus by providing two new command line flags;\n:code:`--ida-record` will record all IDAPython API calls and IDA's behavior\nwhile running tests into specified json file. Using :code:`--ida-replay` and a\njson recording file, pytest-idapro is then able to replay the IDA environment\nand IDAPython API behavior without an IDA executable or the :code:`--ida` flag.\n\nFixtures\n--------\n\nPytest `Fixtures \u003chttps://docs.pytest.org/en/latest/fixture.html\u003e`_ are\nexteremly powerful when writing tests, and pytest-idapro currently comes with\ntwo helpful fixtures:\n\n1. :code:`idapro_plugin_entry` - pytest-idapro will automatically identify all\n   ida plugin entry points (functions named :code:`PLUGIN_ENTRY`) across your\n   code base and let you easily writing tests for all plugin objects defined.\n2. :code:`idapro_action_entry` - pytest-idapro will automatically identify all\n   ida actions (objects inheriting the :code:`action_handler_t` class)\n   throughout your code and again, let you easily write tests for all of your\n   actions.\n\nPeeking Under the Hood\n======================\n\nBy providing the :code:`--ida` flag ipytest-idapro will run a worker pytest\ninstance inside IDA which will execute all tests, collect results and\ncommunicate with the main pytest process (this behavior is somewhat similar to\nthe pytest-xdist plugin). By defualt IDA will open a temporary empty database\nfile unless  the :code:`--ida-file` flag is used to specify IDB or binary file\nfor IDA to analyze before running any tests.\n\nRecording\n---------\n\nIn order to record API calls, IDA python objects and their interaction, a\nseries of proxy/wrapper objects are created for all IDA implemented python\nobjects (modules, functions, clases, objects, etc). Those proxy objects will\nbehave identically but will register all interaction between executed code and\nthe IDAPython interface, which will eventually be dumped to a JSON file.\n\nFor the recording to take place as soon as possible, pytest-idapro will modify\nIDA's python initialization script (python/init.py). The change is performed\njust before starting an IDA instance and revereted as soon as possible.\n\nInstance Matching\n-----------------\n\nWhen an IDA API function is called during replaying, the appropriate return\nvalue must be returned. This is easy when every function is called once, but is\nincreasingly difficult when the same function is called more then once, and\neven more so when it's called more than once with the same arguments.\nTo correctly return the right value for every call, all calls are recorded with\nmetadata describing call environment such as the call stack and arguments.\nThose are then used to match the correct instance of a call or a class\ninstantiation while replaying.\n\nCaveats\n-------\n\n1. Recording python objects is difficult and requires some object specific\n   handling, even more so with the amount of swig, backporting and monkey\n   patching in IDA. Therefore, certain APIs may break. Hopefully those will be\n   reported and fixed.\n2. As mentioned before IDA's init.py file is patched in order to inject the\n   code proxy/record system. A special effort was made to revert the\n   modifications immidiately regardless of any errors, but if any unexpected\n   behavior is observed when pytest-idapro is unused, you may want to check the\n   top of :code`\u003cIDA DIR\u003e/python/init.py`.\n3. No effort is corrently made into sanitaizing private information from the\n   record JSON file. As API results and executable file paths are recorded into\n   the json file, details such as paths (and therefore usernames) and other\n   personal data may be exposed through the record JSON file. Only use with\n   IDBs you don't mind sharing!\n4. Instance matching hueristics have their limits, although some types of\n   changes won't interfere with the hueristics so much, however ability to\n   match old recordings will decrease as more changes are made.\n   Users are therefore encouraged to report significantly degrading changes (so\n   hueristics will be adjusted accordingly) as well as execute against a real\n   IDA instance every once in a while.\n\n.. |Build Status| image:: https://travis-ci.org/nirizr/pytest-idapro.svg?branch=master\n   :alt: Build Status\n   :target: https://travis-ci.org/nirizr/pytest-idapro\n.. |PyPI| image:: https://img.shields.io/pypi/v/pytest-idapro.svg\n   :alt: PyPI\n   :target: https://pypi.python.org/pypi/pytest-idapro\n","funding_links":[],"categories":["\u003ca id=\"58b6684347a223e01d4d76d9ca185a88\"\u003e\u003c/a\u003eReplay\u0026\u0026重播","\u003ca id=\"ad68872e14f70db53e8d9519213ec039\"\u003e\u003c/a\u003eIDAPython本身"],"sub_categories":["\u003ca id=\"2299bc16945c25652e5ad4d48eae8eca\"\u003e\u003c/a\u003e未分类"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnirizr%2Fpytest-idapro","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnirizr%2Fpytest-idapro","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnirizr%2Fpytest-idapro/lists"}