mirror of
https://github.com/trufflesecurity/trufflehog.git
synced 2026-06-15 13:24:37 +00:00
* [secret-storage] Thread original chunk data through engine pipeline Adds OriginalData/ChunkData fields to preserve pre-decode source data through the scan pipeline: 1. Chunk.OriginalData: captures chunk.Data before iterativeDecode 2. engine.go: sets chunk.OriginalData = chunk.Data before decode 3. ResultWithMetadata.ChunkData: populated by CopyMetadata from OriginalData (falls back to Data when nil) This enables downstream consumers (e.g. the dispatcher in thog) to access the original source data for secret storage encryption. * Update TestChunkSize for OriginalData field addition Chunk struct grew from 80 to 104 bytes with the OriginalData []byte slice header (24 bytes). Field placement is already optimal (adjacent to Data []byte). * fix: preserve OriginalData field in EscapedUnicode decoder The EscapedUnicode decoder constructed a new sources.Chunk manually copying fields but omitted OriginalData. This caused CopyMetadata to fall back to the decoded Data instead of the original pre-decode content, defeating the purpose of preserving original chunk data for secret storage encryption. * Address PR review feedback: use testify/assert, add nil-guard comment, remove stale alignment comment --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com>
17 lines
444 B
Go
17 lines
444 B
Go
package sources
|
|
|
|
import (
|
|
"testing"
|
|
"unsafe"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
// TestChunkSize ensures that the Chunk struct does not exceed 104 bytes.
|
|
// Size increased from 80 to 104 with the addition of OriginalData []byte
|
|
// (24-byte slice header) for secret storage chunk threading.
|
|
func TestChunkSize(t *testing.T) {
|
|
t.Parallel()
|
|
assert.Equal(t, unsafe.Sizeof(Chunk{}), uintptr(104), "Chunk struct size exceeds 104 bytes")
|
|
}
|