mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 19:17:28 +01:00
* 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>
34 lines
804 B
Go
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
|
|
}
|
|
}
|
|
}
|