From 6dde52f37731396424339c9647775f7f8db92fcc Mon Sep 17 00:00:00 2001 From: Jakub Kadlčík Date: Apr 19 2017 13:25:22 +0000 Subject: Add config option for allowing custom scmurls --- diff --git a/conf/config.py b/conf/config.py index 0dc82f3..42f600c 100644 --- a/conf/config.py +++ b/conf/config.py @@ -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/' diff --git a/module_build_service/config.py b/module_build_service/config.py index 16d0862..cbd407b 100644 --- a/module_build_service/config.py +++ b/module_build_service/config.py @@ -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/', diff --git a/module_build_service/views.py b/module_build_service/views.py index 0b84df7..c79a528 100644 --- a/module_build_service/views.py +++ b/module_build_service/views.py @@ -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)