MCPcopy Create free account
hub / github.com/Hidden-Node/GooseRelayVPN-AndroidClient / redactJSONValue

Function redactJSONValue

cmd/client/diagnostics.go:235–268  ·  view source on GitHub ↗
(key string, v any)

Source from the content-addressed store, hash-verified

233}
234
235func redactJSONValue(key string, v any) any {
236 lowerKey := strings.ToLower(key)
237 switch x := v.(type) {
238 case map[string]any:
239 out := make(map[string]any, len(x))
240 for k, child := range x {
241 out[k] = redactJSONValue(k, child)
242 }
243 return out
244 case []any:
245 out := make([]any, len(x))
246 for i, child := range x {
247 if lowerKey == "script_keys" {
248 out[i] = redactScriptKeyEntry(child)
249 continue
250 }
251 out[i] = redactJSONValue(lowerKey, child)
252 }
253 return out
254 case string:
255 switch {
256 case lowerKey == "script_keys":
257 return redactSecretString(x, "deployment")
258 case lowerKey == "relay_urls" || lowerKey == "upstream_proxy":
259 return redactEndpoint(x)
260 case isSensitiveConfigKey(lowerKey):
261 return redactSecretString(x, "secret")
262 default:
263 return x
264 }
265 default:
266 return v
267 }
268}
269
270func redactScriptKeyEntry(v any) any {
271 switch x := v.(type) {

Callers 2

redactConfigJSONFunction · 0.85
redactScriptKeyEntryFunction · 0.85

Calls 4

redactScriptKeyEntryFunction · 0.85
redactSecretStringFunction · 0.85
redactEndpointFunction · 0.85
isSensitiveConfigKeyFunction · 0.85

Tested by

no test coverage detected