Skip to content

netbios: support a list of names in nbns_resolve - #5217

Open
Skarthik06 wants to merge 2 commits into
secdev:masterfrom
Skarthik06:netbios-resolve-list
Open

Skarthik06 wants to merge 2 commits into
secdev:masterfrom
Skarthik06:netbios-resolve-list

Conversation

@Skarthik06

Copy link
Copy Markdown

Fixes #5202

nbns_resolve() used the unhashable qname (a list or a bytearray) in its cache key, which raised a TypeError. A list of names is now resolved one name at a time and returned as a dict {name: result}; a bytearray is converted to bytes. Single-name behaviour is unchanged.

Reproduction (before the fix):

from unittest import mock
from scapy.layers.netbios import nbns_resolve
with mock.patch("scapy.layers.netbios.conf.route.get_if_bcast",
                return_value=["192.0.2.255"]):
    nbns_resolve(["ALPHA", "BETA"], iface="test")

This PR was written with the help of AI (Claude Sonnet 5.5).

The cache key introduced in secdev#5115 contained the list (or bytearray) as is, which raised TypeError: unhashable type. A list now resolves each name separately and returns a dict, and a bytearray is converted to bytes.

AI-Assisted: yes (Claude Sonnet 5.5)
Cover a list with duplicate names, raw and default results of the same name, and names cached before a timeout in a list.

AI-Assisted: yes (Claude Sonnet 5.5)
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.

netbios: nbns_resolve with a list of names now raises TypeError: unhashable type: 'list' (since #5115)

1 participant