diff --git a/x-pack/plugins/osquery/server/routes/asset/update_assets_route.ts b/x-pack/plugins/osquery/server/routes/asset/update_assets_route.ts index 57800729d643..690ea4206b84 100644 --- a/x-pack/plugins/osquery/server/routes/asset/update_assets_route.ts +++ b/x-pack/plugins/osquery/server/routes/asset/update_assets_route.ts @@ -42,9 +42,10 @@ export const updateAssetsRoute = (router: IRouter, osqueryContext: OsqueryAppCon }, }, }, - async (context, request, response) => { - const savedObjectsClient = (await context.core).savedObjects.client; - const currentUser = await osqueryContext.security.authc.getCurrentUser(request)?.username; + async (context, _request, response) => { + const coreContext = await context.core; + const savedObjectsClient = coreContext.savedObjects.client; + const currentUser = coreContext.security.authc.getCurrentUser()?.username; let installation; diff --git a/x-pack/plugins/osquery/server/routes/live_query/create_live_query_route.ts b/x-pack/plugins/osquery/server/routes/live_query/create_live_query_route.ts index c93b58cf5af7..6372a48c89b6 100644 --- a/x-pack/plugins/osquery/server/routes/live_query/create_live_query_route.ts +++ b/x-pack/plugins/osquery/server/routes/live_query/create_live_query_route.ts @@ -42,7 +42,8 @@ export const createLiveQueryRoute = (router: IRouter, osqueryContext: OsqueryApp }, async (context, request, response) => { const [coreStartServices] = await osqueryContext.getStartServices(); - const soClient = (await context.core).savedObjects.client; + const coreContext = await context.core; + const soClient = coreContext.savedObjects.client; const { osquery: { writeLiveQueries, runSavedQueries }, @@ -106,7 +107,7 @@ export const createLiveQueryRoute = (router: IRouter, osqueryContext: OsqueryApp } try { - const currentUser = await osqueryContext.security.authc.getCurrentUser(request)?.username; + const currentUser = coreContext.security.authc.getCurrentUser()?.username; const { response: osqueryAction, fleetActionsCount } = await createActionHandler( osqueryContext, request.body, diff --git a/x-pack/plugins/osquery/server/routes/pack/create_pack_route.ts b/x-pack/plugins/osquery/server/routes/pack/create_pack_route.ts index d69182762c8e..31f9395d2174 100644 --- a/x-pack/plugins/osquery/server/routes/pack/create_pack_route.ts +++ b/x-pack/plugins/osquery/server/routes/pack/create_pack_route.ts @@ -64,7 +64,7 @@ export const createPackRoute = (router: IRouter, osqueryContext: OsqueryAppConte const agentPolicyService = osqueryContext.service.getAgentPolicyService(); const packagePolicyService = osqueryContext.service.getPackagePolicyService(); - const currentUser = await osqueryContext.security.authc.getCurrentUser(request)?.username; + const currentUser = coreContext.security.authc.getCurrentUser()?.username; // eslint-disable-next-line @typescript-eslint/naming-convention const { name, description, queries, enabled, policy_ids, shards = {} } = request.body; diff --git a/x-pack/plugins/osquery/server/routes/pack/update_pack_route.ts b/x-pack/plugins/osquery/server/routes/pack/update_pack_route.ts index 5715806a19b5..0109270f539d 100644 --- a/x-pack/plugins/osquery/server/routes/pack/update_pack_route.ts +++ b/x-pack/plugins/osquery/server/routes/pack/update_pack_route.ts @@ -71,7 +71,7 @@ export const updatePackRoute = (router: IRouter, osqueryContext: OsqueryAppConte ); const agentPolicyService = osqueryContext.service.getAgentPolicyService(); const packagePolicyService = osqueryContext.service.getPackagePolicyService(); - const currentUser = await osqueryContext.security.authc.getCurrentUser(request)?.username; + const currentUser = coreContext.security.authc.getCurrentUser()?.username; // eslint-disable-next-line @typescript-eslint/naming-convention const { name, description, queries, enabled, policy_ids, shards = {} } = request.body; diff --git a/x-pack/plugins/osquery/server/routes/saved_query/create_saved_query_route.ts b/x-pack/plugins/osquery/server/routes/saved_query/create_saved_query_route.ts index d59f1c5ba0f8..1be4cb24a2ea 100644 --- a/x-pack/plugins/osquery/server/routes/saved_query/create_saved_query_route.ts +++ b/x-pack/plugins/osquery/server/routes/saved_query/create_saved_query_route.ts @@ -55,7 +55,7 @@ export const createSavedQueryRoute = (router: IRouter, osqueryContext: OsqueryAp ecs_mapping, } = request.body; - const currentUser = await osqueryContext.security.authc.getCurrentUser(request)?.username; + const currentUser = coreContext.security.authc.getCurrentUser()?.username; const conflictingEntries = await savedObjectsClient.find({ type: savedQuerySavedObjectType, diff --git a/x-pack/plugins/osquery/server/routes/saved_query/update_saved_query_route.ts b/x-pack/plugins/osquery/server/routes/saved_query/update_saved_query_route.ts index f6bcad9d4bed..4225f0f223cd 100644 --- a/x-pack/plugins/osquery/server/routes/saved_query/update_saved_query_route.ts +++ b/x-pack/plugins/osquery/server/routes/saved_query/update_saved_query_route.ts @@ -51,7 +51,7 @@ export const updateSavedQueryRoute = (router: IRouter, osqueryContext: OsqueryAp async (context, request, response) => { const coreContext = await context.core; const savedObjectsClient = coreContext.savedObjects.client; - const currentUser = await osqueryContext.security.authc.getCurrentUser(request)?.username; + const currentUser = coreContext.security.authc.getCurrentUser()?.username; const { id,