Package com.alibaba.druid.wall.spi

Examples of com.alibaba.druid.wall.spi.MySqlWallProvider


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

        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);
View Full Code Here

        config.setTenantColumn("tenant");

        config_callback.setTenantCallBack(new TenantTestCallBack());
       
        WallProvider.setTenantValue(123);
        MySqlWallProvider provider = new MySqlWallProvider(config);
        WallCheckResult checkResult = provider.check(sql);
        Assert.assertEquals(0, checkResult.getViolations().size());

        String resultSql = SQLUtils.toSQLString(checkResult.getStatementList(), JdbcConstants.MYSQL);
        Assert.assertEquals(expect_sql, resultSql);
    }
View Full Code Here

        config.setTenantTablePattern("*");
        config.setTenantColumn("tenant");

        config_callback.setTenantCallBack(new TenantTestCallBack());

        MySqlWallProvider provider = new MySqlWallProvider(config_callback);
        WallCheckResult checkResult = provider.check(sql);
        Assert.assertEquals(0, checkResult.getViolations().size());

        String resultSql = SQLUtils.toSQLString(checkResult.getStatementList(), JdbcConstants.MYSQL);
        Assert.assertEquals(expect_sql, resultSql);
    }
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

TOP

Related Classes of com.alibaba.druid.wall.spi.MySqlWallProvider

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.