MCPcopy Create free account
hub / github.com/coder/coder / redactJSONValue

Function redactJSONValue

coderd/x/chatd/chatdebug/redaction.go:246–280  ·  view source on GitHub ↗
(value any)

Source from the content-addressed store, hash-verified

244}
245
246func redactJSONValue(value any) (any, bool) {
247 switch typed := value.(type) {
248 case map[string]any:
249 changed := false
250 for key, child := range typed {
251 if isSensitiveJSONKey(key) {
252 if current, ok := child.(string); ok && current == RedactedValue {
253 continue
254 }
255 typed[key] = RedactedValue
256 changed = true
257 continue
258 }
259
260 redactedChild, childChanged := redactJSONValue(child)
261 if childChanged {
262 typed[key] = redactedChild
263 changed = true
264 }
265 }
266 return typed, changed
267 case []any:
268 changed := false
269 for i, child := range typed {
270 redactedChild, childChanged := redactJSONValue(child)
271 if childChanged {
272 typed[i] = redactedChild
273 changed = true
274 }
275 }
276 return typed, changed
277 default:
278 return value, false
279 }
280}

Callers 1

RedactJSONSecretsFunction · 0.85

Calls 1

isSensitiveJSONKeyFunction · 0.85

Tested by

no test coverage detected