Provide a diff feature that refine packet comparison#4779
Provide a diff feature that refine packet comparison#4779alxroyer-thales wants to merge 3 commits intosecdev:masterfrom
Conversation
- `ApproximateField` class added in 'fields.py'. - `PacketCmp` class added in a new 'diff.py' module, exported in 'all.py'. - 'test/diff.uts' unit test added.
|
Could you show a demo of what it does in action? Thanks. |
scapy/fields.py
Outdated
| # See https://scapy.net/ for more information | ||
| # Copyright (C) Philippe Biondi <phil@secdev.org> | ||
| # Copyright (C) Michael Farrell <micolous+git@gmail.com> | ||
| # Copyright (C) 2025 Thales |
There was a problem hiding this comment.
My personal opinion : this one is unecessary considering the changes in the file.
There was a problem hiding this comment.
I've set this line following our legal department recommendations.
Let me check with them.
Sure. It would be worth adding faithful documentation in the end if you validate this proposal. To reply quickly, here are extracts of outputs from the 'diff.uts' unit test I've proposed. Comparison of packet with exact matchMemo: The The lines after the The
Successful comparison with approximationComparison failure with aproximate field out of tolerance |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4779 +/- ##
==========================================
- Coverage 81.62% 81.02% -0.61%
==========================================
Files 358 366 +8
Lines 85652 89275 +3623
==========================================
+ Hits 69915 72336 +2421
- Misses 15737 16939 +1202
🚀 New features to boost your workflow:
|
polybassa
left a comment
There was a problem hiding this comment.
The code looks good so far, however, could you please add a few more unit tests with more complex packets as test cases.
|
|
||
| Uses :meth:`_debug()` for the purpose. | ||
| """ | ||
| if self._debug_logging_level is not None: |
There was a problem hiding this comment.
Redundant code. This is already tested in "self._debug"
|
|
||
| return DebugIndentationContext() | ||
|
|
||
| def _debug( |
There was a problem hiding this comment.
I'm not a fan of introducing a custom debug function in this class.
I suggest to use log_runtime by default and give the option to provide a custom logger in init:
def __init__(self, ..., logger = log_runtime):
self.logger = logger
Draft PR for #4739.
Initiated as a draft PR for preliminary discussions before an official delivery (not squashed yet).
To be discussed:
Checklist:
cd test && ./run_testsortox)