From 2816428064b6fa921141ee2c9a4821bbaba09029 Mon Sep 17 00:00:00 2001 From: Mark Stemm Date: Wed, 16 Oct 2024 13:44:56 -0700 Subject: [PATCH] Add a source to rule_update_info It's possible that someone might want to override a property for a non-syscall rule source. To assist in this, decode any source property for rules with append/override and save it in the rule_update_info object. A later change will ensure that the sources match up when appending/redefining/overriding/enabling. Signed-off-by: Mark Stemm --- userspace/engine/rule_loader.h | 1 + userspace/engine/rule_loader_reader.cpp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/userspace/engine/rule_loader.h b/userspace/engine/rule_loader.h index 4a270e4932f..622066e9253 100644 --- a/userspace/engine/rule_loader.h +++ b/userspace/engine/rule_loader.h @@ -488,6 +488,7 @@ struct rule_update_info { context cond_ctx; std::string name; std::optional cond; + std::string source; std::optional output; std::optional desc; std::optional> tags; diff --git a/userspace/engine/rule_loader_reader.cpp b/userspace/engine/rule_loader_reader.cpp index 146eed35400..378ef2039a0 100644 --- a/userspace/engine/rule_loader_reader.cpp +++ b/userspace/engine/rule_loader_reader.cpp @@ -591,6 +591,9 @@ void rule_loader::reader::read_item(rule_loader::configuration& cfg, rule_loader::context ctx(item, rule_loader::context::RULE, name, parent); + std::string source = ""; + decode_optional_val(item, "source", source, ctx); + bool has_append_flag = false; decode_optional_val(item, "append", has_append_flag, ctx); if(has_append_flag) { @@ -648,6 +651,7 @@ void rule_loader::reader::read_item(rule_loader::configuration& cfg, "append", "condition", ctx)) { + v.source = source; decode_val(item, "condition", v.cond, ctx); } @@ -682,6 +686,7 @@ void rule_loader::reader::read_item(rule_loader::configuration& cfg, "replace", "condition", ctx)) { + v.source = source; decode_val(item, "condition", v.cond, ctx); } @@ -765,6 +770,7 @@ void rule_loader::reader::read_item(rule_loader::configuration& cfg, } else if(has_append_flag) { rule_loader::rule_update_info v(ctx); v.name = name; + v.source = source; if(item["condition"].IsDefined()) { v.cond_ctx = rule_loader::context(item["condition"],