Skip to content

feat(notifications): add actor fields to NewRuntimeIncident - #712

Merged
slashben merged 2 commits into
mainfrom
feat/runtime-incident-actor
Oct 11, 2026
Merged

slashben merged 2 commits into
mainfrom
feat/runtime-incident-actor

Conversation

@slashben

@slashben slashben commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds optional UserName and UserGroups fields to notifications.NewRuntimeIncident.

A customer asked for the actor in runtime incident Slack alerts (e.g. who ran "Exec to pod"). Admission incidents already record the requesting Kubernetes user in AdmissionAlert.UserInfo, but the notification payload drops it.

The JSON tags (userName, userGroups) match the fields added to RuntimeIncidentIngesterOnFinishedMessage in kubescape/messaging#113 (released in v0.0.114). users-notification-service passes that message through as the notification data, so matching tags are what carries the actor into the template data.

Notes

  • Both fields use omitempty, so existing producers and consumers are unaffected.
  • JSON tags only: NewRuntimeIncident is never stored in MongoDB and none of its fields carry bson tags.
  • Adds runtimeincidents_test.go covering decoding of the actor fields and their omission when empty.
  • Adds docs/features/runtime-incident-actor.md describing the contract.
  • Follow-up: armosec/backend PR to populate the fields in event-ingester-service and render an Actor row in users-notification-service templates.

AI-skills: armosec-shared-rules:writing-docs | cmds: /model

Carry the Kubernetes user (name and groups) of admission incidents such as
exec to pod, so alert channels (Slack, Teams, etc.) can show who triggered
the incident. JSON tags match kubescape/messaging
RuntimeIncidentIngesterOnFinishedMessage (v0.0.114), which
users-notification-service passes through as the notification data.
Signed-off-by: Ben <ben@armosec.io>
Copilot AI balanced review requested due to automatic review settings October 7, 2026 11:43
@slashben slashben added the ai-assisted Created through Armosec AI tooling (armosec-shared-rules plugin) label Oct 7, 2026
@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9d5e4e64-5064-465c-a39c-7cd18b532f02
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The new fields omit BSON tags required by the repository-wide serialization convention.

Review effort: Balanced
Findings: 2 Low severity

Open (2)
What changed in this PR

Adds Kubernetes actor metadata to runtime incident notification payloads.

Changes:

  • Adds optional username and group fields.
  • Adds JSON contract tests and documentation.
File Description
notifications/​runtimeincidents.go Adds actor fields.
notifications/​runtimeincidents_test.go Tests decoding and omission.
docs/​features/​runtime-incident-actor.md Documents the contract.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread docs/features/runtime-incident-actor.md Outdated
Comment thread notifications/runtimeincidents.go Outdated
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 37616023381

Warning

No base build found for commit 1613d46 on main.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 52.094%

Details

  • Patch coverage: No coverable lines changed in this PR.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 5634
Covered Lines: 2935
Line Coverage: 52.09%
Coverage Strength: 9.96 hits per line

💛 - Coveralls

@slashben
slashben requested a review from rotemamsa October 7, 2026 14:12
Keep json and bson tag names aligned per AGENTS.md, pin them with a bson
round-trip test, and describe the tags in the feature doc.
Signed-off-by: Ben <ben@armosec.io>

@rotemamsa rotemamsa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Small and backward compatible, tags are pinned by tests. Please link a SUB ticket and update the PR body (it still says JSON tags only). For the backend follow-up, both event-ingester-service and users-notification-service need kubescape/messaging >= v0.0.114.

@slashben
slashben merged commit f0be32d into main Oct 11, 2026
2 checks passed
@slashben
slashben deleted the feat/runtime-incident-actor branch October 11, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-assisted Created through Armosec AI tooling (armosec-shared-rules plugin)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants