API: Fix requested attrs/joins/meta type errors in object query response

fixes #5377

Signed-off-by: Michael Friedrich <michael.friedrich@icinga.com>
This commit is contained in:
Stefar77 2017-08-11 16:20:47 +02:00 committed by Michael Friedrich
parent 6a624c08c8
commit 6b66e332fb
1 changed files with 26 additions and 3 deletions

View File

@ -123,9 +123,32 @@ bool ObjectQueryHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& re
qd.Types.insert(type->GetName());
qd.Permission = "objects/query/" + type->GetName();
Array::Ptr uattrs = params->Get("attrs");
Array::Ptr ujoins = params->Get("joins");
Array::Ptr umetas = params->Get("meta");
Array::Ptr uattrs, ujoins, umetas;
try {
uattrs = params->Get("attrs");
} catch (const std::exception&) {
HttpUtility::SendJsonError(response, 400,
"Invalid type for 'attrs' attribute specified. Array type is required.", Empty);
return true;
}
try {
ujoins = params->Get("joins");
} catch (const std::exception&) {
HttpUtility::SendJsonError(response, 400,
"Invalid type for 'joins' attribute specified. Array type is required.", Empty);
return true;
}
try {
umetas = params->Get("meta");
} catch (const std::exception&) {
HttpUtility::SendJsonError(response, 400,
"Invalid type for 'meta' attribute specified. Array type is required.", Empty);
return true;
}
bool allJoins = HttpUtility::GetLastParameter(params, "all_joins");
params->Set("type", type->GetName());