[Rules] Auto Update Rule Notes from Source (#4891)

* [Rules] Auto Update Rule Notes from Source

* Update rulesys.cpp
This commit is contained in:
Chris Miles 2025-05-16 13:38:59 -05:00 committed by GitHub
parent 276b7e238a
commit fb49ce2404
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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;