Code Monkey home page Code Monkey logo

abatis's People

Contributors

wonhyeongju avatar

Watchers

 avatar  avatar

Forkers

hunwoopark

abatis's Issues

This tool doesn't support parameters in sqlite DB. SQL injection risk!!!

I have checked your souce code of this tool. I found this part of method 
executeForMapList:

...
 if (bindParams != null) {
            Iterator<String> mapIterator = bindParams.keySet().iterator();
            while (mapIterator.hasNext()) {
                String key = mapIterator.next();
                Object value = bindParams.get(key);
                sql = sql.replaceAll("#" + key.toLowerCase() + "#", value == null ? null : "'" + value.toString() + "'");
            }
        }
        if (sql.indexOf('#') != -1) {
            Log.e(TAG, "undefined parameter");
            return null;
        }
        Cursor cursor = dbObj.rawQuery(sql, null);
...


I don't understand why you don't use parameters (placeholders) in sql queries. 
I suggest to rewrite this part to (not tested!):


...
 if (bindParams != null) {
            Iterator<String> mapIterator = bindParams.keySet().iterator();
            int index = 0;
            String[] values = new String[bindParams.keySet().size()];
            while (mapIterator.hasNext()) {
                String key = mapIterator.next();
                Object value = bindParams.get(key);
                sql = sql.replaceAll("#" + key.toLowerCase() + "#", value == null ? null : "?"+(index+1));
                if(value != null){
                  values[index] = value.toString();
                  index++;
                }                
            }
        }
        if (sql.indexOf('#') != -1) {
            Log.e(TAG, "undefined parameter");
            return null;
        }
        Cursor cursor = dbObj.rawQuery(sql, values);
...

Original issue reported on code.google.com by [email protected] on 3 Nov 2011 at 4:42

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.