@@ -71,30 +71,30 @@ class SanitizeKeysProcessor(Processor):
7171
7272 MASK = '*' * 8
7373
74- def __init__ ( self , client ):
75- super ( SanitizeKeysProcessor , self ). __init__ ( client )
76- fields = getattr (client , 'sanitize_keys' )
77- if fields is None :
74+ @ property
75+ def sanitize_keys ( self ):
76+ keys = getattr (self . client , 'sanitize_keys' )
77+ if keys is None :
7878 raise ValueError ('The sanitize_keys setting must be present to use SanitizeKeysProcessor' )
79- self . fields = fields
79+ return keys
8080
81- def sanitize (self , key , value ):
81+ def sanitize (self , item , value ):
8282 if value is None :
8383 return
8484
85- if not key : # key can be a NoneType
85+ if not item : # key can be a NoneType
8686 return value
8787
8888 # Just in case we have bytes here, we want to make them into text
8989 # properly without failing so we can perform our check.
90- if isinstance (key , bytes ):
91- key = key .decode ('utf-8' , 'replace' )
90+ if isinstance (item , bytes ):
91+ item = item .decode ('utf-8' , 'replace' )
9292 else :
93- key = text_type (key )
93+ item = text_type (item )
9494
95- key = key .lower ()
96- for field in self .fields :
97- if field in key :
95+ item = item .lower ()
96+ for key in self .sanitize_keys :
97+ if key in item :
9898 # store mask as a fixed length for security
9999 return self .MASK
100100 return value
@@ -146,7 +146,8 @@ class SanitizePasswordsProcessor(SanitizeKeysProcessor):
146146 Asterisk out things that look like passwords, credit card numbers,
147147 and API keys in frames, http, and basic extra data.
148148 """
149- FIELDS = frozenset ([
149+
150+ KEYS = frozenset ([
150151 'password' ,
151152 'secret' ,
152153 'passwd' ,
@@ -158,12 +159,12 @@ class SanitizePasswordsProcessor(SanitizeKeysProcessor):
158159 ])
159160 VALUES_RE = re .compile (r'^(?:\d[ -]*?){13,16}$' )
160161
161- def __init__ ( self , client ):
162- super ( SanitizeKeysProcessor , self ). __init__ ( client ) # run the __init__ method of Processor, not SanitizeKeysProcessor
163- self . fields = self .FIELDS
162+ @ property
163+ def sanitize_keys ( self ):
164+ return self .KEYS
164165
165- def sanitize (self , key , value ):
166- value = super (SanitizePasswordsProcessor , self ).sanitize (key , value )
166+ def sanitize (self , item , value ):
167+ value = super (SanitizePasswordsProcessor , self ).sanitize (item , value )
167168 if isinstance (value , string_types ) and self .VALUES_RE .match (value ):
168169 return self .MASK
169170 return value
0 commit comments