forked from facebook/mysql-5.6
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FB8-54, FB8-55, FB8-70, FB8-101: Expose more information to audit plu…
…gin (facebook#934) (facebook#934) Summary: JIRA: https://jira.percona.com/browse/FB8-54 JIRA: https://jira.percona.com/browse/FB8-55 JIRA: https://jira.percona.com/browse/FB8-70 JIRA: https://jira.percona.com/browse/FB8-101 This commit adds the following fields to the generic event in audit log: * query_id * database * affected_rows * connection_certificate Reference Patch: facebook@1def6b7 Reference Patch: facebook@ce95a09 Reference Patch: facebook@588be34 Reference Patch: facebook@ba03c70 Reference Patch: facebook@be8c587 Reference Patch: facebook@22b2508 We need some extra info for the shadowing and security logging. This is a simple first step of info that MariaDB actually also exposes. Now we would have the `query_id` and the database name for general events. Making as few changes as possible to accomplish it, so I'm just taking the information from the TDH and exposing it through `mysql_event_general` struct and as a argument to disconnect. Forward the connection certificate to the audit plugin. The connection certificate can then be parsed by the audit plugin and handled appropriately. It made more sense for the certificate to live in the connection events, since they generally don't change between every general event, so the move was done. This is done by caching a BUF_MEM struct on the THD object. Since it's not possible to change certificates on the same connection, this caching should be correct. The BUF_MEM is released on THD::release_resources. If upstream bumps the MYSQL_AUDIT_INTERFACE_VERSION, we should bump ours to be greater or equal to it. Expose the port current mysqld is running on for the audit plugin. If no port, 0 is used. Pull Request resolved: facebook#934 Reviewed By: lloyd Differential Revision: D13874133 Pulled By: lth
- Loading branch information
Showing
18 changed files
with
271 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
INSTALL PLUGIN null_audit SONAME 'adt_null.so'; | ||
SET @@null_audit_extended_log = 1; | ||
CREATE TABLE foo (v INT); | ||
DROP TABLE foo; | ||
SHOW STATUS LIKE "Audit_null_generic_event_response"; | ||
Variable_name Value | ||
Audit_null_generic_event_response database:test | ||
CREATE TABLE foo (v INT); | ||
SHOW STATUS LIKE "Audit_null_generic_event_response"; | ||
Variable_name Value | ||
Audit_null_generic_event_response affected_rows:0 | ||
INSERT INTO foo VALUES (1), (2); | ||
SHOW STATUS LIKE "Audit_null_generic_event_response"; | ||
Variable_name Value | ||
Audit_null_generic_event_response affected_rows:2 | ||
SELECT * FROM foo; | ||
v | ||
1 | ||
2 | ||
SHOW STATUS LIKE "Audit_null_generic_event_response"; | ||
Variable_name Value | ||
Audit_null_generic_event_response affected_rows:-1 | ||
DELETE FROM foo; | ||
SHOW STATUS LIKE "Audit_null_generic_event_response"; | ||
Variable_name Value | ||
Audit_null_generic_event_response affected_rows:2 | ||
DROP TABLE foo; | ||
SHOW STATUS LIKE "Audit_null_generic_event_response"; | ||
Variable_name Value | ||
Audit_null_generic_event_response port:MYSQLD_PORT | ||
UNINSTALL PLUGIN null_audit; | ||
Warnings: | ||
Warning 1620 Plugin is busy and will be uninstalled on shutdown |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
INSTALL PLUGIN null_audit SONAME 'adt_null.so'; | ||
CREATE USER cert_auth@localhost REQUIRE X509; | ||
GRANT SELECT ON test.* TO cert_auth@localhost; | ||
CREATE TABLE foo (i INT); | ||
FLUSH PRIVILEGES; | ||
SET @@null_audit_extended_log = 1; | ||
SELECT * FROM foo; | ||
i | ||
SHOW STATUS LIKE "Audit_null_connect_event_response"; | ||
Variable_name Value | ||
Audit_null_connect_event_response connection_certificate:-----BEGIN CERTIFICATE-----\nMIIDyDCCArCgAwIBAgIJAOG0pVw936YVMA0GCSqGSIb3DQEBCwUAMGMxCzAJBgNV\nBAYTAlNFMRIwEAYDVQQIDAlTdG9ja2hvbG0xEjAQBgNVBAcMCVN0b2NraG9sbTEP\nMA0GA1UECgwGT3JhY2xlMQ4wDAYDVQQLDAVNeVNRTDELMAkGA1UEAwwCQ0EwHhcN\nMTQxMjA1MDQ0OTIzWhcNMjkxMjAx | ||
DROP USER cert_auth@localhost; | ||
DROP TABLE foo; | ||
UNINSTALL PLUGIN null_audit; | ||
Warnings: | ||
Warning 1620 Plugin is busy and will be uninstalled on shutdown |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
$AUDIT_NULL_OPT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--source include/have_null_audit_plugin.inc | ||
--source include/count_sessions.inc | ||
--source include/have_debug.inc | ||
|
||
eval INSTALL PLUGIN null_audit SONAME '$AUDIT_NULL'; | ||
|
||
SET @@null_audit_extended_log = 1; | ||
|
||
## database name in generic event | ||
CREATE TABLE foo (v INT); | ||
DROP TABLE foo; | ||
|
||
--replace_regex /.*(database:[^;]*).*/\1/ | ||
SHOW STATUS LIKE "Audit_null_generic_event_response"; | ||
|
||
## affected_rows in generic event | ||
CREATE TABLE foo (v INT); | ||
--replace_regex /.*(affected_rows:[^;]*).*/\1/ | ||
SHOW STATUS LIKE "Audit_null_generic_event_response"; | ||
|
||
INSERT INTO foo VALUES (1), (2); | ||
--replace_regex /.*(affected_rows:[^;]*).*/\1/ | ||
SHOW STATUS LIKE "Audit_null_generic_event_response"; | ||
|
||
SELECT * FROM foo; | ||
--replace_regex /.*(affected_rows:[^;]*).*/\1/ | ||
SHOW STATUS LIKE "Audit_null_generic_event_response"; | ||
|
||
DELETE FROM foo; | ||
--replace_regex /.*(affected_rows:[^;]*).*/\1/ | ||
SHOW STATUS LIKE "Audit_null_generic_event_response"; | ||
|
||
DROP TABLE foo; | ||
|
||
## port | ||
let $MYSQLD_PORT= `SELECT @@port`; | ||
--replace_result $MYSQLD_PORT MYSQLD_PORT | ||
--replace_regex /.*(port:[^;]*).*/\1/ | ||
SHOW STATUS LIKE "Audit_null_generic_event_response"; | ||
|
||
|
||
UNINSTALL PLUGIN null_audit; | ||
|
||
--source include/wait_until_count_sessions.inc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--ssl-mode=VERIFY_CA | ||
--ssl-ca=$MYSQL_TEST_DIR/std_data/cacert.pem | ||
--ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem | ||
--ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
$AUDIT_NULL_OPT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--source include/count_sessions.inc | ||
--source include/have_debug.inc | ||
|
||
eval INSTALL PLUGIN null_audit SONAME '$AUDIT_NULL'; | ||
|
||
CREATE USER cert_auth@localhost REQUIRE X509; | ||
GRANT SELECT ON test.* TO cert_auth@localhost; | ||
CREATE TABLE foo (i INT); | ||
FLUSH PRIVILEGES; | ||
connect(con1,localhost,cert_auth,,,,,SSL); | ||
|
||
SET @@null_audit_extended_log = 1; | ||
|
||
SELECT * FROM foo; | ||
|
||
# As "certificate:" part in the status var may be truncated because of the | ||
# max status var length limit, taking only first 255 chars here to make this | ||
# test stable | ||
--replace_regex /.*(connection_certificate:[^;]{255}).*/\1/ | ||
SHOW STATUS LIKE "Audit_null_connect_event_response"; | ||
|
||
disconnect con1; | ||
connection default; | ||
DROP USER cert_auth@localhost; | ||
DROP TABLE foo; | ||
|
||
UNINSTALL PLUGIN null_audit; | ||
|
||
--source include/wait_until_count_sessions.inc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.