Skip to content

Conversation

@BrianSipos
Copy link

@BrianSipos BrianSipos commented Nov 18, 2025

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 BrianSipos marked this pull request as ready for review November 18, 2025 02:30
@BrianSipos BrianSipos force-pushed the 4874-add-cbor-codec branch 2 times, most recently from da6269d to d8c22bd Compare November 18, 2025 03:22
@polybassa
Copy link
Contributor

@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
Copy link

codecov bot commented Nov 26, 2025

Codecov Report

❌ Patch coverage is 18.70702% with 591 lines in your changes missing coverage. Please review.
✅ Project coverage is 48.00%. Comparing base (3255441) to head (a5b8d37).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
scapy/contrib/bpv7.py 0.44% 225 Missing ⚠️
scapy/cbor.py 23.52% 208 Missing ⚠️
scapy/cborfields.py 30.90% 114 Missing ⚠️
scapy/cborpacket.py 27.86% 44 Missing ⚠️

❗ 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%> (ø)

... and 320 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@BrianSipos
Copy link
Author

@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.

@polybassa
Copy link
Contributor

@gpotter2 What do you think about using #4855 for this?

@polybassa
Copy link
Contributor

@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
Copy link
Author

@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.

@gpotter2
Copy link
Member

gpotter2 commented Dec 12, 2025

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..)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[enhancement] Handle CBOR-based protocols in a consistent way

3 participants