mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improve WallFilter, support intersectAllow
This commit is contained in:
@@ -45,6 +45,7 @@ public class WallConfig implements WallConfigMBean {
|
||||
private boolean insertAllow = true;
|
||||
private boolean mergeAllow = true;
|
||||
private boolean minusAllow = false;
|
||||
private boolean intersectAllow = false;
|
||||
|
||||
private boolean multiStatementAllow = false;
|
||||
|
||||
@@ -91,10 +92,18 @@ public class WallConfig implements WallConfigMBean {
|
||||
|
||||
}
|
||||
|
||||
public boolean isIntersectAllow() {
|
||||
return intersectAllow;
|
||||
}
|
||||
|
||||
public void setIntersectAllow(boolean intersectAllow) {
|
||||
this.intersectAllow = intersectAllow;
|
||||
}
|
||||
|
||||
public boolean isMinusAllow() {
|
||||
return minusAllow;
|
||||
}
|
||||
|
||||
|
||||
public void setMinusAllow(boolean minusAllow) {
|
||||
this.minusAllow = minusAllow;
|
||||
}
|
||||
|
||||
@@ -753,6 +753,11 @@ public class WallVisitorUtils {
|
||||
return;
|
||||
}
|
||||
|
||||
if (x.getOperator() == SQLUnionOperator.INTERSECT && !visitor.getConfig().isIntersectAllow()) {
|
||||
addViolation(visitor, x);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!visitor.getConfig().isSelectUnionCheck()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallConfig;
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
||||
public class IntersectTest extends TestCase {
|
||||
|
||||
public void test_false() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateOracle(//
|
||||
"SELECT * FROM A MINUS SELECT * FROM B")); //
|
||||
}
|
||||
|
||||
public void test_true() throws Exception {
|
||||
WallConfig config = new WallConfig();
|
||||
config.setMinusAllow(true);
|
||||
Assert.assertTrue(WallUtils.isValidateOracle(//
|
||||
"SELECT * FROM A MINUS SELECT * FROM B", config)); //
|
||||
}
|
||||
}
|
||||
@@ -11,13 +11,13 @@ public class MinusTest extends TestCase {
|
||||
|
||||
public void test_false() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateOracle(//
|
||||
"SELECT * FROM A MINUS SELECT * FROM B")); //
|
||||
"SELECT * FROM A Intersect SELECT * FROM B")); //
|
||||
}
|
||||
|
||||
public void test_true() throws Exception {
|
||||
WallConfig config = new WallConfig();
|
||||
config.setMinusAllow(true);
|
||||
config.setIntersectAllow(true);
|
||||
Assert.assertTrue(WallUtils.isValidateOracle(//
|
||||
"SELECT * FROM A MINUS SELECT * FROM B", config)); //
|
||||
"SELECT * FROM A Intersect SELECT * FROM B", config)); //
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user