8.4.7.4 MySQL Enterprise Firewall Reference (original) (raw)

8.4.7.4 MySQL Enterprise Firewall Reference

The following sections provide a reference to MySQL Enterprise Firewall elements:

MySQL Enterprise Firewall Tables

MySQL Enterprise Firewall maintains profile information on a per-group and per-account basis. It uses tables in the firewall database for persistent storage and INFORMATION_SCHEMA or Performance Schema tables to provide views into in-memory cached data. When enabled, the firewall bases operational decisions on the cached data. The firewall database can be themysql system database or a custom schema (see Installing MySQL Enterprise Firewall).

Firewall Group Profile Tables

MySQL Enterprise Firewall maintains group profile information using tables in the firewall database (mysql or custom) for persistent storage and Performance Schema tables to provide views into in-memory cached data.

Each system and Performance Schema table is accessible only by accounts that have the SELECT privilege for it.

The_`default-database`_.firewall_groups table lists names and operational modes of registered firewall group profiles. The table has the following columns (with the corresponding Performance Schemafirewall_groups table having similar but not necessarily identical columns):

The_`default-database`_.firewall_group_allowlist table lists allowlist rules of registered firewall group profiles. The table has the following columns (with the corresponding Performance Schemafirewall_group_allowlist table having similar but not necessarily identical columns):

The_`default-database`_.firewall_membership table lists the members (accounts) of registered firewall group profiles. The table has the following columns (with the corresponding Performance Schemafirewall_membership table having similar but not necessarily identical columns):

Firewall Account Profile Tables

MySQL Enterprise Firewall maintains account profile information using tables in the firewall database for persistent storage andINFORMATION_SCHEMA tables to provide views into in-memory cached data. The firewall database can be themysql system database or a custom schema (see Installing MySQL Enterprise Firewall).

Each default database table is accessible only by accounts that have the SELECT privilege for it. The INFORMATION_SCHEMA tables are accessible by anyone.

These tables are deprecated, and subject to removal in a future MySQL version. SeeMigrating Account Profiles to Group Profiles.

The_`default-database`_.firewall_users table lists names and operational modes of registered firewall account profiles. The table has the following columns (with the correspondingMYSQL_FIREWALL_USERS table having similar but not necessarily identical columns):

The_`firewall-database`_.firewall_whitelist table lists allowlist rules of registered firewall account profiles. The table has the following columns (with the correspondingMYSQL_FIREWALL_WHITELIST table having similar but not necessarily identical columns):

MySQL Enterprise Firewall Stored Procedures

MySQL Enterprise Firewall stored procedures perform tasks such as registering profiles with the firewall, establishing their operational mode, and managing transfer of firewall data between the cache and persistent storage. These procedures invoke administrative functions that provide an API for lower-level tasks.

Firewall stored procedures are created in the firewall database. The firewall database can be themysql system database or a custom schema (see Installing MySQL Enterprise Firewall).

To invoke a firewall stored procedure, either do so while the specified firewall database is the default database, or qualify the procedure name with the database name. For example, if mysql is the firewall database:

CALL mysql.sp_set_firewall_group_mode(group, mode);

In MySQL 8.4, firewall stored procedures are transactional; if an error occurs during execution of a firewall stored procedure, all changes made by it up to that point are rolled back, and an error is reported.

Note

If you have installed MySQL Enterprise Firewall in a custom schema, then make appropriate substitution for your system. For example, if the firewall is installed in the fwdb schema, then execute the stored procedures like this:

CALL fwdb.sp_set_firewall_group_mode(group, mode);
Firewall Group Profile Stored Procedures

These stored procedures perform management operations on firewall group profiles:

CALL mysql.sp_firewall_group_delist('g', 'fwuser@localhost');  
CALL mysql.sp_firewall_group_enlist('g', 'fwuser@localhost');  
CALL mysql.sp_reload_firewall_group_rules('myapp');  

Warning
This procedure clears the group profile in-memory allowlist rules before reloading them from persistent storage, and sets the profile mode toOFF. If the profile mode was notOFF prior to thesp_reload_firewall_group_rules() call, usesp_set_firewall_group_mode() to restore its previous mode after reloading the rules. For example, if the profile was inPROTECTING mode, that is no longer true after callingsp_reload_firewall_group_rules() and you must set it to PROTECTING again explicitly.

