mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Co-authored-by: Patryk Kopyciński <patryk.kopycinski@elastic.co>
This commit is contained in:
parent
081fd3267d
commit
a5fa683afc
5 changed files with 7 additions and 17 deletions
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import { uniq } from 'lodash';
|
||||
import type { KibanaRequest, SavedObjectsClientContract } from 'src/core/server';
|
||||
import type { SavedObjectsClientContract } from 'src/core/server';
|
||||
import { PACKAGE_POLICY_SAVED_OBJECT_TYPE } from '../../../fleet/common';
|
||||
import { OSQUERY_INTEGRATION_NAME } from '../../common';
|
||||
import { OsqueryAppContext } from './osquery_app_context_services';
|
||||
|
@ -34,7 +34,6 @@ const aggregateResults = async (
|
|||
};
|
||||
|
||||
export const parseAgentSelection = async (
|
||||
request: KibanaRequest,
|
||||
soClient: SavedObjectsClientContract,
|
||||
context: OsqueryAppContext,
|
||||
agentSelection: AgentSelection
|
||||
|
@ -42,7 +41,7 @@ export const parseAgentSelection = async (
|
|||
const selectedAgents: Set<string> = new Set();
|
||||
const addAgent = selectedAgents.add.bind(selectedAgents);
|
||||
const { allAgentsSelected, platformsSelected, policiesSelected, agents } = agentSelection;
|
||||
const agentService = context.service.getAgentService()?.asScoped(request);
|
||||
const agentService = context.service.getAgentService()?.asInternalUser;
|
||||
const packagePolicyService = context.service.getPackagePolicyService();
|
||||
const kueryFragments = [];
|
||||
|
||||
|
|
|
@ -45,12 +45,7 @@ export const createActionRoute = (router: IRouter, osqueryContext: OsqueryAppCon
|
|||
);
|
||||
|
||||
const { agentSelection } = request.body as { agentSelection: AgentSelection };
|
||||
const selectedAgents = await parseAgentSelection(
|
||||
request,
|
||||
soClient,
|
||||
osqueryContext,
|
||||
agentSelection
|
||||
);
|
||||
const selectedAgents = await parseAgentSelection(soClient, osqueryContext, agentSelection);
|
||||
incrementCount(internalSavedObjectsClient, 'live_query');
|
||||
if (!selectedAgents.length) {
|
||||
incrementCount(internalSavedObjectsClient, 'live_query', 'errors');
|
||||
|
|
|
@ -20,15 +20,13 @@ export const getAgentDetailsRoute = (router: IRouter, osqueryContext: OsqueryApp
|
|||
options: { tags: [`access:${PLUGIN_ID}-read`] },
|
||||
},
|
||||
async (context, request, response) => {
|
||||
const esClient = context.core.elasticsearch.client.asInternalUser;
|
||||
|
||||
let agent;
|
||||
|
||||
try {
|
||||
agent = await osqueryContext.service
|
||||
.getAgentService()
|
||||
// @ts-expect-error update types
|
||||
?.getAgent(esClient, request.params.id);
|
||||
?.asInternalUser // @ts-expect-error update types
|
||||
?.getAgent(request.params.id);
|
||||
} catch (err) {
|
||||
return response.notFound();
|
||||
}
|
||||
|
|
|
@ -49,8 +49,7 @@ export const getAgentPoliciesRoute = (router: IRouter, osqueryContext: OsqueryAp
|
|||
await bluebird.map(
|
||||
agentPolicies,
|
||||
(agentPolicy: GetAgentPoliciesResponseItem) =>
|
||||
agentService
|
||||
?.asScoped(request)
|
||||
agentService?.asInternalUser
|
||||
.getAgentStatusForAgentPolicy(agentPolicy.id)
|
||||
.then(({ total: agentTotal }) => (agentPolicy.agents = agentTotal)),
|
||||
{ concurrency: 10 }
|
||||
|
|
|
@ -24,8 +24,7 @@ export const getAgentsRoute = (router: IRouter, osqueryContext: OsqueryAppContex
|
|||
try {
|
||||
agents = await osqueryContext.service
|
||||
.getAgentService()
|
||||
?.asScoped(request)
|
||||
// @ts-expect-error update types
|
||||
?.asInternalUser // @ts-expect-error update types
|
||||
.listAgents(request.query);
|
||||
} catch (error) {
|
||||
return response.badRequest({ body: error });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue