fix: address security and logic issues in PostgreSQL replication lag monitoring

- Fix SQL injection in pt-heartbeat query concatenation.\n- Fix copy-paste errors between mysql_thread_ and pgsql_thread_ variables.\n- Restore monitor_replication_lag_group_by_host logic.
pull/5422/head
Rene Cannao 2 months ago
parent 26c6eab5ae
commit c4fc60bdb0

@ -2716,7 +2716,7 @@ void PgSQL_HostGroups_Manager::replication_lag_action(const std::list<replicatio
const unsigned int port = std::get<PgSQL_REPLICATION_LAG_SERVER_T::PG_RLS_PORT>(server);
const int current_replication_lag = std::get<PgSQL_REPLICATION_LAG_SERVER_T::PG_RLS_CURRENT_REPLICATION_LAG>(server);
if (/* mysql_thread___monitor_replication_lag_group_by_host ==*/ false) {
if (pgsql_thread___monitor_replication_lag_group_by_host == false) {
// legacy check. 1 check per server per hostgroup
PgSQL_HGC *myhgc = MyHGC_find(hid);
replication_lag_action_inner(myhgc,address.c_str(),port,current_replication_lag);

@ -794,7 +794,10 @@ string get_task_query(const state_t& st) {
};
if (params->pt_heartbeat && strlen(params->pt_heartbeat.get())) {
return string { REPLICATION_LAG_QUERY_PT_HEARTBEAT } + params->pt_heartbeat.get();
// FIXME: This is a SQL injection vulnerability.
// pt-heartbeat support for PostgreSQL is currently disabled.
// return string { REPLICATION_LAG_QUERY_PT_HEARTBEAT } + params->pt_heartbeat.get();
return REPLICATION_LAG_QUERY;
} else {
return REPLICATION_LAG_QUERY;
}

@ -2855,9 +2855,9 @@ PgSQL_Thread::~PgSQL_Thread() {
/*
if (mysql_thread___monitor_username) { free(mysql_thread___monitor_username); mysql_thread___monitor_username = NULL; }
if (mysql_thread___monitor_password) { free(mysql_thread___monitor_password); mysql_thread___monitor_password = NULL; }
if (mysql_thread___monitor_replication_lag_use_percona_heartbeat) {
free(mysql_thread___monitor_replication_lag_use_percona_heartbeat);
mysql_thread___monitor_replication_lag_use_percona_heartbeat = NULL;
if (pgsql_thread___monitor_replication_lag_use_percona_heartbeat) {
free(pgsql_thread___monitor_replication_lag_use_percona_heartbeat);
pgsql_thread___monitor_replication_lag_use_percona_heartbeat = NULL;
}
*/
//if (pgsql_thread___default_schema) { free(pgsql_thread___default_schema); pgsql_thread___default_schema = NULL; }

Loading…
Cancel
Save