@@ -61,7 +61,7 @@ def _redact(d: dict[str, Any]) -> dict[str, Any]:
6161 for k , v in d .items ():
6262 if k in sensitive_keys :
6363 if isinstance (v , str ) and (is_mac_address (v ) or is_mac_address_mask (v )):
64- # Redact only the first 6 hex characters of a MAC address
64+ # Redact only the last part of a MAC address to a dummy value
6565 redacted_d [k ] = "00:11:22:33:" + v .replace ("-" , ":" ).upper ()[- 5 :]
6666 elif isinstance (v , str ) and is_ip_address (v ):
6767 # Redact to a dummy local IP address
@@ -71,6 +71,21 @@ def _redact(d: dict[str, Any]) -> dict[str, Any]:
7171 ):
7272 # Redact list of IPs to a dummy list
7373 redacted_d [k ] = ["127.0.0.3" ] # type: ignore[assignment]
74+ elif isinstance (v , list ) and all (
75+ isinstance (i , dict ) and "addr" in i and is_ip_address (i ["addr" ])
76+ for i in v
77+ ):
78+ # Redact list of dictionaries with IP addresses to a dummy list
79+ redacted_list = []
80+ for item in v :
81+ redacted_item = item .copy ()
82+ redacted_item ["addr" ] = (
83+ "127.0.0.3"
84+ if ipaddress .ip_address (redacted_item ["addr" ]).version == 4
85+ else "::1"
86+ )
87+ redacted_list .append (redacted_item )
88+ redacted_d [k ] = redacted_list # type: ignore[assignment]
7489 else :
7590 redacted_d [k ] = "REDACTED"
7691 elif isinstance (v , dict ):
0 commit comments