mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
sqll wall improved oracle support, fix #4103
This commit is contained in:
@@ -2724,6 +2724,12 @@ public class WallVisitorUtils {
|
||||
}
|
||||
}
|
||||
|
||||
if ((!isWhite) && visitor.getDbType() == DbType.oracle) {
|
||||
if (text.startsWith("+")) {
|
||||
isWhite = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isWhite) {
|
||||
addViolation(visitor, ErrorCode.EVIL_HINTS, "hint not allow", x);
|
||||
}
|
||||
|
||||
@@ -27,10 +27,17 @@ public class OracleWallTest extends TestCase {
|
||||
public void testWall() throws Exception {
|
||||
WallConfig config = new WallConfig();
|
||||
config.setSelectUnionCheck(true);
|
||||
Assert.assertTrue(WallUtils.isValidateOracle("select f1, f2 from t where c=1 union select 1, 2",config));
|
||||
Assert.assertFalse(WallUtils.isValidateOracle("select f1, f2 from t where c=1 union select 1, 2 --",config));
|
||||
assertTrue(WallUtils.isValidateOracle("select f1, f2 from t where c=1 union select 1, 2",config));
|
||||
assertFalse(WallUtils.isValidateOracle("select f1, f2 from t where c=1 union select 1, 2 --",config));
|
||||
|
||||
Assert.assertFalse(WallUtils.isValidateOracle("SELECT * FROM T UNION select * from TAB"));
|
||||
Assert.assertFalse(WallUtils.isValidateOracle("SELECT * FROM T UNION select * from ALL_TABLES where (1=1 or (1+1)=2) and (4=8 or 1=1)"));
|
||||
assertFalse(WallUtils.isValidateOracle("SELECT * FROM T UNION select * from TAB"));
|
||||
assertFalse(WallUtils.isValidateOracle("SELECT * FROM T UNION select * from ALL_TABLES where (1=1 or (1+1)=2) and (4=8 or 1=1)"));
|
||||
}
|
||||
|
||||
public void testWall_1() throws Exception {
|
||||
WallConfig config = new WallConfig();
|
||||
|
||||
assertTrue(
|
||||
WallUtils.isValidateOracle("select/*+QUERY_TIMEOUT(600000000)*/ * from test_number",config));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user