-
Notifications
You must be signed in to change notification settings - Fork 31
ROX-33614: Update Falco to 0.23.1 #2976
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,8 @@ | |
|
|
||
| #include <uuid/uuid.h> | ||
|
|
||
| #include <libsinsp/sinsp.h> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh lord, no, please let's not start polluting the code base with sinsp headers again, we even have a proposal to stop doing this (#3502). AFAICT, this is only needed for the
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, I tried locally removing it and it just compiled, so maybe it is not needed at all. |
||
|
|
||
| #include <google/protobuf/util/time_util.h> | ||
|
|
||
| #include "internalapi/sensor/signal_iservice.pb.h" | ||
|
|
@@ -59,8 +61,8 @@ std::string extract_proc_args(sinsp_threadinfo* tinfo) { | |
| ProcessSignalFormatter::ProcessSignalFormatter( | ||
| sinsp* inspector, | ||
| const CollectorConfig& config) : event_names_(EventNames::GetInstance()), | ||
| inspector_(inspector), | ||
| event_extractor_(std::make_unique<system_inspector::EventExtractor>()), | ||
| container_metadata_(inspector), | ||
| config_(config) { | ||
| event_extractor_->Init(inspector); | ||
| } | ||
|
|
@@ -176,8 +178,9 @@ ProcessSignal* ProcessSignalFormatter::CreateProcessSignal(sinsp_evt* event) { | |
| signal->set_allocated_time(timestamp); | ||
|
|
||
| // set container_id | ||
| if (const std::string* container_id = event_extractor_->get_container_id(event)) { | ||
| signal->set_container_id(*container_id); | ||
| auto container_id = GetContainerID(event); | ||
| if (!container_id.empty()) { | ||
| signal->set_container_id(container_id); | ||
| } | ||
|
|
||
| // set process lineage | ||
|
|
@@ -190,7 +193,7 @@ ProcessSignal* ProcessSignalFormatter::CreateProcessSignal(sinsp_evt* event) { | |
| } | ||
|
|
||
| CLOG(DEBUG) << "Process (" << signal->container_id() << ": " << signal->pid() << "): " | ||
| << signal->name() << "[" << container_metadata_.GetNamespace(event) << "] " | ||
| << signal->name() << "[" << container_id << "]" | ||
| << " (" << signal->exec_file_path() << ")" | ||
| << " " << signal->args(); | ||
|
|
||
|
|
@@ -232,16 +235,16 @@ ProcessSignal* ProcessSignalFormatter::CreateProcessSignal(sinsp_threadinfo* tin | |
| signal->set_pid(tinfo->m_pid); | ||
|
|
||
| // set user and group id credentials | ||
| signal->set_uid(tinfo->m_user.uid()); | ||
| signal->set_gid(tinfo->m_group.gid()); | ||
| signal->set_uid(tinfo->m_uid); | ||
| signal->set_gid(tinfo->m_gid); | ||
|
|
||
| // set time | ||
| auto timestamp = Allocate<Timestamp>(); | ||
| *timestamp = TimeUtil::NanosecondsToTimestamp(tinfo->m_clone_ts); | ||
| signal->set_allocated_time(timestamp); | ||
|
|
||
| // set container_id | ||
| signal->set_container_id(tinfo->m_container_id); | ||
| signal->set_container_id(GetContainerID(*tinfo)); | ||
|
|
||
| // set process lineage | ||
| std::vector<LineageInfo> lineage; | ||
|
|
@@ -254,7 +257,7 @@ ProcessSignal* ProcessSignalFormatter::CreateProcessSignal(sinsp_threadinfo* tin | |
| } | ||
|
|
||
| CLOG(DEBUG) << "Process (" << signal->container_id() << ": " << signal->pid() << "): " | ||
| << signal->name() | ||
| << signal->name() << "[" << signal->container_id() << "]" | ||
| << " (" << signal->exec_file_path() << ")" | ||
| << " " << signal->args(); | ||
|
|
||
|
|
@@ -265,11 +268,11 @@ std::string ProcessSignalFormatter::ProcessDetails(sinsp_evt* event) { | |
| std::stringstream ss; | ||
| const std::string* path = event_extractor_->get_exepath(event); | ||
| const std::string* name = event_extractor_->get_comm(event); | ||
| const std::string* container_id = event_extractor_->get_container_id(event); | ||
| auto container_id = GetContainerID(event); | ||
| const char* args = event_extractor_->get_proc_args(event); | ||
| const int64_t* pid = event_extractor_->get_pid(event); | ||
|
|
||
| ss << "Container: " << (container_id ? *container_id : "null") | ||
| ss << "Container: " << (container_id.empty() ? "null" : container_id) | ||
| << ", Name: " << (name ? *name : "null") | ||
| << ", PID: " << (pid ? *pid : -1) | ||
| << ", Path: " << (path ? *path : "null") | ||
|
|
@@ -327,7 +330,7 @@ void ProcessSignalFormatter::GetProcessLineage(sinsp_threadinfo* tinfo, | |
| return; | ||
| } | ||
| } | ||
| sinsp_threadinfo::visitor_func_t visitor = [this, &lineage](sinsp_threadinfo* pt) { | ||
| sinsp_thread_manager::visitor_func_t visitor = [this, &lineage](sinsp_threadinfo* pt) { | ||
| if (pt == NULL) { | ||
| return false; | ||
| } | ||
|
|
@@ -341,13 +344,13 @@ void ProcessSignalFormatter::GetProcessLineage(sinsp_threadinfo* tinfo, | |
| // | ||
| // In back-ported eBPF probes, `m_vpid` will not be set for containers | ||
| // running when collector comes online because /proc/{pid}/status does | ||
| // not contain namespace information, so `m_container_id` is checked | ||
| // instead. `m_container_id` is not enough on its own to identify | ||
| // not contain namespace information, so the container ID is checked | ||
| // instead. The container ID is not enough on its own to identify | ||
| // containerized processes, because it is not guaranteed to be set on | ||
| // all platforms. | ||
| // | ||
| if (pt->m_vpid == 0) { | ||
| if (pt->m_container_id.empty()) { | ||
| if (GetContainerID(*pt).empty()) { | ||
| return false; | ||
| } | ||
| } else if (pt->m_pid == pt->m_vpid) { | ||
|
|
@@ -361,7 +364,7 @@ void ProcessSignalFormatter::GetProcessLineage(sinsp_threadinfo* tinfo, | |
| // Collapse parent child processes that have the same path | ||
| if (lineage.empty() || (lineage.back().parent_exec_file_path() != pt->m_exepath)) { | ||
| LineageInfo info; | ||
| info.set_parent_uid(pt->m_user.uid()); | ||
| info.set_parent_uid(pt->m_uid); | ||
| info.set_parent_exec_file_path(pt->m_exepath); | ||
| lineage.push_back(info); | ||
| } | ||
|
|
@@ -373,7 +376,7 @@ void ProcessSignalFormatter::GetProcessLineage(sinsp_threadinfo* tinfo, | |
|
|
||
| return true; | ||
| }; | ||
| mt->traverse_parent_state(visitor); | ||
| inspector_->m_thread_manager->traverse_parent_state(*mt, visitor); | ||
| CountLineage(lineage); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might want to do something closer to what falco does:
It's more verbose, but also more explicit about what operations should make these checks. The compiler should still be able to optimize the case conditions to range checks.