Skip to content
/ server Public
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions mysql-test/suite/plugins/r/server_audit_double_comma.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#
# Test for double comma handling in SERVER_AUDIT_INCL_USERS
# Bug: Double commas (e.g., 'user1,,user2') cause all users to be logged
# Expected: Only user1 and user2 should be logged
#
CREATE USER 'audit_user1'@'localhost' IDENTIFIED BY 'password1';
CREATE USER 'audit_user2'@'localhost' IDENTIFIED BY 'password2';
CREATE USER 'audit_user3'@'localhost' IDENTIFIED BY 'password3';
GRANT ALL ON *.* TO 'audit_user1'@'localhost';
GRANT ALL ON *.* TO 'audit_user2'@'localhost';
GRANT ALL ON *.* TO 'audit_user3'@'localhost';
#
# Install the audit plugin
#
INSTALL PLUGIN server_audit SONAME 'server_audit';
#
# Set up audit log file
#
#
# Configure audit with double comma in incl_users
#
SET GLOBAL server_audit_logging = OFF;
SET GLOBAL server_audit_events = 'QUERY';
SET GLOBAL server_audit_file_path = 'server_audit_double_comma.log';
SET GLOBAL server_audit_output_type = 'FILE';
SET GLOBAL server_audit_incl_users = 'audit_user1,,audit_user2';
SET GLOBAL server_audit_logging = ON;
#
# Connect as user1 - should be logged
#
connect conn1, localhost, audit_user1, password1,;
SELECT 'query_from_user1';
query_from_user1
query_from_user1
disconnect conn1;
#
# Connect as user2 - should be logged
#
connect conn2, localhost, audit_user2, password2,;
SELECT 'query_from_user2';
query_from_user2
query_from_user2
disconnect conn2;
#
# Connect as user3 - should NOT be logged (not in incl_users)
#
connect conn3, localhost, audit_user3, password3,;
SELECT 'query_from_user3_NOT_in_list';
query_from_user3_NOT_in_list
query_from_user3_NOT_in_list
disconnect conn3;
connection default;
#
# Cleanup
#
SET GLOBAL server_audit_logging = OFF;
UNINSTALL PLUGIN server_audit;
Warnings:
Warning 1620 Plugin is busy and will be uninstalled on shutdown
DROP USER 'audit_user1'@'localhost';
DROP USER 'audit_user2'@'localhost';
DROP USER 'audit_user3'@'localhost';
#
# Verify audit log - user3 queries should NOT appear
#
# The audit log should contain queries from user1 and user2 only
# If the bug exists, user3 queries will also appear (all users logged)
TIME,HOSTNAME,root,localhost,CONNECTION_ID,QUERY_ID,QUERY,test,'SET GLOBAL server_audit_logging = ON',0
TIME,HOSTNAME,audit_user1,localhost,CONNECTION_ID,QUERY_ID,QUERY,test,'SELECT \'query_from_user1\'',0
TIME,HOSTNAME,audit_user2,localhost,CONNECTION_ID,QUERY_ID,QUERY,test,'SELECT \'query_from_user2\'',0
TIME,HOSTNAME,root,localhost,CONNECTION_ID,QUERY_ID,QUERY,test,'SET GLOBAL server_audit_logging = OFF',0
#
# Remove the temporary audit log
#
# Test completed - double comma handling verified
104 changes: 104 additions & 0 deletions mysql-test/suite/plugins/r/server_audit_edge_commas.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@

=======================================================================
Test for leading and trailing commas in SERVER_AUDIT_INCL_USERS
Bug: Edge commas (e.g., ',user1,user2,') cause all users to be logged
Expected: Only user1 and user2 should be logged
=======================================================================
CREATE USER 'audit_user1'@'localhost' IDENTIFIED BY 'password1';
CREATE USER 'audit_user2'@'localhost' IDENTIFIED BY 'password2';
CREATE USER 'audit_user3'@'localhost' IDENTIFIED BY 'password3';
GRANT ALL ON *.* TO 'audit_user1'@'localhost';
GRANT ALL ON *.* TO 'audit_user2'@'localhost';
GRANT ALL ON *.* TO 'audit_user3'@'localhost';

