Hello again,
Thank you very much for your answer, I haven't thought of using sibling decoders for this purpose, I will definitely give it a try.
I'd have another question about other custom decoding. I am working on ingesting DDoS logs from Radware DefensePro appliances, but I am encountering issues because of the pre-decoding phase. Here are three sample logs (as they arrive in Wazuh, taken from archives.log):
Jan 01 00:00:00 cyber-controller-server : [Device: x.x.x.x x.x.x.x] M_20000: An attack of type "Anti-Scanning" started. Detected by policy: My-Policy; Attack name: TCP IP Scan; Source IP: x.x.x.x; Destination IP: Multiple; Destination port: 0; Action: drop.
Jan 01 00:00:00 cyber-controller-server : [Device: x.x.x.x x.x.x.x] M_20000: 3 attacks of type "Anti-Scanning" started between 00:00:00 CEST and 00:00:00 CEST. Detected by policies: Policy-A, Policy-B; Attack name: TCP IP Scan; Source IPs: x.x.x.x, x.x.x.x; Destination IP: Multiple; Destination port: 0; Action: drop.
Jan 01 00:00:00 cyber-controller-server : [Device: x.x.x.x x.x.x.x] M_20000: An attack of type "DoS" started. Detected by policy: Policy-A; Attack name: My-Attack; Source IP: x.x.x.x; Destination IP: x.x.x.x; Destination port: 443; Action: drop.
I have linked the decoder I wrote to parse such logs in attachments. The issue I have is that the pre-decoding phase breaks the decoder in a way that I do not understand:
**Phase 1: Completed pre-decoding.
    full event: 'Jan 01 00:00:00 cyber-controller-server : [Device: x.x.x.x x.x.x.x] M_20000: An attack of type "Anti-Scanning" started. Detected by policy: My-Policy; Attack name: TCP IP Scan; Source IP: x.x.x.x; Destination IP: Multiple; Destination port: 0; Action: drop.'
    timestamp: 'Jan 01 00:00:00'
    hostname: 'cyber-controller-server'
    program_name: ''
**Phase 2: Completed decoding.
    No decoder matched.
**Phase 3: Completed filtering (rules).
    id: '1002'
    level: '2'
    description: 'Unknown problem somewhere in the system.'
    groups: '['syslog', 'errors']'
    firedtimes: '1'
    gpg13: '['4.3']'
    mail: 'False'
**Alert to be generated.
Here the pre-decoder gets the timestamp and hostname correctly, but it gives an empty 'program_name'. The weird thing is that it does not trigger any decoder, even when using a dummy empty or single letter prematch which should basically match anything. Why is that? I suspect the predecoder consumes the entire log, which prevents anything from matching. In fact, when adding any character in front of the log to prevent the pre-decoding (like a '1' for example), my decoder works just as expected:
**Phase 1: Completed pre-decoding.
    full event: '1 Jan 01 00:00:00 cyber-controller-server : [Device: x.x.x.x x.x.x.x] M_20000: 3 attacks of type "Anti-Scanning" started between 00:00:00 CEST and 00:00:00 CEST. Detected by policies: Policy-A, Policy-B; Attack name: TCP IP Scan; Source IPs: x.x.x.x, x.x.x.x; Destination IP: Multiple; Destination port: 0; Action: drop.'
**Phase 2: Completed decoding.
    name: 'ddos'
    action: 'drop'
    appliance_ip: 'x.x.x.x'
    appliance_name: 'M_20000'
    attack_count: '3'
    attack_name: 'TCP IP Scan'
    attack_type: 'Anti-Scanning'
    dstip: 'Multiple'
    dstport: '0'
    end_time: '00:00:00 CEST'
    policies: 'Policy-A, Policy-B'
    srcip: 'x.x.x.x, x.x.x.x'
    start_time: '00:00:00 CEST'
**Phase 3: Completed filtering (rules).
    id: '1002'
    level: '2'
    description: 'Unknown problem somewhere in the system.'
    groups: '['syslog', 'errors']'
    firedtimes: '1'
    gpg13: '['4.3']'
    mail: 'False'
**Alert to be generated.
I have come across
this post, but in my case, I am sending the logs from an aggregation platform to the Wazuh syslog listener, and I would like to avoid adding custom configuration to my forwarding routes just to add a dummy prefix to the logs. Adding an empty program_name tag as mentioned
here does not work either.
Is there a way to work around that? I think you should add a way to disable the pre-decoding phase and allow the user to parse the header variables themselves, this has caused me hassles more than once.
(Sidenote: I am running Wazuh 4.11.2)
Thank you again for your help.
Best regards,
Pierre