Search in sources :

Example 6 with WallConfig

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

the class Issue_728 method test1.

public void test1() throws Exception {
    String sql = "select * from city_list where city_id = 3-1";
    WallConfig config = new WallConfig();
    config.setConstArithmeticAllow(false);
    Assert.assertFalse(WallUtils.isValidateMySql(sql, config));
}
Also used : WallConfig(com.alibaba.druid.wall.WallConfig)

Example 7 with WallConfig

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

the class Issue_728 method test2.

public void test2() throws Exception {
    String sql = "SELECT * from city_list where 2 = case when 2=1 then 1 else 2 END";
    WallConfig config = new WallConfig();
    config.setCaseConditionConstAllow(false);
    Assert.assertFalse(WallUtils.isValidateMySql(sql, config));
}
Also used : WallConfig(com.alibaba.druid.wall.WallConfig)

Example 8 with WallConfig

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

the class BitwiseAndTest method test_false.

public void test_false() throws Exception {
    WallConfig config = new WallConfig();
    config.setConditionOpBitwseAllow(false);
    Assert.assertFalse(//
    WallUtils.isValidateMySql("SELECT * from t where (id = 1) & 2", //
    config));
}
Also used : WallConfig(com.alibaba.druid.wall.WallConfig)

Example 9 with WallConfig

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

the class BitwiseOrTest method test_false.

public void test_false() throws Exception {
    WallConfig config = new WallConfig();
    config.setConditionOpBitwseAllow(false);
    Assert.assertFalse(//
    WallUtils.isValidateMySql("SELECT * from t where (id = 1) | 2", //
    config));
}
Also used : WallConfig(com.alibaba.druid.wall.WallConfig)

Example 10 with WallConfig

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

the class BitwiseXorTest method test_false.

public void test_false() throws Exception {
    WallConfig config = new WallConfig();
    config.setConditionOpBitwseAllow(false);
    Assert.assertFalse(//
    WallUtils.isValidateMySql("SELECT * from t where (id = 1) ^ (1=1)", //
    config));
}
Also used : WallConfig(com.alibaba.druid.wall.WallConfig)

Aggregations

WallConfig (com.alibaba.druid.wall.WallConfig)83 Properties (java.util.Properties)8 WallFilter (com.alibaba.druid.wall.WallFilter)5 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)4 WallCheckResult (com.alibaba.druid.wall.WallCheckResult)3 Filter (com.alibaba.druid.filter.Filter)2 SQLExpr (com.alibaba.druid.sql.ast.SQLExpr)2 OracleMockDriver (com.alibaba.druid.test.util.OracleMockDriver)2 WallContext (com.alibaba.druid.wall.WallContext)2 MySqlWallProvider (com.alibaba.druid.wall.spi.MySqlWallProvider)2 SQLCommentHint (com.alibaba.druid.sql.ast.SQLCommentHint)1 SQLStatement (com.alibaba.druid.sql.ast.SQLStatement)1 SQLStartTransactionStatement (com.alibaba.druid.sql.ast.statement.SQLStartTransactionStatement)1 MySqlCommitStatement (com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlCommitStatement)1 MySqlDeleteStatement (com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlDeleteStatement)1 MySqlDescribeStatement (com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlDescribeStatement)1 MySqlHintStatement (com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlHintStatement)1 MySqlLockTableStatement (com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlLockTableStatement)1 MySqlRenameTableStatement (com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlRenameTableStatement)1 MySqlReplaceStatement (com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlReplaceStatement)1