Skip to content

Commit

Permalink
fix(dependency): update cryptography import (apache#22744)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Draper <daniel.draper@understand.ai>
  • Loading branch information
2 people authored and PawankumarES committed Feb 13, 2023
1 parent 6563ad4 commit de23782
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
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
# 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:
"""
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

0 comments on commit de23782

Please sign in to comment.