Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
4 Trả lời
19326 Lượt xem

Is there a config or system parameter in odoo to prevent showing traceback popup to user with filenames and lines. If not, is it not a security issue?

 Note: Using Odoo 10

Ảnh đại diện
Huỷ bỏ

have a look at handle_exception function in ir_http.py that might give you idea... even sending it as email or logging it to external services too.

Use sys.tracebacklimit = 0

This way you sets python to show only the exception type.

From python documentation:

sys.tracebacklimit¶

When this variable is set to an integer value, it determines the maximum number of levels of traceback information printed when an unhandled exception occurs. The default is 1000. When set to 0 or less, all traceback information is suppressed and only the exception type and value are printed.

Câu trả lời hay nhất

Hi,

Add a override odoo.http's _handle_exception like below

def _handle_exception(self, exception):
"""Called within an except block to allow converting exceptions
to arbitrary responses. Anything returned (except None) will
be used as response."""
try:
return super(JsonRequest, self)._handle_exception(exception)
except Exception:
if not isinstance(exception, SessionExpiredException):
if exception.args and exception.args[0] == "bus.Bus not available in test mode":
_logger.info(exception)
elif isinstance(exception, (odoo.exceptions.Warning, odoo.exceptions.except_orm,
werkzeug.exceptions.NotFound)):
_logger.warning(exception)
else:
_logger.exception("Exception during JSON request handling.")
error = {
'code': 200,
'message': "Odoo Server Error",
'data': serialize_exception(exception),
}
if isinstance(exception, werkzeug.exceptions.NotFound):
error['http_status'] = 404
error['code'] = 404
error['message'] = "404: Not Found"
if isinstance(exception, AuthenticationError):
error['code'] = 100
error['message'] = "Odoo Session Invalid"
if isinstance(exception, SessionExpiredException):
error['code'] = 100
error['message'] = "Odoo Session Expired"
_logger.exception(self._json_response(error=error))
pass

Regards

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

On our custom models we can catch the errors, but on odoo's built in modules this is not applicable. so either we can make a script to catch all errors from odoo models. 

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 4 23
4944
1
thg 8 22
13761
4
thg 8 22
16244
4
thg 12 24
45945
0
thg 10 18
4161