Skip to content

Commit fb2b9a4

Browse files
authored
[Security Solution] [Cases] Bugfix for special character tags filtering (#74849)
1 parent be7e21c commit fb2b9a4

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

x-pack/plugins/security_solution/public/cases/containers/api.test.tsx

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,32 @@ describe('Case Configuration API', () => {
159159
query: {
160160
...DEFAULT_QUERY_PARAMS,
161161
reporters,
162-
tags,
162+
tags: ['"coke"', '"pepsi"'],
163+
search: 'hello',
164+
},
165+
signal: abortCtrl.signal,
166+
});
167+
});
168+
test('tags with weird chars get handled gracefully', async () => {
169+
const weirdTags: string[] = ['(', '"double"'];
170+
171+
await getCases({
172+
filterOptions: {
173+
...DEFAULT_FILTER_OPTIONS,
174+
reporters: [...respReporters, { username: null, full_name: null, email: null }],
175+
tags: weirdTags,
176+
status: '',
177+
search: 'hello',
178+
},
179+
queryParams: DEFAULT_QUERY_PARAMS,
180+
signal: abortCtrl.signal,
181+
});
182+
expect(fetchMock).toHaveBeenCalledWith(`${CASES_URL}/_find`, {
183+
method: 'GET',
184+
query: {
185+
...DEFAULT_QUERY_PARAMS,
186+
reporters,
187+
tags: ['"("', '"\\"double\\""'],
163188
search: 'hello',
164189
},
165190
signal: abortCtrl.signal,

x-pack/plugins/security_solution/public/cases/containers/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export const getCases = async ({
132132
}: FetchCasesProps): Promise<AllCases> => {
133133
const query = {
134134
reporters: filterOptions.reporters.map((r) => r.username ?? '').filter((r) => r !== ''),
135-
tags: filterOptions.tags,
135+
tags: filterOptions.tags.map((t) => `"${t.replace(/"/g, '\\"')}"`),
136136
...(filterOptions.status !== '' ? { status: filterOptions.status } : {}),
137137
...(filterOptions.search.length > 0 ? { search: filterOptions.search } : {}),
138138
...queryParams,

0 commit comments

Comments
 (0)