Repository navigation
fix(toolkit): accept tshark's True/False TCP flags in the pyshark trace (#1514) - #1527
Merged
Merged
Conversation
Contributor
|
Coverage: 90.11% (unit tier, Python 3.14,
Per-file detail: the |
3 of 5 tasks
…ce (#1514) - Flags: tcp_traceflow parsed tcp.flags_syn/fin/reset with bool(int(...)), but tshark 4.x reports them as 'True'/'False', so the first traced TCP frame raised ValueError. _parse_flag accepts both spellings and raises ProtocolError otherwise. - Timestamp: frame.time_epoch was handed over as text; it is now float(Decimal(...)), the default engine's float. - Sequence numbers: tcp.seq/tcp.ack are tshark's relative numbers; read tcp.seq_raw/tcp.ack_raw, falling back where they are absent. - Frame layer: packet2dict, encap_type and time_epoch read frame_info, which is pkt_comment on a commented packet; look the frame layer up by name. - Index: take the engine's frame count, as dpkt and scapy do, not tshark's frame number. - Engine agreement: delete the #1514 Gap row; compare pyshark trace inputs without header/payload and pyshark flows by label and index only, since pyshark has no frame bytes (ruling on #1507). Unit tests cover each fix; tests/toolkit, the engine module, tests/project, the docstring contract and the tier guard pass. Closes #1514
JarryShaw
force-pushed
the
fix/1514-pyshark-tcp-flags
branch
from
October 9, 2026 23:24
80ecc34 to
b1c6cc2
Compare
Owner
Author
|
Verdict: GOOD TO GO at
Non-blocking:
|
3 of 5 tasks
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.
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
Fixes
pcapkit.toolkit.pysharkso its flow-trace input matches the default engine's. The #1514ValueErrorhad been hiding the later bugs:tcp.flags_*as'True'/'False', sobool(int(...))raised._parse_flagaccepts'1'/'0'and'True'/'False'and raisesProtocolErrorotherwise.frame.time_epochwas handed over as text. It is nowfloat(Decimal(...)), bit-identical to the default engine. A Simple Packet Block has notime_epoch, so itssniff_timestampis used instead.tcp.seq_raw/tcp.ack_raw, which exist from Wireshark 3.2.0 (checked inpacket-tcp.cfor 3.0.0, 3.2.0 and CI's 4.2.2), and falls back toseq/ackwithout them.packet2dict,encap_typeandtime_epochreadframe_info, which ispkt_commenton a commented packet; a commented TCP packet raisedMissingKeyError: 'frame'. The frame layer is now looked up by name.count, as dpkt and scapy do, instead of tshark'spacket.number. This aligns with fix(engines): the pyshark engine skips non-packet PCAP-NG blocks (#1515) #1531; it needs a one-line change at thetcp_traceflowcall infoundation/engines/pyshark.py.Engine agreement: deletes the #1514
Gaprow. Per the ruling on #1507, pyshark has no frame bytes, so two pyshark comparisons are narrowed:traceskipsheader/payload(NO_TCP_OCTETS, citingextraction.py:1446-1455).flowscompares labels and indices only (JSON_TRACE, citingextraction.py:1440-1444).Tests: 19 new or updated in
tests/toolkit/test_pyshark_unit.py; 16 fail onorigin/main. With pyshark and tshark 4.6.9 the engine module passes (625 subtests), and so does a merge with #1531. That merge conflicts only on the adjacent #1514/#1515 rows; resolve it by deleting both. On a journal block followed by two TCP packets, the merge gives indices 1 and 2, as the default engine does.Closes #1514