Files
seaweedfs/weed/pb/filer_pb/entry_scrub.go
T
Chris LuandClaude Opus 5.5 d2ae75516c notification: keep chunk cipher keys out of webhook payloads (#13014)
* filer_pb: scrub cipher keys from both entries of an event

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* notification: keep chunk cipher keys out of webhook payloads

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 08:21:09 -08:00

34 lines
804 B
Go

package filer_pb
import "google.golang.org/protobuf/proto"
// ScrubCipherKeys returns a copy of entry with every chunk's CipherKey
// cleared, so logging it cannot leak per-chunk encryption keys.
func ScrubCipherKeys(entry *Entry) *Entry {
if entry == nil {
return nil
}
clone := proto.Clone(entry).(*Entry)
clearCipherKeys(clone)
return clone
}
// ScrubEventCipherKeys is ScrubCipherKeys for both entries of an event.
func ScrubEventCipherKeys(event *EventNotification) *EventNotification {
if event == nil {
return nil
}
clone := proto.Clone(event).(*EventNotification)
clearCipherKeys(clone.OldEntry)
clearCipherKeys(clone.NewEntry)
return clone
}
func clearCipherKeys(entry *Entry) {
for _, chunk := range entry.GetChunks() {
if chunk != nil {
chunk.CipherKey = nil
}
}
}