mirror of
https://github.com/falcosecurity/falco.git
synced 2025-09-09 10:39:28 +00:00
update(userspace/engine): let the rule loader reader and collector be able to load rules with both numeric and semver string required_engine_version
Signed-off-by: Lorenzo Susini <susinilorenzo1@gmail.com>
This commit is contained in:
@@ -19,6 +19,7 @@ limitations under the License.
|
||||
#include <vector>
|
||||
|
||||
#include "rule_loader_reader.h"
|
||||
#include "falco_engine_version.h"
|
||||
|
||||
#define THROW(cond, err, ctx) { if ((cond)) { throw rule_loader::rule_load_exception(falco::load_result::LOAD_ERR_YAML_VALIDATE, (err), (ctx)); } }
|
||||
|
||||
@@ -255,8 +256,22 @@ static void read_item(
|
||||
{
|
||||
rule_loader::context ctx(item, rule_loader::context::REQUIRED_ENGINE_VERSION, "", parent);
|
||||
rule_loader::engine_version_info v(ctx);
|
||||
|
||||
try
|
||||
{
|
||||
// Convert convert to an uint (more restrictive than converting to a string)
|
||||
uint32_t ver;
|
||||
decode_val(item, "required_engine_version", ver, ctx);
|
||||
|
||||
// Build proper semver representation
|
||||
v.version = std::to_string(FALCO_DEFAULT_ENGINE_MAJOR) + "." + std::to_string(ver) + "." + std::to_string(FALCO_DEFAULT_ENGINE_PATCH);
|
||||
}
|
||||
catch(std::exception& e)
|
||||
{
|
||||
// Convert to string
|
||||
decode_val(item, "required_engine_version", v.version, ctx);
|
||||
}
|
||||
|
||||
decode_val(item, "required_engine_version", v.version, ctx);
|
||||
collector.define(cfg, v);
|
||||
}
|
||||
else if(item["required_plugin_versions"].IsDefined())
|
||||
|
Reference in New Issue
Block a user