I think I understand what the problem is.
and this condition is governed by the last record that has arrived.
This can be seen between these two commands:
root@wazuh:/var/ossec/etc/rules# grep dstport=443 ~/previous_output | head -1 | cat - ~/full_log | /var/ossec/bin/wazuh-logtest
. . .
transport: '65022'
type: 'traffic'
vd: 'saad'
**Phase 3: Completed filtering (rules).
id: '110056'
level: '10'
description: 'File Shares Enumeration - SMB Enumeration'
groups: '['local', 'syslog', 'sshd']'
firedtimes: '1'
frequency: '2'
mail: 'False'
**Alert to be generated.
root@wazuh:/var/ossec/etc/rules# grep dstport=443 ~/previous_output | head -1 | cat ~/full_log - | /var/ossec/bin/wazuh-logtest
. . .
time: '15:58:39'
trandisp: 'noop'
type: 'traffic'
vd: 'XXXX'
**Phase 3: Completed filtering (rules).
id: '81618'
level: '1'
description: 'Fortigate: Traffic to be aware of.'
groups: '['fortigate', 'syslog']'
firedtimes: '2'
gdpr: '['IV_35.7.d']'
hipaa: '['164.312.b']'
mail: 'False'
nist_800_53: '['AU.6']'
pci_dss: '['10.6.1']'
One way to approach this is to rely on a rule that considers the required port value.
<rule id="81699" level="9">
<if_matched_sid>81618</if_matched_sid>
<dstport type="pcre2">^445$</dstport>
<description>81618 with port 445</description>
</rule>
<rule id="110056" level="10" frequency="2" timeframe="60">
<if_matched_sid>81699</if_matched_sid>
<!--same_dstport /-->
<same_source_ip />
<!--
<different_dstip />
-->
<description>File Shares Enumeration - SMB Enumeration</description>
</rule>
In this case it is important that the new base rule has a lower priority than the final rule.
root@wazuh:/var/ossec/etc/rules# grep dstport=443 ~/previous_output | head -1 | cat - ~/full_log ~/full_log | /var/ossec/bin/wazuh-logtest
. . .
transip: '10.10.6.1'
transport: '65022'
type: 'traffic'
vd: 'saad'
**Phase 3: Completed filtering (rules).
id: '110056'
level: '10'
description: 'File Shares Enumeration - SMB Enumeration'
groups: '['local', 'syslog', 'sshd']'
firedtimes: '1'
frequency: '2'
mail: 'False'
**Alert to be generated.