Merge pull request #621 from yakolee/master

improve sqlwall
This commit is contained in:
Yako
2014-08-22 16:26:31 +08:00
2 changed files with 28 additions and 0 deletions
@@ -445,6 +445,11 @@ public class MySqlWallVisitor extends MySqlASTVisitorAdapter implements WallVisi
@Override
public boolean visit(SQLCommentHint x) {
if(!provider.getConfig().isHintAllow()) {
addViolation(new IllegalSQLObjectViolation(ErrorCode.EVIL_HINTS, "hint not allow", SQLUtils.toMySqlString(x)));
return true;
}
String text = x.getText();
text = text.trim();
if (text.startsWith("!")) {
@@ -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 HintTest extends TestCase {
public void test_false() throws Exception {
WallConfig config = new WallConfig();
config.setHintAllow(false);
String sql = "select * from person where id = '3'/**/union select 0,1,v from (select 1,2,user/*!() as v*/) a where '1'<>''";
Assert.assertFalse(WallUtils.isValidateMySql(sql, config)); //
}
public void test_true() throws Exception {
String sql = "select * from person where id = '3'/**/union select 0,1,v from (select 1,2,user/*!() as v*/) a where '1'<>''";
Assert.assertTrue(WallUtils.isValidateMySql(sql)); //
}
}