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.

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

2 participants