Skip to content

Commit

Permalink
fix(userspace/falco): make sure validation summary is populated even …
Browse files Browse the repository at this point in the history
…when json output is requested

Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
  • Loading branch information
jasondellaluce committed Oct 12, 2022
1 parent 2ec8b43 commit 34596df
Showing 1 changed file with 21 additions and 24 deletions.
45 changes: 21 additions & 24 deletions userspace/falco/app_actions/validate_rules_files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,33 +89,30 @@ application::run_result application::validate_rules_files()
{
results.push_back(res->as_json(rc));
}
else

if(summary != "")
{
if(summary != "")
{
summary += "\n";
}
summary += "\n";
}

// Add to the summary if not successful, or successful
// with no warnings.
if(!res->successful() ||
(res->successful() && !res->has_warnings()))
{
summary += res->as_string(true, rc);
}
else
// Add to the summary if not successful, or successful
// with no warnings.
if(!res->successful() || (res->successful() && !res->has_warnings()))
{
summary += res->as_string(true, rc);
}
else
{
// If here, there must be only warnings.
// Add a line to the summary noting that the
// 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)
{
// If here, there must be only warnings.
// Add a line to the summary noting that the
// 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)
{
fprintf(stderr, "%s\n", res->as_string(true, rc).c_str());
}
fprintf(stderr, "%s\n", res->as_string(true, rc).c_str());
}
}
}
Expand Down

0 comments on commit 34596df

Please sign in to comment.