system/auth: extract group.name and set event.action for groupadd/groupdel - #20606
system/auth: extract group.name and set event.action for groupadd/groupdel#20606Tacklebox wants to merge 1 commit into
Conversation
…updel Fix group.name not being populated for groupadd messages in the /etc/group and /etc/gshadow formats (e.g. "group added to /etc/gshadow: name=fleet") and for groupdel removal messages (e.g. "group 'fleet' removed from /etc/gshadow"). Previously only the "new group: name=..., GID=..." format was handled. Also populate event.action with group-added or group-deleted for these events; event.type was being set correctly (creation/deletion) but event.action was always absent. Closes #20063 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
✅ Elastic Docs Style Checker (Vale)No issues found on modified lines! The Vale linter checks documentation changes against the Elastic Docs style guide. To use Vale locally or report issues, refer to Elastic style guide for Vale. |
|
✅ All changelog entries have the correct PR link. |
nicholasberlin
left a comment
There was a problem hiding this comment.
Human Review
Finding 1 seems worth doing to avoid the same issue coming up later for a slightly different log line.
Finding 2 seems fine to me.
PR Review: #20606 — system/auth: extract group.name and set event.action for groupadd/groupdel
Author: Tacklebox
Branch: system-auth-groupadd-groupdel-fixes -> main
Commits: 1 | Files changed: 11 | +198 -1
URL: #20606
Reviewed commit: 0519830
Reviewed by: claude-fable-5-thinking
Summary
Fixes #20063 by adding two conditional grok processors to the shared message.yml auth pipeline that extract group.name (and group.id where present) from the /etc/group and /etc/gshadow message variants of groupadd/groupdel, and by setting event.action: group-added / group-deleted based on process.name. The change is correct, consistent with the pipeline's existing patterns, and well covered by tests. I verified the grok patterns against every groupadd/groupdel message in the fixtures, and confirmed that all five test inputs containing such messages had their expected outputs updated — none were missed.
Verification details:
- The new grok patterns correctly match all fixture messages:
group added to /etc/group: name=tsg, GID=1003,group added to /etc/gshadow: name=tsg(optional GID group works with the non-greedyDATApattern), and bothgroup 'fleet' removed from /etc/{group,gshadow}variants. group.idis extracted as a string, consistent with the pre-existingnew group: name=..., GID=...pattern and the ECS keyword mapping.- The
setprocessors forevent.actionrun late in the pipeline and are keyed onprocess.namealone; I checked all earlierevent.actionsetters (chauthtok, gpasswd, usermod, userdel, faillock, session open/close, SSH script) and none can realistically fire for groupadd/groupdel messages, so no clobbering occurs. - Placement and style (tags,
ignore_missing/ignore_failure, conditional onctx.process?.name) match the neighboring usermod/userdel/gpasswd processors; action values follow the pipeline's kebab-case convention (group-user-added,group-member-removed, etc.). - Manifest bump (2.22.2 -> 2.22.3) and changelog entry are consistent; linking the changelog to the issue rather than the PR has precedent in this file, and the repo's changelog-link CI check passes.
- The new
test-groupdel.log-config.ymlcorrectly usesdynamic_fieldsfor@timestamp, so the year-less syslog timestamps won't cause failures when the year rolls over.
Findings
Minor
-
The third groupdel syslog line is not covered. shadow-utils
groupdelemits three lines on success:group 'X' removed from /etc/group,group 'X' removed from /etc/gshadow, and a final summarygroup 'X' removed(seeSYSLOG ((LOG_INFO, "group '%s' removed\n", group_name))insrc/groupdel.c). The new pattern anchors onremoved from /etc/(?:group|gshadow)$, so the summary line getsevent.action: group-deletedbut nogroup.name. Adding a second pattern (^group '%{DATA:group.name}' removed$) or making the suffix optional would close the gap; the existing userdel grok already uses an unanchored^removed (?:shadow )?group '...'pattern as precedent. Not blocking — the two formats reported in the issue are fully handled. -
event.actionis asserted for unparsed groupadd/groupdel messages. Because the newsetprocessors key onprocess.nameonly, any message from these processes — including failure messages or the literalthis is the messagefixture intest-host-syslog-processor.json— getsgroup-added/group-deleted. This mirrors how the pipeline already setsevent.category: iamandevent.type: group/creation/deletionunconditionally for these processes, and ECS treatsevent.actionas the attempted action (outcome is carried separately inevent.outcome), so this is defensible and consistent. Noting it only because it is a semantic choice a maintainer may want to confirm.
Verdict
APPROVE — correct, well-tested fix that follows the pipeline's established conventions. The two minor notes are optional improvements, not blockers.
💚 Build Succeeded
|
|
Tick the box to add this pull request to the merge queue (same as
|
Summary
Fixes #20063
Two bugs in the
system.authingest pipeline forgroupaddandgroupdelevents:group.namenot extracted from the additional message formats Linux emits alongside the primarynew group:line:group added to /etc/group: name=fleet, GID=1234(groupadd)group added to /etc/gshadow: name=fleet(groupadd)group 'fleet' removed from /etc/gshadow(groupdel)group 'fleet' removed from /etc/group(groupdel)event.actionnever set for groupadd or groupdel events. The pipeline was correctly settingevent.category: iamandevent.type: [group, creation/deletion]but leftevent.actionempty.Changes
grok-groupaddprocessor (conditional onprocess.name == 'groupadd') to extractgroup.name(andgroup.idwhere present) from the/etc/groupand/etc/gshadowmessage formats.grok-groupdelprocessor (conditional onprocess.name == 'groupdel') to extractgroup.namefromgroup 'xxx' removed from /etc/...messages.event.action: group-addedforgroupaddandevent.action: group-deletedforgroupdel.test-groupdel.logtest fixture covering the exact message formats from the issue.Test plan
system/authpipeline tests pass (elastic-package test pipeline)test-groupdel.logtest confirmsgroup.nameandevent.actionare populated for both groupadd and groupdel messages🤖 Generated with Claude Code