Add some proj/repo length sanity checks

Since we'll be feeding this to a listener socket, apply some sanity
limits on the length of the repo.

Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
diff --git a/contrib/pubsubv1.py b/contrib/pubsubv1.py
index 808ef4b..9de8696 100644
--- a/contrib/pubsubv1.py
+++ b/contrib/pubsubv1.py
@@ -29,6 +29,9 @@
 
 from configparser import ConfigParser, ExtendedInterpolation
 
+# Some sanity defaults
+MAX_PROJ_LEN = 32
+MAX_REPO_LEN = 1024
 
 # noinspection PyBroadException
 class PubsubListener(object):
@@ -64,6 +67,11 @@
             resp.body = 'Invalid characters in project name\n'
             return
 
+        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
+
         confdir = os.environ.get('GROKMIRROR_CONFIG_DIR', '/etc/grokmirror')
         cfgfile = os.path.join(confdir, '{}.conf'.format(proj))
         if not os.access(cfgfile, os.R_OK):