mirror of
https://github.com/openappsec/openappsec.git
synced 2025-09-29 19:24:26 +03:00
Aug_23_2023-Dev
This commit is contained in:
@@ -177,6 +177,16 @@ FogAuthenticator::registerAgent(
|
||||
request << details;
|
||||
}
|
||||
|
||||
auto i_agent_details = Singleton::Consume<I_AgentDetails>::by<FogAuthenticator>();
|
||||
if (
|
||||
i_agent_details->getOrchestrationMode() == OrchestrationMode::HYBRID ||
|
||||
getSettingWithDefault<string>("management", "profileManagedMode") == "declarative"
|
||||
) {
|
||||
request << make_pair("managedMode", "declarative");
|
||||
} else {
|
||||
request << make_pair("managedMode", "management");
|
||||
}
|
||||
|
||||
if (details_resolver->isReverseProxy()) {
|
||||
request << make_pair("reverse_proxy", "true");
|
||||
}
|
||||
@@ -202,7 +212,6 @@ FogAuthenticator::registerAgent(
|
||||
auto fog_messaging = Singleton::Consume<I_Messaging>::by<FogAuthenticator>();
|
||||
if (fog_messaging->sendObject(request, HTTPMethod::POST, fog_address_ex + "/agents")) {
|
||||
dbgDebug(D_ORCHESTRATOR) << "Agent has registered successfully.";
|
||||
auto i_agent_details = Singleton::Consume<I_AgentDetails>::by<FogAuthenticator>();
|
||||
i_agent_details->setAgentId(request.getAgentId());
|
||||
i_agent_details->setProfileId(request.getProfileId());
|
||||
i_agent_details->setTenantId(request.getTenantId());
|
||||
@@ -252,7 +261,7 @@ FogAuthenticator::getAccessToken(const UserCredentials &user_credentials) const
|
||||
}
|
||||
|
||||
dbgInfo(D_ORCHESTRATOR) << "New access token was saved";
|
||||
fog_messaging->loadAccessToken();
|
||||
Singleton::Consume<I_AgentDetails>::by<FogAuthenticator>()->loadAccessToken();
|
||||
|
||||
return AccessToken(request.getAccessToken(), chrono::seconds(request.getExpirationTime()));
|
||||
}
|
||||
|
@@ -117,13 +117,20 @@ FogCommunication::downloadAttributeFile(const GetResourceFile &resourse_file)
|
||||
}
|
||||
|
||||
Maybe<void>
|
||||
FogCommunication::sendPolicyVersion(const string &policy_version) const
|
||||
FogCommunication::sendPolicyVersion(const string &policy_version, const string &policy_versions) const
|
||||
{
|
||||
PolicyVersionPatchRequest request(policy_version);
|
||||
PolicyVersionPatchRequest request(policy_version, policy_versions);
|
||||
auto fog_messaging = Singleton::Consume<I_Messaging>::by<FogCommunication>();
|
||||
dbgTrace(D_ORCHESTRATOR)
|
||||
<< "Sending patch request to the fog. Policy version: "
|
||||
<< policy_version
|
||||
<< " , Policy versions: "
|
||||
<< policy_versions;
|
||||
if (fog_messaging->sendNoReplyObject(request, HTTPMethod::PATCH, fog_address_ex + "/agents")) {
|
||||
dbgInfo(D_ORCHESTRATOR)
|
||||
dbgTrace(D_ORCHESTRATOR)
|
||||
<< "Patch request was sent successfully to the fog."
|
||||
<< " Policy versions: "
|
||||
<< policy_versions
|
||||
<< " Policy version: "
|
||||
<< policy_version;
|
||||
return Maybe<void>();
|
||||
|
@@ -157,7 +157,7 @@ HybridCommunication::downloadAttributeFile(const GetResourceFile &resourse_file)
|
||||
}
|
||||
|
||||
Maybe<void>
|
||||
HybridCommunication::sendPolicyVersion(const string &policy_version) const
|
||||
HybridCommunication::sendPolicyVersion(const string &policy_version, const string &) const
|
||||
{
|
||||
dbgFlow(D_ORCHESTRATOR);
|
||||
policy_version.empty();
|
||||
|
@@ -175,7 +175,7 @@ LocalCommunication::setAddressExtenesion(const string &)
|
||||
}
|
||||
|
||||
Maybe<void>
|
||||
LocalCommunication::sendPolicyVersion(const string &) const
|
||||
LocalCommunication::sendPolicyVersion(const string &, const string &) const
|
||||
{
|
||||
dbgTrace(D_ORCHESTRATOR) << "Agent in offline mode, no need to send policy version";
|
||||
return Maybe<void>();
|
||||
|
@@ -75,9 +75,9 @@ public:
|
||||
}
|
||||
|
||||
Maybe<void>
|
||||
sendPolicyVersion(const string &policy_version) const override
|
||||
sendPolicyVersion(const string &policy_version, const string &policy_versions) const override
|
||||
{
|
||||
return i_update_comm_impl->sendPolicyVersion(policy_version);
|
||||
return i_update_comm_impl->sendPolicyVersion(policy_version, policy_versions);
|
||||
}
|
||||
|
||||
Maybe<string>
|
||||
|
@@ -39,9 +39,9 @@ public:
|
||||
}
|
||||
|
||||
Maybe<void>
|
||||
sendPolicyVersion(const string &version)
|
||||
sendPolicyVersion(const string &version, const string &policy_versions)
|
||||
{
|
||||
return local_communication.sendPolicyVersion(version);
|
||||
return local_communication.sendPolicyVersion(version, policy_versions);
|
||||
}
|
||||
|
||||
Maybe<string>
|
||||
@@ -228,6 +228,6 @@ TEST_F(LocalCommunicationTest, setAddressExtenesion)
|
||||
|
||||
TEST_F(LocalCommunicationTest, sendPolicyVersion)
|
||||
{
|
||||
auto res = sendPolicyVersion("12");
|
||||
auto res = sendPolicyVersion("12", "");
|
||||
EXPECT_TRUE(res.ok());
|
||||
}
|
||||
|
Reference in New Issue
Block a user