Repository navigation
fix(pcapng): blocks and options rebuild as parsed (#1272, #1273, #1277, #1278, #1281, #1286) - #1378
Conversation
|
Cross-review verdict on
Retarget to Follow-ups filed, both pre-existing: #1382 — an undefined direction or reception value raises, so such a capture cannot round-trip, and bits 9–11 deserve names; #1383 — an NRB name list ending in empty names loses them. |
|
Resolve merge conflicts |
#1278, #1281, #1286) - A Section Header Block keeps its parsed byte order; make() takes one. - epb_flags/pack_flags number bits from the least-significant bit, in the section's byte order; bits 9-23 are kept as `reserved`, and an undefined direction or reception raises ProtocolError. - NRB record names and ns_dnsname decode as UTF-8, and a name that is not UTF-8 keeps its octets through the split into names. - An unknown block's length counts the 12 framing octets and its padding. - epb_verdict may repeat. - The WireGuard key log error names the offending line.
e552608 to
497a3e9
Compare
|
Conflicts resolved. The branch still carried #1373's pre-squash commit The verdict carries over. The patch-id is identical across the original |
…and zero-filled on rebuild OptionField.unpack reads each option through a proxy that notes short reads, and raises ProtocolError when an option that began with octets present then reads past the end of its data. An option starting at the end of the data keeps the end-of-option-list handling. Inside a parent layer the octets are kept as captured and rebuild byte for byte. BREAKING CHANGE: a truncated IPv4 or TCP option no longer parses with zero-filled data; the layer raises ProtocolError, and a parent keeps it as raw octets. The #431/#572 pins and the #1394 raw-item cases are rewritten to match. PCAP-NG is a follow-up after #1378. Refs #1325
|
Coverage: 89.41% (unit tier, Python 3.14,
Per-file detail: the |
make isortis clean pertests/project/test_isort_clean.py; pylint and mypy not runmake testpasses, and a test case covers the change — the modules below, not the full suiteWhat is the purpose of your pull request?
fix— corrects a defectDescription
Closes #1272
Closes #1273
Closes #1277
Closes #1278
Closes #1281
Closes #1286
Spec claims are checked against draft-ietf-opsawg-pcapng-06:
epb_verdictis "multiple allowed: yes"ns_dnsnameare UTF-8dhcp_big_endian.pcapngSHB rebuilds4d3c2b1a(LE)make(block={'byteorder': 'big'})also worksmake(direction=INBOUND)writes00000040; wiree5010000→ValueError01000000;(1, 1, 15)('愮數慭灬攀戮數慭灬攀',)('a.example', 'b.example'); a non-UTF-8 name rebuilds byte-exactlyinvalid length: 8option must be only one, but 2 foundformat: {line!r}format: 'a b c'Breaking changes:
EPB_FlagsOption/PACK_FlagsOptiongain a requiredreservedfield (bits 9-23, verbatim), and the makers gainreserved=0.flagsis a new LSB-0FlagsFieldthat reads the word in the section's byte order.0b11) or reception (5-7) raisesProtocolError.FieldValueErrorinstead ofValueError.Judgement call: bits 9-11 (checksum and TSO offload) and 16-23 sit inside
reservedinstead of getting named fields.Existing tests that pinned old behaviour, now updated in
test_pcapng_unit.py:flagsdict and the two flags data models gainreservedepb_verdictis dropped from the duplicate-guard listThe 11 new tests are in
TestPCAPNGModellingintests/protocols/misc/test_pcapng_roundtrip2_unit.py. With #1373's three source files written back over this fix, the run reports12 failed, 9 passed. All 11 new tests fail, along with thens_dnsnamesubtest: Latin-1caf\xe9was read ascaféby charset guessing. With the fix, the module reports19 passed, 7 subtests passed.Fixture check: all 165 blocks of the six
examples/captures/*.pcapngfiles now rebuild byte-exactly (0 mismatches).Test results:
test_pcapng_unit: 97 passedtest_pcapng_roundtrip_unit: 8 passedtest_option_roundtrip_unit: 6 passed / 362 subteststest_pcapng_regression: 11 passedtest_pcapng_end_to_end: 6 passedtest_docstring_contract: 7 passedrun_unittest_leg.py protocols --exclude protocols/internet: 940 tests, 0 failurestests/project: 389 passed, 1 failed (test_isort_clean, an over-long import line). After isort fixed the line,test_isort_cleanpasses on its own.