Skip to content

Validate --module names against expansion modules only - #30

Open
elhoim wants to merge 1 commit into
MISP:mainfrom
elhoim:fix/30-module-validated-against-all
Open

Validate --module names against expansion modules only#30
elhoim wants to merge 1 commit into
MISP:mainfrom
elhoim:fix/30-module-validated-against-all

Conversation

@elhoim

@elhoim elhoim commented Aug 31, 2026

Copy link
Copy Markdown
Member

Finding 30 (Medium) — bin/cli.py:890-894

Problem

--module names are validated against every module in /modules rather than only expansion modules, so a valid import/export module name passes validation, matches nothing in find_modules_for_type, queries nothing, and exits 0.

Fix

The --module flag was validated against every module returned by /modules (import, export, and expansion alike), not just expansion modules. This let a valid import/export module name (e.g. "ocr") pass validation, then match nothing in find_modules_for_type since that function only scans expansion modules — the command would silently query nothing and exit 0 as if successful. Fixed by validating selected module names against get_expansion_modules(modules) and rewording the error message to make clear only expansion modules are valid here.

Verification

Reproduced against the unmodified code at 9b8c605, then re-checked after the change.

Before
Constructed modules = [{"name":"ocr","type":"import"}, {"name":"virustotal","type":"expansion","mispattributes":{"input":["ip-src"]}}]; selected_modules=["ocr"]. Old check: available_modules built from all `modules` → missing_modules == [] (ocr passes), but find_modules_for_type(modules, "ip-src") returns only virustotal — ocr matches nothing, so the CLI would proceed and silently produce no output for the requested module while exiting 0.
After
Same modules/selected_modules, but available_modules built from get_expansion_modules(modules) → missing_modules == ["ocr"], correctly rejected with "[!] Unknown expansion module name(s): ocr. Use /modules introspection to list available expansion module names." and exit 1.

python bin/cli.py --help exits 0 and the module still imports cleanly. Verification was performed offline against the pure functions — no running misp-modules instance is required.

Branched from 9b8c605. This PR addresses only this finding; the other findings from the same review are in separate PRs, so they will need rebasing against each other as they merge.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DYX4TKA5inzByJ4qGWKjqh

The --module argument was validated against every module in /modules (import, export, and expansion alike). This let a valid import/export module name pass validation, then silently match nothing in find_modules_for_type and query nothing, exiting 0 as if it had worked. Validate against get_expansion_modules(modules) instead, and report the mismatch as an unknown expansion module.
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