refactor(userspace/engine): const correctness

Signed-off-by: Samuel Gaist <samuel.gaist@idiap.ch>
This commit is contained in:
Samuel Gaist
2025-07-16 18:04:25 +02:00
committed by poiana
parent 01d2976b0a
commit 2da40e798b
5 changed files with 13 additions and 13 deletions

View File

@@ -56,7 +56,7 @@ bool evttype_index_ruleset::run_wrappers(sinsp_evt *evt,
filter_wrapper_list &wrappers,
uint16_t ruleset_id,
falco_rule &match) {
for(auto &wrap : wrappers) {
for(const auto &wrap : wrappers) {
if(wrap->m_filter->run(evt)) {
match = wrap->m_rule;
return true;
@@ -72,7 +72,7 @@ bool evttype_index_ruleset::run_wrappers(sinsp_evt *evt,
std::vector<falco_rule> &matches) {
bool match_found = false;
for(auto &wrap : wrappers) {
for(const auto &wrap : wrappers) {
if(wrap->m_filter->run(evt)) {
matches.push_back(wrap->m_rule);
match_found = true;

View File

@@ -329,7 +329,7 @@ const std::string& rule_loader::result::as_summary_string() {
os << " " << schema_validation_status.size() << " schema warnings: [";
bool first = true;
for(auto& status : schema_validation_status) {
for(const auto& status : schema_validation_status) {
if(!first) {
os << " ";
}
@@ -409,7 +409,7 @@ const std::string& rule_loader::result::as_verbose_string(const rules_contents_t
os << schema_validation_status.size() << " Schema warnings:" << std::endl;
for(auto& status : schema_validation_status) {
for(const auto& status : schema_validation_status) {
os << "------" << std::endl;
os << status << std::endl;
}

View File

@@ -271,7 +271,7 @@ static std::shared_ptr<ast::expr> parse_condition(std::string condition,
}
}
void rule_loader::compiler::compile_list_infos(configuration& cfg,
void rule_loader::compiler::compile_list_infos(const configuration& cfg,
const collector& col,
indexed_vector<falco_list>& out) const {
std::list<std::string> used_names;
@@ -300,7 +300,7 @@ void rule_loader::compiler::compile_list_infos(configuration& cfg,
}
// note: there is a visibility ordering between macros
void rule_loader::compiler::compile_macros_infos(configuration& cfg,
void rule_loader::compiler::compile_macros_infos(const configuration& cfg,
const collector& col,
indexed_vector<falco_list>& lists,
indexed_vector<falco_macro>& out) const {
@@ -332,7 +332,7 @@ static bool err_is_unknown_type_or_field(const std::string& err) {
err.find("unknown event type") != std::string::npos;
}
bool rule_loader::compiler::compile_condition(configuration& cfg,
bool rule_loader::compiler::compile_condition(const configuration& cfg,
filter_macro_resolver& macro_resolver,
indexed_vector<falco_list>& lists,
const indexed_vector<rule_loader::macro_info>& macros,
@@ -389,7 +389,7 @@ bool rule_loader::compiler::compile_condition(configuration& cfg,
return true;
}
void rule_loader::compiler::compile_rule_infos(configuration& cfg,
void rule_loader::compiler::compile_rule_infos(const configuration& cfg,
const collector& col,
indexed_vector<falco_list>& lists,
indexed_vector<falco_macro>& macros,

View File

@@ -56,7 +56,7 @@ protected:
ast_out/filter_out with the compiled filter + ast. Returns false if
the condition could not be compiled and should be skipped.
*/
bool compile_condition(configuration& cfg,
bool compile_condition(const configuration& cfg,
filter_macro_resolver& macro_resolver,
indexed_vector<falco_list>& lists,
const indexed_vector<rule_loader::macro_info>& macros,
@@ -70,16 +70,16 @@ protected:
std::shared_ptr<sinsp_filter>& filter_out) const;
private:
void compile_list_infos(configuration& cfg,
void compile_list_infos(const configuration& cfg,
const collector& col,
indexed_vector<falco_list>& out) const;
void compile_macros_infos(configuration& cfg,
void compile_macros_infos(const configuration& cfg,
const collector& col,
indexed_vector<falco_list>& lists,
indexed_vector<falco_macro>& out) const;
void compile_rule_infos(configuration& cfg,
void compile_rule_infos(const configuration& cfg,
const collector& col,
indexed_vector<falco_list>& lists,
indexed_vector<falco_macro>& macros,

View File

@@ -356,7 +356,7 @@ static void read_rule_exceptions(rule_loader::configuration& cfg,
v_ex.name = name;
// Check if an exception with the same name has already been defined
for(auto& exception : exceptions) {
for(const auto& exception : exceptions) {
if(v_ex.name == exception.name) {
cfg.res->add_warning(
falco::load_result::LOAD_EXCEPTION_NAME_NOT_UNIQUE,