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
|
@ -1,28 +1,27 @@
|
|||
import logging
|
||||
|
||||
import features
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class SecurityConfigValidator(object):
|
||||
""" Helper class for validating the security scanner configuration. """
|
||||
def __init__(self, config):
|
||||
if not features.SECURITY_SCANNER:
|
||||
def __init__(self, feature_sec_scan, sec_scan_endpoint):
|
||||
if not feature_sec_scan:
|
||||
return
|
||||
|
||||
self._config = config
|
||||
self._feature_sec_scan = feature_sec_scan
|
||||
self._sec_scan_endpoint = sec_scan_endpoint
|
||||
|
||||
def valid(self):
|
||||
if not features.SECURITY_SCANNER:
|
||||
if not self._feature_sec_scan:
|
||||
return False
|
||||
|
||||
if self._config.get('SECURITY_SCANNER_ENDPOINT') is None:
|
||||
if self._sec_scan_endpoint is None:
|
||||
logger.debug('Missing SECURITY_SCANNER_ENDPOINT configuration')
|
||||
return False
|
||||
|
||||
endpoint = self._config.get('SECURITY_SCANNER_ENDPOINT')
|
||||
endpoint = self._sec_scan_endpoint
|
||||
if not endpoint.startswith('http://') and not endpoint.startswith('https://'):
|
||||
logger.debug('SECURITY_SCANNER_ENDPOINT configuration must start with http or https')
|
||||
return False
|
||||
|
|
Reference in a new issue