chore(clippy): enforce production denies in CI#238
Merged
Conversation
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.
98d7736 to
9e9be12
Compare
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.
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.