From 8836ed44ce711708cdfcb31ea8668a789cc4cc0e Mon Sep 17 00:00:00 2001 From: Jeff Bradberry Date: Thu, 29 Aug 2019 11:38:24 -0400 Subject: [PATCH] Construct an ID for Gitlab webhooks by taking the SHA1 of the body of the webhook request. --- awx/api/views/webhooks.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/awx/api/views/webhooks.py b/awx/api/views/webhooks.py index d72fc098b2..65635b033a 100644 --- a/awx/api/views/webhooks.py +++ b/awx/api/views/webhooks.py @@ -138,8 +138,10 @@ class GitlabWebhookReceiver(WebhookReceiverBase): return self.request.META.get('HTTP_X_GITLAB_EVENT') def get_event_guid(self): - # Gitlab does not provide a unique identifier on events. - return '' + # Gitlab does not provide a unique identifier on events, so construct one. + h = sha1() + h.update(force_bytes(self.request.read())) + return h.hexdigest() def get_signature(self): return force_bytes(self.request.META.get('HTTP_X_GITLAB_TOKEN'))