[ews-app] Use API_KEY to accept results data
authoraakash_jain@apple.com <aakash_jain@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 1 Apr 2019 21:57:13 +0000 (21:57 +0000)
committeraakash_jain@apple.com <aakash_jain@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 1 Apr 2019 21:57:13 +0000 (21:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196461

Reviewed by Dewei Zhu.

* BuildSlaveSupport/ews-app/ews/views/results.py:
(Results.post): Validate EWS_API_KEY before accepting any data.
* BuildSlaveSupport/ews-build/events.py:
(Events.sendData): Send EWS_API_KEY if available along with event data.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243716 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/BuildSlaveSupport/ews-app/ews/views/results.py
Tools/BuildSlaveSupport/ews-build/events.py
Tools/ChangeLog

index 6e76731..842df67 100644 (file)
@@ -24,6 +24,7 @@ from __future__ import unicode_literals
 
 import json
 import logging
+import os
 
 from django.http import HttpResponse
 from django.shortcuts import render
@@ -42,6 +43,10 @@ class Results(View):
     def post(self, request):
         data = json.loads(request.body)
 
+        if data.get('EWS_API_KEY') != os.getenv('EWS_API_KEY', None):
+            _log.error('Incorrect API Key {}. Host: {}. Ignoring data.'.format(data.get('EWS_API_KEY'), data.get('hostname')))
+            return HttpResponse('Incorrect API Key received')
+
         if data.get('type') == u'ews-build':
             return self.build_event(data)
 
index 6602b38..c8ccec0 100644 (file)
@@ -22,6 +22,7 @@
 
 import datetime
 import json
+import os
 import time
 
 from buildbot.util import service
@@ -88,6 +89,8 @@ class Events(service.BuildbotService):
         self.master_hostname = master_hostname
 
     def sendData(self, data):
+        if os.getenv('EWS_API_KEY', None):
+            data['EWS_API_KEY'] = os.getenv('EWS_API_KEY')
         agent = Agent(reactor)
         body = JSONProducer(data)
 
index 5850c5a..078eeff 100644 (file)
@@ -1,3 +1,15 @@
+2019-04-01  Aakash Jain  <aakash_jain@apple.com>
+
+        [ews-app] Use API_KEY to accept results data
+        https://bugs.webkit.org/show_bug.cgi?id=196461
+
+        Reviewed by Dewei Zhu.
+
+        * BuildSlaveSupport/ews-app/ews/views/results.py:
+        (Results.post): Validate EWS_API_KEY before accepting any data.
+        * BuildSlaveSupport/ews-build/events.py:
+        (Events.sendData): Send EWS_API_KEY if available along with event data.
+
 2019-04-01  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         Unable to copy and paste a PDF from Notes into Mail compose body