Export functions for subshell access (CRITICAL FIX)
HTTP monitoring runs in subshells (from tail pipe) but functions were not exported, making them unavailable in those subshells. Exported functions: - write_ip_data_to_file (writes scores to file) - update_ip_intelligence (updates IP scores) - get_ip_intelligence (reads IP data) - get_threat_level (calculates threat level) - get_threat_color (gets display color) This fixes the critical bug where HTTP attacks reached Score:100 but were never blocked because scores weren't written to ip_data file. Without exports: function called in subshell = command not found With exports: function available in all child processes
This commit is contained in:
@@ -304,6 +304,7 @@ get_ip_intelligence() {
|
|||||||
echo "${IP_DATA[$ip]}"
|
echo "${IP_DATA[$ip]}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
export -f get_ip_intelligence
|
||||||
|
|
||||||
# Write IP data directly to file (for cross-process communication)
|
# Write IP data directly to file (for cross-process communication)
|
||||||
write_ip_data_to_file() {
|
write_ip_data_to_file() {
|
||||||
@@ -330,6 +331,7 @@ write_ip_data_to_file() {
|
|||||||
|
|
||||||
) 200>"$TEMP_DIR/ip_data.lock"
|
) 200>"$TEMP_DIR/ip_data.lock"
|
||||||
}
|
}
|
||||||
|
export -f write_ip_data_to_file
|
||||||
|
|
||||||
# Update IP intelligence
|
# Update IP intelligence
|
||||||
update_ip_intelligence() {
|
update_ip_intelligence() {
|
||||||
@@ -497,6 +499,7 @@ update_ip_intelligence() {
|
|||||||
(update_ip_reputation "$ip" 1 "$score" 0 "Live monitor: $new_attacks" >/dev/null 2>&1) &
|
(update_ip_reputation "$ip" 1 "$score" 0 "Live monitor: $new_attacks" >/dev/null 2>&1) &
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
export -f update_ip_intelligence
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Advanced Intelligence Functions
|
# Advanced Intelligence Functions
|
||||||
@@ -1175,6 +1178,7 @@ get_threat_level() {
|
|||||||
echo "LOW"
|
echo "LOW"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
export -f get_threat_level
|
||||||
|
|
||||||
# Get color for threat level
|
# Get color for threat level
|
||||||
get_threat_color() {
|
get_threat_color() {
|
||||||
@@ -1189,6 +1193,7 @@ get_threat_color() {
|
|||||||
*) echo "$INFO_COLOR" ;;
|
*) echo "$INFO_COLOR" ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
export -f get_threat_color
|
||||||
|
|
||||||
# Get bot color
|
# Get bot color
|
||||||
get_bot_color() {
|
get_bot_color() {
|
||||||
|
|||||||
Reference in New Issue
Block a user