Examples of checkValid()


Examples of com.alibaba.druid.wall.WallProvider.checkValid()

public class MySqlWallTest133 extends TestCase {

    public void test_false() throws Exception {
        WallProvider provider = new MySqlWallProvider();

        Assert.assertFalse(provider.checkValid("select * from t where id = 1 " //
                                               + "UNION SELECT @ from t"));
    }

}
View Full Code Here

Examples of com.alibaba.druid.wall.WallProvider.checkValid()

        WallProvider provider = new MySqlWallProvider();
        provider.getConfig().setCommentAllow(false);

        String sql = "select * from t where id = ? or binary true";

        Assert.assertFalse(provider.checkValid(sql));
    }

}
View Full Code Here

Examples of com.alibaba.druid.wall.WallProvider.checkValid()

    public void test_false() throws Exception {
        WallProvider provider = new MySqlWallProvider();
        provider.getConfig().setCommentAllow(true);
       
        Assert.assertFalse(provider.checkValid("select * from t where id = 1 UNION SELECT GROUP_CONCAT(table_name) FROM information_schema.tables WHERE version=10;"));
    }

}
View Full Code Here

Examples of com.alibaba.druid.wall.WallProvider.checkValid()

    public void test_true() throws Exception {
        WallProvider provider = new MySqlWallProvider();

        provider.getConfig().setSelectHavingAlwayTrueCheck(true);

        Assert.assertTrue(provider.checkValid(//
        "select * from (select t10006_men_xing_jia_ge_fen_lei.bian_hao as \"bian_hao\", " + //
                "   t10006_men_xing_jia_ge_fen_lei.ming_cheng as \"ming_cheng\" " + //
                "from t10006_men_xing_jia_ge_fen_lei where 1=1 ) as tables where 1=1 order by tables.bian_hao"));

        Assert.assertEquals(1, provider.getTableStats().size());
View Full Code Here

Examples of com.alibaba.druid.wall.WallProvider.checkValid()

    public void test_true() throws Exception {
        WallProvider provider = new MySqlWallProvider();
        provider.getConfig().setSchemaCheck(true);

        Assert.assertTrue(provider.checkValid(//
        "show create table `mysql`.`help_relation`"));

        Assert.assertEquals(1, provider.getTableStats().size());
    }
View Full Code Here

Examples of com.alibaba.druid.wall.WallProvider.checkValid()

        // 预热
        WallProvider provider = new MySqlWallProvider();
        provider.setBlackListEnable(false);
        provider.setWhiteListEnable(false);
        for (int i = 0; i < 1000 * 100; i++) {
            provider.checkValid("select sum(payment_ft) from order_goods where order_id=1 AND (SELECT 4552 FROM(SELECT COUNT(*),CONCAT(CHAR(58,107,98,119,58),(SELECT (CASE WHEN (4552=4552) THEN 1 ELSE 0 END)),CHAR(58,98,105,101,58),FLOOR(RAND(0)*2))x FROM information_schema.tables GROUP BY x)a)");
        }
    }

    public void test_1() throws Exception {
        String sql = "SELECT plaza_id,plaza_name,plaza_logo,plaza_address,plaza_averageMoney,plaza_discount,2*ASIN(SQRT(POW(SIN(PI()*(22.54605355-plaza_latitude)/360),2)+COS(PI()*22.54605355/180)*COS(plaza_latitude*PI()/180)*POW(SIN(PI()*(114.02597366-plaza_longitude)/360),2)))*6378.137*1000 as jl FROM plaza where 2*ASIN(SQRT(POW(SIN(PI()*(22.54605355-plaza_latitude)/360),2)+COS(PI()*22.54605355/180)*COS(plaza_latitude*PI()/180)*POW(SIN(PI()*(114.02597366-plaza_longitude)/360),2)))*6378.137*1000<= 5000 and plaza_check=2 ORDER BY jl ASC";
View Full Code Here

Examples of com.alibaba.druid.wall.WallProvider.checkValid()

            provider.setBlackListEnable(false);
            provider.setWhiteListEnable(false);

            long time = System.nanoTime();
            for (int i = 0; i < num; i++) {
                provider.checkValid(sql);
            }

            return (System.nanoTime() - time) / num / 1000;
        } catch (Exception e) {
            return new Long(-1);
View Full Code Here

Examples of com.alibaba.druid.wall.WallProvider.checkValid()

public class MySqlWallTest55 extends TestCase {

    public void test_true() throws Exception {
        WallProvider provider = new MySqlWallProvider();

        Assert.assertTrue(provider.checkValid(//
        "SELECT USER()"));

        Assert.assertEquals(0, provider.getTableStats().size());
    }
   
View Full Code Here

Examples of com.alibaba.druid.wall.WallProvider.checkValid()

    }
   
    public void test_true_1() throws Exception {
        WallProvider provider = new MySqlWallProvider();
       
        Assert.assertTrue(provider.checkValid(//
                "SELECT USER() FROM DUAL"));
       
        Assert.assertEquals(1, provider.getTableStats().size());
    }
   
View Full Code Here

Examples of com.alibaba.druid.wall.WallProvider.checkValid()

    }
   
    public void test_true_2() throws Exception {
        WallProvider provider = new MySqlWallProvider();
       
        Assert.assertTrue(provider.checkValid(//
                "SELECT USER() FROM X"));
       
        Assert.assertEquals(1, provider.getTableStats().size());
    }
   
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.