diff options
author | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2020-08-11 17:11:20 -0400 |
---|---|---|
committer | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2020-08-11 17:11:20 -0400 |
commit | 71cd3868343685d1b7e1227963076eeef088c3c0 (patch) | |
tree | 6d4e0ef2f812047c777cba7001e9a2c63502f6ee | |
parent | 1b16136e1e040a6adda3085f18ea189e16b2d55d (diff) | |
download | grokmirror-71cd3868343685d1b7e1227963076eeef088c3c0.tar.gz |
Disallow whitespace in repo/project name
Theoretically, there could be repos containing spaces, but I don't want
to consider this horrible horrible thing.
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r-- | contrib/pubsubv1.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/contrib/pubsubv1.py b/contrib/pubsubv1.py index 9de8696..7fe534a 100644 --- a/contrib/pubsubv1.py +++ b/contrib/pubsubv1.py @@ -26,6 +26,7 @@ import falcon import json import os import socket +import re from configparser import ConfigParser, ExtendedInterpolation @@ -61,15 +62,21 @@ class PubsubListener(object): resp.body = 'Not a pubsub v1 payload\n' return - # Proj shouldn't contain slashes - if proj.find('/') > -1: + if len(proj) > MAX_PROJ_LEN or len(repo) > MAX_REPO_LEN: + resp.status = falcon.HTTP_500 + resp.body = 'Repo or project value too long\n' + return + + # Proj shouldn't contain slashes or whitespace + if re.search(r'[\s/]', proj): resp.status = falcon.HTTP_500 resp.body = 'Invalid characters in project name\n' return - if len(proj) > MAX_PROJ_LEN or len(repo) > MAX_REPO_LEN: + # Repo shouldn't contain whitespace + if re.search(r'\s', proj): resp.status = falcon.HTTP_500 - resp.body = 'Repo or project value too long\n' + resp.body = 'Invalid characters in repo name\n' return confdir = os.environ.get('GROKMIRROR_CONFIG_DIR', '/etc/grokmirror') |