=======================================================================
Install the audit plugin
=======================================================================
INSTALL PLUGIN server_audit SONAME 'server_audit';

=======================================================================
Set up audit log file
=======================================================================

=======================================================================
TEST 1: Leading comma - ',user1,user2'
=======================================================================
SET GLOBAL server_audit_logging = OFF;
SET GLOBAL server_audit_events = 'QUERY';
SET GLOBAL server_audit_file_path = 'server_audit_edge_commas_leading.log';
SET GLOBAL server_audit_output_type = 'FILE';
SET GLOBAL server_audit_incl_users = ',audit_user1,audit_user2';
SET GLOBAL server_audit_logging = ON;
connect conn1a, localhost, audit_user1, password1,;
SELECT 'leading_test_user1';
leading_test_user1
leading_test_user1
disconnect conn1a;
connect conn3a, localhost, audit_user3, password3,;
SELECT 'leading_test_user3_NOT_in_list';
leading_test_user3_NOT_in_list
leading_test_user3_NOT_in_list
disconnect conn3a;
connection default;
SET GLOBAL server_audit_logging = OFF;
# Leading comma test - user3 should NOT appear:
TIME,HOSTNAME,root,localhost,CONNECTION_ID,QUERY_ID,QUERY,test,'SET GLOBAL server_audit_logging = ON',0
TIME,HOSTNAME,audit_user1,localhost,CONNECTION_ID,QUERY_ID,QUERY,test,'SELECT \'leading_test_user1\'',0
TIME,HOSTNAME,root,localhost,CONNECTION_ID,QUERY_ID,QUERY,test,'SET GLOBAL server_audit_logging = OFF',0

=======================================================================
TEST 2: Trailing comma - 'user1,user2,'
=======================================================================
SET GLOBAL server_audit_file_path = 'server_audit_edge_commas_trailing.log';
SET GLOBAL server_audit_incl_users = 'audit_user1,audit_user2,';
SET GLOBAL server_audit_logging = ON;
connect conn1b, localhost, audit_user1, password1,;
SELECT 'trailing_test_user1';
trailing_test_user1
trailing_test_user1
disconnect conn1b;
connect conn3b, localhost, audit_user3, password3,;
SELECT 'trailing_test_user3_NOT_in_list';
trailing_test_user3_NOT_in_list
trailing_test_user3_NOT_in_list
disconnect conn3b;
connection default;
SET GLOBAL server_audit_logging = OFF;
# Trailing comma test - user3 should NOT appear:
TIME,HOSTNAME,root,localhost,CONNECTION_ID,QUERY_ID,QUERY,test,'SET GLOBAL server_audit_logging = ON',0
TIME,HOSTNAME,audit_user1,localhost,CONNECTION_ID,QUERY_ID,QUERY,test,'SELECT \'trailing_test_user1\'',0
TIME,HOSTNAME,root,localhost,CONNECTION_ID,QUERY_ID,QUERY,test,'SET GLOBAL server_audit_logging = OFF',0

=======================================================================
TEST 3: Both leading and trailing commas - ',user1,user2,'
=======================================================================
SET GLOBAL server_audit_file_path = 'server_audit_edge_commas_both.log';
SET GLOBAL server_audit_incl_users = ',audit_user1,audit_user2,';
SET GLOBAL server_audit_logging = ON;
connect conn1c, localhost, audit_user1, password1,;
SELECT 'both_test_user1';
both_test_user1
both_test_user1
disconnect conn1c;
connect conn3c, localhost, audit_user3, password3,;
SELECT 'both_test_user3_NOT_in_list';
both_test_user3_NOT_in_list
both_test_user3_NOT_in_list
disconnect conn3c;
connection default;
SET GLOBAL server_audit_logging = OFF;
# Both commas test - user3 should NOT appear:
TIME,HOSTNAME,root,localhost,CONNECTION_ID,QUERY_ID,QUERY,test,'SET GLOBAL server_audit_logging = ON',0
TIME,HOSTNAME,audit_user1,localhost,CONNECTION_ID,QUERY_ID,QUERY,test,'SELECT \'both_test_user1\'',0
TIME,HOSTNAME,root,localhost,CONNECTION_ID,QUERY_ID,QUERY,test,'SET GLOBAL server_audit_logging = OFF',0

