Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_path_supports_emoji(self):
import bugsnag.wsgi.middleware
environ = self.environ.copy()
environ['PATH_INFO'] = '/😇'
config = Configuration()
notification = Notification(
Exception("oops"),
config,
RequestConfiguration.get_instance()
)
bugsnag.configure_request(wsgi_environ=environ)
bugsnag.wsgi.middleware.add_wsgi_request_data_to_notification(
notification
)
# You can validate this by using "encodeURIComponent" in a browser.
self.assertEqual(
'http://localhost/%F0%9F%98%87',
notification.meta_data['request']['url']
)
def test_path_supports_non_ascii_characters(self):
import bugsnag.wsgi.middleware
environ = self.environ.copy()
environ['PATH_INFO'] = '/ôßłガ'
config = Configuration()
notification = Notification(
Exception("oops"),
config,
RequestConfiguration.get_instance()
)
bugsnag.configure_request(wsgi_environ=environ)
bugsnag.wsgi.middleware.add_wsgi_request_data_to_notification(
notification
)
# You can validate this by using "encodeURIComponent" in a browser.
self.assertEqual(
'http://localhost/%C3%B4%C3%9F%C5%82%E3%82%AC',
notification.meta_data['request']['url']
)
def hello():
bugsnag.configure_request(meta_data=meta_data.pop())
raise SentinelError("oops")
def test_wrongly_encoded_url_should_not_raise(self):
import bugsnag.wsgi.middleware
environ = self.environ.copy()
environ['PATH_INFO'] = '/%83'
bugsnag.configure_request(wsgi_environ=environ)
config = Configuration()
notification = Notification(
Exception("oops"),
config,
RequestConfiguration.get_instance()
)
bugsnag.wsgi.middleware.add_wsgi_request_data_to_notification(
notification
)
# We have to use "urllib.parse.quote" here because the exact output
# differs on different Python versions because of how they handle
# invalid encoding sequences
self.assertEqual(
def __init__(self, environ, start_response):
bugsnag.configure_request(meta_data={"account":
{"paying": True}})
def wrapper(*args, **kwargs):
token = request.auth_token
if not token:
raise http_errors.Unauthorized(messages.missing_auth_token)
elif not safe_str_cmp(str(token), g.toolbox_auth_token):
raise http_errors.Unauthorized(messages.invalid_auth_token)
user_id = request.user_id
if not user_id:
raise http_errors.Unauthorized(messages.missing_user_id)
bugsnag.configure_request(user={"id": user_id})
newrelic_agent.add_custom_parameter('userId', user_id)
return handler(*args, **kwargs)
def process_request(self, request):
bugsnag.configure_request(django_request=request)
return None
def __init__(self, application, environ, start_response):
self.environ = environ
bugsnag.configure_request(wsgi_environ=self.environ)
try:
if bugsnag.configuration.auto_capture_sessions:
bugsnag.start_session()
self.app = application(environ, start_response)
except Exception as e:
bugsnag.auto_notify(
e,
severity_reason=self.SEVERITY_REASON
)
raise
if not prefs.getBooleanPref("analytics_enabled"):
return
try:
import bugsnag
from bugsnag.handlers import BugsnagHandler
koDirSvc = components.classes["@activestate.com/koDirs;1"].getService()
bugsnag.configure(
api_key = prefs.getString("bugsnag_key"),
project_root = koDirSvc.installDir,
release_stage = i.buildFlavour,
app_version = i.version)
bugsnag.configure_request(extra_data = {
"platform": i.buildPlatform,
"release": i.osRelease,
"type": i.productType,
"version": i.version,
"build": i.buildNumber,
"releaseStage": i.buildFlavour
}, user = {"id": prefs.getString("analytics_ga_uid", "")})
# Hook it up to our loggers
logger = logging.getLogger()
logger.addHandler(BugsnagHandler())
except Exception as e:
log.error("Failed starting bugsnag error reporter: %s" % e.message)