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

Replace unmaintained pycrypto dependency with pycryptodome #6324

Merged
merged 2 commits into from
Jun 13, 2018
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
14 changes: 7 additions & 7 deletions config/galaxy.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -475,19 +475,19 @@ galaxy:
#default_job_shell: /bin/bash

# Citation related caching. Tool citations information maybe fetched
# from external sources such as http://dx.doi.org/ by Galaxy - the
# from external sources such as https://doi.org/ by Galaxy - the
# following parameters can be used to control the caching used to
# store this information.
#citation_cache_type: file

# Citation related caching. Tool citations information maybe fetched
# from external sources such as http://dx.doi.org/ by Galaxy - the
# from external sources such as https://doi.org/ by Galaxy - the
# following parameters can be used to control the caching used to
# store this information.
#citation_cache_data_dir: database/citations/data

# Citation related caching. Tool citations information maybe fetched
# from external sources such as http://dx.doi.org/ by Galaxy - the
# from external sources such as https://doi.org/ by Galaxy - the
# following parameters can be used to control the caching used to
# store this information.
#citation_cache_lock_dir: database/citations/lock
Expand Down Expand Up @@ -1178,10 +1178,10 @@ galaxy:
# Galaxy encodes various internal values when these values will be
# output in some format (for example, in a URL or cookie). You should
# set a key to be used by the algorithm that encodes and decodes these
# values. It can be any string up to 448 bits long. One simple way to
# generate a value for this is with the shell command: python -c
# 'from __future__ import print_function; import time;
# print(time.time())' | md5sum | cut -f 1 -d ' '
# values. It can be any string with a length between 5 and 56 bytes.
# One simple way to generate a value for this is with the shell
# command: python -c 'from __future__ import print_function; import
# time; print(time.time())' | md5sum | cut -f 1 -d ' '
#id_secret: USING THE DEFAULT IS NOT SECURE!

# User authentication can be delegated to an upstream proxy server
Expand Down
6 changes: 3 additions & 3 deletions config/tool_shed.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -323,19 +323,19 @@ tool_shed:
#brand: null

# Citation related caching. Tool citations information maybe fetched
# from external sources such as http://dx.doi.org/ by Galaxy - the
# from external sources such as https://doi.org/ by Galaxy - the
# following parameters can be used to control the caching used to
# store this information.
#citation_cache_type: file

# Citation related caching. Tool citations information maybe fetched
# from external sources such as http://dx.doi.org/ by Galaxy - the
# from external sources such as https://doi.org/ by Galaxy - the
# following parameters can be used to control the caching used to
# store this information.
#citation_cache_data_dir: database/citations/data

# Citation related caching. Tool citations information maybe fetched
# from external sources such as http://dx.doi.org/ by Galaxy - the
# from external sources such as https://doi.org/ by Galaxy - the
# following parameters can be used to control the caching used to
# store this information.
#citation_cache_lock_dir: database/citations/lock
Expand Down
21 changes: 11 additions & 10 deletions doc/source/admin/galaxy_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -846,8 +846,8 @@

:Description:
Citation related caching. Tool citations information maybe
fetched from external sources such as https://doi.org/ by Galaxy
- the following parameters can be used to control the caching used
fetched from external sources such as https://doi.org/ by Galaxy -
the following parameters can be used to control the caching used
to store this information.
:Default: ``file``
:Type: str
Expand All @@ -859,8 +859,8 @@

:Description:
Citation related caching. Tool citations information maybe
fetched from external sources such as https://doi.org/ by Galaxy
- the following parameters can be used to control the caching used
fetched from external sources such as https://doi.org/ by Galaxy -
the following parameters can be used to control the caching used
to store this information.
:Default: ``database/citations/data``
:Type: str
Expand All @@ -872,8 +872,8 @@

:Description:
Citation related caching. Tool citations information maybe
fetched from external sources such as https://doi.org/ by Galaxy
- the following parameters can be used to control the caching used
fetched from external sources such as https://doi.org/ by Galaxy -
the following parameters can be used to control the caching used
to store this information.
:Default: ``database/citations/lock``
:Type: str
Expand Down Expand Up @@ -2440,10 +2440,11 @@
Galaxy encodes various internal values when these values will be
output in some format (for example, in a URL or cookie). You
should set a key to be used by the algorithm that encodes and
decodes these values. It can be any string up to 448 bits long.
One simple way to generate a value for this is with the shell
command: python -c 'from __future__ import print_function;
import time; print(time.time())' | md5sum | cut -f 1 -d ' '
decodes these values. It can be any string with a length between 5
and 56 bytes. One simple way to generate a value for this is with
the shell command: python -c 'from __future__ import
print_function; import time; print(time.time())' | md5sum | cut -f
1 -d ' '
:Default: ``USING THE DEFAULT IS NOT SECURE!``
:Type: str

Expand Down
6 changes: 4 additions & 2 deletions lib/galaxy/datatypes/display_applications/util.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from Crypto.Cipher import Blowfish

from galaxy.util import smart_str


def encode_dataset_user(trans, dataset, user):
# encode dataset id as usual
Expand All @@ -11,7 +13,7 @@ def encode_dataset_user(trans, dataset, user):
user_hash = str(user.id)
# Pad to a multiple of 8 with leading "!"
user_hash = ("!" * (8 - len(user_hash) % 8)) + user_hash
cipher = Blowfish.new(str(dataset.create_time))
cipher = Blowfish.new(smart_str(dataset.create_time), mode=Blowfish.MODE_ECB)
user_hash = cipher.encrypt(user_hash).encode('hex')
return dataset_hash, user_hash

