refactor(userspace/engine): refactor falco_engine with new loader defs

Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
This commit is contained in:
Jason Dellaluce 2022-09-13 12:31:25 +00:00 committed by poiana
parent f6f763fe84
commit 9c240198a0
2 changed files with 11 additions and 7 deletions

View File

@ -27,7 +27,8 @@ limitations under the License.
#include "falco_engine.h"
#include "falco_utils.h"
#include "falco_engine_version.h"
#include "rule_reader.h"
#include "rule_loader_reader.h"
#include "rule_loader_compiler.h"
#include "formats.h"
@ -59,7 +60,7 @@ falco_engine::falco_engine(bool seed_rng)
falco_engine::~falco_engine()
{
m_rules.clear();
m_rule_loader.clear();
m_rule_collector.clear();
m_rule_stats_manager.clear();
m_sources.clear();
}
@ -185,15 +186,17 @@ std::unique_ptr<load_result> falco_engine::load_rules(const std::string &rules_c
cfg.replace_output_container_info = m_replace_container_info;
cfg.default_ruleset_id = m_default_ruleset_id;
rule_reader reader;
if (reader.load(cfg, m_rule_loader))
rule_loader::reader reader;
if (reader.read(cfg, m_rule_collector))
{
for (auto &src : m_sources)
{
src.ruleset = src.ruleset_factory->new_ruleset();
}
rule_loader::compiler compiler;
m_rules.clear();
m_rule_loader.compile(cfg, m_rules);
compiler.compile(cfg, m_rule_collector, m_rules);
}
if (cfg.res->successful())
@ -515,7 +518,7 @@ bool falco_engine::check_plugin_requirements(
std::string& err) const
{
err = "";
for (const auto &alternatives : m_rule_loader.required_plugin_versions())
for (const auto &alternatives : m_rule_collector.required_plugin_versions())
{
if (!check_plugin_requirement_alternatives(plugins, alternatives, err))
{

View File

@ -32,6 +32,7 @@ limitations under the License.
#include "gen_filter.h"
#include "filter_ruleset.h"
#include "rule_loader.h"
#include "rule_loader_collector.h"
#include "stats_manager.h"
#include "falco_common.h"
#include "falco_source.h"
@ -278,7 +279,7 @@ private:
//
inline bool should_drop_evt() const;
rule_loader m_rule_loader;
rule_loader::collector m_rule_collector;
indexed_vector<falco_rule> m_rules;
stats_manager m_rule_stats_manager;