Search in sources :

Example 11 with WallContext

use of com.alibaba.druid.wall.WallContext in project druid by alibaba.

the class WallVisitorUtils method check.

public static void check(WallVisitor visitor, SQLCreateTableStatement x) {
    String tableName = ((SQLName) x.getName()).getSimpleName();
    WallContext context = WallContext.current();
    if (context != null) {
        WallSqlTableStat tableStat = context.getTableStat(tableName);
        if (tableStat != null) {
            tableStat.incrementCreateCount();
        }
    }
}
Also used : WallSqlTableStat(com.alibaba.druid.wall.WallSqlTableStat) SQLName(com.alibaba.druid.sql.ast.SQLName) WallContext(com.alibaba.druid.wall.WallContext)

Example 12 with WallContext

use of com.alibaba.druid.wall.WallContext in project druid by alibaba.

the class WallVisitorUtils method check.

public static void check(WallVisitor visitor, SQLDropTableStatement x) {
    for (SQLTableSource item : x.getTableSources()) {
        if (item instanceof SQLExprTableSource) {
            SQLExpr expr = ((SQLExprTableSource) item).getExpr();
            String tableName = ((SQLName) expr).getSimpleName();
            WallContext context = WallContext.current();
            if (context != null) {
                WallSqlTableStat tableStat = context.getTableStat(tableName);
                if (tableStat != null) {
                    tableStat.incrementDropCount();
                }
            }
        }
    }
}
Also used : WallSqlTableStat(com.alibaba.druid.wall.WallSqlTableStat) SQLName(com.alibaba.druid.sql.ast.SQLName) SQLExpr(com.alibaba.druid.sql.ast.SQLExpr) WallContext(com.alibaba.druid.wall.WallContext)

Aggregations

WallContext (com.alibaba.druid.wall.WallContext)12 SQLName (com.alibaba.druid.sql.ast.SQLName)6 SQLExpr (com.alibaba.druid.sql.ast.SQLExpr)5 WallSqlTableStat (com.alibaba.druid.wall.WallSqlTableStat)5 SQLObject (com.alibaba.druid.sql.ast.SQLObject)4 SQLCommentHint (com.alibaba.druid.sql.ast.SQLCommentHint)2 WallConfig (com.alibaba.druid.wall.WallConfig)2 SQLNumericLiteralExpr (com.alibaba.druid.sql.ast.expr.SQLNumericLiteralExpr)1 SQLPropertyExpr (com.alibaba.druid.sql.ast.expr.SQLPropertyExpr)1 SQLValuableExpr (com.alibaba.druid.sql.ast.expr.SQLValuableExpr)1 MySqlDeleteStatement (com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlDeleteStatement)1 MySqlReplaceStatement (com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlReplaceStatement)1 MySqlShowGrantsStatement (com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowGrantsStatement)1 MySqlUpdateStatement (com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlUpdateStatement)1 IllegalSQLObjectViolation (com.alibaba.druid.wall.violation.IllegalSQLObjectViolation)1