Add a security scanner api config object for params

Change SecScanAPI to use a uri creation func instead of test context

Pass config provider through validator context

Remove app config dependency for validators
This commit is contained in:
Sam Chow 2018-05-29 13:50:51 -04:00
parent 554d4f47a8
commit 7df8ed4a60
47 changed files with 305 additions and 166 deletions

View file

@ -1,3 +1,6 @@
from flask import url_for
from urlparse import urljoin
def get_app_url(config):
""" Returns the application's URL, based on the given config. """
return '%s://%s' % (config['PREFERRED_URL_SCHEME'], config['SERVER_HOSTNAME'])
@ -19,3 +22,13 @@ def slash_join(*args):
args = [rmslash(path) for path in args]
return '/'.join(args)
def create_uri_func_from_context(context, url_scheme_and_hostname):
def create_uri(repository_and_namespace, checksum):
with context:
relative_layer_url = url_for('v2.download_blob', repository=repository_and_namespace,
digest=checksum)
return urljoin(get_app_url_from_scheme_hostname(url_scheme_and_hostname), relative_layer_url)
return create_uri