From fa52cb09b2270876c9d9a03106f961be6c9db834 Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Fri, 25 Jan 2013 13:07:34 -0500 Subject: Strip out Traceback from HTTP response We should not let stack traces leak to the REST API users Fixes LP# 1103324 Fixes LP# 1092610 Change-Id: Ic1208bfeb7d44e672f8b8d3a4004a9802c14e7b9 --- nova/api/openstack/wsgi.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py index 8b593d742..a6f255081 100644 --- a/nova/api/openstack/wsgi.py +++ b/nova/api/openstack/wsgi.py @@ -1182,10 +1182,18 @@ class Fault(webob.exc.HTTPException): # Replace the body with fault details. code = self.wrapped_exc.status_int fault_name = self._fault_names.get(code, "computeFault") + explanation = self.wrapped_exc.explanation + offset = explanation.find("Traceback") + if offset is not -1: + LOG.debug(_("API request failed, fault raised to the top of" + " the stack. Detailed stacktrace %s") % + explanation) + explanation = explanation[0:offset - 1] + fault_data = { fault_name: { 'code': code, - 'message': self.wrapped_exc.explanation}} + 'message': explanation}} if code == 413: retry = self.wrapped_exc.headers.get('Retry-After', None) if retry: -- cgit