Skip to content

Conversation

@Molter73
Copy link
Collaborator

@Molter73 Molter73 commented Dec 9, 2025

Description

This patch proposes a simple way of pipelining components. The pattern is to have each new component in the chain take the receiver end of the previous block as part of their builder, having the builder return a tuple with the object and the receiver end of this block, allowing that receiver to be passed to the next block.

In this new approach there are two special cases:

  • The Bpf module starts the chain, so it does not take a receiver.
  • The output module is the end of the chain, so it does not give a receiver back.

Checklist

  • Investigated and inspected CI test results
  • Updated documentation accordingly

Automated testing

  • Added unit tests
  • Added integration tests
  • Added regression tests

If any of these don't apply, please comment below.

Testing Performed

TODO(replace-me)
Use this space to explain how you tested your PR, or, if you didn't test it, why you did not do so. (Valid reasons include "CI is sufficient" or "No testable changes")
In addition to reviewing your code, reviewers must also review your testing instructions, and make sure they are sufficient.

For more details, ref the Confluence page about this section.

This is a very basic implementation of inode tracking meant to be used
in the upcoming release and improved upon in the near future.

The current implementation will perform a scan of the paths that are
configured to be monitored, using the inode and device numbers as a key
to two maps:
- A BPF hash map for kernelspace to know when an inode triggers an
  event.
- A HashMap in userspace that maps the inode to a path that we found the
  inode at.

With these two maps we are able to confidently emit events for files
that are mounted into containers with paths that don't necessarily match
the prefixes configured for monitoring and, at a later stage in
userspace, add the path on the host to the event itself.

The implemented approach is far from complete, it will only work as long
as the files found during the initial scan are not moved, deleted or
replaced by a different file. Future patches will extend the
functionality of both kernel and userspace to be able to catch more
corner cases.
Added tests will validate events generated on an overlayfs file properly
shows the event on the upper layer and the access to the underlying FS.
They also validate a mounted path on a container resolves to the correct
host path.

While developing these tests, it became painfully obvious getting the
information of the process running inside the container is not
straightforward. Because containers tend to be fairly static, we should
be able to manually create the information statically in the test and
still have everything work correctly. In order to minimize the amount of
changes on existing tests, the default Process constructor now takes
fields directly and there is a from_proc class method that builds a new
Process object from /proc. Additionally, getting the pid of a process in
a container is virtually impossible, so we make the pid check optional.
This patch proposes a simple way of pipelining components. The pattern
is to have each new component in the chain take the receiver end of the
previous block as part of their builder, having the builder return a
tuple with the object and the receiver end of this block, allowing that
receiver to be passed to the next block.

In this new approach there are two special cases:
* The Bpf module starts the chain, so it does not take a receiver.
* The output module is the end of the chain, so it does not give a
  receiver back.
Base automatically changed from mauro/ROX-30437/host-scanner-base to main December 15, 2025 14:42
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.

1 participant