File: audit_plugin_bugs.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (231 lines) | stat: -rw-r--r-- 8,551 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
--source include/have_null_audit_plugin.inc
--source include/have_debug.inc

call mtr.add_suppression("Event 'MYSQL_AUDIT_GENERAL_ERROR' cannot be aborted.");

let $expected_extension= so;
if(`SELECT CONVERT(@@version_compile_os USING latin1)
           IN ("Win32","Win64","Windows")`)
{
   let $expected_extension= dll;
}

--echo #
--echo # Bug #22142209: MY_MESSAGE FAILS TO ABORT MYSQL_AUDIT_SERVER_STARTUP_CLASS EVENT
--echo #

let $error_log= $MYSQLTEST_VARDIR/log/my_restart.err;

--error 0,1
--remove_file $error_log

--echo # Shutdown the server
let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect;
--exec echo "wait" > $restart_file
--shutdown_server
--source include/wait_until_disconnected.inc

--echo # Load the plugin at startup and abort on STARTUP with default message
--replace_regex /\.dll/.so/
--error 1
--exec $MYSQLD_CMD --loose-console $AUDIT_NULL_OPT --plugin-load=null_audit=adt_null.$expected_extension --null_audit_event_order_check="MYSQL_AUDIT_SERVER_STARTUP_STARTUP;;ABORT_RET" > $error_log 2>&1

--echo # Search for default abort message
let SEARCH_FILE= $error_log;
let SEARCH_PATTERN= \[ERROR\] \[[^]]*\] \[[^]]*\] Aborted by Audit API \(\'MYSQL_AUDIT_SERVER_STARTUP_STARTUP\'.1\)\.;
--source include/search_pattern.inc

--error 0,1
--remove_file $error_log

--echo # Load the plugin at startup and abort on STARTUP event with custom message
--replace_regex /\.dll/.so/
--error 1
--exec $MYSQLD_CMD --loose-console $AUDIT_NULL_OPT --plugin-load=null_audit=adt_null.$expected_extension --null_audit_event_order_check="MYSQL_AUDIT_SERVER_STARTUP_STARTUP;;ABORT_RET" --null_audit_abort_message="Abort message custom" > $error_log 2>&1

--echo # Search for custom abort message
let SEARCH_PATTERN= \[ERROR\] \[[^]]*\] \[[^]]*\] Abort message custom;
--source include/search_pattern.inc

--error 0,1
--remove_file $error_log

--echo # Startup the server
--exec echo "restart" > $restart_file
--enable_reconnect
--source include/wait_until_connected_again.inc
--disable_reconnect

--echo #
--echo # Bug #22136709: INFINITE RECURSION BY CALLING MY_MESSAGE FROM
--echo #   MYSQL_AUDIT_GENERAL_CLASS HANDLER

--replace_regex /\.dll/.so/
eval INSTALL PLUGIN null_audit SONAME '$AUDIT_NULL';

# Save the initial number of concurrent sessions
--source include/count_sessions.inc

SET @@GLOBAL.null_audit_event_order_check= "MYSQL_AUDIT_GENERAL_ERROR;;ABORT_RET";
SET @@GLOBAL.null_audit_abort_message= "Abort message.";

--echo # Try to enter error state recursively 2 times.
SET @@GLOBAL.null_audit_event_order_check_consume_ignore_count= 2;
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
--error ER_ACCESS_DENIED_ERROR
connect(user1_con,localhost,wrong_root,);
SELECT @@null_audit_event_order_check_consume_ignore_count;

--echo # Try to enter error state infinitely. my_message calls cause stack overrun.
SET @@GLOBAL.null_audit_event_order_check_consume_ignore_count= 10000;
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
--disable_result_log
--error ER_ACCESS_DENIED_ERROR
connect(user1_con,localhost,wrong_root,);
--enable_result_log
SELECT @@null_audit_event_order_check_consume_ignore_count;

# Clean up global variables
SET @@GLOBAL.null_audit_event_order_check= NULL;
SET @@GLOBAL.null_audit_abort_message= NULL;
# Let's hope 10000 calls will overrun the stack frame
SET @@GLOBAL.null_audit_event_order_check_consume_ignore_count= 0;

# Wait till we reached the initial number of concurrent sessions
--source include/wait_until_count_sessions.inc

--echo End of 5.7 tests

--echo #
--echo # Bug#24961932 - create function at bootstrap attempts to evaluate
--echo #                non-resolved expressions
--echo #

--echo # Initial value of the status variable "Audit_null_global_variable_get".
SELECT variable_value FROM performance_schema.global_status
                      WHERE variable_name = 'Audit_null_global_variable_get'
                      INTO @initial_global_var_get_count;

