Update Python and JS modules. Fixes #3154

This commit is contained in:
Murtuza Zabuawala
2018-04-04 10:47:01 +01:00
committed by Dave Page
parent fc886cf8bb
commit be055ce57d
88 changed files with 182 additions and 173 deletions

View File

@@ -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

View File

@@ -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):

View File

@@ -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):

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -9,7 +9,7 @@
from abc import ABCMeta
from flask_babel import gettext
from flask_babelex import gettext
def _decorate_cls_name(module_name):

View File

@@ -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

View File

@@ -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, \