Search in sources :

Example 46 with WallProvider

use of com.alibaba.druid.wall.WallProvider in project druid by alibaba.

the class WallStatTest_select_into method testOracle.

public void testOracle() throws Exception {
    WallProvider provider = new OracleWallProvider();
    Assert.assertTrue(provider.checkValid(sql));
    WallTableStat tableStat = provider.getTableStat("t");
    Assert.assertEquals(1, tableStat.getSelectCount());
}
Also used : WallTableStat(com.alibaba.druid.wall.WallTableStat) OracleWallProvider(com.alibaba.druid.wall.spi.OracleWallProvider) WallProvider(com.alibaba.druid.wall.WallProvider) MySqlWallProvider(com.alibaba.druid.wall.spi.MySqlWallProvider) OracleWallProvider(com.alibaba.druid.wall.spi.OracleWallProvider) PGWallProvider(com.alibaba.druid.wall.spi.PGWallProvider) SQLServerWallProvider(com.alibaba.druid.wall.spi.SQLServerWallProvider)

Example 47 with WallProvider

use of com.alibaba.druid.wall.WallProvider in project druid by alibaba.

the class WallStatTest_update method testMySql.

public void testMySql() throws Exception {
    WallProvider provider = new MySqlWallProvider();
    Assert.assertTrue(provider.checkValid(sql));
    WallTableStat tableStat = provider.getTableStat("t");
    Assert.assertEquals(1, tableStat.getUpdateCount());
}
Also used : WallTableStat(com.alibaba.druid.wall.WallTableStat) WallProvider(com.alibaba.druid.wall.WallProvider) MySqlWallProvider(com.alibaba.druid.wall.spi.MySqlWallProvider) OracleWallProvider(com.alibaba.druid.wall.spi.OracleWallProvider) PGWallProvider(com.alibaba.druid.wall.spi.PGWallProvider) SQLServerWallProvider(com.alibaba.druid.wall.spi.SQLServerWallProvider) MySqlWallProvider(com.alibaba.druid.wall.spi.MySqlWallProvider)

Example 48 with WallProvider

use of com.alibaba.druid.wall.WallProvider in project druid by alibaba.

the class WallStatTest_update method testSQLServer.

public void testSQLServer() throws Exception {
    WallProvider provider = new SQLServerWallProvider();
    Assert.assertTrue(provider.checkValid(sql));
    WallTableStat tableStat = provider.getTableStat("t");
    Assert.assertEquals(1, tableStat.getUpdateCount());
}
Also used : WallTableStat(com.alibaba.druid.wall.WallTableStat) WallProvider(com.alibaba.druid.wall.WallProvider) MySqlWallProvider(com.alibaba.druid.wall.spi.MySqlWallProvider) OracleWallProvider(com.alibaba.druid.wall.spi.OracleWallProvider) PGWallProvider(com.alibaba.druid.wall.spi.PGWallProvider) SQLServerWallProvider(com.alibaba.druid.wall.spi.SQLServerWallProvider) SQLServerWallProvider(com.alibaba.druid.wall.spi.SQLServerWallProvider)

Example 49 with WallProvider

use of com.alibaba.druid.wall.WallProvider in project druid by alibaba.

the class WallStatTest_whiteList_syntaxError method testMySql.

public void testMySql() throws Exception {
    WallProvider provider = new MySqlWallProvider();
    provider.getConfig().setStrictSyntaxCheck(false);
    String sql = "select xx * x *";
    Assert.assertTrue(provider.checkValid(sql));
    {
        WallTableStat tableStat = provider.getTableStat("t");
        Assert.assertEquals(0, tableStat.getSelectCount());
        Assert.assertEquals(0, provider.getBlackListHitCount());
        Assert.assertEquals(0, provider.getWhiteListHitCount());
        Assert.assertEquals(0, provider.getWhiteList().size());
        Assert.assertEquals(0, provider.getBlackList().size());
        Assert.assertEquals(1, provider.getCheckCount());
        Assert.assertEquals(1, provider.getSyntaxErrorCount());
        Assert.assertEquals(1, provider.getHardCheckCount());
    }
    Assert.assertTrue(provider.checkValid(sql));
    {
        WallTableStat tableStat = provider.getTableStat("t");
        Assert.assertEquals(0, tableStat.getSelectCount());
        Assert.assertEquals(0, provider.getBlackListHitCount());
        Assert.assertEquals(0, provider.getWhiteListHitCount());
        Assert.assertEquals(0, provider.getWhiteList().size());
        Assert.assertEquals(0, provider.getBlackList().size());
        Assert.assertEquals(2, provider.getCheckCount());
        Assert.assertEquals(2, provider.getSyntaxErrorCount());
        Assert.assertEquals(2, provider.getHardCheckCount());
    }
}
Also used : WallTableStat(com.alibaba.druid.wall.WallTableStat) WallProvider(com.alibaba.druid.wall.WallProvider) MySqlWallProvider(com.alibaba.druid.wall.spi.MySqlWallProvider) MySqlWallProvider(com.alibaba.druid.wall.spi.MySqlWallProvider)

Example 50 with WallProvider

use of com.alibaba.druid.wall.WallProvider in project druid by alibaba.

the class MySqlWallTest139 method test_false.

public void test_false() throws Exception {
    WallProvider provider = new MySqlWallProvider();
    String sql = //
    "select count(1) as total " + //
    " from (" + //
    "    select '' buyer_nick from dual " + //
    "    where 1=0  " + //
    "    union " + //
    "    select distinct buyer_nick " + //
    "    from sys_info.orders " + //
    "    where 1=1  and receiver_district in ('平谷区')" + //
    ") a " + //
    "inner join (" + //
    "    select buyer_nick from (" + //
    "        select distinct buyer_nick " + //
    "        from sys_info.orders " + //
    "        where 1=1  and created > '2013-07-28' " + //
    "    ) recent_days " + //
    "inner join (" + //
    "    select distinct buyer_nick " + //
    "    from sys_info.orders " + //
    "    where 1=1  and seller_nick in ('创维官方旗舰店') " + //
    "    ) seller_nick using(buyer_nick) " + ") b using(buyer_nick)";
    Assert.assertTrue(provider.checkValid(sql));
}
Also used : WallProvider(com.alibaba.druid.wall.WallProvider) MySqlWallProvider(com.alibaba.druid.wall.spi.MySqlWallProvider) MySqlWallProvider(com.alibaba.druid.wall.spi.MySqlWallProvider)

Aggregations

WallProvider (com.alibaba.druid.wall.WallProvider)195 MySqlWallProvider (com.alibaba.druid.wall.spi.MySqlWallProvider)182 SQLServerWallProvider (com.alibaba.druid.wall.spi.SQLServerWallProvider)47 WallTableStat (com.alibaba.druid.wall.WallTableStat)41 PGWallProvider (com.alibaba.druid.wall.spi.PGWallProvider)36 OracleWallProvider (com.alibaba.druid.wall.spi.OracleWallProvider)34 WallCheckResult (com.alibaba.druid.wall.WallCheckResult)3 Violation (com.alibaba.druid.wall.Violation)2 SQLStatement (com.alibaba.druid.sql.ast.SQLStatement)1 PGSQLStatementParser (com.alibaba.druid.sql.dialect.postgresql.parser.PGSQLStatementParser)1 PGSchemaStatVisitor (com.alibaba.druid.sql.dialect.postgresql.visitor.PGSchemaStatVisitor)1 WallConfig (com.alibaba.druid.wall.WallConfig)1 WallFunctionStat (com.alibaba.druid.wall.WallFunctionStat)1 Map (java.util.Map)1 Test (org.junit.Test)1