From 7322d9a7cdc791dd67bcfe629f05c2d6745bee3f Mon Sep 17 00:00:00 2001 From: Tim Pansino Date: Fri, 5 Jan 2024 12:32:50 -0800 Subject: [PATCH] Squashed commit of the following: commit 3962f54d91bef1980523f40eb4649ef354634396 Author: Uma Annamalai Date: Thu Jan 4 12:50:58 2024 -0800 Remove case sensitive check in ASGIBrowserMiddleware check. (#1017) * Remove case sensitive check in should_insert_html. * [Mega-Linter] Apply linters fixes * Remove header decoding. --------- Co-authored-by: umaannamalai commit c3314aeac97b21615252f18c98384840a47db06f Author: Lalleh Rafeei <84813886+lrafeei@users.noreply.github.com> Date: Tue Jan 2 17:17:20 2024 -0800 Temporarily pin hypercorn version in tests (#1021) * Temporarily pin hypercorn to <0.16 * Temporarily pin hypercorn to <0.16 * Add comment to tox.ini --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> commit 13571451da8e48a8a2ea96d110e45b8e4ef537e3 Author: Uma Annamalai Date: Tue Jan 2 16:17:08 2024 -0800 Drop py27 from memcache testing. (#1018) commit 23f969fcfa9e1bf52e80766be0786152229cd43c Author: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> Date: Wed Dec 20 17:01:50 2023 -0800 Nonced CSP Support (#998) * Add nonce to CSP in browser agent * Adjust nonce position * Add testing for browser timing nonces --- newrelic/api/asgi_application.py | 4 +++- newrelic/api/web_transaction.py | 7 +++++++ tox.ini | 5 +++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/newrelic/api/asgi_application.py b/newrelic/api/asgi_application.py index cce08c0dc8..475faa7cbb 100644 --- a/newrelic/api/asgi_application.py +++ b/newrelic/api/asgi_application.py @@ -97,7 +97,9 @@ def should_insert_html(self, headers): content_type = None for header_name, header_value in headers: - # assume header names are lower cased in accordance with ASGI spec + # ASGI spec (https://asgi.readthedocs.io/en/latest/specs/www.html#http) states + # header names should be lower cased, but not required + header_name = header_name.lower() if header_name == b"content-type": content_type = header_value elif header_name == b"content-encoding": diff --git a/newrelic/api/web_transaction.py b/newrelic/api/web_transaction.py index 5416f2e802..1dfa390b6c 100644 --- a/newrelic/api/web_transaction.py +++ b/newrelic/api/web_transaction.py @@ -161,6 +161,13 @@ def _encode_nonce(nonce): return ' nonce="%s"' % ensure_str(nonce) # Extra space intentional +def _encode_nonce(nonce): + if not nonce: + return "" + else: + return ' nonce="%s"' % ensure_str(nonce) # Extra space intentional + + class WebTransaction(Transaction): unicode_error_reported = False QUEUE_TIME_HEADERS = ("x-request-start", "x-queue-start") diff --git a/tox.ini b/tox.ini index 1892876fac..b25b9e7adc 100644 --- a/tox.ini +++ b/tox.ini @@ -57,7 +57,7 @@ envlist = kafka-messagebroker_kafkapython-{py27,py38}-kafkapython{020001,020000}, kafka-messagebroker_kafkapython-{pypy27,py27,py37,py38,pypy38}-kafkapythonlatest, memcached-datastore_bmemcached-{pypy27,py27,py37,py38,py39,py310,py311,py312}-memcached030, - memcached-datastore_memcache-{py27,py37,py38,py39,py310,py311,py312,pypy27,pypy38}-memcached01, + memcached-datastore_memcache-{py37,py38,py39,py310,py311,py312,pypy38}-memcached01, memcached-datastore_pylibmc-{py27,py37}, memcached-datastore_pymemcache-{py27,py37,py38,py39,py310,py311,py312,pypy27,pypy38}, mongodb-datastore_pymongo-{py27,py37,py38,py39,py310,py311,py312,pypy27}-pymongo03, @@ -174,7 +174,8 @@ deps = adapter_gunicorn-aiohttp03-py312: aiohttp==3.9.0rc0 adapter_gunicorn-gunicorn19: gunicorn<20 adapter_gunicorn-gunicornlatest: gunicorn - adapter_hypercorn-hypercornlatest: hypercorn + ; Temporarily pinned. Needs to be addressed + adapter_hypercorn-hypercornlatest: hypercorn<0.16 adapter_hypercorn-hypercorn0013: hypercorn<0.14 adapter_hypercorn-hypercorn0012: hypercorn<0.13 adapter_hypercorn-hypercorn0011: hypercorn<0.12