Skip to content

Commit

Permalink
[Defend workflows] Stop spreading whole request to ES dsl (elastic#16…
Browse files Browse the repository at this point in the history
  • Loading branch information
tomsonpl committed Jul 19, 2023
1 parent c472fb0 commit 9c7dda0
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions x-pack/plugins/osquery/server/search_strategy/osquery/index.ts
Expand Up @@ -39,7 +39,20 @@ export const osquerySearchStrategyProvider = <T extends FactoryQueryTypes>(
})
).pipe(
mergeMap((exists) => {
const dsl = queryFactory.buildDsl({ ...request, componentTemplateExists: exists });
const strictRequest = {
factoryQueryType: request.factoryQueryType,
filterQuery: request.filterQuery,
...('aggregations' in request ? { aggregations: request.aggregations } : {}),
...('pagination' in request ? { pagination: request.pagination } : {}),
...('sort' in request ? { sort: request.sort } : {}),
...('actionId' in request ? { actionId: request.actionId } : {}),
...('agentId' in request ? { agentId: request.agentId } : {}),
};

const dsl = queryFactory.buildDsl({
...strictRequest,
componentTemplateExists: exists,
} as StrategyRequestType<T>);
// use internal user for searching .fleet* indices
es =
dsl.index?.includes('fleet') || dsl.index?.includes('logs-osquery_manager.action')
Expand All @@ -48,7 +61,7 @@ export const osquerySearchStrategyProvider = <T extends FactoryQueryTypes>(

return es.search(
{
...request,
...strictRequest,
params: dsl,
},
options,
Expand Down

0 comments on commit 9c7dda0

Please sign in to comment.