[damned-lies] Allow gitlab.gnome.org in hook origin check
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Allow gitlab.gnome.org in hook origin check
- Date: Fri, 13 Sep 2019 12:48:15 +0000 (UTC)
commit d0910e031b2dde77af591bb70b39c7871a4de8b3
Author: Claude Paroz <claude 2xlibre net>
Date: Fri Sep 13 14:46:28 2019 +0200
Allow gitlab.gnome.org in hook origin check
common/utils.py | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/common/utils.py b/common/utils.py
index 2355040b..eead3f6f 100644
--- a/common/utils.py
+++ b/common/utils.py
@@ -1,6 +1,7 @@
import errno
import logging
import os
+import socket
from subprocess import Popen, PIPE
from django.conf import settings
@@ -96,8 +97,12 @@ def send_mail(subject, message, **kwargs):
def check_gitlab_request(request):
+ from_host = socket.gethostbyaddr(request.META.get('REMOTE_ADDR'))[0]
return (
- request.method == 'POST' and
- request.META.get('HTTP_X_GITLAB_EVENT') == 'Push Hook' and
- request.META.get('HTTP_X_GITLAB_TOKEN') == settings.GITLAB_TOKEN
+ request.method == 'POST' and (
+ from_host == 'gitlab.gnome.org' or (
+ request.META.get('HTTP_X_GITLAB_EVENT') == 'Push Hook' and
+ request.META.get('HTTP_X_GITLAB_TOKEN') == settings.GITLAB_TOKEN
+ )
+ )
)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]