Skip to content

feat(core): add username field for alerts and telemetry #2021

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rootxrishabh
Copy link
Member

Purpose of PR?:
This PR adds a username field to both alert and log.
Fixes #2009

Does this PR introduce a breaking change?
No
If the changes in this PR are manually verified, list down the scenarios covered::

Additional information for reviewer? :
Mention if this PR is part of any design or a continuation of previous PRs

Checklist:

  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • PR Title follows the convention of <type>(<scope>): <subject>
  • Commit has unit tests
  • Commit has integration tests

@rootxrishabh
Copy link
Member Author

Folks, kept username separate from UID to avoid converting u32 to string.

Sample Log Json -

{
  "timestamp": 1743579248,
  "updatedTime": "2025-04-02T07:34:08.658306Z",
  "hostName": "rootxrishabh",
  "hostPPid": 35429,
  "hostPid": 209850,
  "ppid": 0,
  "pid": 209850,
  "uid": 1000,
  "parentProcessName": "/snap/code/187/usr/share/code/code",
  "processName": "/usr/bin/git",
  "atags": null,
  "type": "HostLog",
  "source": "/snap/code/187/usr/share/code/code",
  "operation": "Process",
  "resource": "/usr/bin/git -c core.quotepath=false -c color.ui=false blame --root --incremental -- KubeArmor/feeder/feeder.go",
  "cwd": "/home/rootxrishabh/accuknox/KubeArmor/",
  "oid": 0,
  "data": "syscall=SYS_EXECVE",
  "result": "Passed",
  "username": "rootxrishabh"
}

@rootxrishabh
Copy link
Member Author

Karmor will need changes to to reflect username field in karmor logs.

@rksharma95
Copy link
Collaborator

@rootxrishabh can you please take a look why CI tests are failing.

Comment on lines +59 to +62
username, err := user.LookupId(fmt.Sprint(msg.ContextSys.UID))
if err != nil {
mon.Logger.Errf("error occured when fetching user %e", err)
}
Copy link
Member

Choose a reason for hiding this comment

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

How's this going to work?
1000 could be named postgres in a postgres container but it might not exist on the host KubeArmor is in?

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.

add username along with userid to telemetry
3 participants