fix: Address production audit gaps for v1.0.1#17
Merged
BitcoinErrorLog merged 2 commits intomainfrom Dec 12, 2025
Merged
Conversation
The storage-queue feature uses tokio::time::sleep for retry backoff but didn't include tokio as a dependency. This caused compilation errors when building examples with the storage-queue feature. Also fixes unused import warning in storage_queue example.
Security Improvements: - Rate limiter: Replace .unwrap() with graceful lock poisoning recovery - Session manager: Handle Mutex poisoning in ThreadSafeSessionManager - Identity payload: Add optional expires_at timestamp validation - Validates expiration BEFORE signature verification (fail-fast) - Backward compatible: None means no expiration check Bug Fixes: - Fix storage_queue example to compile without storage-queue feature - Clean up clippy warnings in example files Files changed: - src/rate_limiter.rs: 9 lock handling improvements - src/session_manager.rs: 8 lock handling improvements - src/identity_payload.rs: Add expires_at field - src/server.rs: Add timestamp validation - src/client.rs: Support expires_at in handshake - examples/storage_queue.rs: Fix conditional compilation - examples/*.rs: Fix clippy warnings - tests/*.rs: Update for new expires_at field - fuzz/fuzz_targets/fuzz_identity_payload.rs: Add expires_at fuzzing All tests pass. No breaking changes to paykit-rs integration.
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.
Summary
This PR addresses all critical, high-priority, and medium-priority issues identified in the production readiness audit.
Changes
Security Improvements
Lock Poisoning Resilience
unwrap_or_else(|e| e.into_inner())instead of.unwrap(), preventing panics if a thread panics while holding a lock (9 instances fixed)ThreadSafeSessionManagernow handles lock poisoning gracefully (8 instances fixed)Optional Timestamp Validation
expires_at: Option<u64>field for defense-in-depth timestamp validationNonemeans no expiration check (existing behavior)Bug Fixes
examples/storage_queue.rsto compile withoutstorage-queuefeaturecargo test --allfailureCode Quality
examples/xx_pattern.rs: Fixed unused variables and needless borrowsexamples/server_example.rs: Fixed needless borrows and inefficient.iter().cloned().collect()examples/error_handling.rs: Fixed literal format stringsTesting
cargo build --all-targets --all-featurespassescargo test --allpasses (96 tests)cargo clippy --all-targets --all-featurescleancargo doc --no-depscompilesBreaking Changes
None - All changes maintain backward compatibility:
expires_atfield defaults toNonevia serdeFiles Changed
src/rate_limiter.rs: Lock poisoning handlingsrc/session_manager.rs: Lock poisoning handlingsrc/identity_payload.rs: Addexpires_atfieldsrc/server.rs: Add timestamp validationsrc/client.rs: Supportexpires_atin handshakeexamples/storage_queue.rs: Fix conditional compilationexamples/*.rs: Fix clippy warningstests/*.rs: Update for newexpires_atfieldfuzz/fuzz_targets/fuzz_identity_payload.rs: Add expires_at fuzzingCHANGELOG.md: Document v1.0.1 changesPRODUCTION_AUDIT_REPORT.md: Updated audit status