Skip to content
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(userspace/engine): always consider all rules (even the ones below min_prio) in m_rule_stats_manager #3060

Merged
merged 2 commits into from
Feb 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions userspace/engine/falco_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ std::unique_ptr<load_result> falco_engine::load_rules(const std::string &rules_c
// clear the rules known by the engine and each ruleset
m_rules.clear();
for (auto &src : m_sources)

// add rules to each ruleset
{
src.ruleset = create_ruleset(src.ruleset_factory);
Expand All @@ -219,12 +218,6 @@ std::unique_ptr<load_result> falco_engine::load_rules(const std::string &rules_c
// add rules to the engine and the rulesets
for (const auto& rule : m_last_compile_output->rules)
{
// skip the rule if below the minimum priority
if (rule.priority > m_min_priority)
{
continue;
}

auto info = m_rule_collector->rules().at(rule.name);
if (!info)
{
Expand All @@ -234,9 +227,19 @@ std::unique_ptr<load_result> falco_engine::load_rules(const std::string &rules_c

auto source = find_source(rule.source);
auto rule_id = m_rules.insert(rule, rule.name);
m_rules.at(rule_id)->id = rule_id;
if (rule_id != rule.id)
{
throw falco_exception("Incompatible ID for rule: " + rule.name +
" | compiled ID: " + std::to_string(rule.id) +
" | stats_mgr ID: " + std::to_string(rule_id));
}

// By default rules are enabled/disabled for the default ruleset
// skip the rule if below the minimum priority
if (rule.priority > m_min_priority)
{
continue;
}
if(info->enabled)
{
source->ruleset->enable(rule.name, true, m_default_ruleset_id);
Expand Down
Loading