Giter Site home page Giter Site logo

Comments (5)

danielfernandez avatar danielfernandez commented on June 29, 2024

The problem is... how would you define SQL escape? I suppose you mean doing the equivalent to what a PreparedStatement does to a query's arguments, but.. can this be done in a database-vendor independent manner?

from unbescape.

baishui2004 avatar baishui2004 commented on June 29, 2024

Yes, as you say, mean doing prevent sql injection. Apache Commons-lang2 has a method StringEscapeUtils.escapeSql(), but has been removed from the API in Commons-lang3, the reason is “This method was not of much use as it was only escaping single quotes”. see: http://java.dzone.com/articles/commons-lang-3-improved-and-powerful-StringEscapeUtils. Do you have any good solutions to prevent sql injection?

from unbescape.

danielfernandez avatar danielfernandez commented on June 29, 2024

Well... obviously, using PreparedStatements. Or manually escaping SQL in a way understandable by your DBMS.

The problem with this escaping is that, in order to support it, it should be complete, not partial. So I understand the reasons why they removed it from Commons-Lang. Performing partial escaping operations is always a source of errors, because it gives the developer a false sense of security and might render the result equally invalid because the specific DBMS might need other chars to be escaped...

from unbescape.

ecki avatar ecki commented on June 29, 2024

You should prefer prepared statements, or use ORMs with a criteria API. This avoids the need to escape and allows the RDBMS to do some optimizations.

from unbescape.

baishui2004 avatar baishui2004 commented on June 29, 2024

Thank you all, I understand. I find a complex solution depends DBMS. Druid provides WallFilter, it is based on the SQL semantic analysis to defense SQL injection attacks, see here : https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE-wallfilter

from unbescape.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.