Fix HARDCODED-PATH check for array elements

Skip array element lines that are part of multi-panel path arrays
Checks previous 10 lines for array declaration pattern
This commit is contained in:
cschantz
2026-01-09 18:12:47 -05:00
parent 52770efb1b
commit 5b7253c1ff
+9
View File
@@ -2964,6 +2964,15 @@ while IFS=: read -r file line_num line_content; do
# Skip array definitions (multi-panel path lists) # Skip array definitions (multi-panel path lists)
echo "$line_content" | grep -qE '^\s*[a-zA-Z_]+=\(' && continue echo "$line_content" | grep -qE '^\s*[a-zA-Z_]+=\(' && continue
# Skip array element lines (e.g., "/path/..." inside arrays)
# Check if previous lines have array declaration
if echo "$line_content" | grep -qE '^\s*"(/var|/home|/usr)'; then
context=$(sed -n "$((line_num - 10)),${line_num}p" "$file" 2>/dev/null)
if echo "$context" | grep -qE '[a-zA-Z_]+=\('; then
continue
fi
fi
# Extract the hardcoded path # Extract the hardcoded path
path=$(echo "$line_content" | grep -oE '(/var/cpanel|/var/log/apache2/domlogs|/home/[^/]*/public_html)' | head -1) path=$(echo "$line_content" | grep -oE '(/var/cpanel|/var/log/apache2/domlogs|/home/[^/]*/public_html)' | head -1)