Skip to content

chore(clippy): enforce production denies in CI#238

Merged
AlfioEmanueleFresta merged 4 commits into
masterfrom
chore/clippy-enforce-denies
May 30, 2026
Merged

chore(clippy): enforce production denies in CI#238
AlfioEmanueleFresta merged 4 commits into
masterfrom
chore/clippy-enforce-denies

Conversation

@AlfioEmanueleFresta
Copy link
Copy Markdown
Member

@AlfioEmanueleFresta AlfioEmanueleFresta commented May 30, 2026

The crate enables a set of strict clippy denies (no panic, unwrap, expect, or unchecked indexing in production code) but gates them on builds without the test or virt features. Every CI job builds with --all-features, which always enables virt, so the denies were switched off across the whole crate in CI and never actually ran. Real violations could land unnoticed, and a few had.

This regates the denies on the test feature alone, so production code stays linted even when virt is enabled. The virt test-utility code keeps the latitude it needs through small local allows, since its panics live on scattered match arms rather than a clean module we could exempt wholesale.

The change also clears the pre-existing violations that surface once the lint runs for real, in the WebAuthn client-data and assertion paths and the HID framing parser. There are no functional changes, and every feature combination builds clean under the enforced denies.

@AlfioEmanueleFresta AlfioEmanueleFresta changed the title Make the clippy production denies actually run in CI chore(clippy): enforce production denies in CI May 30, 2026
CI builds with --all-features, which disables the indexing_slicing deny,
so two ops-layer sites slipped through.

get_assertion: the SHA-256 digest is already 32 bytes, so convert it
into [u8; 32] instead of slicing finalize()[..32].

origin: use as_bytes().get(boundary) for the label-boundary check so an
out-of-range index cannot panic.
to_json serializes a fixed-shape struct of strings and a bool, which
serde_json cannot fail to encode. The API is intentionally infallible,
so allow expect_used on the function rather than threading a Result
through hash() and every caller.
HidMessageParser::update validated continuation packets by indexing
packet[4] and slicing packet[..4]. The length guard at the top of the
function keeps those in bounds, but the raw indexing trips
clippy::indexing_slicing. Use .get() and is_some_and so the accesses are
bounded at the call site, with no change in behaviour.
The denies (panic, unwrap, expect, indexing_slicing, and others) were
gated on not(any(test, feature = "virt")). Every CI job builds with
--all-features, so the virt feature was always on and the denies never
ran in CI. Violations could then land unnoticed.

Gate the denies on not(test) instead, so they cover production code even
when virt is enabled. The few virt test-utility match arms that panic on
a poisoned lock or mark an unreachable path keep a local allow. The
now-redundant module-level deny in psl is dropped.
@AlfioEmanueleFresta AlfioEmanueleFresta force-pushed the chore/clippy-enforce-denies branch from 98d7736 to 9e9be12 Compare May 30, 2026 16:25
@AlfioEmanueleFresta AlfioEmanueleFresta marked this pull request as ready for review May 30, 2026 16:25
@AlfioEmanueleFresta AlfioEmanueleFresta merged commit e104a65 into master May 30, 2026
6 checks passed
@AlfioEmanueleFresta AlfioEmanueleFresta deleted the chore/clippy-enforce-denies branch May 30, 2026 16:33
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