Repository navigation
Add tests + CI, drop unused classify_file param, restore lost threshold PR - #12
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three things, in order:
fix/filter-paths-cwd) before GitHub retargeted it tomaster, so its content never landed.masterstill haddefault="Specify the distance threshold"andclassify_file(..., threshold=1). This re-applies it: documented threshold semantics,threshold=None/negative disables filtering.Xparameter fromclassify_file(it only needs the model, test features,yand the threshold). Call sites inmainandbinutils_test.pyupdated.Tests
tests/test_mantilla.py— classifier logic with only pandas + scikit-learn (importing MANTILLA does not pull native deps thanks to the lazy-bimport):get_feature_dictdefaults,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 areimportorskip-ped.CI
.github/workflows/ci.yml: runs the suite on Python 3.10/3.11/3.12, installinglibfuzzy-dev/libmagic1sossdeep/python-magicinstall and import.pytestadded torequirements-dev.txt.Validation
pytest -q→ 12 passed locally (all native deps present; nothing skipped).🤖 Generated with Claude Code