mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
Fix obvious mistakes like spelling errors
This commit is contained in:
@@ -15,21 +15,6 @@
|
||||
*/
|
||||
package com.alibaba.druid.wall;
|
||||
|
||||
import static com.alibaba.druid.util.JdbcSqlStatUtils.get;
|
||||
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
import com.alibaba.druid.sql.SQLUtils;
|
||||
import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
import com.alibaba.druid.sql.parser.Lexer;
|
||||
@@ -46,6 +31,21 @@ import com.alibaba.druid.wall.violation.ErrorCode;
|
||||
import com.alibaba.druid.wall.violation.IllegalSQLObjectViolation;
|
||||
import com.alibaba.druid.wall.violation.SyntaxErrorViolation;
|
||||
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
import static com.alibaba.druid.util.JdbcSqlStatUtils.get;
|
||||
|
||||
public abstract class WallProvider {
|
||||
|
||||
private String name;
|
||||
@@ -90,7 +90,7 @@ public abstract class WallProvider {
|
||||
protected final AtomicLong hardCheckCount = new AtomicLong();
|
||||
protected final AtomicLong whiteListHitCount = new AtomicLong();
|
||||
protected final AtomicLong blackListHitCount = new AtomicLong();
|
||||
protected final AtomicLong syntaxErrrorCount = new AtomicLong();
|
||||
protected final AtomicLong syntaxErrorCount = new AtomicLong();
|
||||
protected final AtomicLong violationCount = new AtomicLong();
|
||||
protected final AtomicLong violationEffectRowCount = new AtomicLong();
|
||||
|
||||
@@ -315,8 +315,7 @@ public abstract class WallProvider {
|
||||
Map<String, WallSqlFunctionStat> functionStats, List<Violation> violations,
|
||||
boolean syntaxError) {
|
||||
if (!blackListEnable) {
|
||||
WallSqlStat stat = new WallSqlStat(tableStats, functionStats, violations, syntaxError);
|
||||
return stat;
|
||||
return new WallSqlStat(tableStats, functionStats, violations, syntaxError);
|
||||
}
|
||||
|
||||
String mergedSql;
|
||||
@@ -524,11 +523,8 @@ public abstract class WallProvider {
|
||||
|
||||
functionName = functionName.toLowerCase();
|
||||
|
||||
if (getConfig().getDenyFunctions().contains(functionName)) {
|
||||
return false;
|
||||
}
|
||||
return !getConfig().getDenyFunctions().contains(functionName);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean checkDenySchema(String schemaName) {
|
||||
@@ -541,11 +537,8 @@ public abstract class WallProvider {
|
||||
}
|
||||
|
||||
schemaName = schemaName.toLowerCase();
|
||||
if (getConfig().getDenySchemas().contains(schemaName)) {
|
||||
return false;
|
||||
}
|
||||
return !getConfig().getDenySchemas().contains(schemaName);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean checkDenyTable(String tableName) {
|
||||
@@ -554,11 +547,8 @@ public abstract class WallProvider {
|
||||
}
|
||||
|
||||
tableName = WallVisitorUtils.form(tableName);
|
||||
if (getConfig().getDenyTables().contains(tableName)) {
|
||||
return false;
|
||||
}
|
||||
return !getConfig().getDenyTables().contains(tableName);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean checkReadOnlyTable(String tableName) {
|
||||
@@ -567,11 +557,8 @@ public abstract class WallProvider {
|
||||
}
|
||||
|
||||
tableName = WallVisitorUtils.form(tableName);
|
||||
if (getConfig().isReadOnly(tableName)) {
|
||||
return false;
|
||||
}
|
||||
return !getConfig().isReadOnly(tableName);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public WallDenyStat getCommentDenyStat() {
|
||||
@@ -596,7 +583,7 @@ public abstract class WallProvider {
|
||||
|
||||
WallContext context = WallContext.current();
|
||||
|
||||
if (config.isDoPrivilegedAllow() && ispPivileged()) {
|
||||
if (config.isDoPrivilegedAllow() && ispPrivileged()) {
|
||||
WallCheckResult checkResult = new WallCheckResult();
|
||||
checkResult.setSql(sql);
|
||||
return checkResult;
|
||||
@@ -635,7 +622,7 @@ public abstract class WallProvider {
|
||||
violations.add(new IllegalSQLObjectViolation(ErrorCode.COMMENT_STATEMENT_NOT_ALLOW, "comment not allow", sql));
|
||||
incrementCommentDeniedCount();
|
||||
} catch (ParserException e) {
|
||||
syntaxErrrorCount.incrementAndGet();
|
||||
syntaxErrorCount.incrementAndGet();
|
||||
syntaxError = true;
|
||||
if (config.isStrictSyntaxCheck()) {
|
||||
violations.add(new SyntaxErrorViolation(e, sql));
|
||||
@@ -666,10 +653,10 @@ public abstract class WallProvider {
|
||||
violations.addAll(visitor.getViolations());
|
||||
}
|
||||
|
||||
// if (visitor.getViolations().size() == 0 && context != null && context.getWarnnings() >= 2) {
|
||||
// if (visitor.getViolations().size() == 0 && context != null && context.getWarnings() >= 2) {
|
||||
// if (context.getCommentCount() > 0) {
|
||||
// violations.add(new IllegalSQLObjectViolation(ErrorCode.COMMIT_NOT_ALLOW, "comment not allow", sql));
|
||||
// } else if (context.getLikeNumberWarnnings() > 0) {
|
||||
// } else if (context.getLikeNumberWarnings() > 0) {
|
||||
// violations.add(new IllegalSQLObjectViolation(ErrorCode.COMMIT_NOT_ALLOW, "like number", sql));
|
||||
// } else {
|
||||
// violations.add(new IllegalSQLObjectViolation(ErrorCode.COMPOUND, "multi-warnnings", sql));
|
||||
@@ -702,7 +689,7 @@ public abstract class WallProvider {
|
||||
context.setSqlStat(sqlStat);
|
||||
result = new WallCheckResult(sqlStat, statementList);
|
||||
} else {
|
||||
result = new WallCheckResult(sqlStat, violations, tableStats, functionStats, statementList, syntaxError);
|
||||
result = new WallCheckResult(null, violations, tableStats, functionStats, statementList, syntaxError);
|
||||
}
|
||||
|
||||
String resultSql;
|
||||
@@ -725,7 +712,7 @@ public abstract class WallProvider {
|
||||
violationCount.incrementAndGet();
|
||||
|
||||
if (sqlStat.isSyntaxError()) {
|
||||
syntaxErrrorCount.incrementAndGet();
|
||||
syntaxErrorCount.incrementAndGet();
|
||||
}
|
||||
|
||||
sqlStat.incrementAndGetExecuteCount();
|
||||
@@ -742,7 +729,7 @@ public abstract class WallProvider {
|
||||
sqlStat.incrementAndGetExecuteCount();
|
||||
|
||||
if (sqlStat.isSyntaxError()) {
|
||||
syntaxErrrorCount.incrementAndGet();
|
||||
syntaxErrorCount.incrementAndGet();
|
||||
}
|
||||
|
||||
recordStats(sqlStat.getTableStats(), sqlStat.getFunctionStats());
|
||||
@@ -780,13 +767,13 @@ public abstract class WallProvider {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean ispPivileged() {
|
||||
public static boolean ispPrivileged() {
|
||||
Boolean value = privileged.get();
|
||||
if (value == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return value.booleanValue();
|
||||
return value;
|
||||
}
|
||||
|
||||
public static <T> T doPrivileged(PrivilegedAction<T> action) {
|
||||
@@ -818,7 +805,7 @@ public abstract class WallProvider {
|
||||
}
|
||||
|
||||
public long getSyntaxErrorCount() {
|
||||
return syntaxErrrorCount.get();
|
||||
return syntaxErrorCount.get();
|
||||
}
|
||||
|
||||
public long getCheckCount() {
|
||||
@@ -887,7 +874,7 @@ public abstract class WallProvider {
|
||||
statValue.setViolationEffectRowCount(get(violationEffectRowCount, reset));
|
||||
statValue.setBlackListHitCount(get(blackListHitCount, reset));
|
||||
statValue.setWhiteListHitCount(get(whiteListHitCount, reset));
|
||||
statValue.setSyntaxErrorCount(get(syntaxErrrorCount, reset));
|
||||
statValue.setSyntaxErrorCount(get(syntaxErrorCount, reset));
|
||||
|
||||
for (Map.Entry<String, WallTableStat> entry : this.tableStats.entrySet()) {
|
||||
String tableName = entry.getKey();
|
||||
|
||||
Reference in New Issue
Block a user