Skip to content

Commit 0a475af

Browse files
authored
Merge branch 'main' into ecs-docker-id
2 parents c339504 + c07d6f4 commit 0a475af

File tree

15 files changed

+186
-84
lines changed

15 files changed

+186
-84
lines changed

.github/workflows/tests.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,47 @@ jobs:
5454
- name: Success
5555
run: echo "Success!"
5656

57+
# Upload Trivy data
58+
trivy:
59+
if: success() || failure() # Does not run on cancelled workflows
60+
runs-on: ubuntu-20.04
61+
needs:
62+
- tests
63+
64+
steps:
65+
# Git Checkout
66+
- name: Checkout Code
67+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 4.1.1
68+
with:
69+
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
70+
fetch-depth: 0
71+
72+
- name: Run Trivy vulnerability scanner in repo mode
73+
if: ${{ github.event_name == 'pull_request' }}
74+
uses: aquasecurity/[email protected]
75+
with:
76+
scan-type: 'fs'
77+
ignore-unfixed: true
78+
format: table
79+
exit-code: 1
80+
severity: 'CRITICAL,HIGH,MEDIUM,LOW'
81+
82+
- name: Run Trivy vulnerability scanner in repo mode
83+
if: ${{ github.event_name == 'schedule' }}
84+
uses: aquasecurity/[email protected]
85+
with:
86+
scan-type: 'fs'
87+
ignore-unfixed: true
88+
format: 'sarif'
89+
output: 'trivy-results.sarif'
90+
severity: 'CRITICAL,HIGH,MEDIUM,LOW'
91+
92+
- name: Upload Trivy scan results to GitHub Security tab
93+
if: ${{ github.event_name == 'schedule' }}
94+
uses: github/codeql-action/upload-sarif@v3
95+
with:
96+
sarif_file: 'trivy-results.sarif'
97+
5798
# Combine and upload coverage data
5899
coverage:
59100
if: success() || failure() # Does not run on cancelled workflows

newrelic/hooks/logger_loguru.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
_logger = logging.getLogger(__name__)
2727

2828
IS_PYPY = hasattr(sys, "pypy_version_info")
29-
LOGURU_VERSION = get_package_version_tuple("loguru")
3029
LOGURU_FILTERED_RECORD_ATTRS = {"extra", "message", "time", "level", "_nr_original_message", "record"}
3130
ALLOWED_LOGURU_OPTIONS_LENGTHS = frozenset((8, 9))
3231

@@ -69,7 +68,7 @@ def _nr_log_forwarder(message_instance):
6968
try:
7069
time = record.get("time", None)
7170
if time:
72-
time = int(time.timestamp()*1000)
71+
time = int(time.timestamp() * 1000)
7372
record_log_event(message, level_name, time, attributes=attrs)
7473
except Exception:
7574
pass
@@ -116,18 +115,15 @@ def _nr_log_patcher(record):
116115
record["_nr_original_message"] = message = record["message"]
117116
record["message"] = add_nr_linking_metadata(message)
118117

119-
if LOGURU_VERSION > (0, 6, 0):
120-
if original_patcher is not None:
121-
patchers = [p for p in original_patcher] # Consumer iterable into list so we can modify
122-
# Wipe out reference so patchers aren't called twice, as the framework will handle calling other patchers.
123-
original_patcher = None
124-
else:
125-
patchers = []
126-
127-
patchers.append(_nr_log_patcher)
128-
return patchers
118+
if original_patcher is not None:
119+
patchers = [p for p in original_patcher] # Consumer iterable into list so we can modify
120+
# Wipe out reference so patchers aren't called twice, as the framework will handle calling other patchers.
121+
original_patcher = None
129122
else:
130-
return _nr_log_patcher
123+
patchers = []
124+
125+
patchers.append(_nr_log_patcher)
126+
return patchers
131127

132128

133129
def wrap_Logger_init(wrapped, instance, args, kwargs):

newrelic/packages/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
# This file is used by dependabot to keep track of and recommend updates
44
# to the New Relic Python Agent's dependencies in newrelic/packages/.
55
opentelemetry_proto==1.0.0
6-
urllib3==1.26.18
6+
urllib3==1.26.19
77
wrapt==1.16.0
88
asgiref==3.6.0 # We only vendor asgiref.compatibility.py

newrelic/packages/urllib3/LICENSE.txt

Lines changed: 0 additions & 21 deletions
This file was deleted.

