Skip to content

feat(recommendations): add a Wazuh-derived Linux pattern catalogue and a sources and licensing table - #498

Open
TheWitness wants to merge 1 commit into
feat/recommendation-patternsfrom
feat/linux-wazuh-catalogue
Open

TheWitness wants to merge 1 commit into
feat/recommendation-patternsfrom
feat/linux-wazuh-catalogue

Conversation

@TheWitness

@TheWitness TheWitness commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Stacked on #497, which is stacked on #496. This PR targets feat/recommendation-patterns. Retarget it after those merge.

Summary

This finishes phase 2 of the Linux recommendations work:

  1. docs/linux-wazuh.json.gz: 434 manually importable pattern recommendations (feat(recommendations): match recommendations by regular expression and program #497) converted from 315 rules of the Wazuh 4.14.11 ruleset (GPL-2.0). They cover the four groups agreed for phase 2:

    Group Records Rule files
    Core Linux 135 syslog (kernel, su, sudo, cron, user management), PAM, sshd, systemd, firewalld, Dropbear, AppArmor, auditd, USB, Docker
    Network services 177 telnetd, arpwatch, ftpd, ProFTPD, Pure-FTPd, vsftpd, BIND, Samba, racoon, Apache, nginx, Squid, Unbound, OpenVPN
    Mail 71 Sendmail, Postfix, spamd, imapd, MailScanner, Courier, Dovecot, vm-pop3d, vpopmail, OpenSMTPD, Exim
    Databases and applications 51 MySQL, PostgreSQL, ClamAV, Puppet, Redis, FreeIPA, MongoDB, MariaDB

    No forwarder change is needed, because records match on message text and program.

  2. README "Recommendation sources and licensing" table: for every bundled .json.gz, it lists the vendor, file, source, copyright holder and license (with links to the governing terms), and a short sentence on how it was obtained. A paragraph explains that only the systemd, Wazuh and FRRouting-derived data is openly licensed. The remaining catalogues are short factual summaries of proprietary vendor documentation, with references back to it, and are not relicensed under the plugin's GPL.

Conversion (contrib/recommendations/extract_wazuh_rules.py)

  • A rule's own <match>/<regex> conditions are combined with those inherited through if_sid and decoded_as, including the decoder's prematch and named child decoders, into one PCRE pattern. Multiple conditions become lookaheads (^(?=.*?A)(?=.*?B)), and negated ones become (?!…).
  • OS_Match and OS_Regex are compiled case-insensitive by Wazuh (verified in src/analysisd/rules.c), so their conversions start with (?i). OS_Regex classes are expanded and $VARIABLEs substituted. PCRE2 expressions are kept as written.
  • program_name becomes a program glob: ^sshd gives sshd* (which matches sshd-session) and ^postfix gives postfix* (which matches postfix/smtpd). This uses the * wildcards added to feat(recommendations): match recommendations by regular expression and program #497 in 71130e3.
  • Skipped rules:
    • level-0 rules (203);
    • correlation rules or rules on decoder-extracted fields (195);
    • rules with no message condition (2);
    • rule 1002, a catch-all that matches "error", "failed" and similar words.
  • Records are ordered program-bound first, then most severe first, because the plugin tries patterns in import order and shows at most three recommendations.
  • Fields:
    • Severity is mapped from the Wazuh level.
    • The explanation is the rule description plus its ID, level, groups and MITRE ATT&CK techniques.
    • The reference links to the rule's line at the tag.
    • Wazuh provides no recommended actions.
  • build_catalogues.py now keeps regex and program, and the build is byte-reproducible. Rebuilding the existing systemd catalogue leaves it unchanged.

Testing

  • The catalogue-load test now covers linux-wazuh.json.gz. All 434 records import through the plugin's own validation: every pattern compiles under PHP PCRE and none matches an empty message.
  • New end-to-end cases run real syslog lines through the plugin matcher with the full catalogue:
    • a kernel OOM kill matches rule 5108;
    • sshd-session "Invalid user" matches rule 5710;
    • a postfix/smtpd hostname-resolution warning matches rule 3398;
    • the same sshd text from cron, and an ordinary NetworkManager carrier message, match nothing.
  • Full Pest suite against Cacti 1.2.x: 930 passed. The one warning (ProcessHelperCompatTest /proc probe) is also present on develop.

Licensing sources

The terms linked in the README table were checked against each vendor's published terms-of-use or license pages. Juniper, Dell, HPE and Nokia could only be read through search-result text, and Arista through an archived copy. I found no documentation terms for MikroTik. The table records what the sources say; it is not legal advice.

…d a sources and licensing table

Add docs/linux-wazuh.json.gz, a manually importable catalogue of 434
pattern recommendations converted from 315 rules of the Wazuh 4.14.11
ruleset (GPL-2.0): core Linux (syslog, kernel, sshd, PAM, su, sudo,
systemd, auditd, AppArmor, firewalld, Docker, USB), mail, network services
and databases and applications.

contrib/recommendations/extract_wazuh_rules.py reads the release's rule and
decoder XML. It combines a rule's own and inherited (if_sid, decoded_as,
decoder prematch) OS_Match, OS_Regex and PCRE2 conditions into one PCRE
pattern and its program_name into a program glob. Level 0, correlation and
decoded-field rules, and the generic rule 1002, are skipped. Records are
ordered program-bound and most severe first. build_catalogues.py now keeps
the regex and program fields.

The README gains a Recommendation sources and licensing table naming, for
every bundled catalogue, its vendor, source, copyright holder and license,
and how it was obtained. RECOMMENDATION_SOURCES.md documents the Wazuh
conversion.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sonarqubecloud

sonarqubecloud Bot commented Dec 3, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Security Rating on New Code (required ≥ A)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE



def read_xml(path):
with open(path, encoding='utf-8', errors='replace') as fh:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants