Skip to content

pcapng: Name Resolution Block guards report the systemd Journal Export Block #1038

Description

@JarryShaw

Name Resolution Block guards in pcapkit/protocols/misc/pcapng.py raise messages that name the wrong block. Seven sites check one block type and tell the caller about another.

The six ProtocolErrors at :3031, :3057 and :3085 (the read side) and :5140, :5171 and :5202 (the make side) all have this shape:

if self._type != Enum_BlockType.Name_Resolution_Block:
    raise ProtocolError(f'PCAP-NG: [ns_dnsname] option must be in :manpage:`systemd(1)` Journal Export Block, '
                        f'but found in {self._type} block.')

The guard checks Name_Resolution_Block, but the message says "systemd(1) Journal Export Block". The ns_dns* options belong to the NRB. RegistryWarning at :966 has the same problem: register_record warns "systemd(1) journal export record already registered" for what is a nrb_record_* Name Resolution record.

Two side issues: these are runtime strings, so the embedded :manpage: reST role reaches the user as literal text. Two of the six sites also spell the option ns_dnsip4addr/ns_dnsip6addr where the others use ns_dnsIP4addr/ns_dnsIP6addr.

Fix: name the Name Resolution Block (and record) in all seven messages, and drop the reST role from them. Add a test that triggers one read-side guard and one make-side guard and asserts the block named in the message.

Blocked on #1037, an open docstring-only PR (#719 sweep) on the same file. This change waits until #1037 merges or closes, to avoid a conflict. Found while reviewing #1037.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixPull requests that fix a defect (fix: subject prefix)

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions