-
Notifications
You must be signed in to change notification settings - Fork 314
[develop] Upgrade connexion to 2.15.0rc3, upgrade Werkzeug to >=3.0.3 to address CVE-2024-34069 #6932
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
[develop] Upgrade connexion to 2.15.0rc3, upgrade Werkzeug to >=3.0.3 to address CVE-2024-34069 #6932
Conversation
…0 to address CVE. Upgrade serverless_wsgi.py to the latest version. Changes to encoder, flask_app and etc. to adapt the version bump.
@@ -108,7 +108,7 @@ | |||
"1", | |||
] | |||
|
|||
if headers.get("Host", "").endswith(".amazonaws.com") and not strip_stage_path: | |||
if "amazonaws.com" in headers.get("Host", "") and not strip_stage_path: |
Check failure
Code scanning / CodeQL
Incomplete URL substring sanitization High
amazonaws.com
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why changing this check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
serverless_wsgi.py is a file we simply copy paste from https://github.com/logandk/serverless-wsgi/blob/master/serverless_wsgi.py.
@@ -108,7 +108,7 @@ | |||
"1", | |||
] | |||
|
|||
if headers.get("Host", "").endswith(".amazonaws.com") and not strip_stage_path: | |||
if "amazonaws.com" in headers.get("Host", "") and not strip_stage_path: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why changing this check?
CHANGELOG.md
Outdated
@@ -31,6 +31,8 @@ CHANGELOG | |||
- Upgrade DCGM to version 4.2.3 (from 3.3.6) for all OSs except AL2. | |||
- Upgrade Python to 3.12.11 (from 3.12.8) for all OSs except AL2. | |||
- Upgrade Intel MPI Library to 2021.16.0 (from 2021.13.1). | |||
- Upgrade Connexion to ~=2.15.0rc3 (from ~=2.13.0). | |||
- Upgrade Werkzeug to >=3.0.3 (from ~=2.0) in response to this [security risk](https://nvd.nist.gov/vuln/detail/cve-2024-34069). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say "...to address CVE-2024-34069."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously there is one like:
- Upgrade Python from 3.7.10 to 3.7.13 in response to this security risk.
But I am fine with both approach.
"jmespath~=0.10", | ||
"jsii==1.85.0", | ||
"werkzeug>=3.0.3", | ||
"flask~=3.0", | ||
"packaging~=25.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we need to add packaging?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packaging
is in requirement.txt. I didn't add it. It was there but not in setup.py, so I added it here.
cli/src/pcluster/api/encoder.py
Outdated
|
||
from pcluster.api.models.base_model_ import Model | ||
from pcluster.utils import to_iso_timestr | ||
|
||
|
||
class JSONEncoder(FlaskJSONEncoder): | ||
class JSONEncoderForCli(json.JSONEncoder): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why ForCli
? This encoder is used also by the API. Why not keeping the original class name?
"REQUEST_METHOD": event.get("httpMethod", {}), | ||
"SCRIPT_NAME": script_name, | ||
"SERVER_NAME": headers.get("Host", "lambda"), | ||
"SERVER_PORT": headers.get("X-Forwarded-Port", "80"), | ||
"SERVER_PORT": headers.get("X-Forwarded-Port", "443"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and below, why do we need to change the port and protocol?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
serverless_wsgi.py is a file we simply copy paste from https://github.com/logandk/serverless-wsgi/blob/master/serverless_wsgi.py. Don't know why.
cli/src/pcluster/cli/entrypoint.py
Outdated
@@ -217,15 +217,15 @@ def _run_operation(model, args, extra_args): | |||
except Exception as e: | |||
# format exception messages in the same manner as the api | |||
message = pcluster.api.errors.exception_message(e) | |||
error_encoded = encoder.JSONEncoder().encode(message) | |||
error_encoded = encoder.JSONEncoderForCli().encode(message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to use the new Json encoder in entrypoint.py, but not in app.py?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not the new one, it's the old one actually. In connexion new v2 version(not 2.15.0rc3, but before it), the previous FlaskJSONEncoder was removed.
I renamed the two classes. Now it should be better.
cli/setup.py
Outdated
"jmespath~=0.10", | ||
"jsii==1.85.0", | ||
"werkzeug>=3.0.3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to accept only patch version upgrade (~=)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That means we can not get the 3.1.3 latest version. But you are right, we can not say werkzeug 4.0 in the future will not break our prod. I will do it in your way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally do ~=3.1
Description of changes
Tests
References
Checklist
develop
add the branch name as prefix in the PR title (e.g.[release-3.6]
).Please review the guidelines for contributing and Pull Request Instructions.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.