Add parameter validation to 8 more functions in mysql-analyzer.sh
FUNCTIONS FIXED: 1. extract_tables_from_query() - validate query parameter 2. explain_query() - validate db_name and query parameters 3. analyze_queries_for_problems() - validate query_file parameter 4. generate_plugin_statistics() - validate problems_file parameter 5. check_table_bloat() - validate db_name and table_name parameters 6. recommend_fix() - validate issue parameter 7. generate_summary_report() - validate problems_file parameter 8. find_largest_tables() - has optional parameter with default (already safe) PATTERN USED: [ -z "$1" ] && return 1 # For single required parameter [ -z "$1" ] || [ -z "$2" ] && return 1 # For multiple required parameters PROGRESS: - Fixed 8 functions in lib/mysql-analyzer.sh - QA checker now shows different set of HIGH issues (progress!) - HIGH issues moved from mysql-analyzer.sh to system-detect.sh and threat-intelligence.sh NEXT: Fix remaining HIGH issues in other library files
This commit is contained in:
@@ -297,6 +297,7 @@ extract_database_from_query() {
|
|||||||
|
|
||||||
# Extract tables from query
|
# Extract tables from query
|
||||||
extract_tables_from_query() {
|
extract_tables_from_query() {
|
||||||
|
[ -z "$1" ] && return 1
|
||||||
local query="$1"
|
local query="$1"
|
||||||
|
|
||||||
# Extract FROM and JOIN clauses
|
# Extract FROM and JOIN clauses
|
||||||
@@ -305,6 +306,7 @@ extract_tables_from_query() {
|
|||||||
|
|
||||||
# Analyze query performance with EXPLAIN
|
# Analyze query performance with EXPLAIN
|
||||||
explain_query() {
|
explain_query() {
|
||||||
|
[ -z "$1" ] || [ -z "$2" ] && return 1
|
||||||
local db_name="$1"
|
local db_name="$1"
|
||||||
local query="$2"
|
local query="$2"
|
||||||
local explain_file="${TEMP_SESSION_DIR}/explain_${db_name}_$$.tmp"
|
local explain_file="${TEMP_SESSION_DIR}/explain_${db_name}_$$.tmp"
|
||||||
@@ -332,6 +334,7 @@ explain_query() {
|
|||||||
|
|
||||||
# Analyze queries and identify problems
|
# Analyze queries and identify problems
|
||||||
analyze_queries_for_problems() {
|
analyze_queries_for_problems() {
|
||||||
|
[ -z "$1" ] && return 1
|
||||||
local query_file="$1"
|
local query_file="$1"
|
||||||
local problems_file="${TEMP_SESSION_DIR}/query_problems.tmp"
|
local problems_file="${TEMP_SESSION_DIR}/query_problems.tmp"
|
||||||
|
|
||||||
@@ -393,6 +396,7 @@ analyze_queries_for_problems() {
|
|||||||
|
|
||||||
# Generate plugin query statistics
|
# Generate plugin query statistics
|
||||||
generate_plugin_statistics() {
|
generate_plugin_statistics() {
|
||||||
|
[ -z "$1" ] && return 1
|
||||||
local problems_file="$1"
|
local problems_file="$1"
|
||||||
local stats_file="${TEMP_SESSION_DIR}/plugin_stats.tmp"
|
local stats_file="${TEMP_SESSION_DIR}/plugin_stats.tmp"
|
||||||
|
|
||||||
@@ -425,6 +429,7 @@ find_largest_tables() {
|
|||||||
|
|
||||||
# Check for bloated tables
|
# Check for bloated tables
|
||||||
check_table_bloat() {
|
check_table_bloat() {
|
||||||
|
[ -z "$1" ] || [ -z "$2" ] && return 1
|
||||||
local db_name="$1"
|
local db_name="$1"
|
||||||
local table_name="$2"
|
local table_name="$2"
|
||||||
|
|
||||||
@@ -450,6 +455,7 @@ check_table_bloat() {
|
|||||||
|
|
||||||
# Recommend fixes for common issues
|
# Recommend fixes for common issues
|
||||||
recommend_fix() {
|
recommend_fix() {
|
||||||
|
[ -z "$1" ] && return 1
|
||||||
local issue="$1"
|
local issue="$1"
|
||||||
local db_name="$2"
|
local db_name="$2"
|
||||||
local table_name="$3"
|
local table_name="$3"
|
||||||
@@ -493,6 +499,7 @@ recommend_fix() {
|
|||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
generate_summary_report() {
|
generate_summary_report() {
|
||||||
|
[ -z "$1" ] && return 1
|
||||||
local problems_file="$1"
|
local problems_file="$1"
|
||||||
|
|
||||||
print_banner "MySQL Query Analysis Summary"
|
print_banner "MySQL Query Analysis Summary"
|
||||||
|
|||||||
Reference in New Issue
Block a user