mirror of
https://github.com/falcosecurity/falco.git
synced 2025-06-26 06:42:08 +00:00
refactor(userspace/falco): move rules plugin requirements check in an internal funcion
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
This commit is contained in:
parent
5781c53ddc
commit
bbb821fb8e
@ -19,6 +19,21 @@ limitations under the License.
|
||||
|
||||
using namespace falco::app;
|
||||
|
||||
bool application::check_rules_plugin_requirements(std::string& err)
|
||||
{
|
||||
// Ensure that all plugins are compatible with the loaded set of rules
|
||||
// note: offline inspector contains all the loaded plugins
|
||||
std::vector<falco_engine::plugin_version_requirement> plugin_reqs;
|
||||
for (const auto &plugin : m_state->offline_inspector->get_plugin_manager()->plugins())
|
||||
{
|
||||
falco_engine::plugin_version_requirement req;
|
||||
req.name = plugin->name();
|
||||
req.version = plugin->plugin_version().as_string();
|
||||
plugin_reqs.push_back(req);
|
||||
}
|
||||
return m_state->engine->check_plugin_requirements(plugin_reqs, err);
|
||||
}
|
||||
|
||||
void application::check_for_ignored_events()
|
||||
{
|
||||
/* Get the events from the rules. */
|
||||
@ -134,20 +149,10 @@ application::run_result application::load_rules_files()
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure that all plugins are compatible with the loaded set of rules
|
||||
// note: offline inspector contains all the loaded plugins
|
||||
std::string plugin_vers_err = "";
|
||||
std::vector<falco_engine::plugin_version_requirement> plugin_reqs;
|
||||
for (const auto &plugin : m_state->offline_inspector->get_plugin_manager()->plugins())
|
||||
{
|
||||
falco_engine::plugin_version_requirement req;
|
||||
req.name = plugin->name();
|
||||
req.version = plugin->plugin_version().as_string();
|
||||
plugin_reqs.push_back(req);
|
||||
}
|
||||
if (!m_state->engine->check_plugin_requirements(plugin_reqs, plugin_vers_err))
|
||||
std::string err = "";
|
||||
if (!check_rules_plugin_requirements(err))
|
||||
{
|
||||
return run_result::fatal(plugin_vers_err);
|
||||
return run_result::fatal(err);
|
||||
}
|
||||
|
||||
for (const auto& substring : m_options.disabled_rule_substrings)
|
||||
|
@ -284,6 +284,7 @@ private:
|
||||
bool create_handler(int sig, void (*func)(int), run_result &ret);
|
||||
void configure_output_format();
|
||||
void check_for_ignored_events();
|
||||
bool check_rules_plugin_requirements(std::string& err);
|
||||
void format_plugin_info(std::shared_ptr<sinsp_plugin> p, std::ostream& os) const;
|
||||
run_result open_offline_inspector();
|
||||
run_result open_live_inspector(std::shared_ptr<sinsp> inspector, const std::string& source);
|
||||
|
Loading…
Reference in New Issue
Block a user