security - Detect SQL injection in Groovy dynamic SQL -
how can detect sql injection vulnerability in grails app dynamic native sql?
what i'm looking can tell difference between this
def sql = new sql(datasource) def dynamicwhereclause = "" if (params.col) { dynamicwhereclause = " , col = :col" } // ok because dynamic sql not concatenate user input def sqlstring = "select * tab ... ${dynamicwhereclause}" sql.rows(sqlstring, params)
and this
def sql = new sql(datasource) def dynamicwhereclause = "" if (params.col) { // not ok - directly concatenating user input dynamicwhereclause = " , col = '" + params.col + "'" } def sqlstring = "select * tab ... ${dynamicwhereclause}" sql.rows(sqlstring)
sonarqube/findbugs has rule "prepared statement generated nonconstant string" not distinguish between safe 1 , dangerous one. other options out there?
how using static analysis tool such "find security bugs".
see here others compatible groovy.
Comments
Post a Comment