feat(msgpack): export check_msgpack_structure as the shared structural walk (LAB-2735) - #88
Conversation
…l walk (LAB-2735) The header-only MessagePack walk that ByteStorage::retrieve runs as its pre-scan is now public API, so SDKs that decode untrusted MessagePack themselves can call one shared walk instead of keeping copies that drift. The algorithm is unchanged. It needs no optional feature, takes the depth bound from the caller, and returns the bare reason for a rejection.
Code Review Could Not Complete
|
| Options | Enabled |
|---|---|
| Bug | ✅ |
| Performance | ✅ |
| Security | ✅ |
| Business Logic | ✅ |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: cachekit-io/cachekit-core/.coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (5)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. WalkthroughThe structural MessagePack check is now a public, feature-independent API. Envelope decoding uses the crate-root function with a depth limit of 100 and retains its pre-scan error mapping. The README and security documentation describe the API and rejection messages. ChangesMessagePack structural check
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~12 minutes Change: Feature Merge Risk: ⚪ Minimal · up to The change exposes the structural check while preserving the described envelope pre-scan behavior. No actionable merge-blocking regression is established in the supplied review context. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The public API preserves the existing envelope protections and clearly documents its structural-only limits. No introduced security defect was established. Downstream integration remains unverified, so callers’ handling of depth limits and complete validation is still uncertain. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 3 files. (2 skipped: 2 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Makes
check_msgpack_structure(bytes, max_depth), the header-only MessagePack walk thatByteStorage::retrieveandvalidatealready run as their pre-scan, public API at the crate root. cachekit-py's extension and cachekit-rs each keep their own copy of this walk today. They will call this one instead, so there is one shared structural walk rather than three copies that can drift.What changed
check_msgpack_structureispuband re-exported ascachekit_core::check_msgpack_structure. The algorithm is byte-for-byte unchanged.--no-default-features. Only the unit test that builds a real envelope stays behind the envelope features.MAX_DEPTH = 100moved next todecode_envelopeinbyte_storage.rs, since it is the envelope's bound, not the walk's.decode_envelopekeeps itsdecode pre-scan:prefix.u64per open collection (8 KiB at depth 1024). It returns the bare reason with no prefix. It does not enforce the protocol's32..=1024range onmax_depth, so choosing the bound is the caller's job.SECURITY.md→ Envelope decode bounds and the README describe the public walk.Release
The commit type is
feat. Withbump-minor-pre-major, release-please will propose 0.7.0 rather than the pending 0.6.1. That matches how this crate has shipped every additive API so far (0.3.0, 0.6.0), and the SDKs that call the new function have to raise their pin to the release that carries it anyway. If this merges before the open release PR, one release carries both the envelope pre-scan and this export.Tests
Run locally:
cargo fmt --check,cargo clippy --all-features -- -D warnings,cargo test --all-features(including the new doc-test andtests/decode_bounds_vectors.rs,tests/wire_format_vectors.rs,tests/dual_decode.rs),cargo test --features ffi, andcargo test --no-default-features --lib msgpack_bounds.cargo clippy --no-default-features -- -D warningsreports the same twobyte_storage.rswarnings asmain(an unusedInstantimport and an unreaddefault_formatfield) and nothing new.Summary by CodeRabbit