Repository navigation
fix(toolkit): pyshark reads frames to the 64-layer bound and past tshark's 802.1Q limit, and keys its fallback by the header (#1609, #1671) - #1686
Conversation
…ark's 802.1Q limit, and keys its fallback by the header (#1609, #1671) - #1671: where a frame's octets cannot be had, _from_layers read tshark's ip.dst unguarded. tshark reports none behind a route option whose data is no whole number of addresses, so AttributeError ended extract(); behind a live LSRR or SSRR it is the route's last hop. _header_addresses now takes the header's destination (ip.cur_rt there) and reads no segment where tshark reports no address, as the default engine rejects such an option. - #1609: _from_octets followed IP-in-IP, AH and extension headers past layer 64. _network_start now gives the IP layer's place in the frame, and the walk goes through pypcapfile's _walk_upper_layer, which stops at FRAME_LAYER_LIMIT. - #1609: tshark dissects at most 20 802.1Q tags, so frames behind more were never read from their octets. Such a frame now asks for them (_stops_in_vlan_tags; OCTETS_FILTER gains vlan). New tests/toolkit/test_pyshark_fallback_and_layer_bound_1609_1671_unit.py: all 6 tests fail on main and pass here, on 3.11 with tshark 4.6.9. Closes #1609 Closes #1671
|
Verdict: GOOD TO GO at
Left, all already on
|
|
Coverage: 89.46% (unit tier, Python 3.14,
Per-file detail: the |
Third-party engines are best effort (#1687), so the pyshark code that exists only to match the default engine comes out: - revert #1686, #1670 and #1642: the second tshark pass that read a frame's octets, the link type read from the capture file, the 64-layer bound, reading past tshark's 802.1Q limit, and keying a source-routed segment by ip.cur_rt - revert #1613's tshark preferences that turned IP reassembly off, with its FileCapture assertion in test_runtime_engines.py and its sentence in the engines index - keep #1613's partial-TCP-header guard and #1605's keying by the IP header that carries the segment - re-land #1671's crash fix: a TCP layer whose IP layer lacks ip.src or ip.dst is not traced, rather than raising AttributeError - delete the three test modules those reverts added and the agreement checks in test_pyshark_unit.py; the #1611 and #1671 checks assert constants The pyshark test modules, test_runtime_engines.py, test_engine_runtime.py and the project guards pass on 3.11 (tshark 4.6.9) and 3.14.
Please follow the guide below
You will be asked some questions, please read them carefully and answer honestly
Put an
xinto all the boxes [ ] relevant to your pull request (like that [x])Use Preview tab to see how your pull request will actually look like
Searched for similar pull requests
Followed the coding style (
make pylint,make mypy,make isort)make testpasses, and a test case covers the changeAdded a changelog entry under
docs/source/changelog/and regeneratedCHANGELOG.md, if the change is user-visible — N/A — centralised in docs(changelog): shared 1.5.0 changelog — long-lived, merges last (#610, #616, #617, #618, #620) #657What is the purpose of your pull request?
Tick the commit type your subject line carries.
fix— corrects a defectfeat— adds a featureperf— changes performance, not behaviourrefactor— changes neither behaviour nor performancetest— tests onlydocs— documentation onlyci— workflows or build toolingrelease— bumps the version or rolls up a distributionchore— anything elseDescription of your pull request and other information
#1671. The fallback
_from_layersruns where a frame's octets can't be had:tcp_traceflowgets nocaptured, or the engine's second tshark pass or capture-file read fails. It readip.dstunguarded. Behind a route option whose data isn't a whole number of addresses, tshark gives noip.dst, soextract()raised a bareAttributeError. Behind a live LSRR or SSRR,ip.dstis the last hop._header_addresses(pcapkit/toolkit/pyshark.py:604) now keys by the header's destination, which is tshark'sip.cur_rtthere. It returns no segment where tshark gives no address, since the default engine rejects that option (pcapkit/protocols/internet/ipv4.py:898).#1609.
_from_octets(:908) now starts at the depth_network_startgives and walks through #1667's_walk_upper_layer, so it stops atFRAME_LAYER_LIMIT. tshark dissects at most 20 802.1Q tags, so TCP behind 21–61 tags was never read._stops_in_vlan_tags(:685) andvlaninOCTETS_FILTERnow read those frames from their octets.Measured on 3.11 with tshark 4.6.9,
main(7aeeaf804) → this branch. Trace inputs agreeing withdefault:No new disagreements. dpkt, scapy and pypcapfile agree on all 37 #1609 cells on
main.Unchanged from
main, not fixed here (pyshark 0, default 1): an IPv6 jumbogram whose Jumbo Payload Length is ≤ 65535, which tshark flags as malformed (a real one of 70,028 octets agrees), and TCP behind IPv6 Mobility or HIP (#1626). In the fallback sweep, the 4,841 frames whose route options the default engine rejects are still traced as tshark dissects them.Tests. New
tests/toolkit/test_pyshark_fallback_and_layer_bound_1609_1671_unit.py. All 6 tests fail onmain(7 failures, 7 errors underunittest) and pass here. Pins in the #1625 and #1639 files are updated for the new filter, warning and_network_startshape.Closes #1609
Closes #1671