Update Vulnerabilities list

Indenting mysqltuner
Update Usage information
This commit is contained in:
Jean-Marie Renouard 2022-06-23 14:31:46 +02:00
parent 4a4629f862
commit ba21312e00

View file

@ -256,7 +256,7 @@ my @dblist;
# Super structure containing all information # Super structure containing all information
my %result; my %result;
$result{'MySQLTuner'}{'version'} = $tunerversion; $result{'MySQLTuner'}{'version'} = $tunerversion;
$result{'MySQLTuner'}{'datetime'} =`date '+%d-%m-%Y %H:%M:%S'`; $result{'MySQLTuner'}{'datetime'} = `date '+%d-%m-%Y %H:%M:%S'`;
$result{'MySQLTuner'}{'options'} = \%opt; $result{'MySQLTuner'}{'options'} = \%opt;
# Functions that handle the print styles # Functions that handle the print styles
@ -594,7 +594,7 @@ sub update_tuner_version {
} }
my $update; my $update;
my $fullpath=""; my $fullpath = "";
my $url = "https://raw.githubusercontent.com/major/MySQLTuner-perl/master/"; my $url = "https://raw.githubusercontent.com/major/MySQLTuner-perl/master/";
my @scripts = my @scripts =
( "mysqltuner.pl", "basic_passwords.txt", "vulnerabilities.csv" ); ( "mysqltuner.pl", "basic_passwords.txt", "vulnerabilities.csv" );
@ -607,12 +607,12 @@ sub update_tuner_version {
if ( $httpcli =~ /curl$/ ) { if ( $httpcli =~ /curl$/ ) {
debugprint "$httpcli is available."; debugprint "$httpcli is available.";
$fullpath=dirname(__FILE__)."/".$script; $fullpath = dirname(__FILE__) . "/" . $script;
debugprint "FullPath: $fullpath"; debugprint "FullPath: $fullpath";
debugprint debugprint
"$httpcli --connect-timeout 3 '$url$script' 2>$devnull > $fullpath"; "$httpcli --connect-timeout 3 '$url$script' 2>$devnull > $fullpath";
$update = $update =
`$httpcli --connect-timeout 3 '$url$script' 2>$devnull > $fullpath`; `$httpcli --connect-timeout 3 '$url$script' 2>$devnull > $fullpath`;
chomp($update); chomp($update);
debugprint "$script updated: $update"; debugprint "$script updated: $update";
@ -747,7 +747,7 @@ sub mysql_setup {
$remotestring = " -S $opt{socket} -P $opt{port}"; $remotestring = " -S $opt{socket} -P $opt{port}";
} }
if ( $opt{protocol} ne '' ){ if ( $opt{protocol} ne '' ) {
$remotestring = " --protocol=$opt{protocol}"; $remotestring = " --protocol=$opt{protocol}";
} }
@ -1359,7 +1359,8 @@ sub log_file_recommendations {
subheaderprint "Log file Recommendations"; subheaderprint "Log file Recommendations";
if ( "$myvar{'log_error'}" eq "stderr" ) { if ( "$myvar{'log_error'}" eq "stderr" ) {
badprint "log_error is set to $myvar{'log_error'}, but this script can't read stderr"; badprint
"log_error is set to $myvar{'log_error'}, but this script can't read stderr";
return; return;
} }
elsif ( $myvar{'log_error'} =~ /^(docker|podman|kubectl):(.*)/ ) { elsif ( $myvar{'log_error'} =~ /^(docker|podman|kubectl):(.*)/ ) {
@ -1945,21 +1946,25 @@ sub security_recommendations {
debugprint "Password column = $PASS_COLUMN_NAME"; debugprint "Password column = $PASS_COLUMN_NAME";
# IS THERE A ROLE COLUMN # IS THERE A ROLE COLUMN
my $is_role_column = select_one "select count(*) from information_schema.columns where TABLE_NAME='user' AND TABLE_SCHEMA='mysql' and COLUMN_NAME='IS_ROLE'"; my $is_role_column = select_one
"select count(*) from information_schema.columns where TABLE_NAME='user' AND TABLE_SCHEMA='mysql' and COLUMN_NAME='IS_ROLE'";
my $extra_user_condition=""; my $extra_user_condition = "";
$extra_user_condition="IS_ROLE = 'N' AND" if $is_role_column > 0; $extra_user_condition = "IS_ROLE = 'N' AND" if $is_role_column > 0;
my @mysqlstatlist; my @mysqlstatlist;
if ($is_role_column > 0) { if ( $is_role_column > 0 ) {
@mysqlstatlist= select_array "SELECT CONCAT(QUOTE(user), '\@', QUOTE(host)) FROM mysql.user WHERE IS_ROLE='Y'"; @mysqlstatlist = select_array
"SELECT CONCAT(QUOTE(user), '\@', QUOTE(host)) FROM mysql.user WHERE IS_ROLE='Y'";
foreach my $line ( sort @mysqlstatlist ) { foreach my $line ( sort @mysqlstatlist ) {
chomp($line); chomp($line);
infoprint "User $line is User Role"; infoprint "User $line is User Role";
} }
} else { }
else {
debugprint "No Role user detected"; debugprint "No Role user detected";
goodprint "No Role user detected"; goodprint "No Role user detected";
} }
# Looking for Anonymous users # Looking for Anonymous users
@mysqlstatlist = select_array @mysqlstatlist = select_array
"SELECT CONCAT(QUOTE(user), '\@', QUOTE(host)) FROM mysql.user WHERE $extra_user_condition (TRIM(USER) = '' OR USER IS NULL)"; "SELECT CONCAT(QUOTE(user), '\@', QUOTE(host)) FROM mysql.user WHERE $extra_user_condition (TRIM(USER) = '' OR USER IS NULL)";
@ -2135,14 +2140,22 @@ sub get_replication_status {
infoprint "Semi synchronous replication Master: " infoprint "Semi synchronous replication Master: "
. ( . (
( defined( $myvar{'rpl_semi_sync_master_enabled'} ) or defined( $myvar{'rpl_semi_sync_source_enabled'} ) ) (
? ( $myvar{'rpl_semi_sync_master_enabled'} // $myvar{'rpl_semi_sync_source_enabled'} ) defined( $myvar{'rpl_semi_sync_master_enabled'} )
or defined( $myvar{'rpl_semi_sync_source_enabled'} )
)
? ( $myvar{'rpl_semi_sync_master_enabled'}
// $myvar{'rpl_semi_sync_source_enabled'} )
: 'Not Activated' : 'Not Activated'
); );
infoprint "Semi synchronous replication Slave: " infoprint "Semi synchronous replication Slave: "
. ( . (
( defined( $myvar{'rpl_semi_sync_slave_enabled'} ) or defined( $myvar{'rpl_semi_sync_replica_enabled'} ) ) (
? ( $myvar{'rpl_semi_sync_slave_enabled'} // $myvar{'rpl_semi_sync_replica_enabled'} ) defined( $myvar{'rpl_semi_sync_slave_enabled'} )
or defined( $myvar{'rpl_semi_sync_replica_enabled'} )
)
? ( $myvar{'rpl_semi_sync_slave_enabled'}
// $myvar{'rpl_semi_sync_replica_enabled'} )
: 'Not Activated' : 'Not Activated'
); );
if ( scalar( keys %myrepl ) == 0 and scalar( keys %myslaves ) == 0 ) { if ( scalar( keys %myrepl ) == 0 and scalar( keys %myslaves ) == 0 ) {
@ -2156,13 +2169,15 @@ sub get_replication_status {
} }
$result{'Replication'}{'status'} = \%myrepl; $result{'Replication'}{'status'} = \%myrepl;
my ($io_running) = $myrepl{'Slave_IO_Running'} // $myrepl{'Replica_IO_Running'}; my ($io_running) = $myrepl{'Slave_IO_Running'}
// $myrepl{'Replica_IO_Running'};
debugprint "IO RUNNING: $io_running "; debugprint "IO RUNNING: $io_running ";
my ($sql_running) = $myrepl{'Slave_SQL_Running'} // $myrepl{'Replica_SQL_Running'}; my ($sql_running) = $myrepl{'Slave_SQL_Running'}
// $myrepl{'Replica_SQL_Running'};
debugprint "SQL RUNNING: $sql_running "; debugprint "SQL RUNNING: $sql_running ";
my ($seconds_behind_master) = $myrepl{'Seconds_Behind_Master'}
my ($seconds_behind_master) = $myrepl{'Seconds_Behind_Master'} // $myrepl{'Seconds_Behind_Source'} ; // $myrepl{'Seconds_Behind_Source'};
$seconds_behind_master = 1000000 unless defined($seconds_behind_master); $seconds_behind_master = 1000000 unless defined($seconds_behind_master);
debugprint "SECONDS : $seconds_behind_master "; debugprint "SECONDS : $seconds_behind_master ";
@ -2209,18 +2224,20 @@ sub validate_mysql_version {
or mysql_version_eq( 10, 5 ) or mysql_version_eq( 10, 5 )
or mysql_version_eq( 10, 6 ) or mysql_version_eq( 10, 6 )
or mysql_version_eq( 10, 7 ) or mysql_version_eq( 10, 7 )
or mysql_version_eq( 10, 8 ) or mysql_version_eq( 10, 8 ) )
)
{ {
goodprint "Currently running supported MySQL version " goodprint "Currently running supported MySQL version "
. $myvar{'version'} . ""; . $myvar{'version'} . "";
return; return;
} else { }
else {
badprint "Your MySQL version " badprint "Your MySQL version "
. $myvar{'version'} . $myvar{'version'}
. " is EOL software! Upgrade soon!"; . " is EOL software! Upgrade soon!";
push ( @generalrec, "You are using n unsupported version for production environments"); push( @generalrec,
push ( @generalrec, "Upgrade as soon as possible to a supported version !"); "You are using n unsupported version for production environments" );
push( @generalrec,
"Upgrade as soon as possible to a supported version !" );
} }
} }
@ -3188,15 +3205,18 @@ sub mysql_stats {
infoprint infoprint
"Skipped name resolution test due to missing skip_name_resolve in system variables."; "Skipped name resolution test due to missing skip_name_resolve in system variables.";
} }
#Cpanel and Skip name resolve #Cpanel and Skip name resolve
elsif ( -r "/usr/local/cpanel/cpanel" ){ elsif ( -r "/usr/local/cpanel/cpanel" ) {
if ( $result{'Variables'}{'skip_name_resolve'} ne 'OFF') { if ( $result{'Variables'}{'skip_name_resolve'} ne 'OFF' ) {
infoprint "CPanel and Flex system skip-name-resolve should be on"; infoprint "CPanel and Flex system skip-name-resolve should be on";
} }
if ( $result{'Variables'}{'skip_name_resolve'} eq 'OFF') { if ( $result{'Variables'}{'skip_name_resolve'} eq 'OFF' ) {
badprint "CPanel and Flex system skip-name-resolve should be on"; badprint "CPanel and Flex system skip-name-resolve should be on";
push (@generalrec, "name resolution is enabled due to cPanel doesn't support this disabled."); push( @generalrec,
push (@adjvars, "skip-name-resolve=0"); "name resolution is enabled due to cPanel doesn't support this disabled."
);
push( @adjvars, "skip-name-resolve=0" );
} }
} }
elsif ( $result{'Variables'}{'skip_name_resolve'} eq 'OFF' ) { elsif ( $result{'Variables'}{'skip_name_resolve'} eq 'OFF' ) {
@ -3205,7 +3225,7 @@ sub mysql_stats {
push( @generalrec, push( @generalrec,
"Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1" "Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1"
); );
push (@adjvars, "skip-name-resolve=1"); push( @adjvars, "skip-name-resolve=1" );
} }
# Query cache # Query cache
@ -3620,15 +3640,15 @@ sub mysql_myisam {
subheaderprint "MyISAM Metrics"; subheaderprint "MyISAM Metrics";
if ( mysql_version_ge(8) and mysql_version_le(10) ) { if ( mysql_version_ge(8) and mysql_version_le(10) ) {
infoprint "MyISAM Metrics are disabled on last MySQL versions."; infoprint "MyISAM Metrics are disabled on last MySQL versions.";
if ( $myvar{'key_buffer_size'} > 0) { if ( $myvar{'key_buffer_size'} > 0 ) {
push( @adjvars, "key_buffer_size=0" ); push( @adjvars, "key_buffer_size=0" );
push( @generalrec, "Buffer Key MyISAM set to 0, no MyISAM table detected" ); push( @generalrec,
"Buffer Key MyISAM set to 0, no MyISAM table detected" );
} }
return; return;
} }
my $nb_myisam_tables=select_one( my $nb_myisam_tables = select_one(
"SELECT COUNT(*) FROM information_schema.TABLES WHERE ENGINE='MyISAM'" "SELECT COUNT(*) FROM information_schema.TABLES WHERE ENGINE='MyISAM'");
);
if ( $nb_myisam_tables == 0 ) { if ( $nb_myisam_tables == 0 ) {
infoprint "No MyISAM table(s) detected ...."; infoprint "No MyISAM table(s) detected ....";
return; return;
@ -3858,12 +3878,11 @@ sub mysqsl_pfs {
# Performance Schema # Performance Schema
$myvar{'performance_schema'} = 'OFF' $myvar{'performance_schema'} = 'OFF'
unless defined( $myvar{'performance_schema'} ); unless defined( $myvar{'performance_schema'} );
if ($myvar{'performance_schema'} eq 'OFF') { if ( $myvar{'performance_schema'} eq 'OFF' ) {
badprint "Performance_schema should be activated."; badprint "Performance_schema should be activated.";
push( @adjvars, "performance_schema=ON" ); push( @adjvars, "performance_schema=ON" );
push( @generalrec, push( @generalrec,
"Performance schema should be activated for better diagnostics" "Performance schema should be activated for better diagnostics" );
);
} }
if ( $myvar{'performance_schema'} eq 'ON' ) { if ( $myvar{'performance_schema'} eq 'ON' ) {
infoprint "Performance_schema is activated."; infoprint "Performance_schema is activated.";
@ -3888,9 +3907,9 @@ sub mysqsl_pfs {
infoprint "Sys schema Version: " infoprint "Sys schema Version: "
. select_one("select sys_version from sys.version"); . select_one("select sys_version from sys.version");
# Store all sys schema # Store all sys schema
# for my $pfs_view(select_array('use sys;show tables;')){ # for my $pfs_view(select_array('use sys;show tables;')){
#infoprint "$pfs_view" #infoprint "$pfs_view"
# @$result{'sys'}{$pfs_view}{'headers'}=[]; # @$result{'sys'}{$pfs_view}{'headers'}=[];
# for my $h (select_array("select column_name FROM INFORMATION_SCHEMA.COLUMNS c # for my $h (select_array("select column_name FROM INFORMATION_SCHEMA.COLUMNS c
# WHERE c.table_name = '$pfs_view' ORDER BY c.ORDINAL_POSITION")) { # WHERE c.table_name = '$pfs_view' ORDER BY c.ORDINAL_POSITION")) {
@ -3902,7 +3921,7 @@ sub mysqsl_pfs {
# push $result{'sys'}{$pfs_view}{'values'}, $lQuery; # push $result{'sys'}{$pfs_view}{'values'}, $lQuery;
# } # }
# } # }
# Top user per connection # Top user per connection
subheaderprint "Performance schema: Top 5 user per connection"; subheaderprint "Performance schema: Top 5 user per connection";
my $nbL = 1; my $nbL = 1;
for my $lQuery ( for my $lQuery (
@ -6695,8 +6714,7 @@ sub close_outputfile {
} }
sub headerprint { sub headerprint {
prettyprint prettyprint " >> MySQLTuner $tunerversion\n"
" >> MySQLTuner $tunerversion\n"
. "\t * Jean-Marie Renouard <jmrenouard\@gmail.com>\n" . "\t * Jean-Marie Renouard <jmrenouard\@gmail.com>\n"
. "\t * Major Hayden <major\@mhtx.net>\n" . "\t * Major Hayden <major\@mhtx.net>\n"
. " >> Bug reports, feature requests, and downloads at http://mysqltuner.pl/\n" . " >> Bug reports, feature requests, and downloads at http://mysqltuner.pl/\n"