mirror of
https://github.com/falcosecurity/falco.git
synced 2025-09-03 07:34:53 +00:00
fix(userspace): accessing a (json) object can throw exceptions because of wrong types
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
This commit is contained in:
committed by
Lorenzo Fontana
parent
330d7ef2d7
commit
723bc1cabf
@@ -365,7 +365,10 @@ unique_ptr<falco_engine::rule_result> falco_engine::process_k8s_audit_event(json
|
||||
|
||||
bool falco_engine::parse_k8s_audit_json(nlohmann::json &j, std::list<json_event> &evts)
|
||||
{
|
||||
// If the Kind is EventList, split it into individual events.
|
||||
// Note that nlohmann::basic_json::value can throw nlohmann::basic_json::type_error (302, 306)
|
||||
try
|
||||
{
|
||||
// If the kind is EventList, split it into individual events
|
||||
if(j.value("kind", "<NA>") == "EventList")
|
||||
{
|
||||
for(auto &je : j["items"])
|
||||
@@ -396,7 +399,6 @@ bool falco_engine::parse_k8s_audit_json(nlohmann::json &j, std::list<json_event>
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
evts.back().set_jevt(j, ns);
|
||||
return true;
|
||||
}
|
||||
@@ -404,7 +406,13 @@ bool falco_engine::parse_k8s_audit_json(nlohmann::json &j, std::list<json_event>
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
catch(exception &e)
|
||||
{
|
||||
// Propagate the exception
|
||||
rethrow_exception(current_exception());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
unique_ptr<falco_engine::rule_result> falco_engine::process_k8s_audit_event(json_event *ev)
|
||||
|
Reference in New Issue
Block a user