fix: [whoisfreaks] guard parse_domain_reputation against non-dict input - #892
Open
elhoim wants to merge 1 commit into
Open
fix: [whoisfreaks] guard parse_domain_reputation against non-dict input#892elhoim wants to merge 1 commit into
elhoim wants to merge 1 commit into
Conversation
parse_domain_reputation calls data.get("intelligence") without first checking
that data is a dict, unlike expand_whois, expand_dns, and parse_ip_whois in
the same module. If the Domain Reputation endpoint ever returns a non-dict
payload (e.g. null or a list on an unexpected API response), this raises an
AttributeError instead of the graceful empty-result handling the sibling
parsers already provide, turning what should be a "no reputation data"
response into an unhandled crash for the whole enrichment call.
Verified with flake8 (clean) and the full pytest suite against a live
misp-modules server on port 6778: 161 passed, 4 skipped, 5 subtests passed,
matching the 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.
parse_domain_reputation()inwhoisfreaks.pydereferences itsdataargument without checking its type:If the WhoisFreaks Domain Reputation API returns something other than a JSON object (an error payload that is a list, a string, or
null),data.get(...)raisesAttributeError. The three sibling parsers in the same module —expand_whois,expand_dns, andparse_ip_whois— all guard against exactly this withif not isinstance(data, dict): return ..., but this function was missed.Impact: an analyst enriching a domain attribute with the WhoisFreaks module hits an unhandled exception instead of a clean "no reputation data" result whenever the upstream API returns a non-dict response for that endpoint.
Fix: add the same
isinstance(data, dict)guard at the top ofparse_domain_reputation(), returning the function's existing three-tuple contract (attrs, tags, None) on failure, matching the style of the three sibling guards.Found during a review of the repository; other findings are being submitted as separate PRs.
Verification
flake8clean onmisp_modules/modules/expansion/whoisfreaks.py.🤖 Generated with Claude Code
https://claude.ai/code/session_018dfYpyaSZd1nxSRLr8suj8