Skip to content

Commit

Permalink
[Security Solution] [Cases] Bugfix for special character tags filteri…
Browse files Browse the repository at this point in the history
…ng (elastic#74849) (elastic#74872)

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
stephmilovic and elasticmachine committed Aug 13, 2020
1 parent 973c9e8 commit f98cf0e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,32 @@ describe('Case Configuration API', () => {
query: {
...DEFAULT_QUERY_PARAMS,
reporters,
tags,
tags: ['"coke"', '"pepsi"'],
search: 'hello',
},
signal: abortCtrl.signal,
});
});
test('tags with weird chars get handled gracefully', async () => {
const weirdTags: string[] = ['(', '"double"'];

await getCases({
filterOptions: {
...DEFAULT_FILTER_OPTIONS,
reporters: [...respReporters, { username: null, full_name: null, email: null }],
tags: weirdTags,
status: '',
search: 'hello',
},
queryParams: DEFAULT_QUERY_PARAMS,
signal: abortCtrl.signal,
});
expect(fetchMock).toHaveBeenCalledWith(`${CASES_URL}/_find`, {
method: 'GET',
query: {
...DEFAULT_QUERY_PARAMS,
reporters,
tags: ['"("', '"\\"double\\""'],
search: 'hello',
},
signal: abortCtrl.signal,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export const getCases = async ({
}: FetchCasesProps): Promise<AllCases> => {
const query = {
reporters: filterOptions.reporters.map((r) => r.username ?? '').filter((r) => r !== ''),
tags: filterOptions.tags,
tags: filterOptions.tags.map((t) => `"${t.replace(/"/g, '\\"')}"`),
...(filterOptions.status !== '' ? { status: filterOptions.status } : {}),
...(filterOptions.search.length > 0 ? { search: filterOptions.search } : {}),
...queryParams,
Expand Down

0 comments on commit f98cf0e

Please sign in to comment.