Repository navigation
fix(pcapng): constructed and rebuilt blocks round-trip (#1267, #1268, #1269, #1270, #1271) - #1339
Conversation
|
Cross-review verdict on A zero-length EPB regresses. With
So it is only correct if #1331 lands first. Slice the packet bytes to Everything else held:
Worth a line each, not blocking:
|
…1269, #1270, #1271) - #1267: reset the option counter between the make pass and the re-parse in PCAPNG.__post_init__, so an option with an "only one" guard no longer trips it on itself. - #1268: if_IPv6addr declares its 17-octet length, not 8. - #1269: _make_block_isb sets _isb_interface_id before building the isb_starttime / isb_endtime options. - #1270: EPB, SPB and PB rebuilt from their data model keep the packet data, taken from the parsed info's packet octets cut to captured_len. - #1271: the TLS and WireGuard key-log writers end lines with a newline and no longer stamp the current time; a parsed log keeps its text and is written back verbatim, comments and line order included. Removes the 33 EXPECTED_FAILURES entries these close. The two key-log entries now record #1279 (the DSB is never padded) instead.
97c74a5 to
901e123
Compare
|
Round-2 verdict on
|
make pylint,make mypy,make isort) — ran pylint, mypy and isort with the Makefile flags on the twopcapkit/files only. No new findings; mypy's 4 errors were already there.make testpasses, and a test case covers the change — the modules run are listed below.What is the purpose of your pull request?
fix— corrects a defectDescription of your pull request and other information
Closes #1267
Closes #1268
Closes #1269
Closes #1270
Closes #1271
__post_init__resetsself._optbetween the pack and the re-parse.if_IPv6addroption hardcodes length=8 for a 17-octet field (EXPECTED_FAILURESpcapng-option/if_IPv6addr_5) #1268if_IPv6addrdeclareslength=17.isb_starttime/isb_endtimemakers read_isb_interface_id, which only the parse path sets #1269_make_block_isbsets_isb_interface_idbefore it builds the options.packetoctets, cut tocaptured_lenso a zero-length payload stays empty (fix(schema): a computedPayloadFieldlength of 0 swallows the rest of the block #1275 can leave octets there). A model that has nopacketrebuilds it from the decoded next layer instead.os.sepand injectdatetime.now()#1271 Key-log lines end with\n, and the header comment no longer carriesdatetime.now(). A parsed TLS or WireGuard log also keeps its text asdata, a key set by__update__likeprotocols, andfrom_datawrites that text back verbatim. Not breaking: no constructor signature changes.Before → after. The repro in each issue now builds and rebuilds byte-exactly. Every block of
examples/captures/*.pcapnggoes throughfrom_databyte-exactly: 120 EPB, 19 IDB, 14 ISB, 2 NRB, 1 SPB, 1 DSB, 1 systemd and 6 of 7 SHB. The one exception is the big-endian SHB, which is #1272.EXPECTED_FAILURES. 33 of the 35
pcapng-*entries are removed.pcapng-secrets/{TLS,WireGuard}_Key_Lognow fail withCONSTRUCT invalid length, recorded against #1279 (_make_block_dsbnever pads). The newline-terminated logs are not 4-aligned, so the #1271 fix unmasked it.Tests. The new
tests/protocols/misc/test_pcapng_roundtrip_unit.pyhas 8 tests. Without the fix, 6 of them fail. Thecaptured_len=0test guards the #1270 fix itself: it passes onmain, and fails without the cut (both subtests,original_len0 and 60). The remaining one is a control and passes both ways: it checks that the "only one" guard still rejects a repeated option.test_pcapng_unit.pypinnedif_IPv6addrlength 8, so two of its assertions now expect 17.Results:
test_pcapng_unit: 97 passedtest_pcapng_regression: 11 passedtest_pcapng_engine: 14 passedtests/project: 389 passed, 1 skippedrun_unittest_leg.py protocols --exclude protocols/internet: 858 tests, 0 failures