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_contains_ignore_case_no_match(self):
matcher = 'contains-ignore-case'
kwlist = ['XXXXXX']
query_params = "one=1&Two=two&THREE=&4='+'&five='okyeah'"
stripped = strip_secrets(query_params, matcher, kwlist)
self.assertEqual(stripped, "one=1&Two=two&THREE=&4='+'&five='okyeah'")
def test_bad_kwlist(self):
matcher = 'equals'
kwlist = None
query_params = "one=1&Two=two&THREE=&4='+'&five='okyeah'"
stripped = strip_secrets(query_params, matcher, kwlist)
self.assertEqual(stripped, "one=1&Two=two&THREE=&4='+'&five='okyeah'")
def test_contains(self):
matcher = 'contains'
kwlist = ['fi']
query_params = "one=1&Two=two&THREE=&4='+'&five='okyeah'"
stripped = strip_secrets(query_params, matcher, kwlist)
self.assertEqual(stripped, "one=1&Two=two&THREE=&4='+'&five=")
def test_regex(self):
matcher = 'regex'
kwlist = [r"\d"]
query_params = "one=1&Two=two&THREE=&4='+'&five='okyeah'"
stripped = strip_secrets(query_params, matcher, kwlist)
self.assertEqual(stripped, "one=1&Two=two&THREE=&4=&five='okyeah'")
def test_equals_with_path_component(self):
matcher = 'equals'
kwlist = ['Two']
query_params = "/signup?one=1&Two=two&THREE=&4='+'&five='okyeah'"
stripped = strip_secrets(query_params, matcher, kwlist)
self.assertEqual(stripped, "/signup?one=1&Two=&THREE=&4='+'&five='okyeah'")
return res
ctx = tracer.extract(ot.Format.HTTP_HEADERS, env)
self.scope = tracer.start_active_span("wsgi", child_of=ctx)
if hasattr(agent, 'extra_headers') and agent.extra_headers is not None:
for custom_header in agent.extra_headers:
# Headers are available in this format: HTTP_X_CAPTURE_THIS
wsgi_header = ('HTTP_' + custom_header.upper()).replace('-', '_')
if wsgi_header in env:
self.scope.span.set_tag("http.%s" % custom_header, env[wsgi_header])
if 'PATH_INFO' in env:
self.scope.span.set_tag('http.path', env['PATH_INFO'])
if 'QUERY_STRING' in env and len(env['QUERY_STRING']):
scrubbed_params = strip_secrets(env['QUERY_STRING'], agent.secrets_matcher, agent.secrets_list)
self.scope.span.set_tag("http.params", scrubbed_params)
if 'REQUEST_METHOD' in env:
self.scope.span.set_tag(tags.HTTP_METHOD, env['REQUEST_METHOD'])
if 'HTTP_HOST' in env:
self.scope.span.set_tag("http.host", env['HTTP_HOST'])
return self.app(environ, new_start_response)