]> granicus.if.org Git - icinga2/commitdiff
Don't allow acknowledgement expire timestamps in the past 5259/head
authorMichael Friedrich <michael.friedrich@icinga.com>
Mon, 15 May 2017 08:14:19 +0000 (10:14 +0200)
committerMichael Friedrich <michael.friedrich@icinga.com>
Mon, 15 May 2017 08:23:21 +0000 (10:23 +0200)
fixes #5250

lib/icinga/apiactions.cpp
lib/icinga/externalcommandprocessor.cpp

index dacd8fc71afd870d2a869bbc81cdbd33dbaf276e..d488cd5996c6fed826e94da219a62faa8d51a959 100644 (file)
@@ -203,9 +203,12 @@ Dictionary::Ptr ApiActions::AcknowledgeProblem(const ConfigObject::Ptr& object,
                notify = HttpUtility::GetLastParameter(params, "notify");
        if (params->Contains("persistent"))
                persistent = HttpUtility::GetLastParameter(params, "persistent");
-       if (params->Contains("expiry"))
+       if (params->Contains("expiry")) {
                timestamp = HttpUtility::GetLastParameter(params, "expiry");
-       else
+
+               if (timestamp <= Utility::GetTime())
+                       return ApiActions::CreateResult(409, "Acknowledgement 'expiry' timestamp must be in the future for object " + checkable->GetName());
+       } else
                timestamp = 0;
 
        Host::Ptr host;
index a7d97ad0179634c9aa577c4a89ccf7ba2f5b474d..04977924fca44213fb997627890f203ab1e61dac 100644 (file)
@@ -653,6 +653,9 @@ void ExternalCommandProcessor::AcknowledgeSvcProblemExpire(double, const std::ve
        if (service->GetState() == ServiceOK)
                BOOST_THROW_EXCEPTION(std::invalid_argument("The service '" + arguments[1] + "' is OK."));
 
+       if (timestamp != 0 && timestamp <= Utility::GetTime())
+               BOOST_THROW_EXCEPTION(std::invalid_argument("Acknowledgement expire time must be in the future for service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
+
        Log(LogNotice, "ExternalCommandProcessor")
            << "Setting timed acknowledgement for service '" << service->GetName() << "'" << (notify ? "" : ". Disabled notification");
 
@@ -717,6 +720,9 @@ void ExternalCommandProcessor::AcknowledgeHostProblemExpire(double, const std::v
        if (host->GetState() == HostUp)
                BOOST_THROW_EXCEPTION(std::invalid_argument("The host '" + arguments[0] + "' is OK."));
 
+       if (timestamp != 0 && timestamp <= Utility::GetTime())
+               BOOST_THROW_EXCEPTION(std::invalid_argument("Acknowledgement expire time must be in the future for host '" + arguments[0] + "'"));
+
        Comment::AddComment(host, CommentAcknowledgement, arguments[5], arguments[6], persistent, timestamp);
        host->AcknowledgeProblem(arguments[5], arguments[6], sticky ? AcknowledgementSticky : AcknowledgementNormal, notify, persistent, timestamp);
 }