{
Endpoint::Ptr endpoint = origin.FromClient->GetEndpoint();
- if (!endpoint)
+ if (!endpoint) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'check result' message from '" << origin.FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
return Empty;
+ }
if (!params)
return Empty;
if (!checkable)
return Empty;
- if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable) && endpoint != checkable->GetCommandEndpoint())
+ if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable) && endpoint != checkable->GetCommandEndpoint()) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'check result' message from '" << origin.FromClient->GetIdentity() << "': Unauthorized access.";
return Empty;
+ }
if (endpoint == checkable->GetCommandEndpoint())
checkable->ProcessCheckResult(cr);
Value ApiEvents::NextCheckChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params)
{
- if (!origin.FromClient->GetEndpoint())
+ Endpoint::Ptr endpoint = origin.FromClient->GetEndpoint();
+
+ if (!endpoint) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'next check changed' message from '" << origin.FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
return Empty;
+ }
if (!params)
return Empty;
if (!checkable)
return Empty;
- if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable))
+ if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable)) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'next check changed' message from '" << origin.FromClient->GetIdentity() << "': Unauthorized access.";
return Empty;
+ }
checkable->SetNextCheck(params->Get("next_check"), origin);
Value ApiEvents::NextNotificationChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params)
{
- if (!origin.FromClient->GetEndpoint())
+ Endpoint::Ptr endpoint = origin.FromClient->GetEndpoint();
+
+ if (!endpoint) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'next notification changed' message from '" << origin.FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
return Empty;
+ }
if (!params)
return Empty;
if (!notification)
return Empty;
- if (origin.FromZone && !origin.FromZone->CanAccessObject(notification))
+ if (origin.FromZone && !origin.FromZone->CanAccessObject(notification)) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'next notification changed' message from '" << origin.FromClient->GetIdentity() << "': Unauthorized access.";
return Empty;
+ }
notification->SetNextNotification(params->Get("next_notification"), origin);
Value ApiEvents::ForceNextCheckChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params)
{
- if (!origin.FromClient->GetEndpoint())
+ Endpoint::Ptr endpoint = origin.FromClient->GetEndpoint();
+
+ if (!endpoint) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'force next check changed' message from '" << origin.FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
return Empty;
+ }
if (!params)
return Empty;
if (!checkable)
return Empty;
- if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable))
+ if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable)) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'force next check' message from '" << origin.FromClient->GetIdentity() << "': Unauthorized access.";
return Empty;
+ }
checkable->SetForceNextCheck(params->Get("forced"), origin);
Value ApiEvents::ForceNextNotificationChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params)
{
- if (!origin.FromClient->GetEndpoint())
+ Endpoint::Ptr endpoint = origin.FromClient->GetEndpoint();
+
+ if (!endpoint) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'force next notification changed' message from '" << origin.FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
return Empty;
+ }
if (!params)
return Empty;
if (!checkable)
return Empty;
- if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable))
+ if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable)) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'force next notification' message from '" << origin.FromClient->GetIdentity() << "': Unauthorized access.";
return Empty;
+ }
checkable->SetForceNextNotification(params->Get("forced"), origin);
Value ApiEvents::EnableActiveChecksChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params)
{
- if (!origin.FromClient->GetEndpoint())
+ Endpoint::Ptr endpoint = origin.FromClient->GetEndpoint();
+
+ if (!endpoint) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'enable active checks changed' message from '" << origin.FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
return Empty;
+ }
if (!params)
return Empty;
if (!checkable)
return Empty;
- if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable))
+ if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable)) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'enable active checks' changed message from '" << origin.FromClient->GetIdentity() << "': Unauthorized access.";
return Empty;
+ }
checkable->SetEnableActiveChecks(params->Get("enabled"), origin);
Value ApiEvents::EnablePassiveChecksChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params)
{
- if (!origin.FromClient->GetEndpoint())
+ Endpoint::Ptr endpoint = origin.FromClient->GetEndpoint();
+
+ if (!endpoint) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'enable passive checks changed' message from '" << origin.FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
return Empty;
+ }
if (!params)
return Empty;
if (!checkable)
return Empty;
- if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable))
+ if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable)) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'enable passive checks changed' message from '" << origin.FromClient->GetIdentity() << "': Unauthorized access.";
return Empty;
+ }
checkable->SetEnablePassiveChecks(params->Get("enabled"), origin);
Value ApiEvents::EnableNotificationsChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params)
{
- if (!origin.FromClient->GetEndpoint())
+ Endpoint::Ptr endpoint = origin.FromClient->GetEndpoint();
+
+ if (!endpoint) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'enable notifications changed' message from '" << origin.FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
return Empty;
+ }
if (!params)
return Empty;
if (!checkable)
return Empty;
- if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable))
+ if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable)) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'enable notifications changed' message from '" << origin.FromClient->GetIdentity() << "': Unauthorized access.";
return Empty;
+ }
checkable->SetEnableNotifications(params->Get("enabled"), origin);
Value ApiEvents::EnableFlappingChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params)
{
- if (!origin.FromClient->GetEndpoint())
+ Endpoint::Ptr endpoint = origin.FromClient->GetEndpoint();
+
+ if (!endpoint) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'enable flapping changed' message from '" << origin.FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
return Empty;
+ }
if (!params)
return Empty;
if (!checkable)
return Empty;
- if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable))
+ if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable)) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'enable flapping changed' message from '" << origin.FromClient->GetIdentity() << "': Unauthorized access.";
return Empty;
+ }
checkable->SetEnableFlapping(params->Get("enabled"), origin);
Value ApiEvents::EnableEventHandlerChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params)
{
- if (!origin.FromClient->GetEndpoint())
+ Endpoint::Ptr endpoint = origin.FromClient->GetEndpoint();
+
+ if (!endpoint) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'enable event handler changed' message from '" << origin.FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
return Empty;
+ }
if (!params)
return Empty;
if (!checkable)
return Empty;
- if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable))
+ if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable)) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'enable event handler' message from '" << origin.FromClient->GetIdentity() << "': Unauthorized access.";
return Empty;
+ }
checkable->SetEnableEventHandler(params->Get("enabled"), origin);
Value ApiEvents::EnablePerfdataChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params)
{
- if (!origin.FromClient->GetEndpoint())
+ Endpoint::Ptr endpoint = origin.FromClient->GetEndpoint();
+
+ if (!endpoint) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'enable perfdata changed' message from '" << origin.FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
return Empty;
+ }
if (!params)
return Empty;
if (!checkable)
return Empty;
- if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable))
+ if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable)) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'enable perfdata changed' message from '" << origin.FromClient->GetIdentity() << "': Unauthorized access.";
return Empty;
+ }
checkable->SetEnablePerfdata(params->Get("enabled"), origin);
Value ApiEvents::CheckIntervalChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params)
{
- if (!origin.FromClient->GetEndpoint())
+ Endpoint::Ptr endpoint = origin.FromClient->GetEndpoint();
+
+ if (!endpoint) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'check interval changed' message from '" << origin.FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
return Empty;
+ }
if (!params)
return Empty;
if (!checkable)
return Empty;
- if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable))
+ if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable)) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'check interval' changed message from '" << origin.FromClient->GetIdentity() << "': Unauthorized access.";
return Empty;
+ }
checkable->SetCheckInterval(params->Get("interval"), origin);
Value ApiEvents::RetryIntervalChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params)
{
- if (!origin.FromClient->GetEndpoint())
+ Endpoint::Ptr endpoint = origin.FromClient->GetEndpoint();
+
+ if (!endpoint) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'retry interval changed' message from '" << origin.FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
return Empty;
+ }
if (!params)
return Empty;
if (!checkable)
return Empty;
- if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable))
+ if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable)) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'retry interval' changed message from '" << origin.FromClient->GetIdentity() << "': Unauthorized access.";
return Empty;
+ }
checkable->SetRetryInterval(params->Get("interval"), origin);
Value ApiEvents::MaxCheckAttemptsChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params)
{
- if (!origin.FromClient->GetEndpoint())
+ Endpoint::Ptr endpoint = origin.FromClient->GetEndpoint();
+
+ if (!endpoint) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'max checkt attempts changed' message from '" << origin.FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
return Empty;
+ }
if (!params)
return Empty;
if (!checkable)
return Empty;
- if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable))
+ if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable)) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'max check attempts changed' message from '" << origin.FromClient->GetIdentity() << "': Unauthorized access.";
return Empty;
+ }
checkable->SetMaxCheckAttempts(params->Get("attempts"), origin);
Value ApiEvents::EventCommandChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params)
{
- if (!origin.FromClient->GetEndpoint())
+ Endpoint::Ptr endpoint = origin.FromClient->GetEndpoint();
+
+ if (!endpoint) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'event command changed' message from '" << origin.FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
return Empty;
+ }
if (!params)
return Empty;
if (!command)
return Empty;
- if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable))
+ if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable)) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'event command changed' message from '" << origin.FromClient->GetIdentity() << "': Unauthorized access.";
return Empty;
+ }
checkable->SetEventCommand(command, origin);
Value ApiEvents::CheckCommandChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params)
{
- if (!origin.FromClient->GetEndpoint())
+ Endpoint::Ptr endpoint = origin.FromClient->GetEndpoint();
+
+ if (!endpoint) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'check command changed' message from '" << origin.FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
return Empty;
+ }
if (!params)
return Empty;
if (!checkable)
return Empty;
- if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable))
+ if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable)) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'check command changed' message from '" << origin.FromClient->GetIdentity() << "': Unauthorized access.";
return Empty;
+ }
CheckCommand::Ptr command = CheckCommand::GetByName(params->Get("command"));
Value ApiEvents::CheckPeriodChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params)
{
- if (!origin.FromClient->GetEndpoint())
+ Endpoint::Ptr endpoint = origin.FromClient->GetEndpoint();
+
+ if (!endpoint) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'check period changed' message from '" << origin.FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
return Empty;
+ }
if (!params)
return Empty;
if (!checkable)
return Empty;
- if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable))
+ if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable)) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'check period changed' message from '" << origin.FromClient->GetIdentity() << "': Unauthorized access.";
return Empty;
+ }
TimePeriod::Ptr timeperiod = TimePeriod::GetByName(params->Get("timeperiod"));
Value ApiEvents::VarsChangedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params)
{
- if (!origin.FromClient->GetEndpoint())
+ Endpoint::Ptr endpoint = origin.FromClient->GetEndpoint();
+
+ if (!endpoint) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'vars changed' message from '" << origin.FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
return Empty;
+ }
if (!params)
return Empty;
if (!object)
return Empty;
- if (origin.FromZone && !origin.FromZone->CanAccessObject(object))
+ if (origin.FromZone && !origin.FromZone->CanAccessObject(object)) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'vars changed' message from '" << origin.FromClient->GetIdentity() << "': Unauthorized access.";
return Empty;
+ }
Dictionary::Ptr vars = params->Get("vars");
Value ApiEvents::CommentAddedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params)
{
- if (!origin.FromClient->GetEndpoint())
+ Endpoint::Ptr endpoint = origin.FromClient->GetEndpoint();
+
+ if (!endpoint) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'comment added' message from '" << origin.FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
return Empty;
+ }
if (!params)
return Empty;
if (!checkable)
return Empty;
- if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable))
+ if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable)) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'comment added' message from '" << origin.FromClient->GetIdentity() << "': Unauthorized access.";
return Empty;
+ }
Comment::Ptr comment = new Comment();
Deserialize(comment, params->Get("comment"), true);
Value ApiEvents::CommentRemovedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params)
{
- if (!origin.FromClient->GetEndpoint())
+ Endpoint::Ptr endpoint = origin.FromClient->GetEndpoint();
+
+ if (!endpoint) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'comment removed' message from '" << origin.FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
return Empty;
+ }
if (!params)
return Empty;
if (!checkable)
return Empty;
- if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable))
+ if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable)) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'comment removed' message from '" << origin.FromClient->GetIdentity() << "': Unauthorized access.";
return Empty;
+ }
checkable->RemoveComment(params->Get("id"), origin);
Value ApiEvents::DowntimeAddedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params)
{
- if (!origin.FromClient->GetEndpoint())
+ Endpoint::Ptr endpoint = origin.FromClient->GetEndpoint();
+
+ if (!endpoint) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'downtime added' message from '" << origin.FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
return Empty;
+ }
if (!params)
return Empty;
if (!checkable)
return Empty;
- if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable))
+ if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable)) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'downtime added' message from '" << origin.FromClient->GetIdentity() << "': Unauthorized access.";
return Empty;
+ }
Downtime::Ptr downtime = new Downtime();
Deserialize(downtime, params->Get("downtime"), true);
Value ApiEvents::DowntimeRemovedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params)
{
- if (!origin.FromClient->GetEndpoint())
+ Endpoint::Ptr endpoint = origin.FromClient->GetEndpoint();
+
+ if (!endpoint) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'downtime removed' message from '" << origin.FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
return Empty;
+ }
if (!params)
return Empty;
if (!checkable)
return Empty;
- if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable))
+ if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable)) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'downtime removed' message from '" << origin.FromClient->GetIdentity() << "': Unauthorized access.";
return Empty;
+ }
checkable->RemoveDowntime(params->Get("id"), false, origin);
Value ApiEvents::AcknowledgementSetAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params)
{
- if (!origin.FromClient->GetEndpoint())
+ Endpoint::Ptr endpoint = origin.FromClient->GetEndpoint();
+
+ if (!endpoint) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'acknowledgement set' message from '" << origin.FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
return Empty;
+ }
if (!params)
return Empty;
if (!checkable)
return Empty;
- if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable))
+ if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable)) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'acknowledgement set' message from '" << origin.FromClient->GetIdentity() << "': Unauthorized access.";
return Empty;
+ }
checkable->AcknowledgeProblem(params->Get("author"), params->Get("comment"),
static_cast<AcknowledgementType>(static_cast<int>(params->Get("acktype"))),
Value ApiEvents::AcknowledgementClearedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params)
{
- if (!origin.FromClient->GetEndpoint())
+ Endpoint::Ptr endpoint = origin.FromClient->GetEndpoint();
+
+ if (!endpoint) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'acknowledgement cleared' message from '" << origin.FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
return Empty;
+ }
if (!params)
return Empty;
if (!checkable)
return Empty;
- if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable))
+ if (origin.FromZone && !origin.FromZone->CanAccessObject(checkable)) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'acknowledgement cleared' message from '" << origin.FromClient->GetIdentity() << "': Unauthorized access.";
return Empty;
+ }
checkable->ClearAcknowledgement(origin);
{
Endpoint::Ptr sourceEndpoint = origin.FromClient->GetEndpoint();
- if (!sourceEndpoint || (origin.FromZone && !Zone::GetLocalZone()->IsChildOf(origin.FromZone)))
+ if (!sourceEndpoint || (origin.FromZone && !Zone::GetLocalZone()->IsChildOf(origin.FromZone))) {
+ Log(LogNotice, "ApiEvents")
+ << "Discarding 'execute command' message from '" << origin.FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
return Empty;
+ }
ApiListener::Ptr listener = ApiListener::GetInstance();