Skip to content
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

fix(dependency): update cryptography import #22744

Merged
merged 9 commits into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ cron-descriptor==1.2.24
# via apache-superset
croniter==1.0.15
# via apache-superset
cryptography==3.4.7
cryptography==39.0.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strange change, prob joined the major and minor https://pypi.org/project/cryptography/#history

# via
# apache-superset
# paramiko
Expand Down Expand Up @@ -93,7 +93,9 @@ flask-compress==1.13
flask-jwt-extended==4.3.1
# via flask-appbuilder
flask-login==0.6.0
# via flask-appbuilder
# via
# apache-superset
# flask-appbuilder
flask-migrate==3.1.0
# via apache-superset
flask-sqlalchemy==2.5.1
Expand Down Expand Up @@ -150,7 +152,6 @@ markupsafe==2.1.1
# via
# jinja2
# mako
# werkzeug
# wtforms
marshmallow==3.13.0
# via
Expand Down Expand Up @@ -284,6 +285,7 @@ werkzeug==2.1.2
# via
# flask
# flask-jwt-extended
# flask-login
wtforms==2.3.3
# via
# apache-superset
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def get_git_sha() -> str:
"colorama",
"croniter>=0.3.28",
"cron-descriptor",
"cryptography>=3.3.2",
"cryptography>=39.0.0,<40",
"deprecation>=2.1.0, <2.2.0",
"flask>=2.1.3, <2.2",
"flask-appbuilder>=4.1.6, <5.0.0",
Expand Down
9 changes: 3 additions & 6 deletions superset/utils/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,8 @@
import numpy as np
import pandas as pd
import sqlalchemy as sa
from cryptography import x509
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.backends.openssl.x509 import _Certificate
from cryptography.x509 import Certificate, load_pem_x509_certificate
from flask import current_app, flash, g, Markup, render_template, request
from flask_appbuilder import SQLA
from flask_appbuilder.security.sqla.models import Role, User
Expand Down Expand Up @@ -1550,7 +1549,7 @@ def override_user(user: Optional[User], force: bool = True) -> Iterator[Any]:
delattr(g, "user")


def parse_ssl_cert(certificate: str) -> _Certificate:
def parse_ssl_cert(certificate: str) -> Certificate:
Germandrummer92 marked this conversation as resolved.
Show resolved Hide resolved
"""
Parses the contents of a certificate and returns a valid certificate object
if valid.
Expand All @@ -1560,9 +1559,7 @@ def parse_ssl_cert(certificate: str) -> _Certificate:
:raises CertificateException: If certificate is not valid/unparseable
"""
try:
return x509.load_pem_x509_certificate(
certificate.encode("utf-8"), default_backend()
)
return load_pem_x509_certificate(certificate.encode("utf-8"), default_backend())
except ValueError as ex:
raise CertificateException("Invalid certificate") from ex

Expand Down
1 change: 0 additions & 1 deletion tests/integration_tests/utils_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,6 @@ def test_merge_extra_filters_with_extras(self):
def test_ssl_certificate_parse(self):
parsed_certificate = parse_ssl_cert(ssl_certificate)
self.assertEqual(parsed_certificate.serial_number, 12355228710836649848)
self.assertRaises(CertificateException, parse_ssl_cert, "abc" + ssl_certificate)

def test_ssl_certificate_file_creation(self):
path = create_ssl_cert_file(ssl_certificate)
Expand Down