use of com.alibaba.druid.sql.ast.statement.SQLStartTransactionStatement in project druid by alibaba.
the class WallVisitorUtils method preVisitCheck.
public static void preVisitCheck(WallVisitor visitor, SQLObject x) {
WallConfig config = visitor.getProvider().getConfig();
if (!(x instanceof SQLStatement)) {
return;
}
boolean allow = false;
int errorCode;
String denyMessage;
if (x instanceof SQLInsertStatement) {
allow = config.isInsertAllow();
denyMessage = "insert not allow";
errorCode = ErrorCode.INSERT_NOT_ALLOW;
} else if (x instanceof SQLSelectStatement) {
allow = true;
denyMessage = "select not allow";
errorCode = ErrorCode.SELECT_NOT_ALLOW;
} else if (x instanceof SQLDeleteStatement) {
allow = config.isDeleteAllow();
denyMessage = "delete not allow";
errorCode = ErrorCode.DELETE_NOT_ALLOW;
} else if (x instanceof SQLUpdateStatement) {
allow = config.isUpdateAllow();
denyMessage = "update not allow";
errorCode = ErrorCode.UPDATE_NOT_ALLOW;
} else if (x instanceof OracleMultiInsertStatement) {
allow = true;
denyMessage = "multi-insert not allow";
errorCode = ErrorCode.INSERT_NOT_ALLOW;
} else if (x instanceof SQLMergeStatement) {
allow = config.isMergeAllow();
denyMessage = "merge not allow";
errorCode = ErrorCode.MERGE_NOT_ALLOW;
} else if (x instanceof SQLCallStatement || x instanceof SQLServerExecStatement) {
allow = config.isCallAllow();
denyMessage = "call not allow";
errorCode = ErrorCode.CALL_NOT_ALLOW;
} else if (x instanceof SQLTruncateStatement) {
allow = config.isTruncateAllow();
denyMessage = "truncate not allow";
errorCode = ErrorCode.TRUNCATE_NOT_ALLOW;
} else if (//
x instanceof SQLCreateTableStatement || //
x instanceof SQLCreateIndexStatement || //
x instanceof SQLCreateViewStatement || //
x instanceof SQLCreateTriggerStatement || //
x instanceof SQLCreateSequenceStatement) {
allow = config.isCreateTableAllow();
denyMessage = "create table not allow";
errorCode = ErrorCode.CREATE_TABLE_NOT_ALLOW;
} else if (x instanceof SQLAlterTableStatement) {
allow = config.isAlterTableAllow();
denyMessage = "alter table not allow";
errorCode = ErrorCode.ALTER_TABLE_NOT_ALLOW;
} else if (//
x instanceof SQLDropTableStatement || //
x instanceof SQLDropIndexStatement || //
x instanceof SQLDropViewStatement || //
x instanceof SQLDropTriggerStatement || //
x instanceof SQLDropSequenceStatement || //
x instanceof SQLDropProcedureStatement) {
allow = config.isDropTableAllow();
denyMessage = "drop table not allow";
errorCode = ErrorCode.DROP_TABLE_NOT_ALLOW;
} else if (//
x instanceof MySqlSetCharSetStatement || //
x instanceof MySqlSetNamesStatement || //
x instanceof SQLSetStatement || x instanceof SQLServerSetStatement) {
allow = config.isSetAllow();
denyMessage = "set not allow";
errorCode = ErrorCode.SET_NOT_ALLOW;
} else if (x instanceof MySqlReplaceStatement) {
allow = config.isReplaceAllow();
denyMessage = "replace not allow";
errorCode = ErrorCode.REPLACE_NOT_ALLOW;
} else if (x instanceof MySqlDescribeStatement) {
allow = config.isDescribeAllow();
denyMessage = "describe not allow";
errorCode = ErrorCode.DESC_NOT_ALLOW;
} else if (x instanceof MySqlShowStatement || x instanceof PGShowStatement || x instanceof SQLShowTablesStatement) {
allow = config.isShowAllow();
denyMessage = "show not allow";
errorCode = ErrorCode.SHOW_NOT_ALLOW;
} else if (x instanceof MySqlCommitStatement || x instanceof SQLServerCommitStatement) {
allow = config.isCommitAllow();
denyMessage = "commit not allow";
errorCode = ErrorCode.COMMIT_NOT_ALLOW;
} else if (x instanceof SQLRollbackStatement) {
allow = config.isRollbackAllow();
denyMessage = "rollback not allow";
errorCode = ErrorCode.ROLLBACK_NOT_ALLOW;
} else if (x instanceof SQLUseStatement) {
allow = config.isUseAllow();
denyMessage = "use not allow";
errorCode = ErrorCode.USE_NOT_ALLOW;
} else if (x instanceof MySqlRenameTableStatement) {
allow = config.isRenameTableAllow();
denyMessage = "rename table not allow";
errorCode = ErrorCode.RENAME_TABLE_NOT_ALLOW;
} else if (x instanceof MySqlHintStatement) {
allow = config.isHintAllow();
denyMessage = "hint not allow";
errorCode = ErrorCode.HINT_NOT_ALLOW;
} else if (x instanceof MySqlLockTableStatement) {
allow = config.isLockTableAllow();
denyMessage = "lock table not allow";
errorCode = ErrorCode.LOCK_TABLE_NOT_ALLOW;
} else if (x instanceof SQLStartTransactionStatement) {
allow = config.isStartTransactionAllow();
denyMessage = "start transaction not allow";
errorCode = ErrorCode.START_TRANSACTION_NOT_ALLOW;
} else if (x instanceof SQLBlockStatement) {
allow = config.isBlockAllow();
denyMessage = "block statement not allow";
errorCode = ErrorCode.BLOCK_NOT_ALLOW;
} else {
allow = config.isNoneBaseStatementAllow();
errorCode = ErrorCode.NONE_BASE_STATEMENT_NOT_ALLOW;
denyMessage = x.getClass() + " not allow";
}
if (!allow) {
addViolation(visitor, errorCode, denyMessage, x);
}
}
use of com.alibaba.druid.sql.ast.statement.SQLStartTransactionStatement in project druid by alibaba.
the class MySqlASTVisitorAdapterTest method test_adapter.
public void test_adapter() throws Exception {
MySqlASTVisitorAdapter adapter = new MySqlASTVisitorAdapter();
new SQLBooleanExpr().accept(adapter);
new SQLLimit().accept(adapter);
new MySqlTableIndex().accept(adapter);
new MySqlKey().accept(adapter);
new MySqlPrimaryKey().accept(adapter);
new MySqlIntervalExpr().accept(adapter);
new SQLBinaryExpr().accept(adapter);
new MySqlPrepareStatement().accept(adapter);
new MySqlExecuteStatement().accept(adapter);
new MysqlDeallocatePrepareStatement().accept(adapter);
new MySqlDeleteStatement().accept(adapter);
new MySqlInsertStatement().accept(adapter);
new MySqlLoadXmlStatement().accept(adapter);
new MySqlReplaceStatement().accept(adapter);
new SQLStartTransactionStatement().accept(adapter);
new MySqlRollbackStatement().accept(adapter);
new MySqlShowColumnsStatement().accept(adapter);
new MySqlShowDatabasesStatement().accept(adapter);
new MySqlShowWarningsStatement().accept(adapter);
new MySqlShowStatusStatement().accept(adapter);
new CobarShowStatus().accept(adapter);
new MySqlKillStatement().accept(adapter);
new MySqlBinlogStatement().accept(adapter);
new MySqlResetStatement().accept(adapter);
new UserSpecification().accept(adapter);
new MySqlPartitionByKey().accept(adapter);
new MySqlOutFileExpr().accept(adapter);
new MySqlUpdateStatement().accept(adapter);
new MySqlSetTransactionStatement().accept(adapter);
new MySqlSetNamesStatement().accept(adapter);
new MySqlShowMasterLogsStatement().accept(adapter);
new MySqlSetCharSetStatement().accept(adapter);
new MySqlShowAuthorsStatement().accept(adapter);
new MySqlShowCollationStatement().accept(adapter);
new MySqlShowBinLogEventsStatement().accept(adapter);
new MySqlShowCharacterSetStatement().accept(adapter);
new MySqlShowContributorsStatement().accept(adapter);
new MySqlShowCreateDatabaseStatement().accept(adapter);
new MySqlShowCreateEventStatement().accept(adapter);
new MySqlShowCreateFunctionStatement().accept(adapter);
new MySqlShowCreateProcedureStatement().accept(adapter);
new MySqlShowCreateTableStatement().accept(adapter);
new MySqlShowCreateTriggerStatement().accept(adapter);
new MySqlShowCreateViewStatement().accept(adapter);
new MySqlShowEngineStatement().accept(adapter);
new MySqlShowEnginesStatement().accept(adapter);
new MySqlShowErrorsStatement().accept(adapter);
new MySqlShowEventsStatement().accept(adapter);
new MySqlShowFunctionCodeStatement().accept(adapter);
new MySqlShowFunctionStatusStatement().accept(adapter);
new MySqlShowGrantsStatement().accept(adapter);
new MySqlUserName().accept(adapter);
new MySqlShowIndexesStatement().accept(adapter);
new MySqlShowKeysStatement().accept(adapter);
new MySqlShowMasterStatusStatement().accept(adapter);
new MySqlShowOpenTablesStatement().accept(adapter);
new MySqlShowBinaryLogsStatement().accept(adapter);
new MySqlShowPluginsStatement().accept(adapter);
new MySqlShowPrivilegesStatement().accept(adapter);
new MySqlShowProcedureCodeStatement().accept(adapter);
new MySqlShowProcedureStatusStatement().accept(adapter);
new MySqlShowProcessListStatement().accept(adapter);
new MySqlShowProfileStatement().accept(adapter);
new MySqlShowSlaveHostsStatement().accept(adapter);
new MySqlShowRelayLogEventsStatement().accept(adapter);
new MySqlShowSlaveStatusStatement().accept(adapter);
new MySqlShowTableStatusStatement().accept(adapter);
new MySqlShowTriggersStatement().accept(adapter);
new MySqlRenameTableStatement().accept(adapter);
new MySqlUnionQuery().accept(adapter);
new MySqlUseIndexHint().accept(adapter);
new MySqlIgnoreIndexHint().accept(adapter);
new MySqlLockTableStatement().accept(adapter);
new MySqlUnlockTablesStatement().accept(adapter);
new MySqlForceIndexHint().accept(adapter);
new MySqlAlterTableChangeColumn().accept(adapter);
new MySqlAlterTableCharacter().accept(adapter);
new MySqlAlterTableOption().accept(adapter);
new MySqlCreateTableStatement().accept(adapter);
new MySqlCharExpr().accept(adapter);
new MySqlUnique().accept(adapter);
new MySqlAlterTableModifyColumn().accept(adapter);
new MySqlAlterTableDiscardTablespace().accept(adapter);
new MySqlAlterTableImportTablespace().accept(adapter);
new TableSpaceOption().accept(adapter);
}
Aggregations