diff --git a/pagure/default_config.py b/pagure/default_config.py index ebb6fcb..117026f 100644 --- a/pagure/default_config.py +++ b/pagure/default_config.py @@ -137,3 +137,6 @@ SESSION_COOKIE_SECURE = False # Used by SESSION_COOKIE_PATH APPLICATION_ROOT = '/' + +# List of blacklisted project names +BLACKLISTED_PROJECTS = ['static', 'pv'] diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py index d718a6d..4292299 100644 --- a/pagure/lib/__init__.py +++ b/pagure/lib/__init__.py @@ -549,11 +549,17 @@ def add_pull_request_comment(session, request, commit, filename, row, return 'Comment added' -def new_project(session, user, name, +def new_project(session, user, name, blacklist, gitfolder, docfolder, ticketfolder, requestfolder, description=None, parent_id=None): ''' Create a new project based on the information provided. ''' + if name in blacklist: + raise pagure.exceptions.RepoExistsException( + 'No project "%s" are allowed to be created due to potential ' + 'conflicts in URLs with pagure itself' % name + ) + gitrepo = os.path.join(gitfolder, '%s.git' % name) if os.path.exists(gitrepo): raise pagure.exceptions.RepoExistsException( diff --git a/pagure/ui/app.py b/pagure/ui/app.py index bffa44a..ecd2ee5 100644 --- a/pagure/ui/app.py +++ b/pagure/ui/app.py @@ -271,6 +271,7 @@ def new_project(): name=name, description=description, user=flask.g.fas_user.username, + blacklist=APP.config['BLACKLISTED_PROJECTS'], gitfolder=APP.config['GIT_FOLDER'], docfolder=APP.config['DOCS_FOLDER'], ticketfolder=APP.config['TICKETS_FOLDER'],