58 Commits
Author SHA1 Message Date
pancake 6145ad5fd7 Improve command error reporting in r2pipe.cmd2 paths
- R2CommandError now carries the command output and formatted logs
- _exec raises only on real radare2 command errors, not on soft ERROR logs
- curr_seek_addr uses cmd2 directly and clears the temporary seek
- Add tests for _exec raising and _exec_quiet swallowing parse errors
2026-08-28 17:20:09 +02:00
pancake 2c19d6c9dc Ported the remaining classes to use the command builder and _exec:
- Search: string/wide/case-insensitive/Rabin-Karp/JSON searches now use _cmd_arg so patterns with spaces/special chars are safe.
- Flags: removed leftover manual _tmp_off = "" cleanups (now automatic).
- Debugger: added _tmp_addr() helper, removed manual _tmp_off cleanup.
- Esil: ESIL expressions use _cmd_arg; EsilCPU.registers() returns {} on failure; emulateInstr resolves symbol names to numeric
addresses because aesp doesn't accept symbols.
- Config: cleaned up old-style super() and % formatting; config set now uses key=value.
- File: minor __getattr__ cleanup.
- IOMap: setName uses _cmd_arg for arbitrary map names.
- R2Api / Function: af, afn, afn., p8, aoj, axtj now rely on automatic _tmp_off handling; removed duplicated open/files definitions.
2026-08-28 17:05:58 +02:00
pancake 226d4d4661 Switch command execution to r2pipe.cmd2 and add safe argument quoting
- R2Base._exec now uses r2pipe.cmd2 and raises R2CommandError on failure
- Empty JSON responses return None instead of crashing
- Added _cmd_arg helper to quote string/assembly arguments safely
- Ported Write.string/assembly and Print to the new execution path
- Skip debugger register tests when ptrace is unavailable
2026-08-28 16:18:13 +02:00
pancake 90976f9adf Fix broken r2papi APIs and modernize Phase 0 hygiene
- Flags.exists now scans the JSON flag list instead of the broken `??` helper
- Config boolean values are coerced correctly instead of checking the attribute name
- Debugger CPU no longer swallows all errors and handles empty register sets
- IOMap permissions now read/write the correct radare2 field
- Python 2 leftovers removed and string formatting modernized
- All public r2papi classes are now exported
2026-08-28 16:03:25 +02:00
pancake 35466650d3 Use venv instead of global python 2026-08-28 15:40:25 +02:00
Sagittarius-a 1eaa0442c1 test: use pytest fixtures when possible
Also use idiomatic Python. Kept single letter variables to minimize
changes.
2025-11-06 20:48:57 +01:00
Abhi 69c33ff619 python: Implement search (#35) 2025-10-14 06:29:40 +05:30
Abhi 3b46fda689 Enhance & Refactor with latest r2 2025-10-09 23:04:06 +02:00
pancake ae23784744 Easier python doc from make 2024-06-28 10:47:31 +02:00
pancake 6d0fbec267 Minor fixes to publish r2papi-python 2024-01-10 17:20:33 +01:00
pancake 7f10642007 Move the python CI from travis to GHA
* setup.py fails to install the module because of py3 changes
2022-12-28 21:58:02 +01:00
Quim 6aa55c7ee7 Fix function name test 2020-03-12 20:26:13 +01:00
Quim 07c09d2e8a Change _print with print2 2020-03-04 10:48:49 +01:00
Quim 7e12bac435 Fix Travis CI 2020-03-03 11:46:43 +01:00
Quim 6ea5e56225 Cleanup 'function' stuff 2020-03-02 09:56:50 +01:00
Quim 963eac590e Add agfw command, create graph images from functions 2020-02-28 17:17:07 +01:00
Quim ea82627f9a Document with-as syntax 2020-02-28 16:10:55 +01:00
Quim 44e86697a2 Add debruijn 2020-02-28 15:56:41 +01:00
Quim 35147d227d Add docs of missing Print methods 2020-02-28 14:54:27 +01:00
Quim 6bac42863b Improve docs 2020-02-27 14:52:59 +01:00
Quim dfc5dc476a Update CI dependencies 2020-02-27 12:05:31 +01:00
Quim 84f629f5c2 Fix tests 2020-02-27 11:56:51 +01:00
Quim 71a8493012 Fix newlines at the end of the commands output 2020-02-27 11:19:09 +01:00
Quim Aguado 031e336fcb Start writing docs using sphinx (#17) 2018-11-01 20:01:25 +01:00
Quim e26dd37044 Add context manager for R2Api object
As proposed in #14, now it's not necessary to do r.quit() at the end of your
script:

 with R2Api('-') as r:
     r.print.hexdump(5)

First implementation, probably it can be improved.
2018-09-12 20:21:26 +02:00
Pablo Castellano 87392fbf75 fix setuptools 2018-09-08 18:04:57 +02:00
Pablo Castellano 8b9e31cf79 travis: add basic support for running python tests 2018-09-08 18:04:57 +02:00
Pablo Castellano 9dcd8e4947 use shebang and chmod setup.py 2018-09-08 18:04:57 +02:00
Quim d2c0d0762c String rep for EsilCPU and fix tests
* Now EsilCPU have proper __str__
* registers method is more consistent
* Adapt tests to the last r2 version
2018-09-06 11:09:47 +02:00
Alex Bender f327bcc332 Refactor tests 2018-07-20 18:41:05 +03:00
Alex Bender b7c1e93a19 Reformat files with "black" 2018-07-20 12:47:35 +03:00
Quim c5b1d8ed7f Move writeBytes method to Write object. 2018-06-12 22:07:31 +02:00
Quim b6429a81d1 Makefile for tests with coverage. 2018-06-07 21:35:59 +02:00
Quim d892f09a83 Print bytes as a string/bytes object by default 2018-06-06 15:31:04 +02:00
Quim aaba2d2aa3 Debugger CPU pretty print, and change d.CPU to d.cpu 2018-05-24 22:09:17 +02:00
Quim 8aed6998fc Fixing little bugs and extend tests 2018-05-24 10:38:10 +02:00
Quim 58f0e2fc07 Fix Esil eval bug, and add Esil tests.
Still WIP
2018-05-22 22:56:42 +02:00
Quim ec038908fc First implementation of esil VM object, DO TESTS!!
There're probably broken things, we must test everything in the following
commits.
2018-05-21 19:42:56 +02:00
Quim b0ace05ac2 First implementation of the flags object.
Usage:

 from r2api import R2Api
 r = R2Api('/bin/ls')

 # Get all flags as a json python object (dict)
 r.flags.all()

 r.flags.at(0x100).new('my_flag_name')
 # OR
 r.flags.new('my_flag_name', offset=0x100)

 r.flags.rename('my_flag_name', 'foo')

 r.flags.at(0x100).delete()
 # OR
 r.flags.delete(name='foo')
 # OR
 r.flags.delete(offset=0x100)
2018-05-19 13:46:52 +02:00
Quim 7d039f06d7 Fix bug in curr_seek_addr (R2Base)
- Add test to check this case in the future
2018-05-17 15:53:09 +02:00
Quim 7aa0a79e9e Bug fixes.
- Python3 error when using iteritems in a dict.
- write was a method and also an object in r2api.
- Make and fix tests for this cases.
2018-05-16 21:08:57 +02:00
Quim 45bb503ccf First implementation of the Write class 2018-05-14 21:11:54 +02:00
Quim d7a4c73504 Return proper values type from config __getitem__
And add tests
2018-05-10 09:51:35 +02:00
Quim 5345cadf9d Fix iomap test 2018-05-04 13:18:08 +02:00
Quim 59f14dc4f0 Add Config object.
Example:
>>> from r2api import R2Api
>>> r = R2Api('-')
>>> r.config.asm.bits = 16
>>> r.config.asm.bits
'16'
2018-05-04 13:16:46 +02:00
Quim ad8c912334 Add disasmBytes to Print object
And tests
2018-04-22 12:26:45 +02:00
Quim 166dcc162e Add hexdump to Print object
* Remove redundant code
* Little improvements
* Write tests for hexdump
2018-04-22 00:04:18 +02:00
Quim 6512de7d63 First implementation of Print object
Example:
    from r2api import R2Api
    r = R2Api('/bin/ls')
    # python3 or python2 with print_function
    r.print.at('entry0').bytes(10)
    r.print.at('entry0').disassemble(2)
    # python2
    r._print.at('entry0').bytes(10)
    r._print.at('entry0').disassemble(2)
2018-04-21 00:46:13 +02:00
Quim 0bf8b3c667 Make the code python3 compatible 2018-04-21 00:46:13 +02:00
Quim f37a30a8d2 Added binary file for the tests 2018-04-21 00:46:13 +02:00