File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
Sources/Pulse/NetworkLogger Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -190,8 +190,20 @@ private extension Data {
190190private func _redactingSensitiveFields( _ value: Any , _ fields: Set < String > ) -> Any {
191191 switch value {
192192 case var object as [ String : Any ] :
193- for key in object. keys. filter ( fields. contains) {
194- object [ key] = " <private> "
193+ for key in object. keys {
194+ if fields. contains ( key) {
195+ // Redact any value (including objects and arrays) matching the key
196+ object [ key] = " <private> "
197+ } else if let value = object [ key] as? [ String : Any ] {
198+ // Recessively process values that are objects
199+ object [ key] = _redactingSensitiveFields ( value, fields)
200+ } else if var value = object [ key] as? [ Any ] {
201+ // Recessively process values that are arrays
202+ value = value. map ( { _redactingSensitiveFields ( $0, fields) } )
203+ object [ key] = value
204+ } else {
205+ // All other key/values are left untouched.
206+ }
195207 }
196208 return object
197209 case let array as [ Any ] :
You can’t perform that action at this time.
0 commit comments