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

Function maskBySourcePaths

backend/api/v1/document_masking.go:332–347  ·  view source on GitHub ↗

maskBySourcePaths checks if any source field path resolves to a sensitive semantic type. Returns (maskedValue, true, nil) if masked, or (nil, false, nil) if no path is sensitive.

(value any, paths []*parserbase.PathAST, objectSchema *storepb.ObjectSchema, semanticTypeToMasker map[string]masker.Masker)

Source from the content-addressed store, hash-verified

330// maskBySourcePaths checks if any source field path resolves to a sensitive semantic type.
331// Returns (maskedValue, true, nil) if masked, or (nil, false, nil) if no path is sensitive.
332func maskBySourcePaths(value any, paths []*parserbase.PathAST, objectSchema *storepb.ObjectSchema, semanticTypeToMasker map[string]masker.Masker) (any, bool, error) {
333 for _, path := range paths {
334 ast := stripContainerFromPath(path)
335 _, parentSemanticType := getObjectSchemaByPath(objectSchema, ast)
336 if parentSemanticType != "" {
337 if m, ok := semanticTypeToMasker[parentSemanticType]; ok {
338 maskedValue, err := applyMaskerToJSONMember(value, m)
339 if err != nil {
340 return nil, false, err
341 }
342 return maskedValue, true, nil
343 }
344 }
345 }
346 return nil, false, nil
347}
348
349func getObjectSchemaByPath(objectSchema *storepb.ObjectSchema, path *parserbase.PathAST) (*storepb.ObjectSchema, string) {
350 outer := objectSchema

Callers 1

maskFieldBySourcePathsFunction · 0.85

Calls 3

stripContainerFromPathFunction · 0.85
getObjectSchemaByPathFunction · 0.85
applyMaskerToJSONMemberFunction · 0.85

Tested by

no test coverage detected