mirror of
https://github.com/falcosecurity/falco.git
synced 2025-09-06 01:00:36 +00:00
new(falco): implement rule selection configuration in falco.yaml
Signed-off-by: Luca Guerra <luca@guerra.sh>
This commit is contained in:
@@ -242,11 +242,11 @@ std::unique_ptr<load_result> falco_engine::load_rules(const std::string &rules_c
|
||||
}
|
||||
if(info->enabled)
|
||||
{
|
||||
source->ruleset->enable(rule.name, true, m_default_ruleset_id);
|
||||
source->ruleset->enable(rule.name, filter_ruleset::match_type::exact, m_default_ruleset_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
source->ruleset->disable(rule.name, true, m_default_ruleset_id);
|
||||
source->ruleset->disable(rule.name, filter_ruleset::match_type::exact, m_default_ruleset_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -272,17 +272,15 @@ void falco_engine::enable_rule(const std::string &substring, bool enabled, const
|
||||
|
||||
void falco_engine::enable_rule(const std::string &substring, bool enabled, const uint16_t ruleset_id)
|
||||
{
|
||||
bool match_exact = false;
|
||||
|
||||
for(const auto &it : m_sources)
|
||||
{
|
||||
if(enabled)
|
||||
{
|
||||
it.ruleset->enable(substring, match_exact, ruleset_id);
|
||||
it.ruleset->enable(substring, filter_ruleset::match_type::substring, ruleset_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
it.ruleset->disable(substring, match_exact, ruleset_id);
|
||||
it.ruleset->disable(substring, filter_ruleset::match_type::substring, ruleset_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -296,17 +294,37 @@ void falco_engine::enable_rule_exact(const std::string &rule_name, bool enabled,
|
||||
|
||||
void falco_engine::enable_rule_exact(const std::string &rule_name, bool enabled, const uint16_t ruleset_id)
|
||||
{
|
||||
bool match_exact = true;
|
||||
|
||||
for(const auto &it : m_sources)
|
||||
{
|
||||
if(enabled)
|
||||
{
|
||||
it.ruleset->enable(rule_name, match_exact, ruleset_id);
|
||||
it.ruleset->enable(rule_name, filter_ruleset::match_type::exact, ruleset_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
it.ruleset->disable(rule_name, match_exact, ruleset_id);
|
||||
it.ruleset->disable(rule_name, filter_ruleset::match_type::exact, ruleset_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void falco_engine::enable_rule_wildcard(const std::string &rule_name, bool enabled, const std::string &ruleset)
|
||||
{
|
||||
uint16_t ruleset_id = find_ruleset_id(ruleset);
|
||||
|
||||
enable_rule_wildcard(rule_name, enabled, ruleset_id);
|
||||
}
|
||||
|
||||
void falco_engine::enable_rule_wildcard(const std::string &rule_name, bool enabled, const uint16_t ruleset_id)
|
||||
{
|
||||
for(const auto &it : m_sources)
|
||||
{
|
||||
if(enabled)
|
||||
{
|
||||
it.ruleset->enable(rule_name, filter_ruleset::match_type::wildcard, ruleset_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
it.ruleset->disable(rule_name, filter_ruleset::match_type::wildcard, ruleset_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user