mirror of
https://github.com/openappsec/openappsec.git
synced 2025-06-28 16:41:02 +03:00
Declarative when connected to management improvements
This commit is contained in:
parent
8479ad58ed
commit
2fa866d1c5
@ -168,6 +168,10 @@ DeclarativePolicyUtils::getUpdate(CheckUpdateRequest &request)
|
|||||||
|
|
||||||
auto maybe_new_version = getLocalPolicyChecksum();
|
auto maybe_new_version = getLocalPolicyChecksum();
|
||||||
if (!maybe_new_version.ok() || maybe_new_version == curr_version) {
|
if (!maybe_new_version.ok() || maybe_new_version == curr_version) {
|
||||||
|
if (!policy_checksum.ok() || getPolicyChecksum() != policy_checksum.unpack()) {
|
||||||
|
dbgTrace(D_ORCHESTRATOR) << "Update policy checksum";
|
||||||
|
return getPolicyChecksum();
|
||||||
|
}
|
||||||
dbgDebug(D_ORCHESTRATOR) << "No new version is currently available";
|
dbgDebug(D_ORCHESTRATOR) << "No new version is currently available";
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -100,8 +100,11 @@ FogCommunication::downloadAttributeFile(const GetResourceFile &resourse_file, co
|
|||||||
|
|
||||||
string policy_mgmt_mode = getSettingWithDefault<string>("management", "profileManagedMode");
|
string policy_mgmt_mode = getSettingWithDefault<string>("management", "profileManagedMode");
|
||||||
if (policy_mgmt_mode == "declarative" && resourse_file.getFileName() =="policy") {
|
if (policy_mgmt_mode == "declarative" && resourse_file.getFileName() =="policy") {
|
||||||
dbgDebug(D_ORCHESTRATOR) << "Download policy on declarative mode - returnig the local policy";
|
dbgDebug(D_ORCHESTRATOR) << "Download policy on declarative mode - returning the local policy";
|
||||||
return i_declarative_policy->getCurrPolicy();
|
string policy = i_declarative_policy->getCurrPolicy();
|
||||||
|
auto orchestration_tools = Singleton::Consume<I_OrchestrationTools>::by<FogCommunication>();
|
||||||
|
if (orchestration_tools->writeFile(policy, file_path)) return policy;
|
||||||
|
return genError("Failed to write policy to file: " + file_path);
|
||||||
}
|
}
|
||||||
static const string file_attribute_str = "/api/v2/agents/resources/";
|
static const string file_attribute_str = "/api/v2/agents/resources/";
|
||||||
|
|
||||||
|
@ -1417,6 +1417,10 @@ TEST_F(FogCommunicationTest, downloadFileDeclarativeMode)
|
|||||||
mock_ot,
|
mock_ot,
|
||||||
writeFile(encrypted_access_token, data_path + session_token_file_name, false)).WillOnce(Return(true)
|
writeFile(encrypted_access_token, data_path + session_token_file_name, false)).WillOnce(Return(true)
|
||||||
);
|
);
|
||||||
|
EXPECT_CALL(
|
||||||
|
mock_ot,
|
||||||
|
writeFile(_, "/tmp/orch_files/", false)).WillOnce(Return(true)
|
||||||
|
);
|
||||||
EXPECT_CALL(mock_ml, yield(A<chrono::microseconds>())).WillOnce(
|
EXPECT_CALL(mock_ml, yield(A<chrono::microseconds>())).WillOnce(
|
||||||
Invoke(
|
Invoke(
|
||||||
[] (chrono::microseconds microseconds)
|
[] (chrono::microseconds microseconds)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user