Remove non-inclusive language (#43)

Addresses #42

TODO: address pylint
This commit is contained in:
Steve Flanders
2020-09-08 20:06:47 -04:00
committed by GitHub
parent eaeb508242
commit ce66c8d458
9 changed files with 32 additions and 32 deletions

View File

@ -5,11 +5,11 @@
# run arbitrary code. # run arbitrary code.
extension-pkg-whitelist= extension-pkg-whitelist=
# Add files or directories to the blacklist. They should be base names, not # Add files or directories to the denylist. They should be base names, not
# paths. # paths.
ignore=CVS,gen ignore=CVS,gen
# Add files or directories matching the regex patterns to the blacklist. The # Add files or directories matching the regex patterns to the denylist. The
# regex matches against base names, not paths. # regex matches against base names, not paths.
ignore-patterns= ignore-patterns=

View File

@ -1,8 +1,8 @@
from ..utils.formats import flatten_dict from ..utils.formats import flatten_dict
BLACKLIST_ENDPOINT = ['kms', 'sts'] DENYLIST_ENDPOINT = ['kms', 'sts']
BLACKLIST_ENDPOINT_TAGS = { DENYLIST_ENDPOINT_TAGS = {
's3': ['params.Body'], 's3': ['params.Body'],
} }
@ -18,8 +18,8 @@ def truncate_arg_value(value, max_len=1024):
def add_span_arg_tags(span, endpoint_name, args, args_names, args_traced): def add_span_arg_tags(span, endpoint_name, args, args_names, args_traced):
if endpoint_name not in BLACKLIST_ENDPOINT: if endpoint_name not in DENYLIST_ENDPOINT:
blacklisted = BLACKLIST_ENDPOINT_TAGS.get(endpoint_name, []) denylisted = DENYLIST_ENDPOINT_TAGS.get(endpoint_name, [])
tags = dict( tags = dict(
(name, value) (name, value)
for (name, value) in zip(args_names, args) for (name, value) in zip(args_names, args)
@ -29,7 +29,7 @@ def add_span_arg_tags(span, endpoint_name, args, args_names, args_traced):
tags = { tags = {
k: truncate_arg_value(v) k: truncate_arg_value(v)
for k, v in tags.items() for k, v in tags.items()
if k not in blacklisted if k not in denylisted
} }
span.set_tags(tags) span.set_tags(tags)

View File

@ -17,7 +17,7 @@ NORMALIZE_PATTERN = re.compile(r'([^a-z0-9_\-:/]){1}')
def store_request_headers(headers, span, integration_config): def store_request_headers(headers, span, integration_config):
""" """
Store request headers as a span's tags Store request headers as a span's tags
:param headers: All the request's http headers, will be filtered through the whitelist :param headers: All the request's http headers, will be filtered through the allowlist
:type headers: dict or list :type headers: dict or list
:param span: The Span instance where tags will be stored :param span: The Span instance where tags will be stored
:type span: ddtrace.Span :type span: ddtrace.Span
@ -30,7 +30,7 @@ def store_request_headers(headers, span, integration_config):
def store_response_headers(headers, span, integration_config): def store_response_headers(headers, span, integration_config):
""" """
Store response headers as a span's tags Store response headers as a span's tags
:param headers: All the response's http headers, will be filtered through the whitelist :param headers: All the response's http headers, will be filtered through the allowlist
:type headers: dict or list :type headers: dict or list
:param span: The Span instance where tags will be stored :param span: The Span instance where tags will be stored
:type span: ddtrace.Span :type span: ddtrace.Span

View File

@ -86,15 +86,15 @@ class Config(object):
else: else:
self._config[integration] = IntegrationConfig(self, integration, settings) self._config[integration] = IntegrationConfig(self, integration, settings)
def trace_headers(self, whitelist): def trace_headers(self, allowlist):
""" """
Registers a set of headers to be traced at global level or integration level. Registers a set of headers to be traced at global level or integration level.
:param whitelist: the case-insensitive list of traced headers :param allowlist: the case-insensitive list of traced headers
:type whitelist: list of str or str :type allowlist: list of str or str
:return: self :return: self
:rtype: HttpConfig :rtype: HttpConfig
""" """
self._http.trace_headers(whitelist) self._http.trace_headers(allowlist)
return self return self
def header_is_traced(self, header_name): def header_is_traced(self, header_name):

View File

@ -11,30 +11,30 @@ class HttpConfig(object):
""" """
def __init__(self): def __init__(self):
self._whitelist_headers = set() self._allowlist_headers = set()
self.trace_query_string = None self.trace_query_string = None
@property @property
def is_header_tracing_configured(self): def is_header_tracing_configured(self):
return len(self._whitelist_headers) > 0 return len(self._allowlist_headers) > 0
def trace_headers(self, whitelist): def trace_headers(self, allowlist):
""" """
Registers a set of headers to be traced at global level or integration level. Registers a set of headers to be traced at global level or integration level.
:param whitelist: the case-insensitive list of traced headers :param allowlist: the case-insensitive list of traced headers
:type whitelist: list of str or str :type allowlist: list of str or str
:return: self :return: self
:rtype: HttpConfig :rtype: HttpConfig
""" """
if not whitelist: if not allowlist:
return return
whitelist = [whitelist] if isinstance(whitelist, str) else whitelist allowlist = [allowlist] if isinstance(allowlist, str) else allowlist
for whitelist_entry in whitelist: for allowlist_entry in allowlist:
normalized_header_name = normalize_header_name(whitelist_entry) normalized_header_name = normalize_header_name(allowlist_entry)
if not normalized_header_name: if not normalized_header_name:
continue continue
self._whitelist_headers.add(normalized_header_name) self._allowlist_headers.add(normalized_header_name)
return self return self
@ -46,9 +46,9 @@ class HttpConfig(object):
:rtype: bool :rtype: bool
""" """
normalized_header_name = normalize_header_name(header_name) normalized_header_name = normalize_header_name(header_name)
log.debug('Checking header \'%s\' tracing in whitelist %s', normalized_header_name, self._whitelist_headers) log.debug('Checking header \'%s\' tracing in allowlist %s', normalized_header_name, self._allowlist_headers)
return normalized_header_name in self._whitelist_headers return normalized_header_name in self._allowlist_headers
def __repr__(self): def __repr__(self):
return '<{} traced_headers={} trace_query_string={}>'.format( return '<{} traced_headers={} trace_query_string={}>'.format(
self.__class__.__name__, self._whitelist_headers, self.trace_query_string) self.__class__.__name__, self._allowlist_headers, self.trace_query_string)

View File

@ -390,7 +390,7 @@ Examples::
]) ])
The following rules apply: The following rules apply:
- headers configuration is based on a whitelist. If a header does not appear in the whitelist, it won't be traced. - headers configuration is based on a allowlist. If a header does not appear in the allowlist, it won't be traced.
- headers configuration is case-insensitive. - headers configuration is case-insensitive.
- if you configure a specific integration, e.g. 'requests', then such configuration overrides the default global - if you configure a specific integration, e.g. 'requests', then such configuration overrides the default global
configuration, only for the specific integration. configuration, only for the specific integration.

