Skip to content

Commit

Permalink
only use current user
Browse files Browse the repository at this point in the history
  • Loading branch information
XavierM committed Jan 3, 2024
1 parent c4821c5 commit 6db785b
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export const querySignalsRoute = (
},
},
async (context, request, response) => {
const esClient = (await context.core).elasticsearch.client.asCurrentUser;

// eslint-disable-next-line @typescript-eslint/naming-convention
const { query, aggs, _source, fields, track_total_hits, size, runtime_mappings, sort } =
request.body;
Expand All @@ -58,10 +60,11 @@ export const querySignalsRoute = (
body: '"value" must have at least 1 children',
});
}

try {
const spaceId = (await context.securitySolution).getSpaceId();
const result = await ruleDataClient?.getReader({ namespace: spaceId }).search({
const indexPattern = ruleDataClient?.indexNameWithNamespace(spaceId);
const result = await esClient.search({
index: indexPattern,
body: {
query,
// Note: I use a spread operator to please TypeScript with aggs: { ...aggs }
Expand Down

0 comments on commit 6db785b

Please sign in to comment.