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

[Auditbeat] System module: Detect package updates #10508

Merged
merged 7 commits into from Feb 5, 2019

Conversation

cwurm
Copy link
Contributor

@cwurm cwurm commented Feb 3, 2019

Detects package updates by checking if any of the "new" package objects have the same package name as one of the "old" package objects. The event will have event.action: package_updated.

Also fixes two issues:

  1. Removes InstallTime from change detection. It is not set for dpkg, and for Homebrew it is currently the modification time of the package's directory. A touch will cause it to be reported as changed. I'm actually wondering if we should not set it for Homebrew at all. For change detection, we now rely on name, version, release (only set for RPM), and size - all of which (hopefully) only change when the package has indeed changed.
  2. For dpkg, reports packages as removed that have only been removed (apt-get remove) but not purged (apt-get purge). Removed package stay around in /var/lib/dpkg/status, but with a deinstall status.

As an urgent follow-up, we should add tests with sample files for at least:

  • /var/lib/dpkg/status in various stages (no package, installed package, new version, deinstalled package). I wanted to add it here, but we'll need a way to pass the test files to the metricset, and at the moment there is no config value for it (but there probably should be). I didn't want to do that bigger change here.
  • /usr/local/Cellar/{pkg.Name}/INSTALL_RECEIPT.json (read since [Auditbeat] Read formula path from INSTALL_RECEIPT.json for Homebrew packages #10507), and a Ruby formula file.

@cwurm cwurm added review needs_backport PR is waiting to be backported to other branches. Auditbeat SecOps labels Feb 3, 2019
@cwurm cwurm requested a review from a team as a code owner February 3, 2019 14:26
@elasticmachine
Copy link
Collaborator

Pinging @elastic/secops

@cwurm
Copy link
Contributor Author

cwurm commented Feb 4, 2019

jenkins, test this

Copy link
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

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

LGTM.

How does auditbeat ensure that /var/lib/dpkg/status is not being modified by dpkg when it reads?

@cwurm
Copy link
Contributor Author

cwurm commented Feb 4, 2019

How does auditbeat ensure that /var/lib/dpkg/status is not being modified by dpkg when it reads?

I don't think we do. Maybe we should lock the file as dpkg does (seems to use /var/lib/dpkg/lock via lockf(3)) to prevent dpkg from changing it while we read it. Would have to take to clean up properly though so as never to block dpkg.

Copy link
Contributor

@webmat webmat left a comment

Choose a reason for hiding this comment

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

LGTM

@cwurm cwurm merged commit 394d93d into elastic:master Feb 5, 2019
@cwurm cwurm deleted the package_updated branch February 5, 2019 11:50
@cwurm cwurm added v6.7.0 and removed needs_backport PR is waiting to be backported to other branches. labels Feb 5, 2019
cwurm pushed a commit to cwurm/beats that referenced this pull request Feb 5, 2019
Detects package updates by checking if any of the "new" package objects have the same package name as one of the "old" package objects. The event will have `event.action: package_updated`.

Also removes `InstallTime` from change detection. And for dpkg, reports packages as removed that have only been removed (`apt-get remove`) but not purged (`apt-get purge`).

(cherry picked from commit 394d93d)
cwurm pushed a commit that referenced this pull request Feb 5, 2019
…updates (#10562)

Cherry-pick of PR #10508 to 6.x branch. Original message: 

Detects package updates by checking if any of the "new" package objects have the same package name as one of the "old" package objects. The event will have `event.action: package_updated`.

Also removes `InstallTime` from change detection. And for dpkg, reports packages as removed that have only been removed (`apt-get remove`) but not purged (`apt-get purge`).

(cherry picked from commit 394d93d)
@cwurm cwurm mentioned this pull request Feb 9, 2019
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants