[ablegacy] AbLegacy — ST string verification + length guard #353

Merged
dohertj2 merged 1 commits from auto/ablegacy/6 into auto/driver-gaps 2026-04-25 19:21:15 -04:00
Owner

Summary

Verifies libplctag's GetString/SetString round-trips ST-file strings (1-word length prefix + 82 ASCII bytes) and adds a client-side length guard.

  • LibplctagLegacyTagRuntime.EncodeValue — throws ArgumentOutOfRangeException for String writes > 82 chars (new StFileMaxStringLength constant).
  • AbLegacyDriver.WriteAsync — sibling catch (ArgumentOutOfRangeException) → BadOutOfRange clause so the OPC UA client gets a clean rejection instead of a silent libplctag truncation.

Test plan

  • dotnet build src/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy — clean (0 / 0)
  • dotnet test tests/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Tests312 / 312 passed (16 new in AbLegacyStringEncodingTests: empty / 41-char / 82-char-boundary / embedded-NUL / non-ASCII reads and writes for both Slc500 and Plc5 families; theory cases verifying >82-char writes return BadOutOfRange and never reach WriteAsync)
  • Integration tests — skipped (live PLC required)

🤖 Auto-generated by the Mode-B execution loop. Closes #249.

Closes #249

## Summary Verifies libplctag's `GetString`/`SetString` round-trips ST-file strings (1-word length prefix + 82 ASCII bytes) and adds a client-side length guard. - **`LibplctagLegacyTagRuntime.EncodeValue`** — throws `ArgumentOutOfRangeException` for `String` writes > 82 chars (new `StFileMaxStringLength` constant). - **`AbLegacyDriver.WriteAsync`** — sibling `catch (ArgumentOutOfRangeException) → BadOutOfRange` clause so the OPC UA client gets a clean rejection instead of a silent libplctag truncation. ## Test plan - [x] `dotnet build src/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy` — clean (0 / 0) - [x] `dotnet test tests/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Tests` — **312 / 312 passed** (16 new in `AbLegacyStringEncodingTests`: empty / 41-char / 82-char-boundary / embedded-NUL / non-ASCII reads and writes for both Slc500 and Plc5 families; theory cases verifying >82-char writes return `BadOutOfRange` and never reach `WriteAsync`) - [ ] Integration tests — skipped (live PLC required) 🤖 Auto-generated by the Mode-B execution loop. Closes #249. Closes #249
dohertj2 added 1 commit 2026-04-25 19:21:11 -04:00
Verifies libplctag's GetString/SetString round-trips ST file strings (1-word
length prefix + 82 ASCII bytes) end-to-end through the driver, and adds a
client-side length guard so over-82-char writes return BadOutOfRange instead
of being silently truncated by libplctag.

- LibplctagLegacyTagRuntime.EncodeValue: throws ArgumentOutOfRangeException
  for >82-char String writes (StFileMaxStringLength constant).
- AbLegacyDriver.WriteAsync: catches ArgumentOutOfRangeException and maps to
  BadOutOfRange.
- AbLegacyStringEncodingTests: 16 unit tests covering empty / 41-char /
  82-char / embedded-NUL / non-ASCII reads + writes; over-length writes
  return BadOutOfRange and never call WriteAsync; both Slc500 and Plc5
  family paths exercised.

Closes #249

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
dohertj2 merged commit 6743d51db8 into auto/driver-gaps 2026-04-25 19:21:15 -04:00
dohertj2 deleted branch auto/ablegacy/6 2026-04-25 19:21:16 -04:00
Sign in to join this conversation.