fix: [reversedns] fix nameserver fallback when config is an empty dict - #886
Open
elhoim wants to merge 1 commit into
Open
fix: [reversedns] fix nameserver fallback when config is an empty dict#886elhoim wants to merge 1 commit into
elhoim wants to merge 1 commit into
Conversation
The module only fell back to the documented Google public DNS address (8.8.8.8)
when the "config" key was entirely absent from the request. When MISP sends
"config": {} (config present but no nameserver set, which happens whenever the
module is enabled without an explicit nameserver override), the else branch
that sets the fallback never runs, and the resolver silently falls back to
whatever nameservers are configured on the system running misp-modules instead
of the documented default. Analysts get PTR lookups resolved through an
unexpected resolver with no indication the documented fallback was skipped.
Replaced the presence check with a single expression that reads the
nameserver from config when present and non-empty, and otherwise uses
8.8.8.8, matching the documented behavior in all cases.
Verified with flake8 (clean) and the full test suite against a locally
started misp-modules server: 161 passed, 4 skipped, 5 subtests passed.
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.
The reversedns module's documented fallback to Google DNS only triggers when the
configkey is missing entirely:If
configis present but empty or lacksnameserver(e.g.{"config": {}}), neither branch setsr.nameservers, so the resolver silently falls back to the system's default nameservers instead of the documented8.8.8.8fallback.An analyst who submits
{"config": {}}(a common case when a config dict is built but not yet populated, or when only unrelated config keys are set) gets PTR lookups resolved through whatever DNS servers the host happens to use, rather than the documented, predictable8.8.8.8. This can produce inconsistent or environment-dependent enrichment results, and is surprising given the module's documented behavior.Fix
Replaced the if/else block with a single expression that falls back to
8.8.8.8wheneverconfigis absent,config.nameserveris absent, or either is empty/falsy:This is a pure bug fix restoring the module's already-documented fallback behavior; it does not change the documented contract.
Verification
python -m py_compile misp_modules/modules/expansion/reversedns.py— succeeded.flake8on the changed file — clean (no output).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