← 返回刚才阅读的位置

知识卡片

问题卡 · 5025.e.1

仅处理过滤后的输入

理解等级:中级

服务响应可能含恶意或错误数据,客户端须在业务计算前建立输入边界。

入站数据先经过允许清单、类型和范围验证,形成内部安全副本,再交给业务逻辑。未知字段可以忽略,不应被动态执行或自动绑定。语法有效还不够:日期区间须前早后晚,国家和省州也必须互相匹配。

当客户端只负责文档中的税额计算时,可提取并清洗所需字段,计算后把结果合回原文档,保留其他字段供后续组件处理;不必理解整个文档,但绝不能用未验证的原始字段参与自己的业务。

关联:[[入站消息分三层检查]]。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 超媒体客户端 · 查看原书依据

      When receiving a response message, it is a good practice to create an internal, filtered representation of that message and only allow your own code to operate on the filtered representation—not the original. This reduces the chances that your application will mistakenly ingest improperly formed data and limits the possible risk to your application.

    参考来源

    - 位置:《RESTful Web API Patterns and Practices Cookbook》第4章《Hypermedia Clients》(来源项目book-sources:extracted/RESTful Web API Patterns and Practices Cookbook Connecting and Orchestrating Microservices and Distributed Data (Mike Amundsen)/_epub-src/OEBPS/ch04.xhtml,配方4.14) - 结论依据:原文要求允许清单、取值范围及语义关联检查,并把原始消息与过滤后内部表示分开。 - 原始内容:When receiving a response message, it is a good practice to create an internal, filtered representation of that message and only allow your own code to operate on the filtered representation—not the original. This reduces the chances that your application will mistakenly ingest improperly formed data and limits the possible risk to your application.