From fb49ce240461dfa05dc948f72b6ad591c535ea4c Mon Sep 17 00:00:00 2001 From: Chris Miles Date: Fri, 16 May 2025 13:38:59 -0500 Subject: [PATCH] [Rules] Auto Update Rule Notes from Source (#4891) * [Rules] Auto Update Rule Notes from Source * Update rulesys.cpp --- common/rulesys.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/common/rulesys.cpp b/common/rulesys.cpp index f84b65d32..f73112b1b 100644 --- a/common/rulesys.cpp +++ b/common/rulesys.cpp @@ -502,6 +502,19 @@ bool RuleManager::UpdateInjectedRules(Database *db, const std::string &rule_set_ } } + // update rules in the database where the description is different + for (auto &e : RuleValuesRepository::All(*db)) { + auto i = rule_data.find(e.rule_name); + if (i != rule_data.end()) { + // if notes are different, update them + if (i->second.second != nullptr && *i->second.second != e.notes) { + LogInfo("Updating rule [{}] notes to [{}]", i->first, *i->second.second); + e.notes = *i->second.second; + RuleValuesRepository::ReplaceOne(*db, e); + } + } + } + if (injected_rule_entries.size()) { if (!RuleValuesRepository::InjectRules(*db, injected_rule_entries)) { return false;