Skip to content

Instantly share code, notes, and snippets.

@ehfeng
Created July 30, 2018 22:52
Show Gist options
  • Save ehfeng/3c367653073fd5e860291edd9bf69152 to your computer and use it in GitHub Desktop.
Save ehfeng/3c367653073fd5e860291edd9bf69152 to your computer and use it in GitHub Desktop.
Scrubbing sensitive data with Sentry's Python SDK
from flask import Flask
from raven.contrib.flask import Sentry
app = Flask(__name__)
# To remove all client-side processors
# app.config['SENTRY_PROCESSORS'] = tuple()
# To specify which processors you'd like to use (because the raven flask plugin does not allow for a `processor` arg)
# app.config['SENTRY_PROCESSORS'] = ('raven.processors.SanitizePasswordsProcessor', )
sentry = Sentry(app)
@app.route('/')
def index():
# masked correctly
sentry.client.context.merge({'extra': {
'example': '4242424242424242'}})
# shows up in sentry wrapped in single quotes
example_var = "4242424242424242"
unfiltered_var = 'a'
raise Exception('baz')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment