carver: Refactor carver to use the Scheduler #6671
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change refactors the carver code and functionality.
From a functionality perspective, carving is now implemented using a request and handler model. Carving can be requested via the SQLite
carve
function or using the predicateWHERE carve=1
on theosquery_carves
table. Previously when a carve was requested, the carving and posting to a remote endpoint would occur during query execution. Now carve requests are buffered and the scheduler thread periodically "wakes up" a carving thread that handles the requests. Additionally, carving is now unique toosqueryd
and the metadata from successful carve requests will be removed from osquery's internal database after 24hours.From a code point of view the implementation is split into a "carver utilities" set that can be widely used/included. This allows components within osquery to request paths to be carved, as well as a minor amount of inspection into carver statuses. The new "carver" set implements the actual carving and a new "runner" thread to handle carver requests serially. This code should NOT be widely used as it has extensive linkage requirements.