Add config option for allowing custom scmurls

This commit is contained in:
Jakub Kadlčík
2017-04-19 15:25:22 +02:00
parent b0ae5f98ef
commit 6dde52f377
3 changed files with 8 additions and 1 deletions

View File

@@ -47,6 +47,8 @@ class BaseConfiguration(object):
# and be in the build state at a time. Set this to 0 for no restrictions
NUM_CONSECUTIVE_BUILDS = 5
ALLOW_CUSTOM_URLS = False
RPMS_DEFAULT_REPOSITORY = 'git://pkgs.fedoraproject.org/rpms/'
RPMS_ALLOW_REPOSITORY = False
RPMS_DEFAULT_CACHE = 'http://pkgs.fedoraproject.org/repo/pkgs/'

View File

@@ -171,6 +171,10 @@ class Config(object):
'type': list,
'default': ['module'],
'desc': 'List of allowed koji tag prefixes.'},
'allow_custom_urls': {
'type': bool,
'default': False,
'desc': 'Allow custom scmurls.'},
'rpms_default_repository': {
'type': str,
'default': 'git://pkgs.fedoraproject.org/rpms/',

View File

@@ -195,7 +195,8 @@ class SCMHandler(BaseHandler):
raise ValidationError('Missing scmurl')
url = self.data["scmurl"]
if not any(url.startswith(prefix) for prefix in conf.scmurls):
allowed_prefix = any(url.startswith(prefix) for prefix in conf.scmurls)
if not conf.allow_custom_urls and not allowed_prefix:
log.error("The submitted scmurl %r is not allowed" % url)
raise Forbidden("The submitted scmurl %s is not allowed" % url)