improve wall filter

This commit is contained in:
wenshao
2013-05-06 14:23:55 +08:00
parent e4ba0b7a0d
commit 16a1e3a6ec
5 changed files with 101 additions and 4 deletions
@@ -31,7 +31,7 @@ public class WallConfig implements WallConfigMBean {
private boolean selectIntoAllow = true;
private boolean selectIntoOutfileAllow = false;
private boolean selectWhereAlwayTrueCheck = true;
private boolean selectHavingAlwayTrueCheck = true;
private boolean selectHavingAlwayTrueCheck = false;
private boolean selectUnionCheck = true;
private boolean createTableAllow = true;
private boolean dropTableAllow = true;
@@ -63,6 +63,7 @@ import com.alibaba.druid.wall.WallContext;
import com.alibaba.druid.wall.WallProvider;
import com.alibaba.druid.wall.WallSqlTableStat;
import com.alibaba.druid.wall.WallVisitor;
import com.alibaba.druid.wall.spi.WallVisitorUtils.WallConditionContext;
import com.alibaba.druid.wall.violation.ErrorCode;
import com.alibaba.druid.wall.violation.IllegalSQLObjectViolation;
@@ -255,8 +256,8 @@ public class MySqlWallVisitor extends MySqlASTVisitorAdapter implements WallVisi
}
if (varName.startsWith("@@") && !checkVar(x.getParent(), x.getName())) {
boolean isTop = WallVisitorUtils.isTopNoneFromSelect(this, x);
if (!isTop) {
boolean noneCondition = WallVisitorUtils.getWallConditionContext() == null;
if (!noneCondition) {
violations.add(new IllegalSQLObjectViolation(ErrorCode.VARIANT_DENY, "variable not allow : "
+ x.getName(), toSQL(x)));
}
@@ -678,7 +678,9 @@ public class WallVisitorUtils {
WallContext context = WallContext.current();
if (context != null) {
if (current.hasPartAlwayTrue() || Boolean.TRUE == value) {
context.incrementWarnnings();
if (!isFirst(x)) {
context.incrementWarnnings();
}
}
}