MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / RedactRawGlobalSyncData

Function RedactRawGlobalSyncData

db/document.go:171–186  ·  view source on GitHub ↗

RedactRawGlobalSyncData runs HashRedact on the given global sync data.

(syncData []byte, redactSalt string)

Source from the content-addressed store, hash-verified

169
170// RedactRawGlobalSyncData runs HashRedact on the given global sync data.
171func RedactRawGlobalSyncData(syncData []byte, redactSalt string) ([]byte, error) {
172 if redactSalt == "" {
173 return nil, fmt.Errorf("redact salt must be set")
174 }
175
176 var gsd GlobalSyncData
177 if err := json.Unmarshal(syncData, &gsd); err != nil {
178 return nil, fmt.Errorf("couldn't unmarshal sync data: %w", err)
179 }
180
181 if err := gsd.HashRedact(redactSalt); err != nil {
182 return nil, fmt.Errorf("couldn't redact global sync data: %w", err)
183 }
184
185 return json.Marshal(gsd)
186}
187
188// HashRedact does in-place redaction of UserData inside GlobalSyncData, by hashing attachment names.
189func (gsd *GlobalSyncData) HashRedact(salt string) error {

Callers 1

GetRawDocMethod · 0.85

Calls 3

HashRedactMethod · 0.95
ErrorfMethod · 0.80
UnmarshalMethod · 0.45

Tested by

no test coverage detected