From 8e61e4601693b765b5bcd28662463115eac09ee5 Mon Sep 17 00:00:00 2001 From: Mark Stemm Date: Wed, 10 Aug 2022 18:21:56 -0700 Subject: [PATCH] Add an "Ok, with warnings" overall status. In outputs it could be confusing to see a line: : Ok followed by a set of warnings. To differentiate this, add a top level status "Ok, with warnings" when rule loading was successful but had warnings. Signed-off-by: Mark Stemm --- userspace/engine/rule_loader.cpp | 28 +++++++++++++++++-- .../app_actions/validate_rules_files.cpp | 5 ++-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/userspace/engine/rule_loader.cpp b/userspace/engine/rule_loader.cpp index 1ed972c5..3ded9313 100644 --- a/userspace/engine/rule_loader.cpp +++ b/userspace/engine/rule_loader.cpp @@ -266,7 +266,19 @@ const std::string& rule_loader::result::as_summary_string() os << name << ": "; } - os << (success ? "Ok" : "Invalid"); + if(success) + { + os << "Ok"; + + if (!warnings.empty()) + { + os << ", with warnings"; + } + } + else + { + os << "Invalid"; + } if(!errors.empty()) { @@ -326,7 +338,19 @@ const std::string& rule_loader::result::as_verbose_string(const rules_contents_t os << name << ": "; } - os << (success ? "Ok" : "Invalid"); + if(success) + { + os << "Ok"; + + if (!warnings.empty()) + { + os << ", with warnings"; + } + } + else + { + os << "Invalid"; + } if (!errors.empty()) { diff --git a/userspace/falco/app_actions/validate_rules_files.cpp b/userspace/falco/app_actions/validate_rules_files.cpp index b33a2996..1461ffc1 100644 --- a/userspace/falco/app_actions/validate_rules_files.cpp +++ b/userspace/falco/app_actions/validate_rules_files.cpp @@ -102,8 +102,9 @@ application::run_result application::validate_rules_files() { // If here, there must be only warnings. // Add a line to the summary noting that the - // file was ok without printing the warnings. - summary += filename + ": Ok"; + // file was ok with warnings, without actually + // printing the warnings. + summary += filename + ": Ok, with warnings"; // If verbose is true, print the warnings now. if(m_options.verbose)