=======================================================================
Cleanup
=======================================================================
UNINSTALL PLUGIN server_audit;
Warnings:
Warning 1620 Plugin is busy and will be uninstalled on shutdown
DROP USER 'audit_user1'@'localhost';
DROP USER 'audit_user2'@'localhost';
DROP USER 'audit_user3'@'localhost';
# Test completed - edge commas handling verified
84 changes: 84 additions & 0 deletions mysql-test/suite/plugins/r/server_audit_empty_input.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@

=======================================================================
Test for empty and invalid input in SERVER_AUDIT_INCL_USERS
Tests: empty string, only commas, only whitespace and commas
Expected: When incl_users is effectively empty, ALL users are logged
(empty inclusion list = no filtering)
=======================================================================
CREATE USER 'audit_user1'@'localhost' IDENTIFIED BY 'password1';
GRANT ALL ON *.* TO 'audit_user1'@'localhost';

=======================================================================
Install the audit plugin
=======================================================================
INSTALL PLUGIN server_audit SONAME 'server_audit';

=======================================================================
Set up audit log file
=======================================================================

=======================================================================
TEST 1: Only commas - ',,,'
=======================================================================
SET GLOBAL server_audit_logging = OFF;
SET GLOBAL server_audit_events = 'QUERY';
SET GLOBAL server_audit_file_path = 'server_audit_empty1.log';
SET GLOBAL server_audit_output_type = 'FILE';
SET GLOBAL server_audit_incl_users = ',,,';
SET GLOBAL server_audit_logging = ON;
connect conn1a, localhost, audit_user1, password1,;
SELECT 'empty1_test_user1_should_log_all';
empty1_test_user1_should_log_all
empty1_test_user1_should_log_all
disconnect conn1a;
connection default;
SET GLOBAL server_audit_logging = OFF;
# Only commas test - all users should be logged (no filter):
TIME,HOSTNAME,root,localhost,CONNECTION_ID,QUERY_ID,QUERY,test,'SET GLOBAL server_audit_logging = ON',0
TIME,HOSTNAME,audit_user1,localhost,CONNECTION_ID,QUERY_ID,QUERY,test,'SELECT \'empty1_test_user1_should_log_all\'',0
TIME,HOSTNAME,root,localhost,CONNECTION_ID,QUERY_ID,QUERY,test,'SET GLOBAL server_audit_logging = OFF',0

=======================================================================
TEST 2: Whitespace and commas - ' , , '
=======================================================================
SET GLOBAL server_audit_file_path = 'server_audit_empty2.log';
SET GLOBAL server_audit_incl_users = ' , , ';
SET GLOBAL server_audit_logging = ON;
connect conn1b, localhost, audit_user1, password1,;
SELECT 'empty2_test_user1_should_log_all';
empty2_test_user1_should_log_all
empty2_test_user1_should_log_all
disconnect conn1b;
connection default;
SET GLOBAL server_audit_logging = OFF;
# Whitespace and commas test - all users should be logged (no filter):
TIME,HOSTNAME,root,localhost,CONNECTION_ID,QUERY_ID,QUERY,test,'SET GLOBAL server_audit_logging = ON',0
TIME,HOSTNAME,audit_user1,localhost,CONNECTION_ID,QUERY_ID,QUERY,test,'SELECT \'empty2_test_user1_should_log_all\'',0
TIME,HOSTNAME,root,localhost,CONNECTION_ID,QUERY_ID,QUERY,test,'SET GLOBAL server_audit_logging = OFF',0

=======================================================================
TEST 3: Empty string - ''
=======================================================================
SET GLOBAL server_audit_file_path = 'server_audit_empty3.log';
SET GLOBAL server_audit_incl_users = '';
SET GLOBAL server_audit_logging = ON;
connect conn1c, localhost, audit_user1, password1,;
SELECT 'empty3_test_user1_should_log_all';
empty3_test_user1_should_log_all
empty3_test_user1_should_log_all
disconnect conn1c;
connection default;
SET GLOBAL server_audit_logging = OFF;
# Empty string test - all users should be logged (no filter):
TIME,HOSTNAME,root,localhost,CONNECTION_ID,QUERY_ID,QUERY,test,'SET GLOBAL server_audit_logging = ON',0
TIME,HOSTNAME,audit_user1,localhost,CONNECTION_ID,QUERY_ID,QUERY,test,'SELECT \'empty3_test_user1_should_log_all\'',0
TIME,HOSTNAME,root,localhost,CONNECTION_ID,QUERY_ID,QUERY,test,'SET GLOBAL server_audit_logging = OFF',0

