sqll wall improved oracle support, fix #4103

This commit is contained in:
高铁
2020-12-26 06:27:38 +08:00
parent ff9a671fea
commit 0cdc717924
2 changed files with 17 additions and 4 deletions
@@ -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));
}
}