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)
| 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. |
| 332 | func 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 | |
| 349 | func getObjectSchemaByPath(objectSchema *storepb.ObjectSchema, path *parserbase.PathAST) (*storepb.ObjectSchema, string) { |
| 350 | outer := objectSchema |
no test coverage detected