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 token = self.request.get('token', '').strip() | |
| 25 crash_config = CrashConfig.Get() | |
| 26 if token != crash_config.fracas.get('crash_data_push_token'): | |
| 27 logging.warning('Unauthorized access.') | |
| 28 return self.CreateError( | |
| 29 'Unauthorized access: invalid token "%s"' % token, 403) | |
| 30 | |
| 31 received_message = json.loads(self.request.body) | |
| 32 pubsub_message = received_message['message'] | |
| 33 crash_data = json.loads(base64.b64decode(pubsub_message['data'])) | |
| 34 | |
| 35 logging.info('Processing message %s from subscription %s.', | |
| 36 pubsub_message['message_id'], received_message['subscription']) | |
| 37 | |
| 38 fracas_crash_pipeline.ScheduleNewAnalysisForCrash( | |
| 39 crash_data['channel'], crash_data['platform'], crash_data['signature'], | |
|
mimee
2016/04/07 23:43:09
I prefer passing the object and unpacking it in th
stgao
2016/04/08 01:14:08
I'd unpack the json here to prevent malformed data
| |
| 40 crash_data['stack_trace'], crash_data['chrome_version'], | |
| 41 crash_data['cpm'], queue_name=constants.CRASH_ANALYSIS_FRACAS_QUEUE) | |
| OLD | NEW |