Skip to content

Commit

Permalink
Merge pull request #2982 from simianhacker/fix/2977
Browse files Browse the repository at this point in the history
Closes #2977 - Removed POST body restriction from _search and _validate
  • Loading branch information
rashidkpc committed Feb 11, 2015
2 parents 7f60729 + 1917f15 commit 432eac0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/server/lib/validateRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ function validate(req) {

// methods that accept standard json bodies
var maybeMGet = ('_mget' === maybeMethod && add && jsonBody);
var maybeSearch = ('_search' === maybeMethod && add && jsonBody);
var maybeValidate = ('_validate' === maybeMethod && add && jsonBody);
var maybeSearch = ('_search' === maybeMethod && add);
var maybeValidate = ('_validate' === maybeMethod && add);

// methods that accept bulk bodies
var maybeBulk = ('_bulk' === maybeMethod && add && bulkBody);
Expand Down Expand Up @@ -82,10 +82,10 @@ function validate(req) {
if (maybeKibanaIndex) return;

// allow json bodies sent to _mget _search and _validate
if (jsonBody && (maybeMGet || maybeSearch || maybeValidate)) return;
if (maybeMGet || maybeSearch || maybeValidate) return;

// allow bulk bodies sent to _msearch
if (bulkBody && (maybeMsearch)) return;
if (maybeMsearch) return;

throw new validate.Fail();
}
Expand Down
2 changes: 2 additions & 0 deletions test/server/unit/lib/validateRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ describe('lib/isValid', function () {
run('HEAD', '/other-index', true);
run('GET', '/_cluster/health', true);
run('POST', '/.kibana/__notRealIndex__/_validate/query?q=foo:bar', true);
run('POST', '/_validate', true);
run('POST', '/_search', true);
});
});

Expand Down

0 comments on commit 432eac0

Please sign in to comment.