validate galaxy server settings

involves some changes to the redact code
This commit is contained in:
AlanCoding
2019-08-27 11:32:35 -04:00
parent 093bf6877b
commit 8bda048e6d
2 changed files with 49 additions and 3 deletions

View File

@@ -15,7 +15,7 @@ class UriCleaner(object):
if settings.PRIVATE_GALAXY_URL:
exclude_list = (settings.PUBLIC_GALAXY_URL, settings.PRIVATE_GALAXY_URL)
else:
exclude_list = (settings.PUBLIC_GALAXY_URL)
exclude_list = (settings.PUBLIC_GALAXY_URL,)
redactedtext = cleartext
text_index = 0
while True:
@@ -25,7 +25,7 @@ class UriCleaner(object):
uri_str = match.group(1)
# Do not redact items from the exclude list
if any(uri_str.startswith(exclude_uri) for exclude_uri in exclude_list):
text_index = match.start() + len(UriCleaner.REPLACE_STR)
text_index = match.start() + len(uri_str)
continue
try:
# May raise a ValueError if invalid URI for one reason or another
@@ -62,7 +62,6 @@ class UriCleaner(object):
redactedtext = t
if text_index >= len(redactedtext):
text_index = len(redactedtext) - 1
print('URL string old: {} new: {}'.format(uri_str_old, uri_str))
except ValueError:
# Invalid URI, redact the whole URI to be safe
redactedtext = redactedtext[:match.start()] + UriCleaner.REPLACE_STR + redactedtext[match.end():]