feat: enhance port matching logic in firewall for improved accuracy in destination port checks
This commit is contained in:
@@ -1709,19 +1709,16 @@ class Firewall extends Component
|
||||
// Protocol match - be flexible
|
||||
$protocolMatch = (empty($protocol) || $protocol === '-' || $normalizedProtocol === $stateProtocol);
|
||||
|
||||
// Port match - check if destination port from log matches any port in state
|
||||
// Port match - destination port from log MUST match a port in state
|
||||
$portMatch = false;
|
||||
if (empty($destPort) || $destPort === '-') {
|
||||
$portMatch = true; // No port specified, match all
|
||||
$portMatch = true; // No port specified in log, match all
|
||||
} else {
|
||||
$destPortNum = (int)$destPort;
|
||||
// Destination port must match either state's dest or source port (for return traffic)
|
||||
if ($stateDestPort === $destPortNum || $stateSourcePort === $destPortNum) {
|
||||
$portMatch = true;
|
||||
}
|
||||
// For source-match type, be more flexible on ports if protocol matches
|
||||
if (!$portMatch && $matchType === 'source-match' && $protocolMatch) {
|
||||
$portMatch = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Log first potential match for debugging
|
||||
|
||||
Reference in New Issue
Block a user