From 68fda334b70034f992faf00254938f84617a4ccb Mon Sep 17 00:00:00 2001 From: Cecylia Bocovich Date: Fri, 14 Aug 2020 09:38:40 -0400 Subject: [PATCH] Stop providing links for invalid paths Gitlab can't (or doesn't, for security reasons) tell the difference between a non-existent or private repository. So, if an invalid Gitlab ticket path is provided, it will return the path along with a ticket title for the sign in page. This change raises an IndexError if the path is invalid. --- tickethelpers.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tickethelpers.py b/tickethelpers.py index e70665b..091621a 100644 --- a/tickethelpers.py +++ b/tickethelpers.py @@ -295,6 +295,10 @@ def _gettitle(self, ticketnumber): path, ticketnumber = ticketnumber url = '%s%s/-/issues/' % (self.url, path) res = super()._gettitle(ticketnumber, url=url) + # Instead of responding with an HTTP 404 error, GitLab returns the sign in page + # if the repository is either not public or doesn't exist + if (res['title'] == "Sign in ยท GitLab"): + raise IndexError('Project not found') res['url'] = url res['path'] = path res['ticketnumber'] = ticketnumber