Secret masking

Secret data masking module.

exception cli2.mask.LearnedError[source]

Raised when a new value is learned, to run masking again.

class cli2.mask.Mask(keys=None, values=None, renderer=None, debug=False)[source]

Masking object that can learn values.

mask = cli2.Mask(keys=['password'], values=['secretval'])
result = mask(dict(password='xx', text='some secretval noise xx'))

Will cause result to be:

password: ***MASKED***
text: some ***MASKED*** noise ***MASKED***

Because:

  • secretval was given as a value to mask

  • password’s value because password was given as a key to match

  • the Mask object learned the value of the password key, and masked it in text

keys

Set of keys that contain values to mask

values

Set of values to mask

renderer

Optionnal callback to render discovered values to mask

debug

Enabled by the DEBUG environment variable, makes this a no-op (don’t mask anything).