Ab.Transport: CIP codec hardening (bounds, path casts, immutable constants) #564

Closed
opened 2026-10-07 19:02:12 -04:00 by dohertj2 · 1 comment
Owner

Context: native .NET Allen-Bradley transport work (plan docs/plans/2026-10-07-native-ab-transport.md, branch feat/native-ab-transport, not yet merged). Parked as a Minor during per-task review — none of these block the plan.

Hardening items in the Ab.Transport CIP codec layer (src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Ab.Transport/Cip, Wire):

  • CipWriter.PatchU16 has no bounds guard.
  • CipReply.ExtendedStatus uses array reference equality (record equality over byte[]).
  • FromCip(0xFF, empty) mapping is untested.
  • CipPath: unchecked length/port casts; WithPathSize does not reject odd/oversize paths.
  • Malformed tag-name exceptions are not ArgumentException.
  • MessageRouter / ConnectionManager expose public mutable byte[] constants — make them ReadOnlySpan<byte>/ImmutableArray.
  • Refused Forward Open statuses surface only in the exception message, not as structured data.
  • Test-only CaptureFile still uses BitConverter (endianness-implicit).
Context: native .NET Allen-Bradley transport work (plan `docs/plans/2026-10-07-native-ab-transport.md`, branch `feat/native-ab-transport`, not yet merged). Parked as a Minor during per-task review — none of these block the plan. Hardening items in the `Ab.Transport` CIP codec layer (`src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Ab.Transport/Cip`, `Wire`): - [ ] `CipWriter.PatchU16` has no bounds guard. - [ ] `CipReply.ExtendedStatus` uses array reference equality (record equality over `byte[]`). - [ ] `FromCip(0xFF, empty)` mapping is untested. - [ ] `CipPath`: unchecked length/port casts; `WithPathSize` does not reject odd/oversize paths. - [ ] Malformed tag-name exceptions are not `ArgumentException`. - [ ] `MessageRouter` / `ConnectionManager` expose public mutable `byte[]` constants — make them `ReadOnlySpan<byte>`/`ImmutableArray`. - [ ] Refused Forward Open statuses surface only in the exception message, not as structured data. - [ ] Test-only `CaptureFile` still uses `BitConverter` (endianness-implicit).
dohertj2 added the driver/abcipdriver/ablegacy labels 2026-10-07 19:02:12 -04:00
Author
Owner

Fixed all items: PatchU16 bounds guard, content-equal CipReply, FromCip(0xFF, empty) test, CipPath port/length/ASCII/odd-size validation, malformed tag names → ArgumentException, MessageRouter/ConnectionManager as ReadOnlySpan, ForwardOpenRefusedException with structured General/Extended status, CaptureFile on BinaryPrimitives. (merge 13a67270 on master, pushed 2026-10-08)

Fixed all items: PatchU16 bounds guard, content-equal CipReply, FromCip(0xFF, empty) test, CipPath port/length/ASCII/odd-size validation, malformed tag names → ArgumentException, MessageRouter/ConnectionManager as ReadOnlySpan<byte>, ForwardOpenRefusedException with structured General/Extended status, CaptureFile on BinaryPrimitives. (merge `13a67270` on master, pushed 2026-10-08)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dohertj2/lmxopcua#564