MCPcopy Create free account
hub / github.com/bytebase/bytebase / applyMaskerToData

Function applyMaskerToData

backend/api/v1/document_masking.go:495–524  ·  view source on GitHub ↗
(data any, m masker.Masker)

Source from the content-addressed store, hash-verified

493}
494
495func applyMaskerToData(data any, m masker.Masker) (any, error) {
496 switch data := data.(type) {
497 case map[string]any:
498 // Recursively apply the masker to the object.
499 for key, value := range data {
500 maskedValue, err := applyMaskerToData(value, m)
501 if err != nil {
502 return nil, err
503 }
504 data[key] = maskedValue
505 }
506 case []any:
507 // Recursively apply the masker to the array.
508 for i, value := range data {
509 maskedValue, err := applyMaskerToData(value, m)
510 if err != nil {
511 return nil, err
512 }
513 data[i] = maskedValue
514 }
515 default:
516 // Apply the masker to the atomic value.
517 if wrappedValue, ok := getRowValueFromJSONAtomicMember(data); ok {
518 maskedValue := m.Mask(&masker.MaskData{Data: wrappedValue})
519 return getJSONMemberFromRowValue(maskedValue), nil
520 }
521 }
522
523 return data, nil
524}
525
526func getJSONMemberFromRowValue(rowValue *v1pb.RowValue) any {
527 switch rowValue := rowValue.Kind.(type) {

Callers 4

walkAndMaskJSONRecursiveFunction · 0.85
maskElasticsearchHitSortFunction · 0.85

Calls 3

MaskMethod · 0.65

Tested by

no test coverage detected