revert wallconfig

This commit is contained in:
Yako
2014-08-28 16:21:41 +08:00
parent 8a858b9549
commit eb928486c8
25 changed files with 125 additions and 116 deletions
@@ -27,11 +27,11 @@ public class WallConfig implements WallConfigMBean {
private boolean noneBaseStatementAllow = false;
private boolean callAllow = true;
private boolean selectAllow = true;
private boolean selelctAllow = true;
private boolean selectIntoAllow = true;
private boolean selectIntoOutfileAllow = false;
private boolean selectWhereAlwaysTrueCheck = true;
private boolean selectHavingAlwaysTrueCheck = true;
private boolean selectWhereAlwayTrueCheck = true;
private boolean selectHavingAlwayTrueCheck = true;
private boolean selectUnionCheck = true;
private boolean selectMinusCheck = true;
private boolean selectExceptCheck = true;
@@ -42,19 +42,19 @@ public class WallConfig implements WallConfigMBean {
private boolean renameTableAllow = true;
private boolean hintAllow = true;
private boolean conditionAndAlwaysTrueAllow = false;
private boolean conditionAndAlwaysFalseAllow = false;
private boolean conditionAndAlwayTrueAllow = false;
private boolean conditionAndAlwayFalseAllow = false;
private boolean conditionDoubleConstAllow = false;
private boolean conditionLikeTrueAllow = true;
private boolean selectAllColumnAllow = true;
private boolean deleteAllow = true;
private boolean deleteWhereAlwaysTrueCheck = true;
private boolean deleteWhereAlwayTrueCheck = true;
private boolean deleteWhereNoneCheck = false;
private boolean updateAllow = true;
private boolean updateWhereAlwaysTrueCheck = true;
private boolean updateWhereAlayTrueCheck = true;
private boolean updateWhereNoneCheck = false;
private boolean insertAllow = true;
@@ -114,7 +114,7 @@ public class WallConfig implements WallConfigMBean {
private boolean metadataAllow = true;
private boolean conditionOpXorAllow = false;
private boolean conditionOpBitwiseAllow = true;
private boolean conditionOpBitwseAllow = true;
private boolean caseConditionConstAllow = false;
@@ -154,22 +154,6 @@ public class WallConfig implements WallConfigMBean {
this.limitZeroAllow = limitZero;
}
public boolean isConditionAndAlwaysTrueAllow() {
return conditionAndAlwaysTrueAllow;
}
public void setConditionAndAlwaysTrueAllow(boolean conditionAndAlwaysTrueAllow) {
this.conditionAndAlwaysTrueAllow = conditionAndAlwaysTrueAllow;
}
public boolean isConditionAndAlwaysFalseAllow() {
return conditionAndAlwaysFalseAllow;
}
public void setConditionAndAlwaysFalseAllow(boolean conditionAndAlwaysFalseAllow) {
this.conditionAndAlwaysFalseAllow = conditionAndAlwaysFalseAllow;
}
public boolean isUseAllow() {
return useAllow;
}
@@ -218,14 +202,6 @@ public class WallConfig implements WallConfigMBean {
this.conditionOpXorAllow = conditionOpXorAllow;
}
public boolean isConditionOpBitwiseAllow() {
return conditionOpBitwiseAllow;
}
public void setConditionOpBitwiseAllow(boolean conditionOpBitwiseAllow) {
this.conditionOpBitwiseAllow = conditionOpBitwiseAllow;
}
public String getTenantTablePattern() {
return tenantTablePattern;
}
@@ -365,14 +341,6 @@ public class WallConfig implements WallConfigMBean {
this.truncateAllow = truncateAllow;
}
public boolean isSelectAllow() {
return selectAllow;
}
public void setSelectAllow(boolean selelctAllow) {
this.selectAllow = selelctAllow;
}
public boolean isSelectIntoAllow() {
return selectIntoAllow;
}
@@ -453,22 +421,6 @@ public class WallConfig implements WallConfigMBean {
this.selectIntersectCheck = selectIntersectCheck;
}
public boolean isSelectWhereAlwaysTrueCheck() {
return selectWhereAlwaysTrueCheck;
}
public void setSelectWhereAlwaysTrueCheck(boolean selectWhereAlwayTrueCheck) {
this.selectWhereAlwaysTrueCheck = selectWhereAlwayTrueCheck;
}
public boolean isSelectHavingAlwaysTrueCheck() {
return selectHavingAlwaysTrueCheck;
}
public void setSelectHavingAlwaysTrueCheck(boolean selectHavingAlwayTrueCheck) {
this.selectHavingAlwaysTrueCheck = selectHavingAlwayTrueCheck;
}
public boolean isDeleteAllow() {
return deleteAllow;
}
@@ -477,14 +429,6 @@ public class WallConfig implements WallConfigMBean {
this.deleteAllow = deleteAllow;
}
public boolean isDeleteWhereAlwaysTrueCheck() {
return deleteWhereAlwaysTrueCheck;
}
public void setDeleteWhereAlwaysTrueCheck(boolean deleteWhereAlwayTrueCheck) {
this.deleteWhereAlwaysTrueCheck = deleteWhereAlwayTrueCheck;
}
public boolean isDeleteWhereNoneCheck() {
return deleteWhereNoneCheck;
}
@@ -501,14 +445,6 @@ public class WallConfig implements WallConfigMBean {
this.updateAllow = updateAllow;
}
public boolean isUpdateWhereAlwaysTrueCheck() {
return updateWhereAlwaysTrueCheck;
}
public void setUpdateWhereAlwaysTrueCheck(boolean updateWhereAlayTrueCheck) {
this.updateWhereAlwaysTrueCheck = updateWhereAlayTrueCheck;
}
public boolean isUpdateWhereNoneCheck() {
return updateWhereNoneCheck;
}
@@ -713,7 +649,7 @@ public class WallConfig implements WallConfigMBean {
public void setCallAllow(boolean callAllow) {
this.callAllow = callAllow;
}
public boolean isHintAllow() {
return hintAllow;
}
@@ -748,4 +684,72 @@ public class WallConfig implements WallConfigMBean {
void filterResultsetTenantColumn(Object value);
}
public boolean isSelelctAllow() {
return selelctAllow;
}
public void setSelelctAllow(boolean selelctAllow) {
this.selelctAllow = selelctAllow;
}
public boolean isSelectWhereAlwayTrueCheck() {
return selectWhereAlwayTrueCheck;
}
public void setSelectWhereAlwayTrueCheck(boolean selectWhereAlwayTrueCheck) {
this.selectWhereAlwayTrueCheck = selectWhereAlwayTrueCheck;
}
public boolean isSelectHavingAlwayTrueCheck() {
return selectHavingAlwayTrueCheck;
}
public void setSelectHavingAlwayTrueCheck(boolean selectHavingAlwayTrueCheck) {
this.selectHavingAlwayTrueCheck = selectHavingAlwayTrueCheck;
}
public boolean isConditionAndAlwayTrueAllow() {
return conditionAndAlwayTrueAllow;
}
public void setConditionAndAlwayTrueAllow(boolean conditionAndAlwayTrueAllow) {
this.conditionAndAlwayTrueAllow = conditionAndAlwayTrueAllow;
}
public boolean isConditionAndAlwayFalseAllow() {
return conditionAndAlwayFalseAllow;
}
public void setConditionAndAlwayFalseAllow(boolean conditionAndAlwayFalseAllow) {
this.conditionAndAlwayFalseAllow = conditionAndAlwayFalseAllow;
}
public boolean isDeleteWhereAlwayTrueCheck() {
return deleteWhereAlwayTrueCheck;
}
public void setDeleteWhereAlwayTrueCheck(boolean deleteWhereAlwayTrueCheck) {
this.deleteWhereAlwayTrueCheck = deleteWhereAlwayTrueCheck;
}
public boolean isUpdateWhereAlayTrueCheck() {
return updateWhereAlayTrueCheck;
}
public void setUpdateWhereAlayTrueCheck(boolean updateWhereAlayTrueCheck) {
this.updateWhereAlayTrueCheck = updateWhereAlayTrueCheck;
}
public boolean isConditionOpBitwseAllow() {
return conditionOpBitwseAllow;
}
public void setConditionOpBitwseAllow(boolean conditionOpBitwseAllow) {
this.conditionOpBitwseAllow = conditionOpBitwseAllow;
}
public void setInited(boolean inited) {
this.inited = inited;
}
}
@@ -37,9 +37,9 @@ public interface WallConfigMBean {
void setTruncateAllow(boolean truncateAllow);
boolean isSelectAllow();
boolean isSelelctAllow();
void setSelectAllow(boolean selectAllow);
void setSelelctAllow(boolean selelctAllow);
boolean isSelectIntoAllow();
@@ -53,29 +53,29 @@ public interface WallConfigMBean {
void setSelectUnionCheck(boolean selectUnionCheck);
boolean isSelectWhereAlwaysTrueCheck();
boolean isSelectWhereAlwayTrueCheck();
void setSelectWhereAlwaysTrueCheck(boolean selectWhereAlwaysTrueCheck);
void setSelectWhereAlwayTrueCheck(boolean selectWhereAlwayTrueCheck);
boolean isSelectHavingAlwaysTrueCheck();
boolean isSelectHavingAlwayTrueCheck();
void setSelectHavingAlwaysTrueCheck(boolean selectHavingAlwaysTrueCheck);
void setSelectHavingAlwayTrueCheck(boolean selectHavingAlwayTrueCheck);
boolean isDeleteAllow();
void setDeleteAllow(boolean deleteAllow);
boolean isDeleteWhereAlwaysTrueCheck();
boolean isDeleteWhereAlwayTrueCheck();
void setDeleteWhereAlwaysTrueCheck(boolean deleteWhereAlwaysTrueCheck);
void setDeleteWhereAlwayTrueCheck(boolean deleteWhereAlwayTrueCheck);
boolean isUpdateAllow();
void setUpdateAllow(boolean updateAllow);
boolean isUpdateWhereAlwaysTrueCheck();
boolean isUpdateWhereAlayTrueCheck();
void setUpdateWhereAlwaysTrueCheck(boolean updateWhereAlwaysTrueCheck);
void setUpdateWhereAlayTrueCheck(boolean updateWhereAlayTrueCheck);
boolean isInsertAllow();
@@ -188,7 +188,7 @@ public class DB2WallVisitor extends DB2ASTVisitorAdapter implements WallVisitor
@Override
public boolean visit(SQLSelectStatement x) {
if (!config.isSelectAllow()) {
if (!config.isSelelctAllow()) {
this.getViolations().add(new IllegalSQLObjectViolation(ErrorCode.SELECT_NOT_ALLOW, "selelct not allow",
this.toSQL(x)));
return false;
@@ -15,6 +15,9 @@
*/
package com.alibaba.druid.wall.spi;
import java.util.ArrayList;
import java.util.List;
import com.alibaba.druid.sql.SQLUtils;
import com.alibaba.druid.sql.ast.SQLCommentHint;
import com.alibaba.druid.sql.ast.SQLName;
@@ -66,9 +69,6 @@ import com.alibaba.druid.wall.spi.WallVisitorUtils.WallTopStatementContext;
import com.alibaba.druid.wall.violation.ErrorCode;
import com.alibaba.druid.wall.violation.IllegalSQLObjectViolation;
import java.util.ArrayList;
import java.util.List;
public class MySqlWallVisitor extends MySqlASTVisitorAdapter implements WallVisitor, MySqlASTVisitor {
private final WallConfig config;
@@ -197,7 +197,7 @@ public class MySqlWallVisitor extends MySqlASTVisitorAdapter implements WallVisi
@Override
public boolean visit(SQLSelectStatement x) {
if (!config.isSelectAllow()) {
if (!config.isSelelctAllow()) {
this.getViolations().add(new IllegalSQLObjectViolation(ErrorCode.SELECT_NOT_ALLOW, "select not allow",
this.toSQL(x)));
return false;
@@ -201,7 +201,7 @@ public class OracleWallVisitor extends OracleASTVisitorAdapter implements WallVi
@Override
public boolean visit(SQLSelectStatement x) {
if (!config.isSelectAllow()) {
if (!config.isSelelctAllow()) {
this.getViolations().add(new IllegalSQLObjectViolation(ErrorCode.SELECT_NOT_ALLOW, "select not allow",
this.toSQL(x)));
return false;
@@ -185,7 +185,7 @@ public class PGWallVisitor extends PGASTVisitorAdapter implements WallVisitor {
@Override
public boolean visit(SQLSelectStatement x) {
if (!config.isSelectAllow()) {
if (!config.isSelelctAllow()) {
this.getViolations().add(new IllegalSQLObjectViolation(ErrorCode.SELECT_NOT_ALLOW, "selelct not allow",
this.toSQL(x)));
return false;
@@ -198,7 +198,7 @@ public class SQLServerWallVisitor extends SQLServerASTVisitorAdapter implements
@Override
public boolean visit(SQLSelectStatement x) {
if (!config.isSelectAllow()) {
if (!config.isSelelctAllow()) {
this.getViolations().add(new IllegalSQLObjectViolation(ErrorCode.SELECT_NOT_ALLOW, "selelct not allow",
this.toSQL(x)));
return false;
@@ -275,7 +275,7 @@ public class WallVisitorUtils {
where.setParent(x);
checkCondition(visitor, x.getWhere());
Object whereValue = getConditionValue(visitor, where, visitor.getConfig().isSelectWhereAlwaysTrueCheck());
Object whereValue = getConditionValue(visitor, where, visitor.getConfig().isSelectWhereAlwayTrueCheck());
if (Boolean.TRUE == whereValue) {
if (!isSimpleConstExpr(where)) {// 简单表达式
@@ -292,7 +292,7 @@ public class WallVisitorUtils {
return;
}
if (Boolean.TRUE == getConditionValue(visitor, x, visitor.getConfig().isSelectHavingAlwaysTrueCheck())) {
if (Boolean.TRUE == getConditionValue(visitor, x, visitor.getConfig().isSelectHavingAlwayTrueCheck())) {
if (!isSimpleConstExpr(x)) {
addViolation(visitor, ErrorCode.ALWAYS_TRUE, "having alway true condition not allow", x);
}
@@ -331,7 +331,7 @@ public class WallVisitorUtils {
if (where != null) {
checkCondition(visitor, where);
if (Boolean.TRUE == getConditionValue(visitor, where, config.isDeleteWhereAlwaysTrueCheck())) {
if (Boolean.TRUE == getConditionValue(visitor, where, config.isDeleteWhereAlwayTrueCheck())) {
if (!isSimpleConstExpr(where)) {
addViolation(visitor, ErrorCode.ALWAYS_TRUE, "delete alway true condition not allow", x);
}
@@ -912,7 +912,7 @@ public class WallVisitorUtils {
where.setParent(x);
checkCondition(visitor, where);
if (Boolean.TRUE == getConditionValue(visitor, where, config.isUpdateWhereAlwaysTrueCheck())) {
if (Boolean.TRUE == getConditionValue(visitor, where, config.isUpdateWhereAlayTrueCheck())) {
if (!isSimpleConstExpr(where)) {
addViolation(visitor, ErrorCode.ALWAYS_TRUE, "update alway true condition not allow", x);
}
@@ -1335,11 +1335,11 @@ public class WallVisitorUtils {
}
}
if (current.hasPartAlwayTrue() && alwayTrueCheck && !visitor.getConfig().isConditionAndAlwaysTrueAllow()) {
if (current.hasPartAlwayTrue() && alwayTrueCheck && !visitor.getConfig().isConditionAndAlwayTrueAllow()) {
addViolation(visitor, ErrorCode.ALWAYS_TRUE, "part alway true condition not allow", x);
}
if (current.hasPartAlwayFalse() && !visitor.getConfig().isConditionAndAlwaysFalseAllow()) {
if (current.hasPartAlwayFalse() && !visitor.getConfig().isConditionAndAlwayFalseAllow()) {
addViolation(visitor, ErrorCode.ALWAYS_FALSE, "part alway false condition not allow", x);
}
@@ -1351,7 +1351,7 @@ public class WallVisitorUtils {
addViolation(visitor, ErrorCode.XOR, "xor not allow", x);
}
if (current.hasBitwise() && !visitor.getConfig().isConditionOpBitwiseAllow()) {
if (current.hasBitwise() && !visitor.getConfig().isConditionOpBitwseAllow()) {
addViolation(visitor, ErrorCode.BITWISE, "bitwise operator not allow", x);
}