Skip to content

Add tests + CI, drop unused classify_file param, restore lost threshold PR - #12

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

ricardojrdez merged 3 commits into
masterfrom
chore/tests-ci

Conversation

@ricardojrdez

Copy link
Copy Markdown
Member

Summary

Three things, in order:

  1. Restore PR Clarify threshold semantics and allow disabling neighbor filtering #4 (threshold semantics). While wiring up the tests I found that Clarify threshold semantics and allow disabling neighbor filtering #4 — like Resolve string references with three r2 queries instead of one per string #6/Document the ARM entropy=-1 extraction artifact #9 earlier — was merged into its now-deleted stacked base branch (fix/filter-paths-cwd) before GitHub retargeted it to master, so its content never landed. master still had default="Specify the distance threshold" and classify_file(..., threshold=1). This re-applies it: documented threshold semantics, threshold=None/negative disables filtering.
  2. Drop the unused X parameter from classify_file (it only needs the model, test features, y and the threshold). Call sites in main and binutils_test.py updated.
  3. Add a pytest suite and GitHub Actions CI.

Tests

  • tests/test_mantilla.py — classifier logic with only pandas + scikit-learn (importing MANTILLA does not pull native deps thanks to the lazy -b import): get_feature_dict defaults, get_features_test, train/classify roundtrip, threshold semantics, empty input.
  • tests/test_feature_extraction.py — pure helpers: _func_offset (addr/offset), entropy calculator, name cleaning, exact-match filters (regression for the substring over-removal), bundled-list filtering. Native deps are importorskip-ped.

CI

.github/workflows/ci.yml: runs the suite on Python 3.10/3.11/3.12, installing libfuzzy-dev/libmagic1 so ssdeep/python-magic install and import. pytest added to requirements-dev.txt.

Validation

pytest -q → 12 passed locally (all native deps present; nothing skipped).

🤖 Generated with Claude Code

Ricardo J. Rodríguez and others added 3 commits June 25, 2026 07:17
The distance threshold was undocumented and its two defaults disagreed:
argparse defaulted to 1.0 (float) while classify_file defaulted to 1
(int). The value is an absolute distance in the chosen metric computed
over unnormalized features, so its meaning depends entirely on feature
magnitudes -- something a caller could not tell from the code.

Document that semantics in both the CLI help and the classify_file
docstring, and let callers disable distance filtering entirely: pass
None to classify_file, or a negative value to -t on the CLI, to let
every k-neighbor vote. The default CLI behavior (threshold 1.0) is
unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
classify_file never used the training feature matrix X; it only needs
the model, the test features, the label array y and the threshold.
Remove the parameter and update both call sites (main and
binutils_test).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add unit tests covering the parts that do not need radare2:
- test_mantilla.py: get_feature_dict defaults, get_features_test, the
  train/classify roundtrip, threshold semantics (None/negative/exact)
  and empty input. Needs only pandas + scikit-learn.
- test_feature_extraction.py: _func_offset (addr/offset), the entropy
  calculator, name cleaning, the exact-match function filters (regression
  for the substring over-removal) and the bundled-list filtering. Native
  deps are importorskip-ped so the module is skipped if they are absent.

Add a CI workflow running the suite on Python 3.10-3.12 (installing
libfuzzy-dev/libmagic1 for ssdeep/python-magic), and add pytest to
requirements-dev.txt.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ricardojrdez
ricardojrdez merged commit 73083dc into master Jun 25, 2026
0 of 3 checks passed
@ricardojrdez
ricardojrdez deleted the chore/tests-ci branch June 25, 2026 05:33
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