test(tools): extend decoder panic-safety guard to multi-param host decoders#69
Merged
Merged
Conversation
…coders The hex and text panic-safety guards in decoder_fuzz_safety_test.go only sweep decoders with exactly one required param (isPureHexDecoder / pureTextDecoderParam both gate on len(Required)==1). That leaves the multi-param host family — 15 tools today: the encoders (rfid_pacs_encode, ioprox_encode, dcf77_synth, noralsy/viking/jablotron/presco_encode), the KDFs (wpa_pmk_derive, hmac_compute, postgres_password, eth_keystore_decrypt) and the wifi_*_hc22000 hashcat-line formatters — with no panic guard at all, even though each parses structured hex / string / integer fields an operator may paste truncated or malformed. Add TestMultiParamDecoders_MalformedInputNeverPanics, completing the guard's stated mission (a new multi-field tool added without bounds-checking a short hex field or an out-of-range count would pass its own happy-path tests but trip here). It sweeps each required param across a type-aware degenerate battery — numeric params get boundary/overflow values, the rest get the truncated-hex / empty / stray-separator strings that historically tripped length-field parsers — while the other params hold a fixed degenerate anchor, plus an all-params-degenerate pass. A sanity floor (10+) guards against the filter silently going inert. All 15 currently pass; this locks that in. No production code change. Also fix a stale §1.1 coverage-matrix row in gap-analysis.md: HID Prox / EM4xxx PACS decode was listed as a NEW gap when rfid_pacs_decode (and the inverse rfid_pacs_encode) shipped long ago — the §3 backlog already marks it shipped; the matrix row lagged.
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.
What
The hex/text panic-safety guards in
decoder_fuzz_safety_test.goonly sweep decoders with exactly one required param (isPureHexDecoder/pureTextDecoderParamboth gate onlen(Required)==1). That leaves the multi-param host family — 15 tools today — with no panic guard at all, even though each parses structured hex/string/integer fields an operator may paste truncated or malformed:rfid_pacs_encode,ioprox_encode,dcf77_synth,noralsy_encode,viking_encode,jablotron_encode,presco_encode,subghz_weather_synth,subghz_pocsag_synth,ir_raw_encode,t5577_config_encodewpa_pmk_derive,hmac_compute,postgres_password,eth_keystore_decryptwifi_eapol_hc22000,wifi_pmkid_hc22000nfc_iso14443a_identifyChange
Adds
TestMultiParamDecoders_MalformedInputNeverPanics, completing the guard's stated mission. It sweeps each required param across a type-aware degenerate battery (numeric params → boundary/overflow values; everything else → truncated-hex / empty / stray-separator strings that historically tripped length-field parsers) while the other params hold a fixed degenerate anchor, plus an all-params-degenerate pass. Atested >= 10sanity floor guards against the filter silently going inert.All 15 currently pass — this is a regression lock, no production code change.
Also fixes a stale §1.1 coverage-matrix row in
gap-analysis.md: HID Prox / EM4xxx PACS decode was listed as a NEW gap whenrfid_pacs_decode(+ inverserfid_pacs_encode) shipped long ago. The §3 backlog already marks it shipped; the matrix row lagged.Verification
gofmtclean,go vet ./...cleangolangci-lint run ./...→ 0 issuesgo test -race ./internal/tools/→ok(161s); new guard sweeps 15 multi-param host decoders, all pass