Logo
Database Firewall

Database Firewall #

SyntaxDescriptionType
SHOW DATABASE FIREWALL STRATEGIESView database firewall strategiesRQL
CREATE DATABASE FIREWALL STRATEGYCreate a database firewall strategyRDL
ALTER DATABASE FIREWALL STRATEGYModify a database firewall strategyRDL
DROP DATABASE FIREWALL STRATEGYDelete a database firewall strategyRDL

1. View Database Firewall Strategies #

 SHOW DATABASE FIREWALL STRATEGIES

Example

View all database firewall strategies

 SHOW DATABASE FIREWALL STRATEGIES
 +---------------+----------------+---------------------+-----------------+---------------+
 | strategy_name | algorithm_type | algorithm_type_name | algorithm_props | objects       |
 +---------------+----------------+---------------------+-----------------+---------------+
 | risk_dml      | matching       | risk_dml            |                 | sharding_db.* |
 | risk_dml      | action         | block               |                 | sharding_db.* |
 +---------------+----------------+---------------------+-----------------+---------------+

View a specific database firewall strategy

SHOW DATABASE FIREWALL STRATEGY risk_dml;
+---------------+----------------+---------------------+-----------------+---------------+
| strategy_name | algorithm_type | algorithm_type_name | algorithm_props | objects       |
+---------------+----------------+---------------------+-----------------+---------------+
| risk_dml      | matching       | risk_dml            |                 | sharding_db.* |
| risk_dml      | action         | block               |                 | sharding_db.* |
+---------------+----------------+---------------------+-----------------+---------------+

Output Explanation

ColumnDescription
strategy_nameStrategy name
algorithm_typeAlgorithm type
algorithm_type_nameAlgorithm name
algorithm_propsAlgorithm parameters
objectsEffective objects

2. Create Database Firewall Strategy #

CREATE DATABASE FIREWALL STRATEGY database_firewall_rule ON db.table (MATCHING_ALGORITHMS(TYPE(NAME=" ")),ACTION_ALGORITHMS(TYPE(NAME=" ")))

Example

Create a single-scenario database firewall strategy

CREATE DATABASE FIREWALL STRATEGY join_query  ON sharding_db.*(
MATCHING_ALGORITHMS(
TYPE(NAME="JOIN_QUERY",PROPERTIES("max-allowed-join-table-count"=2))
),
ACTION_ALGORITHMS(
TYPE(NAME="BLOCK")
));

Create a combined-scenario database firewall strategy

CREATE DATABASE FIREWALL STRATEGY sharding_whitelist ON sharding_db.t_order(
MATCHING_ALGORITHMS(
TYPE(NAME="SHARDING"),
TYPE(NAME="USERNAME",PROPERTIES("whitelist"="root"))
),
ACTION_ALGORITHMS(
TYPE(NAME="BLOCK")
));

Parameter Explanation

db.table: Specifies the object to take effect on. This is optional configuration. If not configured, it defaults to * . * for all objects to take effect.

Refer to Built-in Algorithms for related algorithms.

3. Modify Database Firewall Strategy #

ALTER DATABASE FIREWALL STRATEGY database_firewall_rule ON db.table (MATCHING_ALGORITHMS(TYPE(NAME=" ")),ACTION_ALGORITHMS(TYPE(NAME=" ")))

Example

Modify a database firewall strategy

 ALTER DATABASE FIREWALL STRATEGY join_query (
 MATCHING_ALGORITHMS(
 TYPE(NAME="JOIN_QUERY",PROPERTIES("max-allowed-join-table-count"=2))
 ),
 ACTION_ALGORITHMS(
 TYPE(NAME="BLOCK")
 ));

Parameter Explanation

db.table: Specifies the object to take effect on. This is optional configuration. If not configured, it defaults to * . * for all objects to take effect.

Refer to Built-in Algorithms for related algorithms.

4. Delete Database Firewall Strategy #

 DROP DATABASE FIREWALL STRATEGY  database_firewall_rule1,database_firewall_rule2

Example

Delete a single database firewall strategy

 DROP DATABASE FIREWALL STRATEGY join_query;

Delete multiple database firewall strategies

 DROP DATABASE FIREWALL STRATEGY join_query1,join_query2;

Parameter Explanation

Refer to Built-in Algorithms for related algorithms.