Skip to content
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

Session view processor procfs #38799

Merged
merged 66 commits into from Apr 15, 2024
Merged

Conversation

mjwolf
Copy link
Contributor

@mjwolf mjwolf commented Apr 10, 2024

Proposed commit message

Add a procfs backend to the auditbeat add_session_metadata processor. For systems that don't support ebpf, this procfs backend can be used instead to enrich auditbeat events with the data needed for session view.

However the backend is expected to be less reliable than the ebpf backend; if processes exit before their info is read from procfs, the info will not be available, and some processes will be not be enriched (particularly very short-lived processes).

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

How to test this PR locally

In the auditbeat config file, add below lines to enable the add_session_metadata processor, with forced procfs backend.

- module: auditd
  # Load audit rules from separate files. Same format as audit.rules(7).
  processors:
    - add_session_metadata:
        backend: "procfs"

When running and sending data to a supported Kibana version, the session viewer should show events from auditbeat, powered by procfs.

Related issues

Use cases

Screenshots

Logs

mjwolf and others added 30 commits January 10, 2024 10:53
This processor will enrich process events with additional infomation needed to
enable session view in Kibana.

This processor can be run on Linux systems, and will use eBPF to enrich auditd events
for process exec and exit events. The additional fields that will be added are information
on process parent, session leader and process group leader.
Calculate and append entry leader information to enriched processes.
Co-authored-by: Dan Kortschak <90160302+efd6@users.noreply.github.com>
Remove the DB interface, as there will only be one implementation for it
Add a procfs provider to the add_session_view processor, which can be used to gather
session metadata on systems where the ebpf implementation is not supported.
* Changed to use time.Duration in timeutils for process start NS
* Used go-cmp library to compare ECS docs in tests
Fix linter warnings and upgrade go-libaudit to v2.5.0
ebpfevents library has been updated to use a single channel. Updated to use
latest ebpfevents library and the single channel.
Use watcher, which provides singleton access for ebpfevents
Co-authored-by: Mattia Meleleo <melmat@tuta.io>
Remove possibe panics in program initialization, and handle unexpected events
more gracefully.
If any process ancestry is incomplete, retry scraping the info from proc.

As procfs scraping can miss events, or not be updated when process re-parenting
happens, if any inconsistancy in the DB is found, rescrape to update the data.
@mjwolf mjwolf added enhancement backport-skip Skip notification from the automated backport with mergify labels Apr 10, 2024
@mjwolf mjwolf requested a review from a team as a code owner April 10, 2024 05:38
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Apr 10, 2024
@mergify mergify bot assigned mjwolf Apr 10, 2024
@elasticmachine
Copy link
Collaborator

elasticmachine commented Apr 10, 2024

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2024-04-15T17:27:56.038+0000

  • Duration: 47 min 11 sec

Test stats 🧪

Test Results
Failed 0
Passed 467
Skipped 60
Total 527

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /package : Generate the packages and run the E2E tests.

  • /beats-tester : Run the installation tests with beats-tester.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@andrewkroh andrewkroh added Team:Security-Linux Platform Linux Platform Team in Security Solution Team:Security-Deployment and Devices Deployment and Devices Team in Security Solution labels Apr 12, 2024
@elasticmachine
Copy link
Collaborator

Pinging @elastic/sec-deployment-and-devices (Team:Security-Deployment and Devices)

@elasticmachine
Copy link
Collaborator

Pinging @elastic/sec-linux-platform (Team:Security-Linux Platform)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Apr 12, 2024
@andrewkroh andrewkroh added Auditbeat needs_team Indicates that the issue/PR needs a Team:* label labels Apr 12, 2024
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Apr 12, 2024
Copy link
Contributor

mergify bot commented Apr 15, 2024

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b session_view_processor_procfs upstream/session_view_processor_procfs
git merge upstream/main
git push upstream session_view_processor_procfs

@mjwolf mjwolf merged commit 1898d37 into elastic:main Apr 15, 2024
39 checks passed
@mjwolf mjwolf deleted the session_view_processor_procfs branch April 15, 2024 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auditbeat backport-skip Skip notification from the automated backport with mergify enhancement Team:Security-Deployment and Devices Deployment and Devices Team in Security Solution Team:Security-Linux Platform Linux Platform Team in Security Solution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants