Skip to content

Commit c43f3e7

Browse files
authored
Merge branch '8.19' into backport/8.19/pr-250106
2 parents 46af49b + 8043e70 commit c43f3e7

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

x-pack/platform/plugins/shared/global_search/server/routes/find.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const registerInternalFindRoute = (router: GlobalSearchRouter) => {
2929
}),
3030
options: schema.maybe(
3131
schema.object({
32-
preference: schema.maybe(schema.string()),
32+
preference: schema.maybe(schema.string({ maxLength: 64 })),
3333
})
3434
),
3535
}),

x-pack/platform/plugins/shared/global_search/server/routes/integration_tests/find.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,35 @@ describe('POST /internal/global_search/find', () => {
122122
);
123123
});
124124

125+
it('allows requests with max length options.preference string', async () => {
126+
const longPreference = 'a'.repeat(64); // maxLength is 64
127+
128+
const response = await supertest(httpSetup.server.listener)
129+
.post('/internal/global_search/find')
130+
.send({ params: { term: 'search' }, options: { preference: longPreference } })
131+
.expect(200);
132+
133+
expect(response.body).toEqual({});
134+
});
135+
136+
it('disallows requests with large options.preference string', async () => {
137+
const longPreference = 'a'.repeat(65); // maxLength is 64
138+
139+
const response = await supertest(httpSetup.server.listener)
140+
.post('/internal/global_search/find')
141+
.send({ params: { term: 'search' }, options: { preference: longPreference } })
142+
.expect(400);
143+
144+
expect(response.body).toEqual(
145+
expect.objectContaining({
146+
error: 'Bad Request',
147+
message:
148+
'[request body.options.preference]: value has length [65] but it must have a maximum length of [64].',
149+
statusCode: 400,
150+
})
151+
);
152+
});
153+
125154
it('returns the default error when the observable throws any other error', async () => {
126155
globalSearchHandlerContext.find.mockReturnValue(throwError('any-error'));
127156

0 commit comments

Comments
 (0)