Repository navigation
fix(toolkit): scapy packet2dict dumps nested packets as {} and mutates its input - #1287
Merged
Merged
Conversation
Owner
Author
|
Cross-review verdict on
|
Contributor
|
Coverage: 88.88% (unit tier, Python 3.14,
Per-file detail: the |
…s its input packet2dict now converts field values that are scapy packets, including those inside lists and tuples (IP/IPv6/MH options, DNS records, SCTP params, TCP-AO values), and builds each layer's dict from a copy of packet.fields, so the given packet is left unchanged and no default values are added to dissected layers. Closes #1259 Closes #1260
JarryShaw
force-pushed
the
fix/scapy-packet2dict
branch
from
October 7, 2026 18:25
6a98085 to
c308af6
Compare
Owner
Author
|
Cross-review verdict on
|
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.
make pylint,make mypy,make isort) — ran pylint/mypy/isort ontoolkit/scapy.py: nothing new on the changed lines; the file's existing mypy/isort findings are unchangedmake testpasses, and a test case covers the change — ran the modules listed below, not the full suiteWhat is the purpose of your pull request?
fix— corrects a defectDescription of your pull request and other information
packet2dictnow converts field values that are scapyPackets, including inside lists and tuples (IP/IPv6/MH options, DNSqd/an/ns, SCTP params, TCP-AO values). Each layer's dict is built from a copy ofpacket.fields, so the input packet is not mutated.Defaults: none are added. A layer carries exactly the fields set on it, so a dissected layer carries only what was read from the wire. A hand-built nested packet with no fields set still dumps as
{}, for exampleIPOption_NOP().options-ipv4.pcapdumps with 14{}. In D6,p.fieldsgoes from[]to['IP'], and thenp.copy()raisesKeyError: 'IP'.options-ipv4.pcapdumps with 0{}, and in D6p.fieldsstays[].examples/captures/*: 288 empty{}before, 1 after. The one left isdhcp.pcapngSection Header 1/options, which is a genuinely empty pcapng option list, not a packet object.fieldsplus the payload name: 0 mismatches.tests/toolkit/test_scapy_packet2dict_unit.py, 7 tests:7 passed, 10 subtests passed.main:6 failed, 3 passed.little_endian.pcap.test_scapy_unit: 6 passed.engines/test_scapy_engine: 2 passed.tests/project: 389 passed, 1 skipped.util/run_unittest_leg.py toolkit: 275 tests, 0 failures.Closes #1259
Closes #1260