mirror of
https://github.com/openappsec/openappsec.git
synced 2025-09-29 19:24:26 +03:00
Nov_12_2023-Dev
This commit is contained in:
@@ -22,6 +22,16 @@ DeclarativePolicyUtils::init()
|
||||
RestAction::SET, "apply-policy"
|
||||
);
|
||||
registerListener();
|
||||
char *automatic_load = getenv("autoPolicyLoad");
|
||||
if (automatic_load != nullptr && automatic_load == string("true")) {
|
||||
auto mainloop = Singleton::Consume<I_MainLoop>::by<DeclarativePolicyUtils>();
|
||||
mainloop->addRecurringRoutine(
|
||||
I_MainLoop::RoutineType::Offline,
|
||||
chrono::minutes(1),
|
||||
[&] () { periodicPolicyLoad(); },
|
||||
"Automatic Policy Loading"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// LCOV_EXCL_START Reason: no test exist
|
||||
@@ -170,3 +180,19 @@ DeclarativePolicyUtils::getUpdate(CheckUpdateRequest &request)
|
||||
curr_version = maybe_new_version.unpack();
|
||||
return policy_response;
|
||||
}
|
||||
|
||||
void
|
||||
DeclarativePolicyUtils::periodicPolicyLoad()
|
||||
{
|
||||
auto new_checksum = getLocalPolicyChecksum();
|
||||
|
||||
if (!new_checksum.ok()) {
|
||||
dbgWarning(D_ORCHESTRATOR) << "Failed to calculate checksum";
|
||||
return;
|
||||
}
|
||||
|
||||
if (*new_checksum == curr_checksum) return;
|
||||
|
||||
should_apply_policy = true;
|
||||
curr_checksum = *new_checksum;
|
||||
}
|
||||
|
Reference in New Issue
Block a user