Package com.alibaba.druid.wall

Examples of com.alibaba.druid.wall.WallProvider


import com.alibaba.druid.wall.spi.MySqlWallProvider;

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


import com.alibaba.druid.wall.spi.MySqlWallProvider;

public class MySqlWallTest105 extends TestCase {

    public void test_false() throws Exception {
        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

import com.alibaba.druid.wall.spi.MySqlWallProvider;

public class MySqlWallTest132 extends TestCase {

    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

* @see
*/
public class MySqlWallTest90 extends TestCase {

    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());
        Assert.assertTrue(provider.getTableStats().containsKey("t10006_men_xing_jia_ge_fen_lei"));
    }
View Full Code Here

* @see
*/
public class MySqlWallTest60 extends TestCase {

    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

public class WallPerformanceTest_1 extends TestCase {

    @Override
    protected void setUp() throws Exception {
        // 预热
        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)");
        }
    }
View Full Code Here

        if (sql == null || dbType == null) {
            return new Long(-1);
        }

        try {
            WallProvider provider = null;
            if ("mssql".equalsIgnoreCase(dbType)) {
                provider = new SQLServerWallProvider();
            } else if ("mysql".equalsIgnoreCase(dbType)) {
                provider = new MySqlWallProvider();
            } else {
                return new Long(-1);
            }

            provider.getConfig().setStrictSyntaxCheck(false);
            provider.getConfig().setMultiStatementAllow(true);
            provider.getConfig().setConditionAndAlwayTrueAllow(true);
            provider.getConfig().setConditionAndAlwayFalseAllow(true);
            provider.getConfig().setNoneBaseStatementAllow(true);
            provider.getConfig().setLimitZeroAllow(true);
            provider.getConfig().setConditionDoubleConstAllow(true);

            provider.getConfig().setCommentAllow(true);
            // provider.getConfig().setSelectUnionCheck(false);

            // add by yanhui.liyh
            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

* @see
*/
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

        Assert.assertEquals(0, provider.getTableStats().size());
    }
   
    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

       
        Assert.assertEquals(1, provider.getTableStats().size());
    }
   
    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

Related Classes of com.alibaba.druid.wall.WallProvider

Copyright © 2018 www.massapicom. 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.