Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 import base64 | |
| 6 import json | |
| 7 import logging | |
| 8 | |
| 9 from base_handler import BaseHandler | |
| 10 from base_handler import Permission | |
| 11 from common import constants | |
| 12 from crash import fracas_crash_pipeline | |
| 13 from model.crash.crash_config import CrashConfig | |
| 14 | |
| 15 | |
| 16 FRACAS_ANALYSIS_QUEUE = 'fracas-crash-queue' | |
| 17 | |
| 18 | |
| 19 class FracasCrash(BaseHandler): | |
| 20 PERMISSION_LEVEL = Permission.ANYONE | |
| 21 | |
| 22 def HandlePost(self): | |
| 23 """Handles push delivery from Pub/Sub for crash data. | |
| 24 | |
| 25 The crash data should be in the following json format: | |
| 26 { | |
| 27 'channel': 'canary', | |
| 28 'platform': 'win', | |
| 29 'signature': 'namesapce1:namespace2:class_name:func_name', | |
| 30 'stack_trace': 'frame1\nframe2\nframe3', | |
| 31 'chrome_version': '50.0.2500.0', | |
| 32 'cpms': { | |
| 33 '50.0.2500.0': 1.2, | |
| 34 '50.0.2499.0': 1.0, | |
| 35 }, | |
| 36 } | |
| 37 """ | |
| 38 token = self.request.get('token', '').strip() | |
| 39 crash_config = CrashConfig.Get() | |
| 40 if token != crash_config.fracas.get('crash_data_push_token'): | |
|
Martin Barbella
2016/04/08 18:10:24
Is there a way to actually verify that these pushe
stgao
2016/04/11 20:32:20
This is the only solution for now. A better soluti
| |
| 41 logging.warning('Unauthorized access.') | |
| 42 return self.CreateError( | |
| 43 'Unauthorized access: invalid token "%s"' % token, 403) | |
| 44 | |
| 45 received_message = json.loads(self.request.body) | |
| 46 pubsub_message = received_message['message'] | |
| 47 crash_data = json.loads(base64.b64decode(pubsub_message['data'])) | |
| 48 | |
| 49 logging.info('Processing message %s from subscription %s.', | |
| 50 pubsub_message['message_id'], received_message['subscription']) | |
| 51 | |
| 52 fracas_crash_pipeline.ScheduleNewAnalysisForCrash( | |
| 53 crash_data['channel'], crash_data['platform'], crash_data['signature'], | |
| 54 crash_data['stack_trace'], crash_data['chrome_version'], | |
| 55 crash_data['cpms'], queue_name=constants.CRASH_ANALYSIS_FRACAS_QUEUE) | |
| OLD | NEW |