mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Security Solution] Adding tests for dns pipeline in the endpoint package (#79177)
* Adding tests for dns pipeline in the endpoint package * Adding test to make sure non dns events are ingested correctly * Bring the docker container with the new endpoint package Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
e067604d78
commit
cc633a4a91
4 changed files with 79 additions and 2 deletions
|
@ -718,7 +718,10 @@ export type SafeEndpointEvent = Partial<{
|
|||
forwarded_ip: ECSField<string>;
|
||||
}>;
|
||||
dns: Partial<{
|
||||
question: Partial<{ name: ECSField<string> }>;
|
||||
question: Partial<{
|
||||
name: ECSField<string>;
|
||||
type: ECSField<string>;
|
||||
}>;
|
||||
}>;
|
||||
process: Partial<{
|
||||
entity_id: ECSField<string>;
|
||||
|
|
Binary file not shown.
|
@ -12,7 +12,7 @@ import { defineDockerServersConfig } from '@kbn/test';
|
|||
// Docker image to use for Ingest Manager API integration tests.
|
||||
// This hash comes from the commit hash here: https://github.com/elastic/package-storage/commit
|
||||
export const dockerImage =
|
||||
'docker.elastic.co/package-registry/distribution:a5132271ad37209d6978018bfe6e224546d719a8';
|
||||
'docker.elastic.co/package-registry/distribution:fb58d670bafbac7e9e28baf6d6f99ba65cead548';
|
||||
|
||||
export default async function ({ readConfigFile }: FtrConfigProviderContext) {
|
||||
const xPackAPITestsConfig = await readConfigFile(require.resolve('../api_integration/config.ts'));
|
||||
|
|
|
@ -5,6 +5,10 @@
|
|||
*/
|
||||
import expect from '@kbn/expect';
|
||||
import { SearchResponse } from 'elasticsearch';
|
||||
import {
|
||||
ResolverPaginatedEvents,
|
||||
SafeEndpointEvent,
|
||||
} from '../../../plugins/security_solution/common/endpoint/types';
|
||||
import { eventsIndexPattern } from '../../../plugins/security_solution/common/endpoint/constants';
|
||||
import {
|
||||
EndpointDocGenerator,
|
||||
|
@ -12,6 +16,7 @@ import {
|
|||
} from '../../../plugins/security_solution/common/endpoint/generate_data';
|
||||
import { FtrProviderContext } from '../ftr_provider_context';
|
||||
import { InsertedEvents, processEventsIndex } from '../services/resolver';
|
||||
import { deleteEventsStream } from './data_stream_helper';
|
||||
|
||||
interface EventIngested {
|
||||
event: {
|
||||
|
@ -35,6 +40,8 @@ interface NetworkEvent {
|
|||
const networkIndex = 'logs-endpoint.events.network-default';
|
||||
|
||||
export default function ({ getService }: FtrProviderContext) {
|
||||
const esArchiver = getService('esArchiver');
|
||||
const supertest = getService('supertest');
|
||||
const resolver = getService('resolverGenerator');
|
||||
const es = getService('es');
|
||||
const generator = new EndpointDocGenerator('data');
|
||||
|
@ -59,6 +66,72 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
};
|
||||
|
||||
describe('Endpoint package', () => {
|
||||
describe('network processors', () => {
|
||||
let networkIndexData: InsertedEvents;
|
||||
|
||||
after(async () => {
|
||||
await resolver.deleteData(networkIndexData);
|
||||
});
|
||||
|
||||
it('handles events without the `network.protocol` field being defined', async () => {
|
||||
const eventWithoutNetworkObject = generator.generateEvent();
|
||||
// ensure that `network.protocol` does not exist in the event to test that the pipeline handles those type of events
|
||||
delete eventWithoutNetworkObject.network;
|
||||
|
||||
// this call will fail if the pipeline fails
|
||||
networkIndexData = await resolver.insertEvents([eventWithoutNetworkObject], networkIndex);
|
||||
const eventWithBothIPs = await searchForID<SafeEndpointEvent>(
|
||||
networkIndexData.eventsInfo[0]._id
|
||||
);
|
||||
|
||||
// ensure that the event was inserted into ES
|
||||
expect(eventWithBothIPs.body.hits.hits[0]._source.event?.id).to.be(
|
||||
eventWithoutNetworkObject.event?.id
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('dns processor', () => {
|
||||
before(async () => {
|
||||
await esArchiver.load('endpoint/pipeline/dns', { useCreate: true });
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await deleteEventsStream(getService);
|
||||
});
|
||||
|
||||
it('does not set dns.question.type if it is already populated', async () => {
|
||||
// this id comes from the es archive file endpoint/pipeline/dns
|
||||
const id = 'LrLSOVHVsFY94TAi++++++eF';
|
||||
const { body }: { body: ResolverPaginatedEvents } = await supertest
|
||||
.post(`/api/endpoint/resolver/events?limit=1`)
|
||||
.set('kbn-xsrf', 'xxx')
|
||||
.send({
|
||||
filter: `event.id:"${id}"`,
|
||||
})
|
||||
.expect(200);
|
||||
expect(body.events.length).to.eql(1);
|
||||
expect((body.events[0] as SafeEndpointEvent).dns?.question?.name).to.eql('www.google.com');
|
||||
expect((body.events[0] as SafeEndpointEvent).dns?.question?.type).to.eql('INVALID_VALUE');
|
||||
});
|
||||
|
||||
it('sets dns.question.type if it is not populated', async () => {
|
||||
// this id comes from the es archive file endpoint/pipeline/dns
|
||||
const id = 'LrLSOVHVsFY94TAi++++++eP';
|
||||
const { body }: { body: ResolverPaginatedEvents } = await supertest
|
||||
.post(`/api/endpoint/resolver/events?limit=1`)
|
||||
.set('kbn-xsrf', 'xxx')
|
||||
.send({
|
||||
filter: `event.id:"${id}"`,
|
||||
})
|
||||
.expect(200);
|
||||
expect(body.events.length).to.eql(1);
|
||||
expect((body.events[0] as SafeEndpointEvent).dns?.question?.name).to.eql('www.aol.com');
|
||||
// This value is parsed out of the message field in the event. type 28 = AAAA
|
||||
expect((body.events[0] as SafeEndpointEvent).dns?.question?.type).to.eql('AAAA');
|
||||
});
|
||||
});
|
||||
|
||||
describe('ingested processor', () => {
|
||||
let event: Event;
|
||||
let genData: InsertedEvents;
|
||||
|
@ -92,6 +165,7 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
const eventWithSourceOnly = generator.generateEvent({
|
||||
extensions: { source: { ip: '8.8.8.8' } },
|
||||
});
|
||||
|
||||
networkIndexData = await resolver.insertEvents(
|
||||
[eventWithBothIPs, eventWithSourceOnly],
|
||||
networkIndex
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue