Send validate output to stdout

When parsing rules files with -V (validate), print info on the result of
loading the rules file to stdout. That way a caller can capture stdout
to pass along any rules parsing error.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
This commit is contained in:
Mark Stemm
2019-07-05 15:37:22 -07:00
committed by Mark Stemm
parent dc7bff127f
commit 839d76a760

View File

@@ -716,7 +716,17 @@ int falco_init(int argc, char **argv)
}
for(auto file : validate_rules_filenames)
{
engine->load_rules_file(file, verbose, all_events);
// Only include the prefix if there is more than one file
std::string prefix = (validate_rules_filenames.size() > 1 ? file + ": " : "");
try {
engine->load_rules_file(file, verbose, all_events);
}
catch(falco_exception &e)
{
printf("%s%s\n", prefix.c_str(), e.what());
throw;
}
printf("%sOk\n", prefix.c_str());
}
falco_logger::log(LOG_INFO, "Ok\n");
goto exit;