CALL mysql.sp_set_firewall_group_mode('myapp', 'PROTECTING');  

Example:

CALL mysql.sp_set_firewall_group_mode_and_user('myapp', 'RECORDING', 'myapp_user1@localhost');  
Firewall Account Profile Stored Procedures

These stored procedures perform management operations on firewall account profiles:

CALL sp_reload_firewall_rules('fwuser@localhost');  

Warning
This procedure clears the account profile in-memory allowlist rules before reloading them from persistent storage, and sets the profile mode toOFF. If the profile mode was notOFF prior to thesp_reload_firewall_rules() call, usesp_set_firewall_mode() to restore its previous mode after reloading the rules. For example, if the profile was in PROTECTING mode, that is no longer true after callingsp_reload_firewall_rules() and you must set it to PROTECTING again explicitly.
This procedure is deprecated, and subject to removal in a future MySQL version. SeeMigrating Account Profiles to Group Profiles.

mysql> CALL sp_set_firewall_mode('a@b','PROTECTING');  
+----------------------------------------------------------------------+  
| set_firewall_mode(arg_userhost, arg_mode)                            |  
+----------------------------------------------------------------------+  
| ERROR: PROTECTING mode requested for a@b but the allowlist is empty. |  
+----------------------------------------------------------------------+  

This procedure is deprecated, and subject to removal in a future MySQL version. SeeMigrating Account Profiles to Group Profiles.

Firewall Miscellaneous Stored Procedures

These stored procedures perform miscellaneous firewall management operations.

CALL sp_migrate_firewall_user_to_group('fwuser@localhost', 'mygroup);  
MySQL Enterprise Firewall Administrative Functions

MySQL Enterprise Firewall administrative functions provide an API for lower-level tasks such as synchronizing the firewall cache with the underlying system tables.

Under normal operation, these functions are invoked by the firewall stored procedures, not directly by users. For that reason, these function descriptions do not include details such as information about their arguments and return types.

Firewall Group Profile Functions

These functions perform management operations on firewall group profiles:

SELECT firewall_group_delist('g', 'fwuser@localhost');  
SELECT firewall_group_enlist('g', 'fwuser@localhost');  
SELECT read_firewall_group_allowlist('my_fw_group', fgw.rule)  
FROM mysql.firewall_group_allowlist AS fgw  
WHERE NAME = 'my_fw_group';  
SELECT read_firewall_groups('g', 'RECORDING', 'fwuser@localhost')  
FROM mysql.firewall_groups;  
SELECT set_firewall_group_mode('g', 'DETECTING');  
Firewall Account Profile Functions

These functions perform management operations on firewall account profiles:

SELECT read_firewall_users('fwuser@localhost', 'RECORDING')  
FROM mysql.firewall_users;  

This function is deprecated, and subject to removal in a future MySQL version. SeeMigrating Account Profiles to Group Profiles.

SELECT read_firewall_whitelist('fwuser@localhost', fw.rule)  
FROM mysql.firewall_whitelist AS fw  
WHERE USERHOST = 'fwuser@localhost';  

This function is deprecated, and subject to removal in a future MySQL version. SeeMigrating Account Profiles to Group Profiles.

SELECT set_firewall_mode('fwuser@localhost', 'RECORDING');  

This function is deprecated, and subject to removal in a future MySQL version. SeeMigrating Account Profiles to Group Profiles.

Firewall Miscellaneous Functions

These functions perform miscellaneous firewall operations:

SELECT mysql_firewall_flush_status();  
SELECT normalize_statement('SELECT * FROM t1 WHERE c1 > 2');  

Note
The same digest functionality is available outside firewall context using theSTATEMENT_DIGEST_TEXT() SQL function.

MySQL Enterprise Firewall System Variables

MySQL Enterprise Firewall supports the following system variables. Use them to configure firewall operation. These variables are unavailable unless the firewall is installed (seeSection 8.4.7.2, “Installing or Uninstalling MySQL Enterprise Firewall”).