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:
parent
554d4f47a8
commit
7df8ed4a60
47 changed files with 305 additions and 166 deletions
|
@ -2,6 +2,7 @@ import logging
|
|||
|
||||
from auth.auth_context import get_authenticated_user
|
||||
from data.users import LDAP_CERT_FILENAME
|
||||
from util import create_uri_func_from_context
|
||||
from util.config import URLSchemeAndHostname
|
||||
|
||||
from util.config.validators.validate_database import DatabaseValidator
|
||||
|
@ -99,22 +100,40 @@ class ValidatorContext(object):
|
|||
""" Context to run validators in, with any additional runtime configuration they need
|
||||
"""
|
||||
def __init__(self, config, user_password=None, http_client=None, context=None,
|
||||
url_scheme_and_hostname=None, jwt_auth_max=None, registry_title=None, ip_resolver=None):
|
||||
url_scheme_and_hostname=None, jwt_auth_max=None, registry_title=None,
|
||||
ip_resolver=None, feature_sec_scanner=False, is_testing=False,
|
||||
uri_creator=None, config_provider=None):
|
||||
self.config = config
|
||||
self.user = get_authenticated_user()
|
||||
self.user_password = user_password
|
||||
self.http_client = http_client
|
||||
self.context = context
|
||||
self.scheme_and_hostname = url_scheme_and_hostname
|
||||
self.url_scheme_and_hostname = url_scheme_and_hostname
|
||||
self.jwt_auth_max = jwt_auth_max
|
||||
self.registry_title = registry_title
|
||||
self.ip_resolver = ip_resolver
|
||||
self.feature_sec_scanner = feature_sec_scanner
|
||||
self.is_testing = is_testing
|
||||
self.uri_creator = uri_creator
|
||||
self.config_provider = config_provider
|
||||
|
||||
@classmethod
|
||||
def from_app(cls, config, user_password, app, ip_resolver):
|
||||
cls(config, user_password, app.config['HTTP_CLIENT'], app.app_context,
|
||||
URLSchemeAndHostname(app.config['PREFERRED_URL_SCHEME'], app.config['SERVER_HOSTNAME']),
|
||||
app.config.get('JWT_AUTH_MAX_FRESH_S', 300), app.config['REGISTRY_TITLE'], ip_resolver)
|
||||
def from_app(cls, config, user_password, app, ip_resolver, client=None, config_provider=None):
|
||||
url_scheme = URLSchemeAndHostname(app.config['PREFERRED_URL_SCHEME'], app.config['SERVER_HOSTNAME'])
|
||||
|
||||
cls(config,
|
||||
user_password,
|
||||
client or app.config['HTTPCLIENT'],
|
||||
app.app_context,
|
||||
url_scheme,
|
||||
app.config.get('JWT_AUTH_MAX_FRESH_S', 300),
|
||||
app.config['REGISTRY_TITLE'],
|
||||
ip_resolver,
|
||||
app.config.get('FEATURE_SECURITY_SCANNER', False),
|
||||
app.config.get('TESTING', False),
|
||||
create_uri_func_from_context(app.test_request_context('/'), url_scheme),
|
||||
config_provider)
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Reference in a new issue