mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
sql wall visitor
This commit is contained in:
@@ -206,12 +206,29 @@ public class SQLServerWallVisitor extends SQLServerASTVisitorAdapter implements
|
||||
}
|
||||
|
||||
if (config.isVariantCheck() && varName.startsWith("@@")) {
|
||||
violations.add(new IllegalSQLObjectViolation(ErrorCode.VARIANT_DENY, "global variable not allow", toSQL(x)));
|
||||
|
||||
boolean allow = true;
|
||||
if (WallVisitorUtils.isWhereOrHaving(x) && isDeny(varName)) {
|
||||
allow = false;
|
||||
}
|
||||
|
||||
if (!allow) {
|
||||
violations.add(new IllegalSQLObjectViolation(ErrorCode.VARIANT_DENY, "variable not allow : "
|
||||
+ x.getName(), toSQL(x)));
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isDeny(String varName) {
|
||||
if (varName.startsWith("@@")) {
|
||||
varName = varName.substring(2);
|
||||
}
|
||||
|
||||
return config.getDenyVariants().contains(varName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLServerObjectReferenceExpr x) {
|
||||
if (x.getSchema() != null && !provider.checkDenySchema(x.getSchema())) {
|
||||
|
||||
Reference in New Issue
Block a user