Search in sources :

Example 6 with FirewallConfig

use of com.actiontech.dble.config.model.FirewallConfig in project dble by actiontech.

the class ServerPrivileges method checkFirewallSQLPolicy.

/**
 * @see <a href="https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE-wallfilter">wallfilter config guide</a>
 */
@Override
public boolean checkFirewallSQLPolicy(String user, String sql) {
    if (isManagerUser(user)) {
        // manager User will ignore firewall blacklist
        return true;
    }
    boolean isPassed = true;
    FirewallConfig firewallConfig = DbleServer.getInstance().getConfig().getFirewall();
    if (firewallConfig != null && firewallConfig.isBlackListCheck()) {
        WallCheckResult result = firewallConfig.getProvider().check(sql);
        if (!result.getViolations().isEmpty()) {
            isPassed = false;
            ALARM.warn("Firewall to intercept the '" + user + "' unsafe SQL , errMsg:" + result.getViolations().get(0).getMessage() + " \r\n " + sql);
        }
    }
    return isPassed;
}
Also used : FirewallConfig(com.actiontech.dble.config.model.FirewallConfig) WallCheckResult(com.alibaba.druid.wall.WallCheckResult)

Aggregations

FirewallConfig (com.actiontech.dble.config.model.FirewallConfig)6 UserConfig (com.actiontech.dble.config.model.UserConfig)5 PhysicalDBNode (com.actiontech.dble.backend.datasource.PhysicalDBNode)3 PhysicalDBPool (com.actiontech.dble.backend.datasource.PhysicalDBPool)3 ERTable (com.actiontech.dble.config.model.ERTable)3 SchemaConfig (com.actiontech.dble.config.model.SchemaConfig)3 Set (java.util.Set)3 ConfigInitializer (com.actiontech.dble.config.ConfigInitializer)2 ServerConfig (com.actiontech.dble.config.ServerConfig)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ConfigException (com.actiontech.dble.config.util.ConfigException)1 SystemVariables (com.actiontech.dble.server.variables.SystemVariables)1 VarsExtractorHandler (com.actiontech.dble.server.variables.VarsExtractorHandler)1 WallCheckResult (com.alibaba.druid.wall.WallCheckResult)1 WallConfig (com.alibaba.druid.wall.WallConfig)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Element (org.w3c.dom.Element)1 Node (org.w3c.dom.Node)1