The Scrub Extension provides an easy mechanism for obfuscating sensitive information from command line output. It is useful for debugging and for providing end-user output to developers without including sensitive info like IP addresses, phone numbers, credit card numbers, etc.
Scrubbing happens in a
post_renderhook by iterating over the list of tuples in
re.sub()on the text provided by the output handler in use. Therefore, all output produced by
app.render()will be scrubbed… including JSON, YAML, or any other output handler.
- No external dependencies
This extension does not rely on any application level configuration settings or meta options.
This extension honors the following
A list of tuples in the form of
Example: Using Scrub Extension
from cement import App
label = 'myapp'
extensions = ['scrub', 'print']
scrub = [
# obfuscate ipv4 addresses
with MyApp() as app:
app.print('This is an IPv4 Address: 192.168.1.100')
$ python myapp.py
This is an IPv4 Address: 192.168.1.100
$ python myapp.py --scrub
This is an IPv4 Address: ***.***.***.***
In order for scrubbing to work, output must be rendered via a registered output handler. If only printing to console is desired, use the
app.print()(as in the above example).