Skip to content

test(identify): cover the protobuf structure-scoring branch - #6

Merged
h4x0r merged 1 commit into
mainfrom
fix/coverage-identify
Aug 4, 2026
Merged

test(identify): cover the protobuf structure-scoring branch#6
h4x0r merged 1 commit into
mainfrom
fix/coverage-identify

Conversation

@h4x0r

@h4x0r h4x0r commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

The coverage gate on main named three uncovered lines, none annotated // cov:unreachable: the Confidence::Medium arm in detect_protobuf (identify.rs:478) and both counting arms in count_structure (504, 505).

All three are reachable from one input that no existing test built — a protobuf message whose length-delimited fields carry corroborating structure (a nested submessage and a string), scored without a stronger competing reading. A companion test feeds the identical bytes with strong_present = true, so the only thing that can move the verdict is the flag itself.

Tests only; no production code changes.

Verification — CI’s exact invocation, not a local approximation:

  • cargo llvm-cov --all-features --json + scripts/coverage-gate.pyOK: 100% line + function coverage
  • cargo fmt --all -- --check — clean
  • cargo clippy --workspace --all-targets --all-features -- -D warnings — clean
  • cargo test --workspace --all-features — all suites pass

The coverage gate named three uncovered lines, none annotated
`// cov:unreachable`: the `Confidence::Medium` arm in `detect_protobuf`
(identify.rs:478) and the two counting arms in `count_structure` (504, 505).

All three are reachable from one input, and no existing test built it. A
protobuf message scores Medium only when its length-delimited fields carry
corroborating structure -- a nested submessage or a string -- and no stronger
reading is competing. Opaque scalars alone stay Low, because a permissive
wire format parses plenty of byte runs by coincidence.

The fixture is hand-assembled so it reads as wire format rather than as an
opaque blob:

    0A 05 "hello"   field 1, LEN, five text bytes  -> a string
    12 02 08 01     field 2, LEN, holding `08 01`  -> a nested message

The second test feeds the same bytes with `strong_present = true`. The
structure is identical, so the only thing that can change the verdict is the
flag itself -- anything but a downgrade to Low would mean it is not consulted.

Tests only; no production code changes. Verified with CI's exact invocation
(`cargo llvm-cov --all-features` + `scripts/coverage-gate.py`), which now
reports 100% line and function coverage.
@h4x0r
h4x0r marked this pull request as ready for review August 4, 2026 04:04
@h4x0r
h4x0r merged commit 1338e5c into main Aug 4, 2026
14 of 15 checks passed
@h4x0r
h4x0r deleted the fix/coverage-identify branch August 9, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant