[Security Solution][Hosts, Endpoint] Fix Host Details not showing endpoint related data for users without superuser role (#121090) (#121296)

* add new method to EndpointAppContextServices for getting a internal fleet services interface
* Change Host Details search Strategy to use internal fleet services
* un-skip host details FTR test

Co-authored-by: Paul Tavares <56442535+paul-tavares@users.noreply.github.com>
This commit is contained in:
Kibana Machine 2021-12-15 09:53:29 -05:00 committed by GitHub
parent 46b07f178b
commit d457f3ea9d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 4 deletions

View file

@ -36,6 +36,7 @@ import {
} from './errors';
import {
EndpointFleetServicesFactory,
EndpointInternalFleetServicesInterface,
EndpointScopedFleetServicesInterface,
} from './services/endpoint_fleet_services';
@ -143,6 +144,14 @@ export class EndpointAppContextService {
return this.fleetServicesFactory.asScoped(req);
}
public getInternalFleetServices(): EndpointInternalFleetServicesInterface {
if (this.fleetServicesFactory === null) {
throw new EndpointAppContentServicesNotStartedError();
}
return this.fleetServicesFactory.asInternalUser();
}
/** @deprecated use `getScopedFleetServices()` instead */
public getAgentService(): AgentService | undefined {
return this.startDependencies?.agentService;

View file

@ -188,11 +188,11 @@ export const getHostEndpoint = async (
return null;
}
const { esClient, endpointContext, request } = deps;
const { esClient, endpointContext } = deps;
const logger = endpointContext.logFactory.get('metadata');
try {
const fleetServices = endpointContext.service.getScopedFleetServices(request);
const fleetServices = endpointContext.service.getInternalFleetServices();
const endpointMetadataService = endpointContext.service.getEndpointMetadataService();
const endpointData = await endpointMetadataService

View file

@ -62,8 +62,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await testSubjects.existOrFail('noIngestPermissions');
});
// FIXME:PT skipped. need to fix security-team bug #1929
it.skip('should display endpoint data on Host Details', async () => {
it('should display endpoint data on Host Details', async () => {
const endpoint = indexedData.hosts[0];
await PageObjects.hosts.navigateToHostDetails(endpoint.host.name);
const endpointSummary = await PageObjects.hosts.hostDetailsEndpointOverviewData();