newrelic/packages/urllib3/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,22 @@
1919
from .util.timeout import Timeout
2020
from .util.url import get_host
2121

22+
# === NOTE TO REPACKAGERS AND VENDORS ===
23+
# Please delete this block, this logic is only
24+
# for urllib3 being distributed via PyPI.
25+
# See: https://github.com/urllib3/urllib3/issues/2680
26+
try:
27+
import urllib3_secure_extra # type: ignore # noqa: F401
28+
except ImportError:
29+
pass
30+
else:
31+
warnings.warn(
32+
"'urllib3[secure]' extra is deprecated and will be removed "
33+
"in a future release of urllib3 2.x. Read more in this issue: "
34+
"https://github.com/urllib3/urllib3/issues/2680",
35+
category=DeprecationWarning,
36+
stacklevel=2,
37+
)
2238

2339
__author__ = "Andrey Petrov ([email protected])"
2440
__license__ = "MIT"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# This file is protected via CODEOWNERS
2-
__version__ = "1.26.18"
2+
__version__ = "1.26.19"

newrelic/packages/urllib3/connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class BrokenPipeError(Exception):
6868

6969
# When it comes time to update this value as a part of regular maintenance
7070
# (ie test_recent_date is failing) update it to ~6 months before the current date.
71-
RECENT_DATE = datetime.date(2022, 1, 1)
71+
RECENT_DATE = datetime.date(2024, 1, 1)
7272

7373
_CONTAINS_CONTROL_CHAR_RE = re.compile(r"[^-!#$%&'*+.^_`|~0-9a-zA-Z]")
7474

@@ -437,7 +437,7 @@ def connect(self):
437437
and self.ssl_version is None
438438
and hasattr(self.sock, "version")
439439
and self.sock.version() in {"TLSv1", "TLSv1.1"}
440-
):
440+
): # Defensive:
441441
warnings.warn(
442442
"Negotiating TLSv1/TLSv1.1 by default is deprecated "
443443
"and will be disabled in urllib3 v2.0.0. Connecting to "

newrelic/packages/urllib3/connectionpool.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,9 @@ def _is_ssl_error_message_from_http_proxy(ssl_error):
768768
# so we try to cover our bases here!
769769
message = " ".join(re.split("[^a-z]", str(ssl_error).lower()))
770770
return (
771-
"wrong version number" in message or "unknown protocol" in message
771+
"wrong version number" in message
772+
or "unknown protocol" in message
773+
or "record layer failure" in message
772774
)
773775

774776
# Try to detect a common user error with proxies which is to

newrelic/packages/urllib3/util/retry.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,9 @@ class Retry(object):
235235
RETRY_AFTER_STATUS_CODES = frozenset([413, 429, 503])
236236

237237
#: Default headers to be used for ``remove_headers_on_redirect``
238-
DEFAULT_REMOVE_HEADERS_ON_REDIRECT = frozenset(["Cookie", "Authorization"])
238+
DEFAULT_REMOVE_HEADERS_ON_REDIRECT = frozenset(
239+
["Cookie", "Authorization", "Proxy-Authorization"]
240+
)
239241

240242
#: Maximum backoff time.
241243
DEFAULT_BACKOFF_MAX = 120

setup.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,30 @@
1717

1818
python_version = sys.version_info[:2]
1919

20-
assert python_version >= (3, 7), "The New Relic Python agent only supports Python 3.7+."
20+
if python_version >= (3, 7):
21+
pass
22+
else:
23+
error_msg = "The New Relic Python agent only supports Python 3.7+. We recommend upgrading to a newer version of Python."
24+
25+
try:
26+
# Lookup table for the last agent versions to support each Python version.
27+
last_supported_version_lookup = {
28+
(2, 6): "3.4.0.95",
29+
(2, 7): "9.13.0",
30+
(3, 3): "3.4.0.95",
31+
(3, 4): "4.20.0.120",
32+
(3, 5): "5.24.0.153",
33+
(3, 6): "7.16.0.178",
34+
}
35+
last_supported_version = last_supported_version_lookup.get(python_version, None)
36+
37+
if last_supported_version:
38+
python_version_str = "%s.%s" % (python_version[0], python_version[1])
39+
error_msg += " The last agent version to support Python %s was v%s." % (python_version_str, last_supported_version)
40+
except Exception:
41+
pass
42+
43+
raise RuntimeError(error_msg)
2144

2245
with_setuptools = False
2346

0 commit comments

Comments
 (0)