From cecaa73f577a96f45b9e0f4e47700f091348e0aa Mon Sep 17 00:00:00 2001 From: tinlam Date: Wed, 20 Mar 2019 22:08:00 -0500 Subject: [PATCH] Remove extraneous dependency The rstr library relies on the normal random.SystemRandom() and does not perform additional functionalites that would require a whole dependency to be added to pegleg. This patch set places in the logic into pegleg's crypto generation rather than using the whole rstr library. Change-Id: I20c0ceae8ac7d11468f325cd6a4cc035fc176b14 Signed-off-by: Tin Lam --- pegleg/engine/util/cryptostring.py | 17 ++++++----------- requirements.txt | 1 - 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/pegleg/engine/util/cryptostring.py b/pegleg/engine/util/cryptostring.py index d50e6446..aee44209 100644 --- a/pegleg/engine/util/cryptostring.py +++ b/pegleg/engine/util/cryptostring.py @@ -12,9 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. - -from random import SystemRandom -from rstr import Rstr +import random import string __all__ = ['CryptoString'] @@ -24,14 +22,11 @@ class CryptoString(object): def __init__(self): self._pool = string.ascii_letters + string.digits + string.punctuation - self._rs = Rstr(SystemRandom()) + self._random = random.SystemRandom() - def get_crypto_string(self, len=24): + def get_crypto_string(self, length=24): """ - Create and return a random cryptographic string, - of the ``len`` length. + Create and return a random cryptographic string of length ``length``. """ - - if len < 24: - len = 24 - return self._rs.rstr(self._pool, len) + return ''.join(self._random.choice(self._pool) + for _ in range(max(24, length))) diff --git a/requirements.txt b/requirements.txt index 4f97c4c0..c369c097 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,6 @@ cryptography==2.3.1 python-dateutil==2.7.3 # External dependencies -rstr==2.2.6 git+https://github.com/openstack/airship-deckhand.git@49ad9f38842f7f1ecb86d907d86d332f8186eb8c git+https://github.com/openstack/airship-shipyard.git@44f7022df6438de541501c2fdd5c46df198b82bf#egg=shipyard_client&subdirectory=src/bin/shipyard_client git+https://github.com/openstack/airship-promenade.git@a6e8fdbe22bd153c78a008b92cd5d1c245bc63e3