Merge pull request #104 from openappsec/Feb_13_2024

Feb 13 2024
This commit is contained in:
WrightNed 2024-02-18 13:52:06 +02:00 committed by GitHub
commit 4e6ed5734a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 13 additions and 6 deletions

View File

@ -168,6 +168,10 @@ DeclarativePolicyUtils::getUpdate(CheckUpdateRequest &request)
auto maybe_new_version = getLocalPolicyChecksum();
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";
return "";
}

View File

@ -100,8 +100,11 @@ FogCommunication::downloadAttributeFile(const GetResourceFile &resourse_file, co
string policy_mgmt_mode = getSettingWithDefault<string>("management", "profileManagedMode");
if (policy_mgmt_mode == "declarative" && resourse_file.getFileName() =="policy") {
dbgDebug(D_ORCHESTRATOR) << "Download policy on declarative mode - returnig the local policy";
return i_declarative_policy->getCurrPolicy();
dbgDebug(D_ORCHESTRATOR) << "Download policy on declarative mode - returning the local policy";
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/";

View File

@ -1417,6 +1417,10 @@ TEST_F(FogCommunicationTest, downloadFileDeclarativeMode)
mock_ot,
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(
Invoke(
[] (chrono::microseconds microseconds)

View File

@ -83,8 +83,6 @@ gen_help(
"--certs-dir <trusted ca directory>" "Path to the hosts trusted ca directory"
)
set_package_params("--platform x86")
gen_package(
install-cp-nano-service-http-transaction-handler.sh
http_transaction_handler_service

View File

@ -166,8 +166,6 @@ gen_help(
"-ia" "Ignore access control package"
)
set_package_params("--platform x86")
gen_package(
install-cp-nano-agent.sh
orchestration