Repository navigation
feat(recommendations): add a curated Linux catalogue with recommended actions - #499
Conversation
46ce703 to
26dd49d
Compare
26dd49d to
5824f39
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Deduplication can discard actionable recommendations, while an overly broad fault pattern misclassifies user-space crashes as kernel oopses and recommends unnecessary reboots.
2 open issues
What changed in this PR
Adds curated Linux troubleshooting advice to the existing recommendation engine, complementing the systemd and Wazuh catalogues.
Changes:
- Adds 70 recommendations with actions, references and sample messages.
- Prioritizes actionable pattern matches and preserves regex whitespace.
- Adds catalogue regression tests and updates documentation and licensing.
| File | Description |
|---|---|
tests/Unit/RecommendationsTest.php |
Tests catalogue loading, samples, ranking and whitespace. |
syslog_recommendations.php |
Preserves patterns on save and updates matching help. |
README.md |
Documents the catalogue, ordering and licensing. |
NOTICE |
Adds curated catalogue attribution. |
locales/po/cacti.pot |
Updates translatable matching help. |
includes/recommendations.php |
Preserves regex whitespace and prioritizes actions. |
docs/RECOMMENDATION_SOURCES.md |
Documents coverage, references and build instructions. |
docs/linux-curated.json.gz.license |
Adds SPDX licensing metadata. |
contrib/recommendations/linux-curated.json |
Defines recommendations and sample messages. |
contrib/recommendations/build_catalogues.py |
Adds curated catalogue build support. |
CHANGELOG.md |
Records catalogue and matching changes. |
Review effort: Balanced
faa099a to
a9b6074
Compare
a9b6074 to
bd6ec0e
Compare
somethingwithproof
left a comment
There was a problem hiding this comment.
Blocker: linux-kernel-oops matches user-space crashes. Its pattern has an unqualified general protection fault alternative (contrib/recommendations/linux-curated.json:197), and the kernel logs user-space faults under the same program: traps: myapp[1234] general protection fault ip:... sp:... error:0 in libc.so.6[...]. That line gets the oops explanation and "Plan a reboot". Exclude the traps: form, or require the oops form (general protection fault, probably for non-canonical address or general protection fault: 0000), and add a sample that must not match. The 113 samples are all positive, so the test cannot catch this.
Suggestion: syslog_recommendation_pattern_ids() drops a later match whose vendor, message and explanation equal an earlier one (includes/recommendations.php:1002), and the action is not part of that key. A record that differs only by having an action is skipped before the action-first sort runs. The shipped catalogues do not hit this; an imported or edited record can. Add the action to the key, or prefer the record that has one.
Suggestion: linux-systemd-unit-failed starts with an unanchored \S+\., which is quadratic on a long run without spaces. It is bounded by the 2,048 byte cut, but it runs on every systemd message. \b[\w@:-]+\.(?:service|...) or a length bound avoids it.
Nit: the lookup now evaluates every applicable pattern for a details view, not just until three match. Worth a line in the description.
Both Copilot threads on this PR are still open at bd6ec0e. CI on this head was cancelled, and it inherits the PHP 8.3 memory failure described on #498.
bd6ec0e to
310deb9
Compare
63c516e to
9a7a21d
Compare
|
@somethingwithproof thanks, addressed in "fix(recommendations): keep kernel oops advice off user-space faults":
|
9a7a21d to
e1c60d4
Compare
somethingwithproof
left a comment
There was a problem hiding this comment.
No blockers found at e1c60d4.
linux-kernel-oopsnow needs the oops form:general protection fault: 0000 [#1]or thenon-canonical addressvariant. Atraps: myapp[1234] general protection fault ip:...line no longer matches, and the newnon_matchessample covers it.- The duplicate key includes
recommended_action. - The systemd unit pattern is anchored.
CI is green on PHP 8.2 to 8.6.
… actions Add docs/linux-curated.json.gz: 70 hand-written pattern recommendations, each with an explanation and a recommended action, for the most important Linux kernel and service messages (memory and OOM, lockups, hung tasks and crashes, machine-check and EDAC errors, thermal events, block, SATA, SCSI and NVMe errors, ext4, XFS and Btrfs, software RAID, SMART, multipath, NFS, iSCSI, links, bonding, NICs, conntrack, SYN floods, time synchronisation, sshd, sudo, PAM, SELinux, AppArmor, audit, systemd unit failures and crashes, and journald and rsyslog message loss). The source is contrib/recommendations/linux-curated.json, written for this plugin under its GPL; each record carries sample messages that the unit tests replay through the plugin matcher, and references kernel, man page or project documentation. Among matching pattern recommendations, the details flyout now shows those with a recommended action first, so curated advice wins over the description-only Wazuh records whichever catalogue was imported first. Patterns are now stored exactly as written instead of having surrounding spaces trimmed, because whitespace is significant in a regular expression. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Review follow-up for the curated Linux catalogue:
- linux-kernel-oops matched any "general protection fault", so a
user-space crash logged by the kernel (traps: app[pid] general
protection fault ip:... in libc.so.6) got the oops explanation and
"Plan a reboot". Match only the oops form ("general protection
fault[, probably for non-canonical address 0x...]: 0000 [#1]").
- Records may now list "non_matches", messages they must not match,
and the unit test checks them; the traps line is the first.
- Anchor linux-systemd-unit-failed's unit name, so a long run without
spaces no longer costs quadratic backtracking on every systemd line.
- Include the recommended action in the duplicate pattern match key, so
a record that differs from an earlier match only by having an action
is no longer skipped before the action-first ordering.
docs/linux-curated.json.gz is rebuilt with build_catalogues.py.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
e1c60d4 to
d2357c8
Compare
|




Summary
This is phase 3 of the Linux recommendations work: hand-written recommendations with real recommended actions, which Wazuh and the systemd catalog don't provide.
docs/linux-curated.json.gzholds 70 pattern recommendations. Every record has an explanation, a concrete recommended action and a reference to the Linux kernel documentation, man page or project documentation it relies on.Source and licensing
contrib/recommendations/linux-curated.json, built withbuild_catalogues.py linux-curated; the build is byte-reproducible.RECOMMENDATION_SOURCES.mdinclude the new catalogue.Engine changes
Review and testing
I/O tagtimeouts, the newerNETDEV WATCHDOG: CPU:format, RAID5/6md/raid:, and tg3/bnx2 link-down wording;Can't synchronisevariants, and rsyslog 8'sbegin to drop messageswording andrsyslogd-NNNNprogram tags;no_sys_peer(the earlier text wasntpdate's);UserTasksMax=;.gzequals the source without its samples.linux-oom-killbeforewazuh-5108);linux-kernel-oopsmatches only the oops form of a general protection fault (general protection fault[, probably for non-canonical address 0x...]: 0000 [#1]), not user-spacetraps: app[pid] general protection fault ... in libc.so.6lines;non_matches, messages that must not find them, and the sample test checks them; thetraps:line is the first;linux-systemd-unit-failedanchors its unit name, avoiding quadratic backtracking on long runs without spaces;ProcessHelperCompatTest/procprobe) is also present ondevelop.