Expand All @@ -25,7 +27,7 @@ def decode_dataset_user(trans, dataset_hash, user_hash):
if user_hash in [None, 'None']:
user = None
else:
cipher = Blowfish.new(str(dataset.create_time))
cipher = Blowfish.new(smart_str(dataset.create_time), mode=Blowfish.MODE_ECB)
user_id = cipher.decrypt(user_hash.decode('hex')).lstrip("!")
user = trans.sa_session.query(trans.app.model.User).get(int(user_id))
assert user, "A Bad user id was passed to decode_dataset_user"
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/dependencies/pipfiles/default/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ PyYAML = "*"
SQLAlchemy = "*"
SQLAlchemy-Utils = "*"
Mercurial = {version = "<=3.7.3", markers = "python_version < '3'"}
pycrypto = "*"
pycryptodome = "*"
uWSGI = "*"
pysam = "==0.14.1"
bdbag = "*"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ asn1crypto==0.24.0
babel==2.5.3
bagit==1.6.4
bcrypt==3.1.4
bdbag==1.2.4
bdbag==1.3.0
beaker==1.9.1
bioblend==0.10.0
bleach==2.1.3
Expand Down Expand Up @@ -55,7 +55,7 @@ monotonic==1.4
msgpack==0.5.6
munch==2.3.1
netaddr==0.7.19
netifaces==0.10.6
netifaces==0.10.7
nose==1.3.7
numpy==1.14.2
oauthlib==2.0.7
Expand All @@ -81,8 +81,8 @@ pulsar-galaxy-lib==0.8.3
py2-ipaddress==3.4.1; python_version < '3'
pyasn1==0.4.2
pycparser==2.18
pycrypto==2.6.1
pycryptodomex==3.6.0
pycryptodome==3.6.1
pycryptodomex==3.6.1
pyjwkest==1.4.0
pyjwt==1.6.1
pykwalify==1.6.1
Expand Down
2 changes: 0 additions & 2 deletions lib/galaxy/dependencies/pipfiles/flake8/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/galaxy/web/security/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class SecurityHelper(object):
def __init__(self, **config):
id_secret = config['id_secret']
self.id_secret = id_secret
self.id_cipher = Blowfish.new(self.id_secret)
self.id_cipher = Blowfish.new(smart_str(self.id_secret), mode=Blowfish.MODE_ECB)

per_kind_id_secret_base = config.get('per_kind_id_secret_base', self.id_secret)
self.id_ciphers_for_kind = _cipher_cache(per_kind_id_secret_base)
Expand Down Expand Up @@ -116,7 +116,7 @@ def __init__(self, secret_base):
def __missing__(self, key):
assert len(key) < 15, KIND_TOO_LONG_MESSAGE
secret = self.secret_base + "__" + key
return Blowfish.new(_last_bits(secret))
return Blowfish.new(_last_bits(secret), mode=Blowfish.MODE_ECB)


def _last_bits(secret):
Expand Down
4 changes: 2 additions & 2 deletions lib/galaxy/webapps/galaxy/config_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1821,8 +1821,8 @@ mapping:
desc: |
Galaxy encodes various internal values when these values will be output in
some format (for example, in a URL or cookie). You should set a key to be
used by the algorithm that encodes and decodes these values. It can be any
string up to 448 bits long.
used by the algorithm that encodes and decodes these values. It can be any
string with a length between 5 and 56 bytes.
One simple way to generate a value for this is with the shell command:
python -c 'from __future__ import print_function; import time; print(time.time())' | md5sum | cut -f 1 -d ' '

Expand Down
14 changes: 0 additions & 14 deletions scripts/api/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import logging
import sys

from Crypto.Cipher import Blowfish
from six.moves.urllib.error import HTTPError
from six.moves.urllib.request import Request, urlopen

Expand Down Expand Up @@ -185,16 +184,3 @@ def delete(api_key, url, data, return_formatted=True):
print('Response')
print('--------')
print(r)


def encode_id(config_id_secret, obj_id):
"""
utility method to encode ID's
"""
id_cipher = Blowfish.new(config_id_secret)
# Convert to string
s = str(obj_id)
# Pad to a multiple of 8 with leading "!"
s = ("!" * (8 - len(s) % 8)) + s
# Encrypt
return id_cipher.encrypt(s).encode('hex')
4 changes: 2 additions & 2 deletions test/unit/test_security_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from galaxy.web import security


test_helper_1 = security.SecurityHelper(id_secret="sec1")
test_helper_2 = security.SecurityHelper(id_secret="sec2")
test_helper_1 = security.SecurityHelper(id_secret="secu1")
test_helper_2 = security.SecurityHelper(id_secret="secu2")


def test_maximum_length_handling_ascii():
Expand Down
4 changes: 2 additions & 2 deletions test/unit/unittest_utils/galaxy_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class MockAppConfig(Bunch):
def __init__(self, root=None, **kwargs):
Bunch.__init__(self, **kwargs)
root = root or '/tmp'
self.security = security.SecurityHelper(id_secret='bler')
self.security = security.SecurityHelper(id_secret='6e46ed6483a833c100e68cc3f1d0dd76')
self.use_remote_user = kwargs.get('use_remote_user', False)
self.file_path = '/tmp'
self.jobs_directory = '/tmp'
Expand Down Expand Up @@ -142,7 +142,7 @@ class MockWebapp(object):

def __init__(self, **kwargs):
self.name = kwargs.get('name', 'galaxy')
self.security = security.SecurityHelper(id_secret='bler')
self.security = security.SecurityHelper(id_secret='6e46ed6483a833c100e68cc3f1d0dd76')


class MockTrans(object):
Expand Down