View File

@ -117,7 +117,7 @@ class BotocoreTest(BaseTracerTestCase):
self.assertEqual(spans[1].resource, 's3.putobject') self.assertEqual(spans[1].resource, 's3.putobject')
self.assertEqual(spans[1].get_tag('params.Key'), stringify(params['Key'])) self.assertEqual(spans[1].get_tag('params.Key'), stringify(params['Key']))
self.assertEqual(spans[1].get_tag('params.Bucket'), stringify(params['Bucket'])) self.assertEqual(spans[1].get_tag('params.Bucket'), stringify(params['Bucket']))
# confirm blacklisted # confirm denylisted
self.assertIsNone(spans[1].get_tag('params.Body')) self.assertIsNone(spans[1].get_tag('params.Body'))
@mock_sqs @mock_sqs

View File

@ -137,7 +137,7 @@ class TestHeaders(object):
}, span, integration_config) }, span, integration_config)
assert span.get_tag('http.response.headers.content-type') == ' some;value ' assert span.get_tag('http.response.headers.content-type') == ' some;value '
def test_no_whitelist(self, span, integration_config): def test_no_allowlist(self, span, integration_config):
""" """
:type span: Span :type span: Span
:type integration_config: IntegrationConfig :type integration_config: IntegrationConfig
@ -147,7 +147,7 @@ class TestHeaders(object):
}, span, integration_config) }, span, integration_config)
assert span.get_tag('http.response.headers.content-type') is None assert span.get_tag('http.response.headers.content-type') is None
def test_whitelist_exact(self, span, integration_config): def test_allowlist_exact(self, span, integration_config):
""" """
:type span: Span :type span: Span
:type integration_config: IntegrationConfig :type integration_config: IntegrationConfig
@ -158,7 +158,7 @@ class TestHeaders(object):
}, span, integration_config) }, span, integration_config)
assert span.get_tag('http.response.headers.content-type') == 'some;value' assert span.get_tag('http.response.headers.content-type') == 'some;value'
def test_whitelist_case_insensitive(self, span, integration_config): def test_allowlist_case_insensitive(self, span, integration_config):
""" """
:type span: Span :type span: Span
:type integration_config: IntegrationConfig :type integration_config: IntegrationConfig

View File

@ -47,7 +47,7 @@ class TestHttpConfig(BaseTestCase):
assert http_config.header_is_traced('some_header') assert http_config.header_is_traced('some_header')
assert not http_config.header_is_traced('some_other_header') assert not http_config.header_is_traced('some_other_header')
def test_trace_headers_whitelist_case_insensitive(self): def test_trace_headers_allowlist_case_insensitive(self):
http_config = HttpConfig() http_config = HttpConfig()
http_config.trace_headers('some_header') http_config.trace_headers('some_header')
assert http_config.header_is_traced('sOmE_hEaDeR') assert http_config.header_is_traced('sOmE_hEaDeR')