mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improve sql wall
This commit is contained in:
@@ -169,9 +169,9 @@ public class WallContext {
|
||||
}
|
||||
|
||||
public void incrementUpdateNoneConditionWarnnings() {
|
||||
if (this.updateNoneConditionWarnnings == 0) {
|
||||
this.incrementWarnnings();
|
||||
}
|
||||
// if (this.updateNoneConditionWarnnings == 0) {
|
||||
// this.incrementWarnnings();
|
||||
// }
|
||||
this.updateNoneConditionWarnnings++;
|
||||
}
|
||||
|
||||
@@ -180,9 +180,9 @@ public class WallContext {
|
||||
}
|
||||
|
||||
public void incrementDeleteNoneConditionWarnnings() {
|
||||
if (this.deleteNoneConditionWarnnings == 0) {
|
||||
this.incrementWarnnings();
|
||||
}
|
||||
// if (this.deleteNoneConditionWarnnings == 0) {
|
||||
// this.incrementWarnnings();
|
||||
// }
|
||||
this.deleteNoneConditionWarnnings++;
|
||||
}
|
||||
|
||||
|
||||
@@ -665,11 +665,7 @@ public abstract class WallProvider {
|
||||
}
|
||||
|
||||
if (visitor.getViolations().size() == 0 && context != null && context.getWarnnings() >= 2) {
|
||||
if (context.getDeleteNoneConditionWarnnings() > 0) {
|
||||
violations.add(new IllegalSQLObjectViolation(ErrorCode.NONE_CONDITION, "delete none condition", sql));
|
||||
} else if (context.getUpdateNoneConditionWarnnings() > 0) {
|
||||
violations.add(new IllegalSQLObjectViolation(ErrorCode.NONE_CONDITION, "update none condition", sql));
|
||||
} else if (context.getCommentCount() > 0) {
|
||||
if (context.getCommentCount() > 0) {
|
||||
violations.add(new IllegalSQLObjectViolation(ErrorCode.COMMIT_NOT_ALLOW, "comment not allow", sql));
|
||||
} else if (context.getLikeNumberWarnnings() > 0) {
|
||||
violations.add(new IllegalSQLObjectViolation(ErrorCode.COMMIT_NOT_ALLOW, "like number", sql));
|
||||
|
||||
@@ -277,10 +277,6 @@ public class WallVisitorUtils {
|
||||
Object whereValue = getConditionValue(visitor, where, visitor.getConfig().isSelectWhereAlwayTrueCheck());
|
||||
|
||||
if (Boolean.TRUE == whereValue) {
|
||||
if (queryBlockFromIsNull(visitor, x, false)) {
|
||||
addViolation(visitor, ErrorCode.EMPTY_QUERY_HAS_CONDITION, "empty select has condition", x);
|
||||
}
|
||||
|
||||
if (!isSimpleConstExpr(where)) {// 简单表达式
|
||||
addViolation(visitor, ErrorCode.ALWAY_TRUE, "select alway true condition not allow", x);
|
||||
}
|
||||
@@ -2102,7 +2098,8 @@ public class WallVisitorUtils {
|
||||
return;
|
||||
}
|
||||
|
||||
if (WallVisitorUtils.queryBlockFromIsNull(visitor, x.getRight())) {
|
||||
if (!WallVisitorUtils.queryBlockFromIsNull(visitor, x.getLeft())
|
||||
&& WallVisitorUtils.queryBlockFromIsNull(visitor, x.getRight())) {
|
||||
boolean isTopUpdateStatement = false;
|
||||
boolean isTopInsertStatement = false;
|
||||
SQLObject selectParent = x.getParent();
|
||||
|
||||
@@ -43,10 +43,10 @@ public class SyntaxErrorViolation implements Violation {
|
||||
|
||||
public String getMessage() {
|
||||
if (exception == null) {
|
||||
return null;
|
||||
return "syntax error";
|
||||
}
|
||||
|
||||
return exception.getMessage();
|
||||
return "syntax error: " + exception.getMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user