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

Function RedactRawSyncData

db/document.go:198–213  ·  view source on GitHub ↗

RedactRawSyncData runs HashRedact on the given sync data.

(syncData []byte, redactSalt string)

Source from the content-addressed store, hash-verified

196
197// RedactRawSyncData runs HashRedact on the given sync data.
198func RedactRawSyncData(syncData []byte, redactSalt string) ([]byte, error) {
199 if redactSalt == "" {
200 return nil, fmt.Errorf("redact salt must be set")
201 }
202
203 var sd SyncData
204 if err := json.Unmarshal(syncData, &sd); err != nil {
205 return nil, fmt.Errorf("couldn't unmarshal sync data: %w", err)
206 }
207
208 if err := sd.HashRedact(redactSalt); err != nil {
209 return nil, fmt.Errorf("couldn't redact sync data: %w", err)
210 }
211
212 return json.Marshal(sd)
213}
214
215// HashRedact does in-place redaction of UserData inside SyncData, by hashing channel names, user access, role access, and attachment names.
216func (sd *SyncData) 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