chore(userspace,unit_tests): properly report all schema validation warnings from yaml_helper::validate_node().

`-V` option will print all warnings, while normal run will only print foremost warning.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
This commit is contained in:
Federico Di Pierro
2024-09-10 11:36:56 +02:00
committed by poiana
parent 2f89a2c140
commit 468037151a
6 changed files with 103 additions and 55 deletions

View File

@@ -788,11 +788,11 @@ bool rule_loader::reader::read(rule_loader::configuration& cfg, collector& colle
{
std::vector<YAML::Node> docs;
yaml_helper reader;
std::string schema_validation;
std::vector<std::string> schema_warnings;
rule_loader::context ctx(cfg.name);
try
{
docs = reader.loadall_from_string(cfg.content, schema, &schema_validation);
docs = reader.loadall_from_string(cfg.content, schema, &schema_warnings);
}
catch (YAML::ParserException& e)
{
@@ -810,7 +810,7 @@ bool rule_loader::reader::read(rule_loader::configuration& cfg, collector& colle
cfg.res->add_error(falco::load_result::LOAD_ERR_YAML_PARSE, "unknown YAML parsing error", ctx);
return false;
}
cfg.res->set_schema_validation_status(schema_validation);
cfg.res->set_schema_validation_status(schema_warnings);
for (auto doc = docs.begin(); doc != docs.end(); doc++)
{
if (doc->IsDefined() && !doc->IsNull())