-
Notifications
You must be signed in to change notification settings - Fork 0
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
fix(src,cmake,go-worker): multiple fixes. #6
Conversation
.github/workflows/ci.yml
Outdated
- name: Install deps | ||
run: | ||
sudo apt-get install -y --no-install-recommends libbtrfs-dev libgpgme-dev | ||
sudo apt-get install -y --no-install-recommends libbtrfs-dev |
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.
Only dep left, but is compile time only.
@@ -70,46 +70,49 @@ void from_json(const nlohmann::json& j, container_port_mapping& port) { | |||
} | |||
|
|||
void from_json(const nlohmann::json& j, std::shared_ptr<container_info>& cinfo) { | |||
std::shared_ptr<container_info> info = std::make_shared<container_info>(); |
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.
Fixed cinfo filling to avoid dereferencing null ptr.
info->m_host_ipc = container.value("host_ipc", false); | ||
info->m_host_network = container.value("host_network", false); | ||
info->m_host_pid = container.value("host_pid", false); | ||
info->m_container_ip = container.value("ip", ""); |
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.
Fixed default value for m_container_ip
that is actually a string.
src/container_type.h
Outdated
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.
Removed wrong TODOs.
int32_t(evt_reader.get_type())); | ||
return false; | ||
} | ||
auto thread_id = evt_reader.get_tid(); |
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.
thread_id
is actually an uint64_t
, no need to check for <= 0
.
SPDLOG_ERROR("cannot extract the container_id for the thread id '{}': {}", | ||
} catch(falcosecurity::plugin_exception e) { | ||
// Debug here since many events do not have thread id info (eg: schedswitch) | ||
SPDLOG_DEBUG("cannot extract the container_id for the thread id '{}': {}", |
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.
Just a debug here: there can be events (eg: schedswitch) that do not have any threadinfo associated.
@@ -138,15 +135,18 @@ std::string my_plugin::compute_container_id_for_thread(const falcosecurity::tabl | |||
tr, | |||
[&](const falcosecurity::table_entry& e) | |||
{ | |||
if (!container_id.empty()) { |
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.
I thought that returning false
would stop the loop, instead it raised an exception 💀
} | ||
return true; | ||
} catch (falcosecurity::plugin_exception &e) { | ||
SPDLOG_ERROR("cannot attach container_id to new process event for the thread id '{}': {}", |
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.
This is actually an error since we are parsing a process
event (ie: execve, clone and so on), therefore thread_id
MUST be present.
@@ -4,6 +4,7 @@ | |||
"license": "MIT", | |||
"dependencies": [ | |||
"re2", | |||
"spdlog" | |||
"spdlog", | |||
"gpgme" |
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.
New dep.
First of all, podman had a runtime dep on `gpgme` (`libgpgme-dev`). Install it through vcpkg (as static) to avoid linking issues for the library consumer. Second, in go-worker Container struct, omit empty structured fields (slices, maps...), to avoid wasting memory space (plus all the back and forth copies). Finally, fixed some bugs all around the C++ implementation. Signed-off-by: Federico Di Pierro <[email protected]>
0809359
to
178eb89
Compare
First of all, podman had a runtime dep on
gpgme
(libgpgme-dev
). Install it through vcpkg (as static) to avoid linking issues for the library consumer.Second, in go-worker Container struct, omit empty structured fields (slices, maps...), to avoid wasting memory space (plus all the back and forth copies).
Finally, fixed some bugs all around the C++ implementation.
All of these were spotted thanks to the newly added possibility to load plugins in sinsp-example: falcosecurity/libs#2179.