fix: [csvimport] avoid AttributeError on unset header/delimiter config - #874
Open
elhoim wants to merge 1 commit into
Open
fix: [csvimport] avoid AttributeError on unset header/delimiter config#874elhoim wants to merge 1 commit into
elhoim wants to merge 1 commit into
Conversation
dict_handler() calls .strip() directly on request["config"].get("header")
and request["config"].get("special_delimiter"). When a MISP instance
submits the import without these optional config keys set, .get() returns
None and the subsequent .strip() raises AttributeError instead of falling
back to the intended defaults (an empty header list or the "," delimiter),
so the import fails with an unhandled exception rather than a clean
misperrors response.
Verified with flake8 (clean) and the full pytest suite against a live
modules server on port 6757: 161 passed, 4 skipped, 5 subtests passed,
matching the recorded baseline.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018dfYpyaSZd1nxSRLr8suj8
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.
csvimport'sdict_handler()crashes when the module is invoked without the optionalheader/special_delimiterconfig keys set:request["config"].get("header")(and the delimiter equivalent) returnsNonewhen the key is absent, andNone.strip()raisesAttributeErrorbefore the intended fallback (empty header list /,delimiter) is ever reached.Impact: an analyst importing a CSV via this module without explicitly setting
headerorspecial_delimiterin the config gets an unhandledAttributeErrorinstead of the module falling back to its documented defaults — the import fails outright rather than degrading gracefully.Fix: wrap both
.get(...)calls as(request["config"].get(key) or "").strip(), so a missing key is treated as an empty string and the existing fallback logic (empty header list /,delimiter) runs as originally intended. No change to behavior when the keys are present and set.Verification
flake8 misp_modules/modules/import_mod/csvimport.py— clean, no output.python -m misp_modules -l 127.0.0.1 -p 6666) and ran the full test suite:python -m pytest tests/ -q→161 passed, 4 skipped, 5 subtests passed in 20.10s.Found during a review of the repository; other findings are being submitted as separate PRs.
🤖 Generated with Claude Code
https://claude.ai/code/session_018dfYpyaSZd1nxSRLr8suj8