improve sql wall

This commit is contained in:
yakolee
2014-04-10 11:20:02 +08:00
parent b5eda0cf2e
commit e62605bfed
3 changed files with 12 additions and 3 deletions
@@ -632,7 +632,7 @@ public abstract class WallProvider {
+ lastToken, sql));
}
} catch (NotAllowCommentException e) {
violations.add(new SyntaxErrorViolation(e, sql));
violations.add(new IllegalSQLObjectViolation(ErrorCode.COMMENT_STATEMENT_NOT_ALLOW, "comment not allow", sql));
incrementCommentDeniedCount();
} catch (ParserException e) {
syntaxErrrorCount.incrementAndGet();
@@ -347,6 +347,12 @@ public class WallVisitorUtils {
}
for (SQLExpr part : parts) {
if(isFirst(part)) {
Object evalValue = part.getAttribute(EVAL_VALUE);
if(evalValue != null && evalValue instanceof Boolean && (Boolean)evalValue) {
return true;
}
}
boolean isSimpleConstExpr = false;
if (part == sqlExpr || part instanceof SQLLiteralExpr) {
isSimpleConstExpr = true;
@@ -2358,11 +2364,11 @@ public class WallVisitorUtils {
errorCode = ErrorCode.SHOW_NOT_ALLOW;
} else if (x instanceof MySqlCommitStatement) {
allow = config.isCommitAllow();
denyMessage = "show not allow";
denyMessage = "commit not allow";
errorCode = ErrorCode.COMMIT_NOT_ALLOW;
} else if (x instanceof SQLRollbackStatement) {
allow = config.isRollbackAllow();
denyMessage = "show not allow";
denyMessage = "rollback not allow";
errorCode = ErrorCode.ROLLBACK_NOT_ALLOW;
} else if (x instanceof SQLUseStatement) {
allow = config.isUseAllow();
@@ -45,5 +45,8 @@ public class MySqlWallTest extends TestCase {
Assert.assertTrue(WallUtils.isValidateMySql("select 'outfile'"));
Assert.assertFalse(WallUtils.isValidateMySql("select f1, f2 from t union select 1, 2"));
Assert.assertTrue(WallUtils.isValidateMySql("select c1 from t where 1=1 or id =1"));
Assert.assertFalse(WallUtils.isValidateMySql("select c1 from t where id =1 or 1=1"));
}
}