Repository navigation
examples/generators/options.py: TCP_BASE's seq and ack_flag are silently dropped, so every option fixture has seq=0 #602
Description
examples/generators/options.py's TCP_BASE passes keyword arguments that TCP.make does not declare. They are silently dropped, with no warning, so every option fixture this generator produces is built with different field values than the dictionary states.
Measured
On origin/main (13a75dfcd), CPython 3.14.7:
TCP_BASE keys: ['ack', 'ack_flag', 'checksum', 'cwr', 'dstport', 'ece', 'fin',
'ns', 'payload', 'psh', 'rst', 'seq', 'srcport', 'syn', 'urg',
'urgent_pointer', 'window']
TCP(**TCP_BASE).info.seq = 0 while TCP_BASE says seq = 1
warnings captured: []
Nothing warns. warnings.simplefilter('always') around the construction captures nothing — no UnknownFieldWarning, no DeprecationWarning. The value is simply not applied.
Two distinct problems in one dictionary
seqis not amakeparameter and is dropped.TCP_BASEdeclaresseq = 1; the constructed object reportsinfo.seq == 0.ackandack_flagare both present, andackis not the acknowledgement number.ackbinds to the ACK flag, so'ack': 0sets a flag rather than a sequence value, whileack_flagis not a declared parameter at all and is dropped.
So the dictionary reads as though it sets a sequence number of 1 and an explicit ACK flag, and does neither.
Why it matters beyond this file
options.py:403 and :417 both construct via TCP(options=…, **TCP_BASE), so this is the base for the generated option fixtures. Every fixture built through it carries seq = 0 regardless of what the generator says, and an ack that means something other than it appears to.
That makes the fixtures weaker evidence than they look: a test asserting round-trip fidelity over them is asserting it over a packet whose header fields were not what the generator specified.
Notes
- Found by the Constructing an MP_JOIN option raises AttributeError: TCP._make builds the options before assigning self._flags #587 worker while fixing the MP_JOIN flag-ordering defect; disclosed in fix(tcp): resolve the connection flags before building the options (#587) #597's body and deliberately not fixed there, correctly, since it is a fixture-generator concern rather than a
tcp.pyone. - Related: silently dropping unknown keywords is the behaviour
pcapkit/protocols/schema/schema.py:450warns about withUnknownFieldWarningfor schema construction. Whethermakeshould do the same for undeclared parameters is a design question this issue raises but does not answer — it is the reason the defect was invisible, and TCP._make_mptcp_addaddr cannot pack: kind/length rejected as fields, then the port predicate KeyErrors on length #541 and Two dropped-keyword/wrong-cast defects flagged in review and never filed (hip.py:3533, ipv6_route.py:207) #556 were about the same class of silence. - Verified by execution rather than relayed.
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsDone
Activity
fix(generators): spell TCP_BASE's keys the way TCP.make declares them (…
fix(protocol): refuse a construction keyword no signature declares (#617
fix(protocol): refuse a construction keyword no signature declares (#617
fix(protocol): refuse a construction keyword no signature declares (#617
fix(protocol): refuse a construction keyword no signature declares (#617
fix(protocol): refuse a construction keyword no signature declares (#617