Search in sources :

Example 51 with WallProvider

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

the class MySqlWallTest140 method test_false.

public void test_false() throws Exception {
    WallProvider provider = new MySqlWallProvider();
    String sql = //
    "SELECT name, '******' password, createTime from user " + //
    "where name like 'admin%' " + "    AND 8600=CONVERT(INT,(SELECT CHAR(113)+CHAR(118)+CHAR(100)+CHAR(114)+CHAR(113)+(SELECT (CASE WHEN (8600=8600) THEN CHAR(49) ELSE CHAR(48) END))+CHAR(113)+CHAR(118)+CHAR(98)+CHAR(97)+CHAR(113))) AND '%'=''";
    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 52 with WallProvider

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

the class MySqlWallTest141 method test_false.

public void test_false() throws Exception {
    WallProvider provider = new MySqlWallProvider();
    String sql = "SELECT name, '******' password, createTime from user where length(name) = 999999.9 or ascii(substring((database()),1,1))=127";
    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 53 with WallProvider

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

the class MySqlWallTest143 method test_false.

public void test_false() throws Exception {
    WallProvider provider = new MySqlWallProvider();
    String sql = //
    "SELECT" + //
    " `Extent1`.`ID`, " + //
    " `Extent1`.`State`, " + //
    " `Extent1`.`CreateTime`, " + //
    " `Extent1`.`UpdateTime`, " + //
    " `Extent1`.`OpeningBank`, " + //
    " `Extent1`.`BankAccount`, " + //
    " `Extent1`.`BankAccountName`, " + //
    " `Extent1`.`Zone`, " + //
    " `Extent1`.`AccountantMobile`, " + //
    " `Extent1`.`IsPublic`" + //
    " FROM `paybank` AS `Extent1`" + //
    " WHERE (`Extent1`.`State` > -1)" + " AND ((`Extent1`.`Zone`) = (CASE WHEN (1 IS  NULL) THEN (1)  ELSE (1) END))";
    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)

Example 54 with WallProvider

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

the class MySqlWallTest43 method test_false.

public void test_false() throws Exception {
    WallProvider provider = new MySqlWallProvider();
    Assert.assertFalse(//
    provider.checkValid(//
    "SELECT COUNT(1) AS count FROM `team` " + "WHERE `team_type` = 'normal' AND 1 = 1 AND `city_id` IN (0,10)"));
    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 55 with WallProvider

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

the class MySqlWallTest43 method test_false2.

public void test_false2() throws Exception {
    WallProvider provider = new MySqlWallProvider();
    Assert.assertFalse(//
    provider.checkValid(//
    "SELECT COUNT(1) AS count FROM `team` " + "WHERE `team_type` = 'normal' AND 1 = 2 AND `city_id` IN (0,10)"));
    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)

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