go.temporal.io/server/common/masker/masker.go

83 LOC · 45 covered · 38 uncovered · 12 ranges · 46 concepts · 4 introducers · 14 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the fileworkflow_handler.go ×11 · 117 introduced LOCworkflow_handler.go ×11common.go ×1 · 11 introduced LOCcommon.go ×1request_response.pb.go ×6 · 246 introduced LOCrequest_response.pb.go ×…visibility_store.go ×17 · 171 introduced LOCvisibility_store.go ×17telemetry.go ×2 · 15 introduced LOCtelemetry.go ×2fx.go ×1 · 4 introduced LOCfx.go ×1collector.go ×7 · 33 introduced LOCcollector.go ×7data_store_factory.go ×29 · 703 introduced LOCdata_store_factory.go ×2…TestNewServer · 0 introduced LOCTestNewServerpri_matcher.go ×1 · 2 introduced LOCpri_matcher.go ×1timer_queue_active_task_executor.go ×1 · 3 introduced LOCtimer_queue_active_task_…TestNewServer · 0 introduced LOCTestNewServermetric_client.go ×3 · 18 introduced LOCmetric_client.go ×3request_response.pb.go ×12 · 137 introduced LOCrequest_response.pb.go ×…workflow_task_completed_handler.go ×9 · 75 introduced LOCworkflow_task_completed_…pri_forwarder.go ×2 · 4 introduced LOCpri_forwarder.go ×2request_response.pb.go ×1 · 7 introduced LOCrequest_response.pb.go ×…logger.go ×1 · 5 introduced LOClogger.go ×1connections.go ×1 · 9 introduced LOCconnections.go ×1persistence_rate_limited_clients.go ×2 · 17 introduced LOCpersistence_rate_limited…logger.go ×1 · 2 introduced LOClogger.go ×1metric_client.go ×2 · 7 introduced LOCmetric_client.go ×2pri_matcher.go ×1 · 4 introduced LOCpri_matcher.go ×1task_queue_partition_manager.go ×2 · 10 introduced LOCtask_queue_partition_man…connections.go ×2 · 12 introduced LOCconnections.go ×2workflow_handler.go ×8 · 144 introduced LOCworkflow_handler.go ×8pri_matcher.go ×1 · 2 introduced LOCpri_matcher.go ×1handler.go ×1 · 20 introduced LOChandler.go ×1pri_matcher.go ×8 · 55 introduced LOCpri_matcher.go ×8matching_engine.go ×1 · 8 introduced LOCmatching_engine.go ×1server.go ×1 · 3 introduced LOCserver.go ×1logger.go ×2 · 21 introduced LOClogger.go ×2queue_scheduled.go ×1 · 2 introduced LOCqueue_scheduled.go ×1handler.go ×25 · 728 introduced LOChandler.go ×25endpoint_registry.go ×2 · 26 introduced LOCendpoint_registry.go ×2server.go ×3 · 13 introduced LOCserver.go ×3scanner.go ×1 · 2 introduced LOCscanner.go ×1mask_internal_error.go ×1 · 2 introduced LOCmask_internal_error.go ×…matching_engine.go ×2 · 5 introduced LOCmatching_engine.go ×2service_resolver.go ×4 · 49 introduced LOCservice_resolver.go ×4lite_server.go ×25 · 303 introduced LOClite_server.go ×25fx.go ×44 · 705 introduced LOCfx.go ×44masker.go ×6 · 21 introduced LOCmasker.go ×6masker.go ×4 · 18 introduced LOCmasker.go ×4masker.go ×1 · 2 introduced LOCmasker.go ×1masker.go ×1 · 4 introduced LOCmasker.go ×1TestMaskStruct · introduced test · go.temporal.io/server/common/masker/TestMaskStructTestMaskStructTestMaskStruct_Nil · introduced test · go.temporal.io/server/common/masker/TestMaskStruct_NilTestMaskStruct_NilTestMaskYaml · introduced test · go.temporal.io/server/common/masker/TestMaskYamlTestMaskYamlTestNewServer · introduced test · go.temporal.io/server/temporal/TestNewServerTestNewServerTestNewServerWithJSONEncoding · introduced test · go.temporal.io/server/temporal/TestNewServerWithJSONEncodingTestNewServerWithJSONEnc…with_OTEL_Collector_running · introduced test · go.temporal.io/server/temporal/TestNewServerWithOTEL/with_OTEL_Collector_runningwith_OTEL_Collector_runn…without_OTEL_Collector_running · introduced test · go.temporal.io/server/temporal/TestNewServerWithOTEL/without_OTEL_Collector_runningwithout_OTEL_Collector_r…ExampleNewServer · introduced test · go.temporal.io/server/temporaltest/ExampleNewServerExampleNewServerTestBaseServerOptions · introduced test · go.temporal.io/server/temporaltest/TestBaseServerOptionsTestBaseServerOptionsTestClientWithCustomInterceptor · introduced test · go.temporal.io/server/temporaltest/TestClientWithCustomInterceptorTestClientWithCustomInte…TestDefaultWorkerOptions · introduced test · go.temporal.io/server/temporaltest/TestDefaultWorkerOptionsTestDefaultWorkerOptionsTestNewServer · introduced test · go.temporal.io/server/temporaltest/TestNewServerTestNewServerTestNewWorkerWithOptions · introduced test · go.temporal.io/server/temporaltest/TestNewWorkerWithOptionsTestNewWorkerWithOptionsTestSearchAttributeRegistration · introduced test · go.temporal.io/server/temporaltest/TestSearchAttributeRegistrationTestSearchAttributeRegis…Focused file · go.temporal.io/server/common/masker/masker.go · 83 LOCmasker/masker.go

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 package masker
2
3 import (
4 "reflect"
5
6 "gopkg.in/yaml.v3"
7 )
8
9 const passwordMask = "******"
10
11 var (
12 DefaultFieldNames = []string{"Password", "KeyData"}
13 DefaultYAMLFieldNames = []string{"password", "keyData"}
14 )
15
16 // MaskYaml replace password values with mask and returns copy of the string.
17 // Does recursive replacement for entire yamlStr.
18 > func MaskYaml(yamlStr string, fieldNamesToMask []string) (string, error) { masker.go ×6
19 > fns := make(map[string]struct{}, len(fieldNamesToMask))
20 > for _, fieldName := range fieldNamesToMask {
21 > fns[fieldName] = struct{}{}
22 > }
23
24 > var parsedYaml map[string]any masker.go ×6
25 > err := yaml.Unmarshal([]byte(yamlStr), &parsedYaml)
26 > if err != nil {
27 return yamlStr, err
28 }
29
30 > maskMap(parsedYaml, fns) masker.go ×6
31 >
32 > strBytes, err := yaml.Marshal(parsedYaml)
33 > if err != nil {
34 return yamlStr, err
35 }
36 > return string(strBytes), nil masker.go ×6
37 }
38
39 // MaskStruct replace password values with mask and returns copy of the strct.
40 // Original strct value is not modified. Doesn't go recursively through strct properties.
41 > func MaskStruct(strct any, fieldNamesToMask []string) any { masker.go ×1
42 > strctV := reflect.ValueOf(strct)
43 >
44 > if strct == nil || (strctV.Kind() == reflect.Pointer && strctV.IsNil()) {
45 > return strct masker.go ×1
46 > }
47
48 > for t := reflect.TypeOf(strct); t.Kind() == reflect.Pointer; t = t.Elem() { masker.go ×4
49 > strctV = strctV.Elem()
50 > }
51
52 // strctV is not a pointer now. Create a copy using assignment.
53 > strctCopy := strctV.Interface() masker.go ×4
54 > strctCopyPV := pointerTo(strctCopy)
55 > strctCopyV := strctCopyPV.Elem()
56 >
57 > for _, passwordFieldName := range fieldNamesToMask {
58 > passwordF := strctCopyV.FieldByName(passwordFieldName)
59 > if passwordF.CanSet() && passwordF.Kind() == reflect.String {
60 > passwordF.SetString(passwordMask)
61 > }
62 }
63
64 > return strctCopyPV.Interface() masker.go ×4
65 }
66
67 > func pointerTo(val any) reflect.Value { masker.go ×4
68 > valPtr := reflect.New(reflect.TypeOf(val))
69 > valPtr.Elem().Set(reflect.ValueOf(val))
70 > return valPtr
71 > }
72
73 > func maskMap(m map[string]any, fns map[string]struct{}) { masker.go ×6
74 > for key, value := range m {
75 > if _, ok := fns[key]; ok {
76 > m[key] = passwordMask
77 > }
78
79 > if valueMap, ok := value.(map[string]any); ok { masker.go ×6
80 > maskMap(valueMap, fns)
81 > }
82 }
83 }