Skip to content

Add radare2 end-to-end integration tests - #14

Merged
ricardojrdez merged 3 commits into
masterfrom
chore/integration-tests
Jun 25, 2026
Merged

Add radare2 end-to-end integration tests#14
ricardojrdez merged 3 commits into
masterfrom
chore/integration-tests

Conversation

@ricardojrdez

Copy link
Copy Markdown
Member

Summary

Closes the test-coverage gap flagged earlier: the radare2-backed extraction path (BinaryAnalyzer) had no automated tests.

tests/test_integration_r2.py compiles a tiny program with the system C compiler and runs BinaryAnalyzer against a real radare2, asserting:

  • get_functions finds the defined functions (compute, greet, main);
  • extract_function_features returns well-typed features with recovered bytes/tlsh/ssdeep/entropy;
  • get_imports returns a list;
  • string_references resolves a known string literal to its function.

The tests skip when a C compiler, radare2, or the native deps are unavailable, and tolerate ELF/Mach-O and radare2 5.x/6.x naming differences (prefix + leading-underscore stripping).

CI now installs radare2 so the integration tests run there as well.

Validation

pytest -v locally against radare2 6.1.9 → 16 passed (12 unit + 4 integration). CI run on this PR validates them on radare2 from Ubuntu.

🤖 Generated with Claude Code

Ricardo J. Rodríguez and others added 3 commits June 25, 2026 08:43
Cover the binary-analysis pipeline that the unit tests could not: compile
a tiny program with the system compiler and run BinaryAnalyzer against a
real radare2, asserting get_functions finds the defined functions,
extract_function_features returns well-typed features with recovered
bytes/tlsh/ssdeep/entropy, get_imports returns a list, and
string_references resolves a known string literal. The tests skip when a
C compiler, radare2, or the native deps are missing, and tolerate
ELF/Mach-O and radare2 5.x/6.x naming differences.

Install radare2 in CI so these run there too.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
_extract_string_references called json.loads directly on izj/aflj/axlj
output. Some radare2 versions return an empty string for axlj, which
raised JSONDecodeError and aborted BinaryAnalyzer construction entirely.
String references are best-effort metadata, so parse these commands
through a _safe_json helper that degrades to an empty result instead of
crashing the analysis. Surfaced by the new integration tests against the
radare2 build in CI.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
extract_function_features indexed afij fields directly, but their names
vary across radare2 versions (Ubuntu's 5.5.0 lacks 'ninstrs'), which
raised KeyError. Read them with .get and sensible defaults, mirroring
get_feature_dict, so extraction degrades gracefully on any version.

CI now installs a pinned radare2 release (6.1.8) via the official .deb
instead of the distro's ancient 5.5.0, so the integration tests run
against a representative modern radare2.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ricardojrdez
ricardojrdez merged commit 3360ca0 into master Jun 25, 2026
3 checks passed
@ricardojrdez
ricardojrdez deleted the chore/integration-tests branch June 25, 2026 08:46
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.

1 participant