Repository navigation
fix(core): resolve non-stem validator names in library mode - #772
Merged
Merged
Conversation
Add functionality to resolve scan functions in library mode.
Added tests for non-stem validator resolution and error handling.
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.
Problem
engine.check()(library mode, documented indocs/USAGE.md) resolves a module's validator asvalidate_<file-stem>. The CLI instead accepts anyvalidate_*function viahelpers.get_scan_func(). Two shipped modules have validators that cannot match their file stem:user_scanner/user_scan/social/cups7.py→validate_7cups(a Python identifier cannot start with a digit)user_scanner/email_scan/sports/besoccer.py→validate_okcats(legacy name)Both scan fine from the CLI, but in library mode always return
Result.error("Function validate_cups7 not found" / "Function validate_besoccer not found")without making any request.Reproduction (no network):
Fix
When the stem-named function is absent, fall back to the same shared resolver the CLI uses (
helpers.get_scan_func). Conforming modules are unaffected (their stem-named validator still wins), and library mode now behaves like the CLI for digit-leading or legacy validator names.Testing
tests/test_engine.py(sync validator, async validator, and a module with no validator still erroring): fail without the fix (2 failed / 24 passed), pass with it (26 passed).mcp<2. An independent second environment observed 514 passed / 4 skipped (the 4 skips aretest_pdf_generator.pyReportLab-absent skips) with the same +3 delta. No real handles were scanned and no network calls were made; tests use stubs.ruff check: the repo carries pre-existing findings on main; the two changed files introduce zero new findings (identical 8 pre-existing ones before and after this change).mypy user_scanner/core/engine.py --ignore-missing-imports: clean.