V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
clino

是不是只要用 sqlalchemy 就能基本防止 sql 注入? 用 sqlalchemy 来执行 sql 是不是也能防止?

  •  
  •   clino · Jan 22, 2016 · 6457 views
    This topic created in 3759 days ago, the information mentioned may be changed or developed.
    我 google 了一些,但感觉不是很确认.用 orm 方式去用应该是可以防止的,不知道用 sqlalchemy 直接执行 sql 是不是也有防止呢?
    Supplement 1  ·  Sep 18, 2016
    参考 http://blog.csdn.net/slvher/article/details/47154363
    看起来用 sqlalchemy 里的 text() 来做参数 binding 应该就能防止, 但是我没看到 sqlalchemy 文档里有针对这块进行说明
    3 replies    2016-01-22 11:23:53 +08:00
    yongzhong
        1
    yongzhong  
       Jan 22, 2016   ❤️ 1
    https://groups.google.com/forum/#!topic/sqlalchemy/RLtezuLDos4
    只要拼接,就是不安全的,请用参数绑定
    dong3580
        2
    dong3580  
       Jan 22, 2016 via Android
    用参数!
    同时尽量前端和后端都要检验非法字符,
    ethego
        3
    ethego  
       Jan 22, 2016
    不使用 excute , sqlalchemy 基本上没有问题
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3369 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 12:12 · PVG 20:12 · LAX 05:12 · JFK 08:12
    ♥ Do have faith in what you're doing.