update(userspace/engine): correctly use describe rule based on config

Signed-off-by: Lorenzo Susini <susinilorenzo1@gmail.com>
This commit is contained in:
Lorenzo Susini
2023-05-12 10:08:51 +00:00
committed by poiana
parent 9947962cb8
commit c1623771d8
2 changed files with 6 additions and 3 deletions

View File

@@ -123,7 +123,7 @@ public:
// Print details on the given rule. If rule is NULL, print
// details on all rules.
//
void describe_rule(std::string *rule) const;
void describe_rule(std::string *rule, bool json) const;
//
// Print statistics on how many events matched each rule.
@@ -298,6 +298,9 @@ private:
//
inline bool should_drop_evt() const;
// Retrieve details of a rule in json format
Json::Value get_json_rule_details(const falco_rule& r) const;
rule_loader::collector m_rule_collector;
indexed_vector<falco_rule> m_rules;
stats_manager m_rule_stats_manager;

View File

@@ -118,13 +118,13 @@ falco::app::run_result falco::app::actions::load_rules_files(falco::app::state&
if (s.options.describe_all_rules)
{
s.engine->describe_rule(NULL);
s.engine->describe_rule(NULL, s.config->m_json_output);
return run_result::exit();
}
if (!s.options.describe_rule.empty())
{
s.engine->describe_rule(&(s.options.describe_rule));
s.engine->describe_rule(&(s.options.describe_rule), s.config->m_json_output);
return run_result::exit();
}