mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
sql wall
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.filter.wall.WallConfig;
|
||||
import com.alibaba.druid.filter.wall.WallUtils;
|
||||
|
||||
/**
|
||||
* 这个场景,检测
|
||||
* @author wenshao
|
||||
*
|
||||
*/
|
||||
public class WallDeleteTest extends TestCase {
|
||||
private String sql = "DELETE FROM T WHERE F1 = ?";
|
||||
|
||||
private WallConfig config = new WallConfig();
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
config.setDeleteAllow(false);
|
||||
}
|
||||
|
||||
public void testMySql() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateMySql(sql, config));
|
||||
}
|
||||
|
||||
public void testORACLE() throws Exception {
|
||||
|
||||
Assert.assertFalse(WallUtils.isValidateOracle(sql, config));
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import org.junit.Assert;
|
||||
import com.alibaba.druid.filter.wall.WallUtils;
|
||||
|
||||
/**
|
||||
* 这个场景,检测可疑的Having条件
|
||||
*
|
||||
* @author wenshao
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.filter.wall.WallUtils;
|
||||
|
||||
/**
|
||||
* 这个场景,检测可疑的Having条件
|
||||
* @author wenshao
|
||||
*
|
||||
*/
|
||||
public class WallDeleteWhereTest1 extends TestCase {
|
||||
private String sql = "DELETE FROM T";
|
||||
|
||||
public void testMySql() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateMySql(sql));
|
||||
}
|
||||
|
||||
public void testORACLE() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateOracle(sql));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.filter.wall.WallConfig;
|
||||
import com.alibaba.druid.filter.wall.WallUtils;
|
||||
|
||||
/**
|
||||
* 这个场景,检测
|
||||
* @author wenshao
|
||||
*
|
||||
*/
|
||||
public class WallInsertTest extends TestCase {
|
||||
private String sql = "INSERT INTO T (F1, F2) VALUES (1, 2)";
|
||||
|
||||
private WallConfig config = new WallConfig();
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
config.setInsertAllow(false);
|
||||
}
|
||||
|
||||
public void testMySql() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateMySql(sql, config));
|
||||
}
|
||||
|
||||
public void testORACLE() throws Exception {
|
||||
|
||||
Assert.assertFalse(WallUtils.isValidateOracle(sql, config));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.filter.wall.WallConfig;
|
||||
import com.alibaba.druid.filter.wall.WallUtils;
|
||||
|
||||
/**
|
||||
* 这个场景,检测
|
||||
* @author wenshao
|
||||
*
|
||||
*/
|
||||
public class WallInsertTest2 extends TestCase {
|
||||
private String sql = "INSERT INTO T (F1, F2) VALUES (1, 2)";
|
||||
|
||||
private WallConfig config = new WallConfig();
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
config.setInsertAllow(true);
|
||||
}
|
||||
|
||||
public void testMySql() throws Exception {
|
||||
Assert.assertTrue(WallUtils.isValidateMySql(sql, config));
|
||||
}
|
||||
|
||||
public void testORACLE() throws Exception {
|
||||
|
||||
Assert.assertTrue(WallUtils.isValidateOracle(sql, config));
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import org.junit.Assert;
|
||||
import com.alibaba.druid.filter.wall.WallUtils;
|
||||
|
||||
/**
|
||||
* 这个场景,检测可疑的Having条件
|
||||
* 这个场景,检测可疑的Where条件
|
||||
* @author wenshao
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.filter.wall.WallConfig;
|
||||
import com.alibaba.druid.filter.wall.WallUtils;
|
||||
|
||||
/**
|
||||
* 这个场景,检测
|
||||
* @author wenshao
|
||||
*
|
||||
*/
|
||||
public class WallUpdateTest extends TestCase {
|
||||
private String sql = "UPDATE T_USER SET FNAME = ? WHERE FID = ?";
|
||||
|
||||
private WallConfig config = new WallConfig();
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
config.setDeleteAllow(false);
|
||||
}
|
||||
|
||||
public void testMySql() throws Exception {
|
||||
Assert.assertTrue(WallUtils.isValidateMySql(sql, config));
|
||||
}
|
||||
|
||||
public void testORACLE() throws Exception {
|
||||
|
||||
Assert.assertTrue(WallUtils.isValidateOracle(sql, config));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.filter.wall.WallConfig;
|
||||
import com.alibaba.druid.filter.wall.WallUtils;
|
||||
|
||||
/**
|
||||
* 这个场景,检测
|
||||
* @author wenshao
|
||||
*
|
||||
*/
|
||||
public class WallUpdateTest1 extends TestCase {
|
||||
private String sql = "UPDATE T_USER SET FNAME = ? WHERE FID = ?";
|
||||
|
||||
private WallConfig config = new WallConfig();
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
config.setUpdateAllow(false);
|
||||
}
|
||||
|
||||
public void testMySql() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateMySql(sql, config));
|
||||
}
|
||||
|
||||
public void testORACLE() throws Exception {
|
||||
|
||||
Assert.assertFalse(WallUtils.isValidateOracle(sql, config));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.filter.wall.WallConfig;
|
||||
import com.alibaba.druid.filter.wall.WallUtils;
|
||||
|
||||
/**
|
||||
* 这个场景,检测
|
||||
* @author wenshao
|
||||
*
|
||||
*/
|
||||
public class WallUpdateTest2 extends TestCase {
|
||||
private String sql = "UPDATE T_USER SET FNAME = ?";
|
||||
|
||||
private WallConfig config = new WallConfig();
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
config.setUpdateAllow(true);
|
||||
}
|
||||
|
||||
public void testMySql() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateMySql(sql, config));
|
||||
}
|
||||
|
||||
public void testORACLE() throws Exception {
|
||||
|
||||
Assert.assertFalse(WallUtils.isValidateOracle(sql, config));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.filter.wall.WallConfig;
|
||||
import com.alibaba.druid.filter.wall.WallUtils;
|
||||
|
||||
/**
|
||||
* 这个场景,检测
|
||||
* @author wenshao
|
||||
*
|
||||
*/
|
||||
public class WallUpdateTest3 extends TestCase {
|
||||
private String sql = "UPDATE T_USER SET FNAME = ? WHERE 1 = 1";
|
||||
|
||||
private WallConfig config = new WallConfig();
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
config.setUpdateAllow(true);
|
||||
}
|
||||
|
||||
public void testMySql() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateMySql(sql, config));
|
||||
}
|
||||
|
||||
public void testORACLE() throws Exception {
|
||||
|
||||
Assert.assertFalse(WallUtils.isValidateOracle(sql, config));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.filter.wall.WallConfig;
|
||||
import com.alibaba.druid.filter.wall.WallUtils;
|
||||
|
||||
/**
|
||||
* 这个场景,检测
|
||||
* @author wenshao
|
||||
*
|
||||
*/
|
||||
public class WallUpdateTest4 extends TestCase {
|
||||
private String sql = "UPDATE T_USER SET FNAME = ? WHERE FID = ? OR 1 = 1";
|
||||
|
||||
private WallConfig config = new WallConfig();
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
config.setUpdateAllow(true);
|
||||
}
|
||||
|
||||
public void testMySql() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateMySql(sql, config));
|
||||
}
|
||||
|
||||
public void testORACLE() throws Exception {
|
||||
|
||||
Assert.assertFalse(WallUtils.isValidateOracle(sql, config));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user