Add CBOR codec and BPv7 packet classes
This change addresses #4874 by adding new base scapy classes to encode and decode CBOR structure RFC 8949. This is in support of a new protocol support for BPv7 RFC 9171. This work was adapted from earlier out-of-source additions from dtn-demo-agent.
Both include a minimal set of unit tests to cover normal behavior. Since this is focused on immediate needs for BPv7 the CBOR fields and packets are not exhaustive.
Fixes #4874
@BrianSipos Thanks a lot for this PR.
Please have a look at the failing tests.
I would also recommend to move the CBOR implementation into "contrib".
Codecov Report
:x: Patch coverage is 18.70702% with 591 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 48.00%. Comparing base (3255441) to head (a5b8d37).
:warning: Report is 1 commits behind head on master.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| scapy/contrib/bpv7.py | 0.44% | 225 Missing :warning: |
| scapy/cbor.py | 23.52% | 208 Missing :warning: |
| scapy/cborfields.py | 30.90% | 114 Missing :warning: |
| scapy/cborpacket.py | 27.86% | 44 Missing :warning: |
:exclamation: There is a different number of reports uploaded between BASE (3255441) and HEAD (a5b8d37). Click for more details.
HEAD has 10 uploads less than BASE
Flag BASE (3255441) HEAD (a5b8d37) 12 2
Additional details and impacted files
@@ Coverage Diff @@
## master #4875 +/- ##
===========================================
- Coverage 80.87% 48.00% -32.88%
===========================================
Files 368 354 -14
Lines 90262 90663 +401
===========================================
- Hits 72998 43521 -29477
- Misses 17264 47142 +29878
| Files with missing lines | Coverage Δ | |
|---|---|---|
| scapy/all.py | 100.00% <100.00%> (ø) |
|
| scapy/cborpacket.py | 27.86% <27.86%> (ø) |
|
| scapy/cborfields.py | 30.90% <30.90%> (ø) |
|
| scapy/cbor.py | 23.52% <23.52%> (ø) |
|
| scapy/contrib/bpv7.py | 0.44% <0.44%> (ø) |
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
@polybassa one need for BPv7 is a CRC-16 and CRC-32C generator. Right now this uses crcmod package, which has not been updated in a while but is still recent Python compatible. Do you have any preference about how to generate CRC values? I don't see other packages used from other protocols in scapy.
@gpotter2 What do you think about using #4855 for this?
@BrianSipos We will merge #4855 into Scapy. However, we didn't decided yet into which directory. Can you use the crc implementation from this PR for your use case?
@BrianSipos We will merge #4855 into Scapy. However, we didn't decided yet into which directory. Can you use the crc implementation from this PR for your use case?
I believe so. The ones depended upon originally are well documented to be able to check known inputs.
Any idea if the CBOR portions of this PR are any more likely to be accepted than the other PR? When submitting this one, I didn't even realize there was an alternative one. The CBOR portion of this PR is, I believe, more general purpose and does not need any outside/new library dependencies for scapy.
Hi. Yeah we need to take the time to compare them both and get the best one (or take the good ideas and tests from both).
Sorry for the delay. (I should have much more time available around the holidays to review all of that..)