mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Update Python and JS modules. Fixes #3154
This commit is contained in:
committed by
Dave Page
parent
fc886cf8bb
commit
be055ce57d
@@ -13,7 +13,7 @@ from collections import defaultdict
|
||||
from operator import attrgetter
|
||||
|
||||
from flask import Blueprint, current_app
|
||||
from flask_babel import gettext
|
||||
from flask_babelex import gettext
|
||||
|
||||
from .paths import get_storage_directory
|
||||
from .preferences import Preferences
|
||||
|
||||
@@ -14,7 +14,7 @@ import decimal
|
||||
|
||||
import simplejson as json
|
||||
from flask import Response
|
||||
from flask_babel import gettext as _
|
||||
from flask_babelex import gettext as _
|
||||
|
||||
|
||||
class DataTypeJSONEncoder(json.JSONEncoder):
|
||||
|
||||
@@ -28,11 +28,11 @@ def encrypt(plaintext, key):
|
||||
"""
|
||||
|
||||
iv = Random.new().read(AES.block_size)
|
||||
cipher = AES.new(pad(key), AES.MODE_CFB, iv)
|
||||
key = pad(key).encode('utf-8')
|
||||
cipher = AES.new(key, AES.MODE_CFB, iv)
|
||||
# If user has entered non ascii password (Python2)
|
||||
# we have to encode it first
|
||||
if hasattr(str, 'decode'):
|
||||
plaintext = plaintext.encode('utf-8')
|
||||
plaintext = plaintext.encode('utf-8')
|
||||
encrypted = base64.b64encode(iv + cipher.encrypt(plaintext))
|
||||
|
||||
return encrypted
|
||||
@@ -51,32 +51,33 @@ def decrypt(ciphertext, key):
|
||||
|
||||
ciphertext = base64.b64decode(ciphertext)
|
||||
iv = ciphertext[:AES.block_size]
|
||||
cipher = AES.new(pad(key), AES.MODE_CFB, iv)
|
||||
key = pad(key).encode('utf-8')
|
||||
cipher = AES.new(key, AES.MODE_CFB, iv)
|
||||
decrypted = cipher.decrypt(ciphertext[AES.block_size:])
|
||||
|
||||
return decrypted
|
||||
|
||||
|
||||
def pad(str):
|
||||
def pad(key):
|
||||
"""Add padding to the key."""
|
||||
|
||||
global padding_string
|
||||
str_len = len(str)
|
||||
str_len = len(key)
|
||||
|
||||
# Key must be maximum 32 bytes long, so take first 32 bytes
|
||||
if str_len > 32:
|
||||
return str[:32]
|
||||
return key[:32]
|
||||
|
||||
# If key size id 16, 24 or 32 bytes then padding not require
|
||||
if str_len == 16 or str_len == 24 or str_len == 32:
|
||||
return str
|
||||
return key
|
||||
|
||||
# Convert bytes to string (python3)
|
||||
if not hasattr(str, 'decode'):
|
||||
padding_string = padding_string.decode()
|
||||
|
||||
# Add padding to make key 32 bytes long
|
||||
return str + ((32 - len(str) % 32) * padding_string)
|
||||
return key + ((32 - str_len % 32) * padding_string)
|
||||
|
||||
|
||||
def pqencryptpassword(password, user):
|
||||
|
||||
@@ -15,7 +15,7 @@ object.
|
||||
"""
|
||||
import datetime
|
||||
from flask import session
|
||||
from flask_babel import gettext
|
||||
from flask_babelex import gettext
|
||||
import psycopg2
|
||||
from psycopg2.extensions import adapt
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ from collections import deque
|
||||
import simplejson as json
|
||||
import psycopg2
|
||||
from flask import g, current_app
|
||||
from flask_babel import gettext
|
||||
from flask_babelex import gettext
|
||||
from flask_security import current_user
|
||||
from pgadmin.utils.crypto import decrypt
|
||||
from psycopg2.extensions import adapt, encodings
|
||||
|
||||
@@ -14,7 +14,7 @@ import os
|
||||
import datetime
|
||||
from flask import current_app, session
|
||||
from flask_security import current_user
|
||||
from flask_babel import gettext
|
||||
from flask_babelex import gettext
|
||||
|
||||
from pgadmin.utils.crypto import decrypt
|
||||
from .connection import Connection
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
from abc import ABCMeta
|
||||
|
||||
from flask_babel import gettext
|
||||
from flask_babelex import gettext
|
||||
|
||||
|
||||
def _decorate_cls_name(module_name):
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
from werkzeug.exceptions import HTTPException
|
||||
from werkzeug.http import HTTP_STATUS_CODES
|
||||
from flask_babel import gettext as _
|
||||
from flask_babelex import gettext as _
|
||||
from flask import request
|
||||
|
||||
from pgadmin.utils.ajax import service_unavailable
|
||||
|
||||
@@ -17,7 +17,7 @@ import simplejson as json
|
||||
|
||||
import dateutil.parser as dateutil_parser
|
||||
from flask import current_app
|
||||
from flask_babel import gettext
|
||||
from flask_babelex import gettext
|
||||
from flask_security import current_user
|
||||
|
||||
from pgadmin.model import db, Preferences as PrefTable, \
|
||||
|
||||
Reference in New Issue
Block a user