mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improve WallFilter
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
||||
public class ConstantArithmeticCheckTest extends TestCase {
|
||||
|
||||
public void test_true() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateMySql(//
|
||||
"SELECT * from t where id = 3 - 1")); //
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallConfig;
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
||||
/**
|
||||
@@ -30,13 +31,27 @@ import com.alibaba.druid.wall.WallUtils;
|
||||
*/
|
||||
public class MySqlWallTest2 extends TestCase {
|
||||
|
||||
public void test_stuff() throws Exception {
|
||||
public void test_true() throws Exception {
|
||||
WallConfig config = new WallConfig();
|
||||
config.setConstArithmeticAllow(true);
|
||||
Assert.assertTrue(WallUtils.isValidateMySql(//
|
||||
"select * from person_qingjia " + //
|
||||
"where isxiao=1 " + //
|
||||
"and ((starttime between 2013-01-15 and 2013-01-15)" + //
|
||||
" or (endtime between 2013-01- 15 and 2013-01-15)" + //
|
||||
") " + //
|
||||
"order by xiaojiatime desc"));
|
||||
"order by xiaojiatime desc", config));
|
||||
}
|
||||
|
||||
public void test_false() throws Exception {
|
||||
WallConfig config = new WallConfig();
|
||||
config.setConstArithmeticAllow(true);
|
||||
Assert.assertFalse(WallUtils.isValidateMySql(//
|
||||
"select * from person_qingjia " + //
|
||||
"where isxiao=1 " + //
|
||||
"and ((starttime between 2013-01-15 and 2013-01-15)" + //
|
||||
" or (endtime between 2013-01- 15 and 2013-01-15)" + //
|
||||
") " + //
|
||||
"order by xiaojiatime desc", config));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user