Fix HARDCODED-PATH false positives

Skip these safe multi-panel patterns:
- Fallback patterns: ${VAR:-/path}
- if/elif path existence checks
- Array definitions with multiple panel paths

These patterns are proper multi-panel implementations.
This commit is contained in:
cschantz
2026-01-09 18:10:12 -05:00
parent b61d16dc7e
commit 52770efb1b
+9
View File
@@ -2955,6 +2955,15 @@ while IFS=: read -r file line_num line_content; do
# Skip comments and variable definitions that are panel-aware # Skip comments and variable definitions that are panel-aware
echo "$line_content" | grep -qE '^\s*#|case.*CONTROL_PANEL' && continue echo "$line_content" | grep -qE '^\s*#|case.*CONTROL_PANEL' && continue
# Skip if using fallback pattern ${VAR:-/path} (proper multi-panel pattern)
echo "$line_content" | grep -qE '\$\{[A-Z_]+:-/var/cpanel|\$\{[A-Z_]+:-/var/log|\$\{[A-Z_]+:-/home' && continue
# Skip if/elif/then statements checking paths (multi-panel aware)
echo "$line_content" | grep -qE '^\s*(if|elif)\s+\[.*-[def].*\]' && continue
# Skip array definitions (multi-panel path lists)
echo "$line_content" | grep -qE '^\s*[a-zA-Z_]+=\(' && continue
# 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)