persist: add CRC32-C integrity check and seq validation to A/B files#3105
Open
wen-coding wants to merge 4 commits intomainfrom
Open
persist: add CRC32-C integrity check and seq validation to A/B files#3105wen-coding wants to merge 4 commits intomainfrom
wen-coding wants to merge 4 commits intomainfrom
Conversation
Add a crc32 field to PersistedWrapper covering seq and data (CRC32-C Castagnoli, matching the WAL library). On load, reject files with missing/zero seq or missing/mismatched crc32 as ErrCorrupt. This catches silent truncation and bit-rot that proto.Unmarshal alone would miss, since trailing optional fields can be silently lost. Made-with: Cursor
|
The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).
|
|
The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).
|
3 tasks
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3105 +/- ##
=======================================
Coverage 58.68% 58.68%
=======================================
Files 2096 2096
Lines 173248 173261 +13
=======================================
+ Hits 101667 101680 +13
Misses 62541 62541
Partials 9040 9040
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Avoid hash.Hash.Write (gosec G104) by chaining crc32.Update like the WAL library; document the parallel with Checksum/Update. Made-with: Cursor
…omment) Made-with: Cursor
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
crc32field toPersistedWrapperproto covering bothseqanddata(CRC32-C Castagnoli, matchingsei-tendermint/internal/libs/wal).seqor missing/mismatchedcrc32asErrCorrupt.proto.Unmarshalalone would miss, since trailing optional fields can be silently lost.Changes:
autobahn.proto: newoptional uint32 crc32 = 3onPersistedWrapperpersist.go:wrapperChecksum(seq, data)helper using CRC32-C over[8-byte LE seq || data]; validation inloadWrapped; checksum set inPersistpersist_test.go: tests for CRC32 mismatch (data corruption), CRC32 mismatch (seq corruption), missing CRC32, missing seq, zero seq, and CRC32 round-trip verificationTest plan
go vetcleanMade with Cursor