Skip to content

Commit

Permalink
[Endpoint]EMT-395: add policy configuration and reenable tests (elast…
Browse files Browse the repository at this point in the history
…ic#67967) (elastic#68011)

[Endpoint]EMT-395: add policy configuration and tests
  • Loading branch information
nnamdifrankie authored Jun 3, 2020
1 parent 2de596f commit 3b3647a
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 26 deletions.
4 changes: 0 additions & 4 deletions x-pack/plugins/siem/common/endpoint/generate_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -845,10 +845,6 @@ export class EndpointDocGenerator {
},
],
id: this.commonInfo.endpoint.policy.id,
policy: {
id: this.commonInfo.endpoint.policy.id,
version: policyVersion,
},
response: {
configurations: {
events: {
Expand Down
4 changes: 0 additions & 4 deletions x-pack/plugins/siem/common/endpoint/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -685,10 +685,6 @@ export interface HostPolicyResponse {
id: string;
status: HostPolicyResponseActionStatus;
actions: HostPolicyResponseAppliedAction[];
policy: {
id: string;
version: string;
};
response: {
configurations: {
malware: HostPolicyResponseConfigurationStatus;
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/siem/scripts/endpoint/resolver_generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ async function main() {
metadataIndex: {
alias: 'mi',
describe: 'index to store host metadata in',
default: 'metrics-endpoint-default-1',
default: 'metrics-endpoint.metadata-default-1',
type: 'string',
},
policyIndex: {
Expand Down
5 changes: 3 additions & 2 deletions x-pack/plugins/siem/server/endpoint/alerts/index_pattern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface IndexPatternRetriever {
export class IngestIndexPatternRetriever implements IndexPatternRetriever {
private static endpointPackageName = 'endpoint';
private static metadataDataset = 'metadata';
private static policyDataset = 'policy';
private readonly log: Logger;
constructor(private readonly service: ESIndexPatternService, loggerFactory: LoggerFactory) {
this.log = loggerFactory.get('index-pattern-retriever');
Expand Down Expand Up @@ -76,7 +77,7 @@ export class IngestIndexPatternRetriever implements IndexPatternRetriever {
}
}

getPolicyResponseIndexPattern(ctx: RequestHandlerContext): Promise<string> {
return Promise.resolve('metrics-endpoint.policy-default-1');
async getPolicyResponseIndexPattern(ctx: RequestHandlerContext): Promise<string> {
return this.getIndexPattern(ctx, IngestIndexPatternRetriever.policyDataset);
}
}
2 changes: 1 addition & 1 deletion x-pack/test/api_integration/apis/endpoint/alerts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default function ({ getService }: FtrProviderContext) {

let nullableEventId = '';

describe.skip('Endpoint alert API', () => {
describe('Endpoint alert API', () => {
describe('when data is in elasticsearch', () => {
before(async () => {
await esArchiver.load('endpoint/alerts/api_feature');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,20 @@ import { FtrProviderContext } from '../../../ftr_provider_context';
export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');

describe.skip('Endpoint index pattern API', () => {
describe('Endpoint index pattern API', () => {
it('should retrieve the index pattern for events', async () => {
const { body } = await supertest.get('/api/endpoint/index_pattern/events').expect(200);
expect(body.indexPattern).to.eql('events-endpoint-*');
});

it('should retrieve the index pattern for metadata', async () => {
const { body } = await supertest.get('/api/endpoint/index_pattern/metadata').expect(200);
expect(body.indexPattern).to.eql('metrics-endpoint-*');
expect(body.indexPattern).to.eql('metrics-endpoint.metadata-*');
});

it('should retrieve the index pattern for policy', async () => {
const { body } = await supertest.get('/api/endpoint/index_pattern/policy').expect(200);
expect(body.indexPattern).to.eql('metrics-endpoint.policy-*');
});

it('should not retrieve the index pattern for an invalid key', async () => {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/api_integration/apis/endpoint/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const numberOfHostsInFixture = 3;
export default function ({ getService }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const supertest = getService('supertest');
describe.skip('test metadata api', () => {
describe('test metadata api', () => {
describe('POST /api/endpoint/metadata when index is empty', () => {
it('metadata api should return empty result when index is empty', async () => {
await esArchiver.unload('endpoint/metadata/api_feature');
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"type": "index",
"value": {
"aliases": {},
"index": "metrics-endpoint-default-1",
"index": "metrics-endpoint.metadata-default-1",
"mappings": {
"_meta": {
"version": "1.5.0-dev"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"type": "doc",
"value": {
"id": "3KVN2G8BYQH1gtPUuYk7",
"index": "metrics-endpoint-default-1",
"index": "metrics-endpoint.metadata-default-1",
"source": {
"@timestamp": 1579881969541,
"agent": {
Expand Down Expand Up @@ -51,7 +51,7 @@
"type": "doc",
"value": {
"id": "3aVN2G8BYQH1gtPUuYk7",
"index": "metrics-endpoint-default-1",
"index": "metrics-endpoint.metadata-default-1",
"source": {
"@timestamp": 1579881969541,
"agent": {
Expand Down Expand Up @@ -99,7 +99,7 @@
"type": "doc",
"value": {
"id": "3qVN2G8BYQH1gtPUuYk7",
"index": "metrics-endpoint-default-1",
"index": "metrics-endpoint.metadata-default-1",
"source": {
"@timestamp": 1579881969541,
"agent": {
Expand Down Expand Up @@ -145,7 +145,7 @@
"type": "doc",
"value": {
"id": "36VN2G8BYQH1gtPUuYk7",
"index": "metrics-endpoint-default-1",
"index": "metrics-endpoint.metadata-default-1",
"source": {
"@timestamp": 1579878369541,
"agent": {
Expand Down Expand Up @@ -194,7 +194,7 @@
"type": "doc",
"value": {
"id": "4KVN2G8BYQH1gtPUuYk7",
"index": "metrics-endpoint-default-1",
"index": "metrics-endpoint.metadata-default-1",
"source": {
"@timestamp": 1579878369541,
"agent": {
Expand Down Expand Up @@ -241,7 +241,7 @@
"type": "doc",
"value": {
"id": "4aVN2G8BYQH1gtPUuYk7",
"index": "metrics-endpoint-default-1",
"index": "metrics-endpoint.metadata-default-1",
"source": {
"@timestamp": 1579878369541,
"agent": {
Expand Down Expand Up @@ -288,7 +288,7 @@
"type": "doc",
"value": {
"id": "4qVN2G8BYQH1gtPUuYk7",
"index": "metrics-endpoint-default-1",
"index": "metrics-endpoint.metadata-default-1",
"source": {
"@timestamp": 1579874769541,
"agent": {
Expand Down Expand Up @@ -336,7 +336,7 @@
"type": "doc",
"value": {
"id": "46VN2G8BYQH1gtPUuYk7",
"index": "metrics-endpoint-default-1",
"index": "metrics-endpoint.metadata-default-1",
"source": {
"@timestamp": 1579874769541,
"agent": {
Expand Down Expand Up @@ -383,7 +383,7 @@
"type": "doc",
"value": {
"id": "5KVN2G8BYQH1gtPUuYk7",
"index": "metrics-endpoint-default-1",
"index": "metrics-endpoint.metadata-default-1",
"source": {
"@timestamp": 1579874769541,
"agent": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"type": "index",
"value": {
"aliases": {},
"index": "metrics-endpoint-default-1",
"index": "metrics-endpoint.metadata-default-1",
"mappings": {
"_meta": {
"version": "1.5.0-dev"
Expand Down

0 comments on commit 3b3647a

Please sign in to comment.