知识卡片
外部错误不泄露内部堆栈
外部错误响应要让调用方知道可采取的动作,但不要携带堆栈、内部组件名或敏感细节。详细诊断信息可以留在受控日志或内部错误字段,经边界层过滤后再输出;可读性与保密性要同时满足。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- · 查看原书依据
Ensure that the error messages sent back to an external consumer do not contain stack traces and other sensitive information. This information can help a hacker aiming to compromise the system. The error structure in the Microsoft guidelines has the concept of an InnerError, which could be useful in which to place more detailed stack traces/descriptions of issues. This would be incredibly helpful for debugging but must be stripped prior to an external consumer.
参考来源
- 位置:《Mastering API Architecture》第1章《Design, Build, and Specify APIs》之《Error Handling》(源文件:_epub-src/OEBPS/ch01.xhtml)
- 结论依据:原文明确警告外部消费者不应收到堆栈等敏感信息,并说明内部 InnerError 可以辅助调试,但必须在对外响应前剥离。
- 原始内容:Ensure that the error messages sent back to an external consumer do not contain stack traces and other sensitive information. This information can help a hacker aiming to compromise the system. The error structure in the Microsoft guidelines has the concept of an InnerError , which could be useful in which to place more detailed stack traces/descriptions of issues. This would be incredibly helpful for debugging but must be stripped prior to an external consumer.