You can create, modify, delete, enable, and disable blacklist rules in the PolarDB console. This topic describes the concept of blacklist rules and how to configure blacklist rules.
Blacklist rules
PolarProxy allows you to configure blacklist rules to block specified types of SQL statements or specific SQL statements.
You can configure blacklist rules in the following ways:
- Fixed rule mode: You can configure common blacklist rules in the console. Each rule can be effective for an account or a cluster. For more information about common rules, see Table 1.
- Custom parameterized SQL mode: You can parameterize all variables in SQL statements that you execute in a database, generate a parameterized template, and record the template in the database. PolarProxy blocks SQL statements that meet the parameterized template.
- Custom SQL mode: You can specify SQL statements to be blocked without parameterizing their variables. SQL statements that use other parameters are not blocked.
Add a blacklist rule
Enable or disable a blacklist rule
Note When you disabled a blacklist rule created in custom parameterized SQL mode or custom
SQL mode, the SQL statements in the blacklist rule table in the database are retained
even if the blacklist rule is disabled. If the blacklist rule is enabled again, the
rule is still applicable to the same accounts. If you want to completely disable the
blacklist rule, you can connect to the primary node in the cluster by using the super
administrator account and delete the SQL statements from the
proxy_auditing.sql_list
table. When you delete the SQL statements this way, the SQL statements will not be
blocked after five seconds. When you delete the SQL statements from the proxy_auditing.sql_list
table, do not execute the DROP
statement to delete the table.
Modify a blacklist rule
Note The parameterized SQL statements in a rule created in custom parameterized SQL mode rule and the SQL statements in a rule created in custom SQL mode cannot be modified in the console. You must delete the SQL statements from the table
and then add them again.
Delete a blacklist rule
Note When you delete a blacklist rule created in custom parameterized SQL mode or custom
SQL mode, the SQL statements in the blacklist rule table in the database are retained
in the
proxy_auditing.sql_list
table even if the blacklist rule is deleted. If you want to completely delete the
blacklist rule, you can connect to the primary node in the cluster by using the super
administrator account and delete the SQL statements from the proxy_auditing.sql_list
table. When you delete the SQL statements this way, the SQL statements will not be
blocked after five seconds. When you delete the SQL statements from the proxy_auditing.sql_list
table, do not execute the DROP
statement to delete the table.
Cancel a blacklist rule created in custom parameterized SQL mode or custom SQL mode
- Cancel a blacklist rule created in custom parameterized SQL mode
You can use one of the following methods to cancel a blacklist rule created in custom parameterized SQL mode:
- Cancel a blacklist rule created in custom parameterized SQL mode as stated in Enable or disable a blacklist rule or Delete a blacklist rule.
Note If you only disable a blacklist rule created in custom parameterized SQL mode in the console and do not delete the parameterized SQL statements from the
proxy_auditing.sql_list
table, the rule of the same account still take effect when the blacklist rule is enabled again in the console. - Connect to the primary node in the cluster by using the super administrator account
and delete the SQL statements from the
proxy_auditing.sql_list
table. The parameterized SQL statement will not be blocked after five seconds.Note When you delete the SQL statements from the proxy_auditing.sql_list table, do not execute theDROP
statement to delete the table.
- Cancel a blacklist rule created in custom parameterized SQL mode as stated in Enable or disable a blacklist rule or Delete a blacklist rule.
- Cancel a blacklist rule created in custom SQL mode
You can use one of the following methods to cancel a blacklist rule created in custom SQL mode:
- Cancel a blacklist rule created in custom SQL mode as stated in Enable or disable a blacklist rule or Delete a blacklist rule.
Note If you only disable a blacklist rule created in custom SQL mode in the console and do not delete the SQL statements from the
proxy_auditing.org_sql_list
table, the rule of the same account still take effect when the blacklist rule is enabled again in the console. - Connect to the primary node in the cluster by using the super administrator account
and delete the SQL statements from the
proxy_auditing.org_sql_list
table. The SQL statement will not be blocked after five seconds.Note When you delete the SQL statements from the proxy_auditing.org_sql_list table, do not execute theDROP
statement to delete the table.
- Cancel a blacklist rule created in custom SQL mode as stated in Enable or disable a blacklist rule or Delete a blacklist rule.