Examples of WallContext


Examples of com.alibaba.druid.wall.WallContext

            return;
        }

        SQLExpr where = x.getWhere();
        if (where == null) {
            WallContext context = WallContext.current();
            if (context != null) {
                context.incrementUpdateNoneConditionWarnnings();
            }

            if (config.isUpdateWhereNoneCheck()) {
                if (x instanceof MySqlUpdateStatement) {
                    MySqlUpdateStatement mysqlUpdate = (MySqlUpdateStatement) x;
View Full Code Here

Examples of com.alibaba.druid.wall.WallContext

        SQLExpr right = x.getRight();
        Object leftResult = getValue(visitor, left);
        Object rightResult = getValue(visitor, right);

        if (x.getOperator() == SQLBinaryOperator.Like || x.getOperator() == SQLBinaryOperator.NotLike) {
            WallContext context = WallContext.current();
            if (context != null) {
                if (rightResult instanceof Number || leftResult instanceof Number) {
                    context.incrementLikeNumberWarnnings();
                }
            }
        }

        if (x.getOperator() == SQLBinaryOperator.BooleanAnd) {
            if (Boolean.FALSE == leftResult || Boolean.FALSE == rightResult) {
                return false;
            }

            if (leftResult == Boolean.TRUE) {
                if (!isFirst(x.getLeft())) {
                    final WallConditionContext current = wallConditionContextLocal.get();
                    if (current != null) {
                        current.setPartAlwayTrue(true);
                    }
                }
            } else if (rightResult == Boolean.TRUE) {
                final WallConditionContext current = wallConditionContextLocal.get();

                boolean isLikeAlwayTrue = false;
                if (right instanceof SQLBinaryOpExpr
                    && ((SQLBinaryOpExpr) right).getOperator() == SQLBinaryOperator.Like) {
                    isLikeAlwayTrue = true;
                }

                if (current != null && !isLikeAlwayTrue) {
                    current.setPartAlwayTrue(true);
                }
            }

            if (Boolean.TRUE == leftResult && Boolean.TRUE == rightResult) {
                return true;
            }
        }

        String dbType = null;
        WallContext wallContext = WallContext.current();
        if (wallContext != null) {
            dbType = wallContext.getDbType();
        }

        return SQLEvalVisitorUtils.eval(dbType, x, Collections.emptyList(), false);
    }
View Full Code Here

Examples of com.alibaba.druid.wall.WallContext

        try {
            wallConditionContextLocal.set(new WallConditionContext());
            final Object value = getValue(visitor, x);

            final WallConditionContext current = wallConditionContextLocal.get();
            WallContext context = WallContext.current();
            if (context != null) {
                if (current.hasPartAlwayTrue() || Boolean.TRUE == value) {
                    if (!isFirst(x)) {
                        context.incrementWarnnings();
                    }
                }
            }

            if (current.hasPartAlwayTrue() && alwayTrueCheck && !visitor.getConfig().isConditionAndAlwayTrueAllow()) {
View Full Code Here

Examples of com.alibaba.druid.wall.WallContext

            return;
        }

        String methodName = x.getMethodName();

        WallContext context = WallContext.current();
        if (context != null) {
            context.incrementFunctionInvoke(methodName);
        }

        if (!visitor.getProvider().checkDenyFunction(methodName)) {
            boolean isTopNoneFrom = isTopNoneFromSelect(visitor, x);
            if (isTopNoneFrom) {
View Full Code Here

Examples of com.alibaba.druid.wall.WallContext

        }

        if (expr instanceof SQLName) {
            String tableName = ((SQLName) expr).getSimleName();

            WallContext context = WallContext.current();
            if (context != null) {
                WallSqlTableStat tableStat = context.getTableStat(tableName);
                if (tableStat != null) {
                    SQLObject parent = x.getParent();

                    while (parent instanceof SQLTableSource) {
                        parent = parent.getParent();
View Full Code Here

Examples of com.alibaba.druid.wall.WallContext

            if (isTopUpdateStatement) {
                return;
            }

            WallContext context = WallContext.current();
            if (context != null) {
                context.incrementUnionWarnnings();
            }

            if (visitor.getConfig().isSelectUnionCheck()) {
                addViolation(visitor, ErrorCode.UNION, "union query not contains 'from clause'", x);
            }
View Full Code Here

Examples of com.alibaba.druid.wall.WallContext

    }

    @Override
    public boolean visit(Limit x) {
        if (x.getRowCount() instanceof SQLNumericLiteralExpr) {
            WallContext context = WallContext.current();

            int rowCount = ((SQLNumericLiteralExpr) x.getRowCount()).getNumber().intValue();
            if (rowCount == 0) {
                if (context != null) {
                    context.incrementWarnnings();
                }

                if (!provider.getConfig().isLimitZeroAllow()) {
                    this.getViolations().add(new IllegalSQLObjectViolation(ErrorCode.LIMIT_ZERO, "limit row 0",
                                                                           this.toSQL(x)));
View Full Code Here

Examples of com.alibaba.druid.wall.WallContext

    }

    @Override
    public boolean visit(MySqlShowCreateTableStatement x) {
        String tableName = ((SQLName) x.getName()).getSimleName();
        WallContext context = WallContext.current();
        if (context != null) {
            WallSqlTableStat tableStat = context.getTableStat(tableName);
            if (tableStat != null) {
                tableStat.incrementShowCount();
            }
        }
        return false;
View Full Code Here

Examples of com.alibaba.druid.wall.WallContext

    }

    @Override
    public boolean visit(Limit x) {
        if (x.getRowCount() instanceof SQLNumericLiteralExpr) {
            WallContext context = WallContext.current();

            int rowCount = ((SQLNumericLiteralExpr) x.getRowCount()).getNumber().intValue();
            if (rowCount == 0) {
                if (context != null) {
                    context.incrementWarnnings();
                }

                if (!provider.getConfig().isLimitZeroAllow()) {
                    this.getViolations().add(new IllegalSQLObjectViolation(ErrorCode.LIMIT_ZERO, "limit row 0",
                                                                           this.toSQL(x)));
View Full Code Here

Examples of com.alibaba.druid.wall.WallContext

    }

    @Override
    public boolean visit(MySqlShowCreateTableStatement x) {
        String tableName = ((SQLName) x.getName()).getSimleName();
        WallContext context = WallContext.current();
        if (context != null) {
            WallSqlTableStat tableStat = context.getTableStat(tableName);
            if (tableStat != null) {
                tableStat.incrementShowCount();
            }
        }
        return false;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.