安全 Rails 5.0 API 模式中,如何在收到参数之前,就统一进行 xss 过滤?

breeze · 2016年07月25日 · 最后由 novtopro 回复于 2016年07月27日 · 7028 次阅读

如题。 希望像 permit(健壮参数) 一样,不需要在后续的实际业务中关心参数过滤的问题

Though it's still buggy sometimes, I'd like to recommend you to check dry-validation out. I think you will like it. The hanami-validation project takes a lot from it.

#1 楼 @novtopro Thank,I will seriously to check it

#1 楼 @novtopro 并不能像题目那样解决问题~希望有更好的方法

@breeze 我用的是 rails_param 包我自己 fork 了一个分支然后使用 optional 或者 requires 时候 会自动把参数名加到一个数组里面,然后写了一个 strong_params 方法可以调用

5 楼 已删除

You have to figure out how to integrate the gem with you application by yourself. By the way, rails_param just sucks! It's ugly as far as I see.

7 楼 已删除
需要 登录 后方可回复, 如果你还没有账号请 注册新账号