Repository navigation
test(python-frame): pin the exact decrypt refusal per vector (LAB-8714) - #161
Conversation
The encrypted python-frame sweep checked only the 'decrypt failed: ' prefix, so a reader that stripped the CK frame or refused CK magic before AES-GCM still passed. Assert the exact message per row: short-ciphertext under 28 bytes (4 rows), authentication failure otherwise (27). AUTH_FAILURE moves to tests/common so both encryption suites share it.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. Summary by CodeRabbit
WalkthroughThe tests now use shared constants for encryption errors. Python frame vector tests check the exact error for each rejected vector based on whether its ciphertext is shorter than 28 bytes. ChangesEncryption test errors
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Other Merge Risk: ⚪ Minimal · up to The change strengthens the encryption-vector tests to distinguish malformed short ciphertext from authentication failures and catches the two described decrypt regressions. No concrete merge-blocking risk remains; normal checks suffice. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)✅ Passed checks (4 passed)
✨ 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 |
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Providing Context (Files & MCPs)Add these hints in your PR description (or a comment) to unlock deeper checks:
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
Pins the exact refusal message in
every_vector_is_refused_at_decrypt_by_an_encrypting_client. The test checked only thedecrypt failed:prefix, so its doc comment's account of how an encrypting reader refuses a CK frame (stored bytes go whole to AES-GCM) was prose, not a test.AUTH_FAILUREmoves fromencryption_vector_tests.rstotests/common/mod.rs; both suites use it. A newSHORT_CIPHERTEXTconstant holdsdecrypt failed: Invalid ciphertext format: Ciphertext too short.SHORT_CIPHERTEXTwhen its bytes are under 28 (nonce + tag),AUTH_FAILUREotherwise. The test asserts 31 rows, 4 of them short.Test code only; nothing under
src/, the vectors or the README changes.Mutants (not committed)
Each was applied to
EncryptionLayer::decrypt, and the test was run with its panic swapped for a report so every failing row is named. With the committed test, each mutant fails the test (first failureraw_payload_frame).Mutant A: refuse CK magic before AES-GCM
Fails all 29 CK rows on all three read paths (
get,interop_get,interop_get_swr): every row startingCKgets a third message that matches neither constant. The two non-CK rows (bare_envelope_fed_to_frame_reader,plain_msgpack_fed_to_frame_reader) pass, as expected.Mutant B: strip the CK frame, decrypt only the payload
Fails 3 rows on all three read paths, each getting
SHORT_CIPHERTEXTwhereAUTH_FAILUREis expected:raw_payload_frameandck_frame_fed_to_interop_reader: 100 bytes, 77-byte header, 16-byte payload.header_overrun_by_one: the declared header runs past the frame, so this mutant slices to the bytes present and is left with an empty payload.Every other CK row of 28 bytes or more keeps a payload of 28 bytes or more and still fails authentication, so it passes. If a re-vendor lengthens those three rows, this mutant survives again.
Checks run locally
cargo fmt --all -- --checkcargo clippy --all-targets --features "cachekitio,redis,encryption,l1,macros,memcached,file,tracing" -- -D warningscargo test --features "cachekitio,redis,encryption,l1,macros,memcached,file,tracing": all suites pass.Closes LAB-8714