mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-05 11:48:33 +08:00
Add config option for allowing custom scmurls
This commit is contained in:
@@ -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/'
|
||||
|
||||
@@ -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/',
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user