Repository navigation
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5252 +/- ##
==========================================
+ Coverage 80.41% 80.45% +0.03%
==========================================
Files 376 376
Lines 98405 98401 -4
==========================================
+ Hits 79137 79167 +30
+ Misses 19268 19234 -34
🚀 New features to boost your workflow:
|
guess_payload_class() and both pre_dissect() loops re-sliced the remaining buffer for every header field, so dissecting a header with N fields copied the whole remainder N times. Add tcpros_iter_field_lengths(), which unpacks each length with struct.unpack_from() and advances an offset, and use it in the three places that walked the field list. The end-of-buffer check in guess_payload_class() becomes an offset comparison instead of comparing the declared length with the length of a freshly built slice. Cover the traversal, the offset start, a 300-field header and the conf.debug_dissector output in test/contrib/tcpros.uts.
63dbae4 to
0772fb7
Compare
|
The Codecov comment above predates the current head ( So the patch should be fully covered on re-run; the stale 86.67% is from the previous commit ( |
|
Pinging for review now that the checks are green. The change is contained to Happy to adjust the approach — e.g. keep the helper private to the module or inline it — if you would rather have it a different way. |
scapy/contrib/tcpros.pyparses its field lists by re-slicing the remaining buffer on every field (guess_payload_class,TCPROSHeader.pre_dissect,TCPROSBody.pre_dissect), so every field copies the rest of the buffer.This reads the field lengths in place with
struct.unpack_from()through a sharedtcpros_iter_field_lengths()helper. The parsing result is unchanged; on a header of 8000 fields,TCPROS.guess_payload_class()goes from 32.7 ms to 1.8 ms.Closes #5244
This message was written with the help of AI.