feat: refine firewall log matching logic for improved accuracy and add detailed logging for connection data retrieval
This commit is contained in:
@@ -1678,27 +1678,17 @@ class Firewall extends Component
|
||||
$normalizedStateDestIP = strtolower(trim($stateDestIP));
|
||||
$normalizedProtocol = strtoupper(trim($protocol));
|
||||
|
||||
// Very flexible matching logic
|
||||
// Matching logic - check if both IPs from the log are present in the state
|
||||
// Either in the same direction or swapped (for return traffic)
|
||||
$ipMatch = false;
|
||||
|
||||
// Check if IPs match in either direction
|
||||
if (($normalizedStateSourceIP === $normalizedSourceIP && $normalizedStateDestIP === $normalizedDestIP) ||
|
||||
($normalizedStateSourceIP === $normalizedDestIP && $normalizedStateDestIP === $normalizedSourceIP)) {
|
||||
// Direction 1: Log source → Log dest matches State source → State dest
|
||||
if ($normalizedStateSourceIP === $normalizedSourceIP && $normalizedStateDestIP === $normalizedDestIP) {
|
||||
$ipMatch = true;
|
||||
}
|
||||
|
||||
// Also try if one of the IPs matches (useful for single-sided matching)
|
||||
if (!$ipMatch && (
|
||||
$normalizedStateSourceIP === $normalizedSourceIP ||
|
||||
$normalizedStateSourceIP === $normalizedDestIP ||
|
||||
$normalizedStateDestIP === $normalizedSourceIP ||
|
||||
$normalizedStateDestIP === $normalizedDestIP)) {
|
||||
// At least one IP matches, check if the other makes sense
|
||||
if ($normalizedStateSourceIP === $normalizedSourceIP || $normalizedStateDestIP === $normalizedSourceIP) {
|
||||
if ($normalizedStateSourceIP === $normalizedDestIP || $normalizedStateDestIP === $normalizedDestIP) {
|
||||
$ipMatch = true;
|
||||
}
|
||||
}
|
||||
// Direction 2: Swapped (return traffic)
|
||||
elseif ($normalizedStateSourceIP === $normalizedDestIP && $normalizedStateDestIP === $normalizedSourceIP) {
|
||||
$ipMatch = true;
|
||||
}
|
||||
|
||||
// Protocol match
|
||||
|
||||
@@ -1079,15 +1079,23 @@
|
||||
loading: false,
|
||||
connectionData: null,
|
||||
error: null,
|
||||
sourceIP: '{{ addslashes($sourceIP) }}',
|
||||
destIP: '{{ addslashes($destIP) }}',
|
||||
sourcePort: '{{ addslashes($sourcePort) }}',
|
||||
destPort: '{{ addslashes($destPort) }}',
|
||||
protocol: '{{ addslashes($protocol) }}',
|
||||
loadConnectionData() {
|
||||
this.loading = true;
|
||||
this.error = null;
|
||||
$wire.getNetworkAnalysisForLog('{{ $sourceIP }}', '{{ $destIP }}', '{{ $sourcePort }}', '{{ $destPort }}', '{{ $protocol }}')
|
||||
console.log('Loading connection data for:', this.sourceIP, '->', this.destIP, 'Port:', this.destPort, 'Protocol:', this.protocol);
|
||||
$wire.getNetworkAnalysisForLog(this.sourceIP, this.destIP, this.sourcePort, this.destPort, this.protocol)
|
||||
.then(data => {
|
||||
console.log('Received connection data:', data);
|
||||
this.connectionData = data;
|
||||
this.loading = false;
|
||||
})
|
||||
.catch(err => {
|
||||
console.error('Failed to load connection data:', err);
|
||||
this.error = 'Failed to load connection data';
|
||||
this.loading = false;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user