diff --git a/src/maat_compile.c b/src/maat_compile.c index 4c656ff..e8ae258 100644 --- a/src/maat_compile.c +++ b/src/maat_compile.c @@ -828,6 +828,11 @@ void maat_compile_hash_set(struct maat_compile **compile_hash, long long compile int maat_compile_hash_remove(struct maat_compile **compile_hash, struct maat_compile *compile, struct maat_garbage_bin *garbage_bin) { + if (compile->user_data_free && compile->user_data) { + compile->user_data_free(compile->user_data); + compile->user_data = NULL; + } + if (0 == compile->actual_clause_num) { HASH_DEL(*compile_hash, compile); maat_garbage_bagging(garbage_bin, compile, (void (*)(void *))maat_compile_free); diff --git a/src/maat_rule.c b/src/maat_rule.c index 49a66f1..25f52a7 100644 --- a/src/maat_rule.c +++ b/src/maat_rule.c @@ -487,10 +487,9 @@ void *rule_monitor_loop(void *arg) if (time_window >= maat_instance->rule_effect_interval_ms / 1000) { maat_runtime_commit(maat_instance->maat_rt, maat_instance->logger); log_info(maat_instance->logger, MODULE_MAAT_RULE, - "Actual update config version %u, %d entries load to rulescan after postpone.", + "Actual update config version %u, %d entries load to maat runtime.", maat_instance->maat_rt->version, maat_instance->maat_rt->rule_num); } - } pthread_mutex_unlock(&(maat_instance->background_update_mutex)); diff --git a/test/maat_framework_gtest.cpp b/test/maat_framework_gtest.cpp index 6375525..2c0a7e6 100644 --- a/test/maat_framework_gtest.cpp +++ b/test/maat_framework_gtest.cpp @@ -970,6 +970,45 @@ TEST_F(CompileTable, CompileEXData) { maat_state_free(&state); } +TEST_F(CompileTable, CompileRuleUpdate) { + //9999 0 0 0 0 0 anything 1 1 0.0 + const char *compile_table_name = "COMPILE"; + const char *table_line_add = "9999\t0\t0\t0\t0\t0\tanything\t1\t1\t0.0"; + struct maat_cmd_line line_rule; + + memset(&line_rule, 0, sizeof(line_rule)); + line_rule.rule_id = 9999; + line_rule.table_line = table_line_add; + line_rule.table_name = compile_table_name; + int ret = maat_cmd_set_line(g_maat_instance, &line_rule); + EXPECT_EQ(ret, 1); + + sleep(1); + const char *table_line_del = "9999\t0\t0\t0\t0\t0\tanything\t0\t1\t0.0"; + memset(&line_rule, 0, sizeof(line_rule)); + line_rule.rule_id = 9999; + line_rule.table_line = table_line_del; + line_rule.table_name = compile_table_name; + ret = maat_cmd_set_line(g_maat_instance, &line_rule); + EXPECT_EQ(ret, 1); + + sleep(1); + memset(&line_rule, 0, sizeof(line_rule)); + line_rule.rule_id = 9999; + line_rule.table_line = table_line_add; + line_rule.table_name = compile_table_name; + ret = maat_cmd_set_line(g_maat_instance, &line_rule); + EXPECT_EQ(ret, 1); + + sleep(1); + memset(&line_rule, 0, sizeof(line_rule)); + line_rule.rule_id = 9999; + line_rule.table_line = table_line_del; + line_rule.table_name = compile_table_name; + ret = maat_cmd_set_line(g_maat_instance, &line_rule); + EXPECT_EQ(ret, 1); +} + class MaatCmdTest : public testing::Test { protected: