Skip to content

Commit

Permalink
Add a source to rule_update_info
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
mstemm committed Oct 16, 2024
1 parent e99b11e commit 2816428
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions userspace/engine/rule_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ struct rule_update_info {
context cond_ctx;
std::string name;
std::optional<std::string> cond;
std::string source;
std::optional<std::string> output;
std::optional<std::string> desc;
std::optional<std::set<std::string>> tags;
Expand Down
6 changes: 6 additions & 0 deletions userspace/engine/rule_loader_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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"],
Expand Down

0 comments on commit 2816428

Please sign in to comment.