dns: stop recording unknown names in the answering machine - #5136
Open
KernelClint wants to merge 1 commit into
Open
dns: stop recording unknown names in the answering machine#5136KernelClint wants to merge 1 commit into
KernelClint wants to merge 1 commit into
Conversation
AI-Assisted: yes (GPT-5.6-Cyber)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #5136 +/- ##
=======================================
Coverage 80.63% 80.64%
=======================================
Files 390 390
Lines 96936 96941 +5
=======================================
+ Hits 78168 78177 +9
+ Misses 18768 18764 -4
🚀 New features to boost your workflow:
|
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.
DNS_amanswers queries from amatchmapping of name to address, falling back to the documentedjokerandjoker6values for anything not configured.That mapping is a
defaultdictbuilt atscapy/layers/dns.py:1677,and the A and AAAA paths reach the fallback by indexing it (
:1811,:1827). Indexing adefaultdictwith a missing key inserts it. Every query for a name the operator never configuredtherefore adds an entry, and the mapping grows for as long as the machine runs, driven entirely by
what arrives.
LLMNR_aminherits the same behaviour.The change uses a plain dictionary and handles the missing key without writing to it:
Configured names resolve as before and both jokers keep their documented behaviour; the only change
is that an unknown name is no longer recorded.
The added regressions cover A and AAAA and assert the mapping is still empty after answering a
series of unknown names. Without the source change they fail.
Performance was measured on one computer, before and after the fix: answering a configured name
took 84.5 ns before and 86.8 ns after, a difference of 2.3 ns. Repeat runs moved by about 2%, which
is the same size as the difference, so the test cannot separate them.