Repository navigation
fix(ospf,ngap): keep the parsed OSPF Packet Length and refuse octets after the NGAP-PDU - #1304
Conversation
|
Cross-review verdict on
|
|
Coverage: 88.91% (unit tier, Python 3.14,
Per-file detail: the |
…after the NGAP-PDU - OSPF: make() takes packet_length, and _make_data passes the parsed len, so the RFC 2328 D.4.3 digest outside Packet Length is no longer counted and a declared Length is not rewritten (#1249). Data without len falls back to 24 + len(payload); a packet_length that is not an int in 0..65535 raises ProtocolError. - OSPF: 8 raw octets are accepted as cryptographic auth_data and unpacked into the schema (#1250); auth_data of any other width raises ProtocolError instead of being padded or cut (#1251, OSPF half). - NGAP: octets after the aligned PER NGAP-PDU raise ProtocolError instead of being dropped (#1252). Closes #1249 Closes #1250 Closes #1252 Refs #1251
c777570 to
17bf03c
Compare
|
Round-2 verdict on
The round-1 One honesty note rather than a change: the PR body's |
make pylint,make mypy,make isort). I ran the Makefile's flags onospf.py/ngap.pyonly, notmake: they report nothing new.make testpasses, and a test case covers the change. I ran the touched modules one by one, plustests/projectand theprotocols --exclude protocols/internetunittest leg.What is the purpose of your pull request?
fix— corrects a defectDescription
Closes #1249
Closes #1250
Closes #1252
Refs #1251 (OSPF
auth_datahalf only; HTTP/2 PING is another PR)makerecomputes the Packet length from the payload and_make_datadrops the parsed one #1249:make()gainspacket_length(default24 + len(payload)) and_make_datapassesdata.len. It is not calledlength, because that name collides withProtocol.__init__(file, length).OSPF(auth_type=2, auth_data=<bytes>)raises AttributeError #1250, fix(httpv2,ospf):makesilently pads or truncates fixed-width inputs #1251: withauth_type=2, 8 raw octets are unpacked intoCryptographicAuthentication. Anyauth_datathat is not 8 octets raisesProtocolError.Charpy, and leftover octets raiseProtocolError: NGAP: N octet(s) after the NGAP-PDU.packet_length:Data_OSPFwithoutlenfalls back to24 + len(payload). A non-int, a bool, or a value outside 0–65535 raisesProtocolError.auth_dataand NGAP trailing octets now raise._make_encrypt_auth(bytes)returns a schema rather than bytes. Two existing tests pinned the old behaviour and are updated:test_ospf_unit.py(bytes were passed through_make_encrypt_auth) andtest_ngap_unit.py"trailing garbage".Probe (
OSPF.from_data(OSPF(w, len(w)).info)/NGAP): before the fix, the crypto+digest packet rebuilds as Length003c, and Lengths0000/001erebuild as002c.auth_type=2with bytes raisedAttributeError,b'abc'was padded, and NGAP+ffffcame back as 58 octets. After the fix, every OSPF repro rebuilds byte-exactly, and the bad inputs raiseProtocolError.Tests: new
test_ospf_ngap_roundtrip_unit.pygives8 passed, 21 subtests passed. Every new test fails without its fix; the exact-PDU case is a control. Other runs:test_ospf_unit3 passed,test_ngap_unit23 passed,test_ospf_cryptographic_authentication_unit4 passed,tests/project389 passed, 1 skipped, and the unittest leg 858 tests, 0 failures.