mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
merge
This commit is contained in:
@@ -172,9 +172,19 @@ public class WallConfig {
|
||||
public Set<String> getPermitObjects() {
|
||||
return permitObjects;
|
||||
}
|
||||
|
||||
public boolean isPermitObjects(String name) {
|
||||
name = WallVisitorUtils.form(name);
|
||||
return permitObjects.contains(name);
|
||||
}
|
||||
|
||||
public boolean containsPermitSchema(String name) {
|
||||
public boolean isPermitSchema(String name) {
|
||||
name = WallVisitorUtils.form(name);
|
||||
return this.permitSchemas.contains(name);
|
||||
}
|
||||
|
||||
public boolean isPermitFunction(String name) {
|
||||
name = WallVisitorUtils.form(name);
|
||||
return this.permitFunctions.contains(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,5 @@ public interface WallVisitor extends SQLASTVisitor {
|
||||
|
||||
boolean containsPermitTable(String name);
|
||||
|
||||
boolean containsPermitObjects(String name);
|
||||
|
||||
String toSQL(SQLObject obj);
|
||||
}
|
||||
|
||||
@@ -46,11 +46,6 @@ public class MySqlWallVisitor extends MySqlASTVisitorAdapter implements WallVisi
|
||||
return config;
|
||||
}
|
||||
|
||||
public boolean containsPermitObjects(String name) {
|
||||
name = name.toLowerCase();
|
||||
return config.getPermitObjects().contains(name);
|
||||
}
|
||||
|
||||
public List<Violation> getViolations() {
|
||||
return violations;
|
||||
}
|
||||
@@ -205,7 +200,7 @@ public class MySqlWallVisitor extends MySqlASTVisitorAdapter implements WallVisi
|
||||
if (!config.isTableCheck()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
name = WallVisitorUtils.form(name);
|
||||
return config.getPermitTables().contains(name);
|
||||
}
|
||||
|
||||
@@ -158,11 +158,6 @@ public class OracleWallVisitor extends OracleASTVIsitorAdapter implements WallVi
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsPermitObjects(String name) {
|
||||
return config.getPermitObjects().contains(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLSelectStatement x) {
|
||||
if (!config.isSelelctAllow()) {
|
||||
|
||||
@@ -47,7 +47,7 @@ public class WallVisitorUtils {
|
||||
if (x.getOwner() instanceof SQLIdentifierExpr) {
|
||||
String owner = x.getOwner().toString();
|
||||
owner = WallVisitorUtils.form(owner);
|
||||
if (visitor.containsPermitObjects(owner)) {
|
||||
if (visitor.getConfig().isPermitObjects(owner)) {
|
||||
visitor.getViolations().add(new IllegalSQLObjectViolation(visitor.toSQL(x)));
|
||||
}
|
||||
}
|
||||
@@ -391,7 +391,7 @@ public class WallVisitorUtils {
|
||||
if (x.getOwner() instanceof SQLIdentifierExpr) {
|
||||
String owner = x.getOwner().toString();
|
||||
owner = WallVisitorUtils.form(owner);
|
||||
if (visitor.containsPermitObjects(owner)) {
|
||||
if (visitor.getConfig().isPermitObjects(owner)) {
|
||||
visitor.getViolations().add(new IllegalSQLObjectViolation(visitor.toSQL(x)));
|
||||
}
|
||||
}
|
||||
@@ -402,7 +402,7 @@ public class WallVisitorUtils {
|
||||
|
||||
String methodName = x.getMethodName();
|
||||
|
||||
if (visitor.getConfig().getPermitFunctions().contains(methodName.toLowerCase())) {
|
||||
if (visitor.getConfig().isPermitFunction(methodName.toLowerCase())) {
|
||||
visitor.getViolations().add(new IllegalSQLObjectViolation(visitor.toSQL(x)));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user