Skip to content

Commit c07d6f4

Browse files
authored
Merge pull request #1213 from newrelic/add-trivy
Add Trivy to CI
2 parents 85f4035 + f142815 commit c07d6f4

File tree

8 files changed

+67
-27
lines changed

8 files changed

+67
-27
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/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

0 commit comments

Comments
 (0)