mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improve wall filter
This commit is contained in:
@@ -24,12 +24,33 @@ public class WallContext {
|
||||
|
||||
private WallSqlStat sqlState;
|
||||
private Map<String, WallSqlTableStat> tableStats;
|
||||
private Map<String, WallSqlFunctionStat> functionStats;
|
||||
private final String dbType;
|
||||
|
||||
public WallContext(String dbType){
|
||||
this.dbType = dbType;
|
||||
}
|
||||
|
||||
public void incrementFunctionInvoke(String tableName) {
|
||||
if (functionStats == null) {
|
||||
functionStats = new HashMap<String, WallSqlFunctionStat>();
|
||||
}
|
||||
|
||||
String lowerCaseName = tableName.toLowerCase();
|
||||
|
||||
WallSqlFunctionStat stat = functionStats.get(lowerCaseName);
|
||||
if (stat == null) {
|
||||
if (functionStats.size() > 100) {
|
||||
return;
|
||||
}
|
||||
|
||||
stat = new WallSqlFunctionStat();
|
||||
functionStats.put(tableName, stat);
|
||||
}
|
||||
|
||||
stat.incrementInvokeCount();
|
||||
}
|
||||
|
||||
public WallSqlTableStat getTableStat(String tableName) {
|
||||
if (tableStats == null) {
|
||||
tableStats = new HashMap<String, WallSqlTableStat>(2);
|
||||
@@ -39,7 +60,7 @@ public class WallContext {
|
||||
|
||||
WallSqlTableStat stat = tableStats.get(lowerCaseName);
|
||||
if (stat == null) {
|
||||
if (tableStats.size() > 10000) {
|
||||
if (tableStats.size() > 100) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -84,6 +105,10 @@ public class WallContext {
|
||||
return tableStats;
|
||||
}
|
||||
|
||||
public Map<String, WallSqlFunctionStat> getFunctionStats() {
|
||||
return functionStats;
|
||||
}
|
||||
|
||||
public String getDbType() {
|
||||
return dbType;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user