DELIMITER $;
# Procedure to check value of the status variable
# "Audit_null_global_variable_get".
CREATE PROCEDURE check_global_var_count()
BEGIN
  SELECT variable_value FROM performance_schema.global_status
                        WHERE variable_name = 'Audit_null_global_variable_get'
                        INTO @cur_global_var_get_count;
  SELECT @cur_global_var_get_count - @initial_global_var_get_count AS
         global_var_count;
END
$

--echo # Procedure p1 using global system variables.
CREATE PROCEDURE p1()
BEGIN
  SET @a=@@global.max_execution_time;
  CREATE TABLE t1 AS SELECT @@global.max_execution_time;
  DROP TABLE t1;
  SELECT @@global.optimizer_trace, @@session.max_execution_time;
END
$
DELIMITER ;$

--echo # Without fix, non-resolved expression is evaluated to audit the global
--echo # system variable get event while creating the stored routines.
--echo # The audit for the system variable get event should be done while
--echo # executing the stored routine but not while creating it. With the fix,
--echo # global system variable get event is audited while executing the stored
--echo # routine. At this time, expression is resolved. Hence status variable
--echo # "Audit_null_global_variable_get" remains unchanged while creating the
--echo # stored routine.
CALL check_global_var_count();

--echo # The same issue exits with the prepared statement too. With the fix,
--echo # system variable get event is not audited while preparing the statement.
--echo # Instead it is done while executing the statement. Hence status variable
--echo # "Audit_null_global_variable_get" remains same here too.
PREPARE stmt FROM 'SELECT @@global.max_execution_time,@@global.optimizer_trace';
CALL check_global_var_count();

--echo # With the fix, system variable get event is audited on each execution of
--echo # the routine. Hence status variable "Audit_null_global_variable_get" is
--echo # incremented by value three by p1() here.
CALL p1();
CALL check_global_var_count();

--echo # With the fix, system variable get event is audited on each execution of
--echo # the routine. Hence status variable "Audit_null_global_variable_get" is
--echo # incremented by value three by p1() here.
CALL p1();
CALL check_global_var_count();

--echo # System variable get event is audited for global variables only. Hence
--echo # status variable "Audit_null_global_variable_get" remain same here.
SELECT @@session.max_execution_time, @@session.optimizer_trace;
CALL check_global_var_count();

--echo # With the fix, system variable get event is audited on each execution of
--echo # the prepared statement. Hence status "Audit_null_global_variable_get"
--echo # variable is incremented by value two here.
EXECUTE stmt;
CALL check_global_var_count();

--echo # With the fix, system variable get event is audited on each execution of
--echo # the prepared statement. Hence status "Audit_null_global_variable_get"
--echo # variable is incremented by value two here.
EXECUTE stmt;
CALL check_global_var_count();

--echo # Verify if system variable get event is audited in the simple select.
--echo # Status variable "Audit_null_global_variable_get" is incremented by
--echo # value two here.
SELECT @@global.max_execution_time, @@global.optimizer_trace;
CALL check_global_var_count();

# Cleanup
DROP PROCEDURE p1;
DROP PROCEDURE check_global_var_count;
DROP PREPARE stmt;

--echo
--echo #
--echo # Bug#27638290 - Set @@null_audit_event_record_def = 
--echo #                'mysql_audit_authentication_flush'; crashed
--echo #
--echo # New connection, unbound thread
connect (con1,localhost,root,,);

--echo # Expect NULL
SELECT @@null_audit_event_record_def;
--echo
--echo # Invalid data
SET @@null_audit_event_record_def = 'ABSOLUTE_NONSENSE';
SELECT 1;
--echo # Expect NULL
--replace_regex /;command_id="[0-9]+"/;command_id="<expected_command_id>"/
SELECT @@null_audit_event_record;
SELECT @@null_audit_event_record_def;

--echo
--echo # Invalid data again
SET @@null_audit_event_record_def = 'MYSQL_AUDIT_AUTHENTICATION_FLUSH;JUNK';
SELECT 1;
--echo # Expect NULL
--replace_regex /;command_id="[0-9]+"/;command_id="<expected_command_id>"/
SELECT @@null_audit_event_record;
SELECT @@null_audit_event_record_def;
--echo

--echo  # Valid data
SET @@null_audit_event_record_def = 'MYSQL_AUDIT_GENERAL_RESULT;MYSQL_AUDIT_COMMAND_END';
SELECT 1;
--replace_regex /;command_id="[0-9]+"/;command_id="<expected_command_id>"/
SELECT @@null_audit_event_record;
--disconnect con1
connection default;

--echo
--echo End of 8.0 tests

--echo # cleanup
UNINSTALL PLUGIN null_audit;