mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
add wall test
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.filter.wall.WallUtils;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* 这个场景测试访问Oracle系统表
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
public class OracleWallPermitTableTest extends TestCase {
|
||||
|
||||
public void test_permitTable() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateOracle("select * from TAB"));
|
||||
Assert.assertFalse(WallUtils.isValidateOracle("select * from tab"));
|
||||
Assert.assertFalse(WallUtils.isValidateOracle("select * from SYS.TAB"));
|
||||
Assert.assertFalse(WallUtils.isValidateOracle("select * from SYS.\"TAB\""));
|
||||
}
|
||||
|
||||
public void test_permitTable_subquery() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateOracle("select * from(select * from TAB) a"));
|
||||
Assert.assertFalse(WallUtils.isValidateOracle("select * from(select * from tab) a"));
|
||||
Assert.assertFalse(WallUtils.isValidateOracle("select * from(select * from SYS.TAB) a"));
|
||||
Assert.assertFalse(WallUtils.isValidateOracle("select * from(select * from SYS.\"TAB\") a"));
|
||||
}
|
||||
|
||||
public void test_permitTable_join() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateOracle("select * from t1, TAB"));
|
||||
Assert.assertFalse(WallUtils.isValidateOracle("select * from t1, tab"));
|
||||
Assert.assertFalse(WallUtils.isValidateOracle("select * from t1, SYS.TAB"));
|
||||
Assert.assertFalse(WallUtils.isValidateOracle("select * from t1, SYS.\"TAB\""));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.filter.wall.WallUtils;
|
||||
|
||||
/**
|
||||
* 这个场景,被攻击者用于测试当前SQL拥有多少字段
|
||||
* @author wenshao
|
||||
*
|
||||
*/
|
||||
public class WallUnionTest extends TestCase {
|
||||
|
||||
public void testMySql() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateMySql("select f1, f2 from t union select 1, 2"));
|
||||
}
|
||||
|
||||
public void testOracle() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateOracle("select f1, f2 from t union select 1, 2"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user