Search in sources :

Example 56 with WallProvider

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

the class MySqlWallTest45 method test_false.

public void test_false() throws Exception {
    WallProvider provider = new MySqlWallProvider();
    Assert.assertTrue(//
    provider.checkValid("SELECT @1119453529t_processID, @1119453529t_ret"));
    Assert.assertEquals(0, provider.getTableStats().size());
}
Also used : WallProvider(com.alibaba.druid.wall.WallProvider) MySqlWallProvider(com.alibaba.druid.wall.spi.MySqlWallProvider) MySqlWallProvider(com.alibaba.druid.wall.spi.MySqlWallProvider)

Example 57 with WallProvider

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

the class MySqlWallTest47 method test_true.

public void test_true() throws Exception {
    WallProvider provider = new MySqlWallProvider();
    Assert.assertTrue(//
    provider.checkValid(//
    "update Fans," + //
    " (select 361659 as ToID, 5 as Score " + //
    "   union all select 382885 as ToID, 2 as Score" + //
    "   union all select 407537 as ToID, 6 as Score) temp  " + //
    "set Fans.score = Fans.score+temp.Score " + "where Fans.FansID = 382885 and Fans.UserID = temp.ToID"));
    Assert.assertEquals(1, provider.getTableStats().size());
}
Also used : WallProvider(com.alibaba.druid.wall.WallProvider) MySqlWallProvider(com.alibaba.druid.wall.spi.MySqlWallProvider) MySqlWallProvider(com.alibaba.druid.wall.spi.MySqlWallProvider)

Example 58 with WallProvider

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

the class MySqlWallTest118 method test_false.

public void test_false() throws Exception {
    WallProvider provider = new MySqlWallProvider();
    provider.getConfig().setCommentAllow(false);
    String sql = "select * from t where id = ? or SPACE(6) = '      '";
    Assert.assertFalse(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)

Example 59 with WallProvider

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

the class MySqlWallTest125 method test_false.

public void test_false() throws Exception {
    WallProvider provider = new MySqlWallProvider();
    provider.getConfig().setCommentAllow(false);
    String sql = "SELECT name, '******' password, createTime from user where name like 'admin' AND 5963=CONVERT(INT,(CHAR(58)+CHAR(108)+CHAR(105)+CHAR(112)+CHAR(58)+(SELECT (CASE WHEN (5963=5963) THEN CHAR(49) ELSE CHAR(48) END))+CHAR(58)+CHAR(117)+CHAR(107)+CHAR(114)+CHAR(58))) AND 'bSho' LIKE 'bSho'";
    Assert.assertFalse(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)

Example 60 with WallProvider

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

the class SQLServerWallTest_6 method test_true.

public void test_true() throws Exception {
    WallProvider provider = new SQLServerWallProvider();
    provider.getConfig().setSelectHavingAlwayTrueCheck(true);
    Assert.assertFalse(//
    provider.checkValid("update t set fid = 1 where LEN(HOST_NAME()) > 0"));
    Assert.assertEquals(1, provider.getTableStats().size());
    Assert.assertTrue(provider.getTableStats().containsKey("t"));
}
Also used : WallProvider(com.alibaba.druid.wall.WallProvider) SQLServerWallProvider(com.alibaba.druid.wall.spi.SQLServerWallProvider) SQLServerWallProvider(com.alibaba.druid.wall.spi.SQLServerWallProvider)

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