]> granicus.if.org Git - icinga2/commitdiff
Ensure that user input for groups is unique on API object creation 6294/head
authorMichael Friedrich <michael.friedrich@icinga.com>
Wed, 9 May 2018 15:18:22 +0000 (17:18 +0200)
committerMichael Friedrich <michael.friedrich@icinga.com>
Wed, 9 May 2018 15:26:10 +0000 (17:26 +0200)
refs #4732

lib/remote/createobjecthandler.cpp

index e3646b3f3df46b1342f70aacf9a317a2a3200064..a365ed6646dfc2309632e6324f942b1f3f34ee0d 100644 (file)
@@ -71,6 +71,14 @@ bool CreateObjectHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& r
                }
        }
 
+       /* Sanity checks for unique groups array. */
+       if (attrs->Contains("groups")) {
+               Array::Ptr groups = attrs->Get("groups");
+
+               if (groups)
+                       attrs->Set("groups", groups->Unique());
+       }
+
        Dictionary::Ptr result1 = new Dictionary();
        String status;
        Array::Ptr errors = new Array();