=======================================================================
Cleanup
=======================================================================
UNINSTALL PLUGIN server_audit;
Warnings:
Warning 1620 Plugin is busy and will be uninstalled on shutdown
DROP USER 'audit_user1'@'localhost';
# Test completed - empty input handling verified
77 changes: 77 additions & 0 deletions mysql-test/suite/plugins/r/server_audit_excl_double_comma.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#
# Test for double comma handling in SERVER_AUDIT_EXCL_USERS
# Bug: Double commas (e.g., 'user1,,user2') cause incorrect exclusion behavior
# Expected: Only user1 and user2 should be excluded from logging
#
CREATE USER 'audit_user1'@'localhost' IDENTIFIED BY 'password1';
CREATE USER 'audit_user2'@'localhost' IDENTIFIED BY 'password2';
CREATE USER 'audit_user3'@'localhost' IDENTIFIED BY 'password3';
GRANT ALL ON *.* TO 'audit_user1'@'localhost';
GRANT ALL ON *.* TO 'audit_user2'@'localhost';
GRANT ALL ON *.* TO 'audit_user3'@'localhost';
#
# Install the audit plugin
#
INSTALL PLUGIN server_audit SONAME 'server_audit';
#
# Set up audit log file
#
#
# Configure audit with double comma in excl_users
# user1 and user2 should be EXCLUDED (not logged)
# user3 should be INCLUDED (logged)
#
SET GLOBAL server_audit_logging = OFF;
SET GLOBAL server_audit_events = 'QUERY';
SET GLOBAL server_audit_file_path = 'server_audit_excl_double_comma.log';
SET GLOBAL server_audit_output_type = 'FILE';
SET GLOBAL server_audit_excl_users = 'audit_user1,,audit_user2';
SET GLOBAL server_audit_logging = ON;
#
# Connect as user1 - should NOT be logged (excluded)
#
connect conn1, localhost, audit_user1, password1,;
SELECT 'query_from_user1_EXCLUDED';
query_from_user1_EXCLUDED
query_from_user1_EXCLUDED
disconnect conn1;
#
# Connect as user2 - should NOT be logged (excluded)
#
connect conn2, localhost, audit_user2, password2,;
SELECT 'query_from_user2_EXCLUDED';
query_from_user2_EXCLUDED
query_from_user2_EXCLUDED
disconnect conn2;
#
# Connect as user3 - SHOULD be logged (not in excl_users)
#
connect conn3, localhost, audit_user3, password3,;
SELECT 'query_from_user3_SHOULD_LOG';
query_from_user3_SHOULD_LOG
query_from_user3_SHOULD_LOG
disconnect conn3;
connection default;
#
# Cleanup
#
SET GLOBAL server_audit_logging = OFF;
UNINSTALL PLUGIN server_audit;
Warnings:
Warning 1620 Plugin is busy and will be uninstalled on shutdown
DROP USER 'audit_user1'@'localhost';
DROP USER 'audit_user2'@'localhost';
DROP USER 'audit_user3'@'localhost';
#
# Verify audit log - only user3 queries should appear
#
# The audit log should contain queries from user3 only
# user1 and user2 are excluded and should NOT appear
# If the bug exists, user1 and user2 queries will also appear
TIME,HOSTNAME,root,localhost,CONNECTION_ID,QUERY_ID,QUERY,test,'SET GLOBAL server_audit_logging = ON',0
TIME,HOSTNAME,audit_user3,localhost,CONNECTION_ID,QUERY_ID,QUERY,test,'SELECT \'query_from_user3_SHOULD_LOG\'',0
TIME,HOSTNAME,root,localhost,CONNECTION_ID,QUERY_ID,QUERY,test,'SET GLOBAL server_audit_logging = OFF',0
#
# Remove the temporary audit log
#
# Test completed - excl_users double comma handling verified
Loading