mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improve sqlwall: 'hints' and 'start transaction'
This commit is contained in:
@@ -42,6 +42,7 @@ public class WallConfig implements WallConfigMBean {
|
||||
private boolean renameTableAllow = true;
|
||||
private boolean hintAllow = true;
|
||||
private boolean lockTableAllow = true;
|
||||
private boolean startTransactionAllow = true;
|
||||
|
||||
private boolean conditionAndAlwayTrueAllow = false;
|
||||
private boolean conditionAndAlwayFalseAllow = false;
|
||||
@@ -761,4 +762,12 @@ public class WallConfig implements WallConfigMBean {
|
||||
this.lockTableAllow = lockTableAllow;
|
||||
}
|
||||
|
||||
public boolean isStartTransactionAllow() {
|
||||
return startTransactionAllow;
|
||||
}
|
||||
|
||||
public void setStartTransactionAllow(boolean startTransactionAllow) {
|
||||
this.startTransactionAllow = startTransactionAllow;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -107,6 +107,7 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSetCharSetStatemen
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSetNamesStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowGrantsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlStartTransactionStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlUpdateStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser;
|
||||
import com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleCreateSequenceStatement;
|
||||
@@ -2416,6 +2417,10 @@ public class WallVisitorUtils {
|
||||
allow = config.isLockTableAllow();
|
||||
denyMessage = "lock table not allow";
|
||||
errorCode = ErrorCode.LOCK_TABLE_NOT_ALLOW;
|
||||
} else if (x instanceof MySqlStartTransactionStatement) {
|
||||
allow = config.isStartTransactionAllow();
|
||||
denyMessage = "start transaction not allow";
|
||||
errorCode = ErrorCode.START_TRANSACTION_NOT_ALLOW;
|
||||
} else {
|
||||
allow = config.isNoneBaseStatementAllow();
|
||||
errorCode = ErrorCode.NONE_BASE_STATEMENT_NOT_ALLOW;
|
||||
|
||||
@@ -33,6 +33,7 @@ public interface ErrorCode {
|
||||
public final static int CALL_NOT_ALLOW = 1300;
|
||||
public final static int COMMIT_NOT_ALLOW = 1301;
|
||||
public final static int ROLLBACK_NOT_ALLOW = 1302;
|
||||
public final static int START_TRANSACTION_NOT_ALLOW = 1303;
|
||||
|
||||
public final static int SET_NOT_ALLOW = 1200;
|
||||
public final static int DESC_NOT_ALLOW = 1201;
|
||||
@@ -47,7 +48,7 @@ public interface ErrorCode {
|
||||
public final static int DROP_TABLE_NOT_ALLOW = 1103;
|
||||
public final static int COMMENT_STATEMENT_NOT_ALLOW = 1104;
|
||||
public final static int RENAME_TABLE_NOT_ALLOW = 1105;
|
||||
public final static int LOCK_TABLE_NOT_ALLOW = 1105;
|
||||
public final static int LOCK_TABLE_NOT_ALLOW = 1106;
|
||||
|
||||
public final static int LIMIT_ZERO = 2200;
|
||||
public final static int MULTI_STATEMENT = 2201;
|
||||
|
||||
Reference in New Issue
Block a user