Remove orb() - #5062
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5062 +/- ##
==========================================
- Coverage 80.59% 80.58% -0.02%
==========================================
Files 390 390
Lines 96841 96798 -43
==========================================
- Hits 78048 78003 -45
- Misses 18793 18795 +2
🚀 New features to boost your workflow:
|
gpotter2
force-pushed
the
orb-removal
branch
8 times, most recently
from
July 29, 2026 23:28
d6ce20c to
58652a8
Compare
AI-Assisted: yes (GPT-5.3-Codex)
AI-Assisted: no
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes the legacy orb() compatibility helper (previously used for Python 2/3 byte handling) and updates Scapy code/tests to use native Python 3 bytes/int semantics instead.
Changes:
- Removed
orb()fromscapy/compat.pyand eliminated related imports/usages across core layers and contrib modules. - Updated numerous protocol parsers/builders to use direct byte indexing (
b[0], iteration yielding ints) and adjusted a few string/bytes expectations in tests. - Refactored parts of the HTTP/2 HPACK implementation to operate more consistently on bytes (but a few regressions were introduced; see comments).
Reviewed changes
Copilot reviewed 86 out of 86 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/scapy/layers/tls/tls.uts | Remove orb() use in TLS test assertion. |
| test/scapy/layers/inet6.uts | Remove orb() use in IPv6 tests; adjust byte handling. |
| test/regression.uts | Drop orb references; update tests to pass bytes where required. |
| test/contrib/tcpao.uts | Remove orb() when parsing first byte for IP version. |
| test/contrib/mqttsn.uts | Use bytes literals instead of text strings for packet inputs. |
| test/contrib/http2.uts | Update expectations to match new HPACK decode return type. |
| scapy/utils6.py | Replace orb() byte conversions with direct indexing/iteration. |
| scapy/utils.py | Remove orb() use in byte formatting and sanitization utilities. |
| scapy/sessions.py | Replace XOR byte handling with direct int XOR from bytes iteration. |
| scapy/packet.py | Remove orb() use in canvas dump hex formatting. |
| scapy/modules/p0f.py | Replace TCP option parsing orb() calls with direct indexing. |
| scapy/modules/krack/crypto.py | Remove orb() in TKIP parsing/building paths. |
| scapy/libs/rfc3961.py | Replace orb() in DES parity/XOR helpers with direct byte ints. |
| scapy/layers/zigbee.py | Remove orb() from dispatch hook byte reads. |
| scapy/layers/x509.py | Switch ASN.1 BIT STRING defaults from "" to b"" where appropriate. |
| scapy/layers/vrrp.py | Replace orb() byte reads in dispatch hooks. |
| scapy/layers/tls/tools.py | Replace orb() for padding length extraction. |
| scapy/layers/tls/record.py | Replace orb() for message type/padlen extraction. |
| scapy/layers/tls/record_tls13.py | Replace orb() for record type extraction. |
| scapy/layers/tls/record_sslv2.py | Replace orb() for message type/padlen extraction. |
| scapy/layers/tls/keyexchange.py | Replace orb() when guessing curve type. |
| scapy/layers/tls/handshake.py | Replace orb() in handshake length packing. |
| scapy/layers/tls/basefields.py | Replace orb() in padding-length extraction. |
| scapy/layers/sixlowpan.py | Replace orb() in link-local address bit manipulation. |
| scapy/layers/sctp.py | Replace orb() in checksum/adler and payload guessing logic. |
| scapy/layers/pptp.py | Replace orb() in dispatch hook option selection. |
| scapy/layers/ppp.py | Replace orb() in multiple PPP dispatch hooks. |
| scapy/layers/ntp.py | Replace orb() for first-byte dispatch inspection. |
| scapy/layers/lltd.py | Replace orb() for flags/cmd extraction. |
| scapy/layers/llmnr.py | Replace orb() for response bit check. |
| scapy/layers/ipsec.py | Replace orb() for ESP padlen/next-header extraction. |
| scapy/layers/inet6.py | Replace orb() across multiple IPv6 parsing helpers. |
| scapy/layers/inet.py | Replace orb() in IP/TCP option parsing and header manipulation. |
| scapy/layers/eap.py | Replace orb() in EAP dispatch hook parsing. |
| scapy/layers/dot15d4.py | Replace orb() in FCS computation. |
| scapy/layers/dot11.py | Replace orb() in multiple 802.11 parsing/dispatch paths. |
| scapy/layers/dhcp6.py | Replace orb() in DHCPv6 type dispatch. |
| scapy/layers/dhcp.py | Replace orb() and ensure values passed to sane() are bytes. |
| scapy/layers/clns.py | Replace orb() in NLPID extraction. |
| scapy/layers/bluetooth4LE.py | Replace orb() in BLE bit swapping loop. |
| scapy/contrib/tzsp.py | Replace orb() for tag parsing and lengths. |
| scapy/contrib/tcpao.py | Replace orb() in TCP option parsing loop. |
| scapy/contrib/tacacs.py | Replace orb() with direct XOR of indexed ints. |
| scapy/contrib/scada/pcom.py | Replace orb() in checksum computation. |
| scapy/contrib/scada/iec104/iec104_fields.py | Replace orb() in sequence number parsing. |
| scapy/contrib/scada/iec104/init.py | Replace orb() in APCI/APDU parsing and checks. |
| scapy/contrib/rtr.py | Replace orb() for version/type extraction. |
| scapy/contrib/rpl_metrics.py | Replace orb() for option type extraction. |
| scapy/contrib/pnio_dcp.py | Replace orb() for option/suboption extraction. |
| scapy/contrib/pim.py | Replace orb() for TLV type extraction. |
| scapy/contrib/pfcp.py | Replace orb() in APN parsing and IE type extraction. |
| scapy/contrib/ospf.py | Replace orb() for LSA type extraction. |
| scapy/contrib/openflow3.py | Replace orb() for OXM/header byte extraction. |
| scapy/contrib/openflow.py | Replace orb() for version/type byte extraction. |
| scapy/contrib/mysql.py | Replace orb() for header/command byte parsing. |
| scapy/contrib/mqttsn.py | Replace orb() in variable-length parsing. |
| scapy/contrib/mqtt.py | Replace orb() in remaining-length decoding loop. |
| scapy/contrib/modbus.py | Replace orb() for function/sub-code extraction. |
| scapy/contrib/mac_control.py | Replace orb() in opcode extraction. |
| scapy/contrib/lldp.py | Replace orb() in TLV matching and TLV type parsing. |
| scapy/contrib/ldp.py | Replace orb() in mask/flags extraction. |
| scapy/contrib/isotp/isotp_scanner.py | Replace orb() in PCI/FC extraction and formatting. |
| scapy/contrib/isotp/isotp_packet.py | Replace orb() in PCI nibble parsing. |
| scapy/contrib/isis.py | Replace orb() in ID formatting and TLV type extraction. |
| scapy/contrib/http2.py | Remove orb() and refactor HPACK string handling and frame byte sizing. |
| scapy/contrib/gtp.py | Replace orb() in dispatch and field parsing. |
| scapy/contrib/gtp_v2.py | Replace orb() in IE/PCO dispatch parsing. |
| scapy/contrib/esmc.py | Replace orb() in payload dispatch. |
| scapy/contrib/eddystone.py | Replace orb() in URL encode/decode loops. |
| scapy/contrib/diameter.py | Replace orb() usage with bytes-aware iteration. |
| scapy/contrib/cdp.py | Replace orb() in length parsing and checksum padding logic. |
| scapy/contrib/bgp.py | Replace orb() in extensive BGP parsing/dispatch code. |
| scapy/contrib/automotive/uds.py | Replace orb() in single-layer service dispatch. |
| scapy/contrib/automotive/uds_scan.py | Replace orb() when building IntelHex output. |
| scapy/contrib/automotive/someip.py | Replace orb() in SD entry/option dispatch parsing. |
| scapy/contrib/automotive/scanner/enumerator.py | Replace orb() in response classification logic. |
| scapy/contrib/automotive/obd/obd.py | Replace orb() in single-layer service dispatch. |
| scapy/contrib/automotive/kwp.py | Replace orb() in single-layer service dispatch. |
| scapy/contrib/automotive/gm/gmlan.py | Replace orb() in single-layer service dispatch. |
| scapy/contrib/automotive/gm/gmlan_scanner.py | Replace orb() when building IntelHex output. |
| scapy/contrib/automotive/ecu.py | Replace orb() in response sorting key. |
| scapy/compat.py | Remove orb() from public API and exports. |
| scapy/cbor/cborcodec.py | Replace orb() in CBOR head decoding. |
| scapy/asn1/ber.py | Replace orb() in BER length/id/num decoding. |
| scapy/asn1/asn1.py | Update BIT STRING readable handling to be bytes-centric. |
| scapy/arch/init.py | Replace orb() in MAC formatting helper. |
Suppressed comments (2)
scapy/contrib/http2.py:1108
- huffman_decode() currently decodes the reconstructed byte string with the default UTF-8 codec. HPACK string literals are defined as opaque octet sequences, so decoding can raise UnicodeDecodeError for valid header values and prevents round-tripping non-UTF8 bytes. Use plain_str() (backslashreplace) for a safe textual representation instead.
s = b''.join(s)
return s.decode()
scapy/contrib/http2.py:1301
- HPackStrLenField.any2i() no longer accepts plain Python str values: it only handles bytes (parsed form) or HPackStringsInterface instances, so constructing HTTP/2/HPACK packets with normal string field values will assert/fail. Handle str by delegating to h2i() (i.e., wrap in HPackLiteralString).
if isinstance(x, bytes):
assert isinstance(pkt, packet.Packet)
return self.m2i(pkt, x)
assert isinstance(x, HPackStringsInterface)
return x
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
polybassa
approved these changes
Aug 14, 2026
Contributor
|
I Hope you could do most of that changes with a regex |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
orb, which was used for the Python 2 / Python 3 compatibility, but is no longer necessary.