Skip to content

Generic codec class - #5006

Open
polybassa wants to merge 7 commits into
secdev:masterfrom
polybassa:generic_codec
Open

Generic codec class#5006
polybassa wants to merge 7 commits into
secdev:masterfrom
polybassa:generic_codec

Conversation

@polybassa

Copy link
Copy Markdown
Contributor

This introduces common classes for shared code between codecs like CBOR and ASN.1

@codecov

codecov Bot commented May 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.50649% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.51%. Comparing base (5e13d41) to head (9d49b4f).
⚠️ Report is 30 commits behind head on master.

Files with missing lines Patch % Lines
scapy/libs/codec.py 93.10% 8 Missing ⚠️
scapy/asn1/ber.py 88.88% 1 Missing ⚠️
scapy/cbor/cborcodec.py 88.88% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5006   +/-   ##
=======================================
  Coverage   80.50%   80.51%           
=======================================
  Files         390      391    +1     
  Lines       96785    96741   -44     
=======================================
- Hits        77920    77893   -27     
+ Misses      18865    18848   -17     
Files with missing lines Coverage Δ
scapy/asn1fields.py 83.84% <100.00%> (-1.02%) ⬇️
scapy/asn1packet.py 90.00% <100.00%> (ø)
scapy/cbor/cborfields.py 77.83% <100.00%> (-0.02%) ⬇️
scapy/asn1/ber.py 86.38% <88.88%> (+0.26%) ⬆️
scapy/cbor/cborcodec.py 88.31% <88.88%> (+0.54%) ⬆️
scapy/libs/codec.py 93.10% <93.10%> (ø)

... and 5 files with indirect coverage changes

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

Copy link
Copy Markdown
Member

I think there are too much comments in this PR

@polybassa

Copy link
Copy Markdown
Contributor Author

Removed comments

@polybassa
polybassa requested a review from gpotter2 July 1, 2026 12:37
Nils Weiss added 7 commits August 1, 2026 13:14
…lementations

AI-Assisted: yes (GitHub CoPilot Auto)
…lementations

AI-Assisted: yes (GitHub CoPilot Auto)
AI-Assisted: no
AI-Assisted: no
AI-Assisted: no
AI-Assisted: yes (Cursor AI)
AI-Assisted: yes (Cursor)
@polybassa

Copy link
Copy Markdown
Contributor Author

@gpotter2 Updated, please have a look.

Comment thread scapy/asn1/ber.py
Comment on lines +295 to +298
_decoding_error_class = BER_Decoding_Error
_generic_error_classes = (BER_Decoding_Error, ASN1_Error)
_decoding_error_object_class = ASN1_DECODING_ERROR

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same than the other PR: if possible, can we move all the codec-specific utils to the 'codec' parameter (ASN1_Codecs.BER) ? I feel like it was designed this way, and it would likely be prettier in the long run

Comment thread scapy/cbor/cborcodec.py
Comment on lines +164 to +167
# Attributes consumed by GenericCodecObject.check_string and .dec
_decoding_error_class = CBOR_Codec_Decoding_Error
_generic_error_classes = (CBOR_Codec_Decoding_Error, CBOR_Error) # type: ignore
_decoding_error_object_class = CBOR_DECODING_ERROR

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Comment thread scapy/libs/codec.py
@@ -0,0 +1,229 @@
# SPDX-License-Identifier: GPL-2.0-only
# This file is part of Scapy
# See https://scapy.net/ for more information

@gpotter2 gpotter2 Aug 6, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might deserve to be in scapy/

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

Labels

None yet

2 participants