mirror of
https://github.com/falcosecurity/falco.git
synced 2025-07-22 02:12:02 +00:00
fix(userspace): handle exceptions for process_k8s_audit_event
This fix has two major points in it: - when `std::stoll` is used in parse_as_int64 handle all the exceptions it can throw (https://en.cppreference.com/w/cpp/string/basic_string/stol) - when `process_k8s_audit_event` an eventual exception in it does not stop the webserver process. This is done by doing a catch all handle outside it and by logging an error message to the caller as well as in stderr Signed-off-by: Lorenzo Fontana <lo@linux.com>
This commit is contained in:
parent
8b0d22dee9
commit
46425b392c
@ -281,7 +281,11 @@ bool json_event_value::parse_as_int64(int64_t &intval, const std::string &val)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (std::invalid_argument &e)
|
catch(std::out_of_range &)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch (std::invalid_argument &)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,17 @@ bool k8s_audit_handler::accept_data(falco_engine *engine,
|
|||||||
for(auto &jev : jevts)
|
for(auto &jev : jevts)
|
||||||
{
|
{
|
||||||
std::unique_ptr<falco_engine::rule_result> res;
|
std::unique_ptr<falco_engine::rule_result> res;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
res = engine->process_k8s_audit_event(&jev);
|
res = engine->process_k8s_audit_event(&jev);
|
||||||
|
}
|
||||||
|
catch(...)
|
||||||
|
{
|
||||||
|
errstr = string("unkown error processing audit event");
|
||||||
|
fprintf(stderr, "%s\n", errstr.c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if(res)
|
if(res)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user