From 6dde52f37731396424339c9647775f7f8db92fcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Kadl=C4=8D=C3=ADk?= Date: Wed, 19 Apr 2017 15:25:22 +0200 Subject: [PATCH] Add config option for allowing custom scmurls --- conf/config.py | 2 ++ module_build_service/config.py | 4 ++++ module_build_service/views.py | 3 ++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/conf/config.py b/conf/config.py index 0dc82f35..42f600c2 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 16d08624..cbd407bc 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 0b84df77..c79a528a 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)