Merge pull request #8450 from Icinga/bugfix/do-not-accept-api-updates-for-unknown-zone

API: Don't accept object updates for unknown global zone
This commit is contained in:
Alexander Aleksandrovič Klimov 2020-11-24 10:40:20 +01:00 committed by GitHub
commit e84a4a290d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 0 deletions

View File

@ -72,6 +72,16 @@ Value ApiListener::ConfigUpdateObjectAPIHandler(const MessageOrigin::Ptr& origin
return Empty;
}
String objZone = params->Get("zone");
if (!Zone::GetByName(objZone)) {
Log(LogNotice, "ApiListener")
<< "Discarding 'config update object' message"
<< " from '" << identity << "' (endpoint: '" << endpoint->GetName() << "', zone: '" << endpointZone->GetName() << "')"
<< " for object '" << objName << "' of type '" << objType << "'. Objects zone '" << objZone << "' isn't known locally.";
return Empty;
}
/* ignore messages if the endpoint does not accept config */
if (!listener->GetAcceptConfig()) {
Log(LogWarning, "ApiListener")
@ -315,6 +325,7 @@ void ApiListener::UpdateConfigObject(const ConfigObject::Ptr& object, const Mess
params->Set("name", object->GetName());
params->Set("type", object->GetReflectionType()->GetName());
params->Set("version", object->GetVersion());
params->Set("zone", object->GetZoneName());
if (object->GetPackage() == "_api") {
String file;