Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SIEM][Detections] Adds large list support using REST endpoints #62552

Merged
merged 82 commits into from
Apr 28, 2020
Merged
Show file tree
Hide file tree
Changes from 56 commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
7ceb7fa
POC Large Lists Support
FrankHassanabad Mar 25, 2020
9324132
added more wip code
FrankHassanabad Mar 25, 2020
c949a1c
Moved from saved objects to data indexes
FrankHassanabad Mar 31, 2020
af269b6
Merge branch 'master' into add-list-endpoints
FrankHassanabad Mar 31, 2020
b1309f4
Fixed type issues and API from update from master
FrankHassanabad Mar 31, 2020
5330743
Added more endpoints for delete and get
FrankHassanabad Apr 1, 2020
2077c49
Added more delete endpoints
FrankHassanabad Apr 1, 2020
e1bd777
Merge branch 'master' into add-list-endpoints
FrankHassanabad Apr 1, 2020
15e14cb
Updated lists to work with custom buffer and fixed bugs
FrankHassanabad Apr 2, 2020
0d52c3e
Merge branch 'master' into add-list-endpoints
FrankHassanabad Apr 2, 2020
b8bbf26
Merge branch 'master' into add-list-endpoints
FrankHassanabad Apr 3, 2020
928b45f
Large sweeping changes
FrankHassanabad Apr 5, 2020
79e0bf4
Fixed single test
FrankHassanabad Apr 5, 2020
4608a13
Changed string to be keyword to be closer to the mapping
FrankHassanabad Apr 5, 2020
48ae3f3
mapping and type changes
FrankHassanabad Apr 5, 2020
7f869c9
Merge branch 'master' into add-list-endpoints
FrankHassanabad Apr 8, 2020
0f6d49b
Merge branch 'master' into add-list-endpoints
FrankHassanabad Apr 9, 2020
a240f11
Changed lists routes to use /api/lists instead of api/detection_engin…
FrankHassanabad Apr 9, 2020
72a007b
Moves detection list items out of detection api folder
FrankHassanabad Apr 13, 2020
815fe14
Merge branch 'master' into add-list-endpoints
FrankHassanabad Apr 13, 2020
3d24148
Remove uneeded modification
FrankHassanabad Apr 13, 2020
9a12ab1
Moved lists to plugin but have not removed the older lists completely
FrankHassanabad Apr 14, 2020
0af51b6
Removed lists functionality from siem as it is now its own plugin
FrankHassanabad Apr 14, 2020
53d98fd
Merge branch 'master' into add-list-endpoints
FrankHassanabad Apr 14, 2020
532703f
Updated to remove all SIEM code and just have lists plugin now
FrankHassanabad Apr 14, 2020
b786df8
Removed the last of the siem code
FrankHassanabad Apr 14, 2020
33d69d5
Fixed up imports a bit more
FrankHassanabad Apr 14, 2020
be48a15
Removed more TODO blocks
FrankHassanabad Apr 15, 2020
30757fc
Merge branch 'master' into add-list-endpoints
FrankHassanabad Apr 15, 2020
9672a48
Added the first client based API and changed things around to work wi…
FrankHassanabad Apr 15, 2020
a2752bf
Created API and cleaned up more of the code
FrankHassanabad Apr 16, 2020
5c9602f
Merge branch 'master' into add-list-endpoints
FrankHassanabad Apr 16, 2020
bf51473
Updated with user and other fields as needed
FrankHassanabad Apr 16, 2020
e161a41
Merge branch 'master' into add-list-endpoints
FrankHassanabad Apr 16, 2020
7c0f042
Merge branch 'master' into add-list-endpoints
FrankHassanabad Apr 17, 2020
740b639
Removed more TODO blocks
FrankHassanabad Apr 17, 2020
d3610c2
More TODO's removed
FrankHassanabad Apr 17, 2020
27a1a4f
Fixed update and patch and removed more TODO blocks and fixed issues …
FrankHassanabad Apr 17, 2020
cbbca14
Removed more TODO blocks
FrankHassanabad Apr 17, 2020
2b67ec8
Merge branch 'master' into add-list-endpoints
FrankHassanabad Apr 17, 2020
c7f7e52
Updated to put siem deps into their own folders and updated the paths…
FrankHassanabad Apr 17, 2020
6027c95
Updated to the new suggested structure
FrankHassanabad Apr 17, 2020
65525a9
Fixed startup issue
FrankHassanabad Apr 17, 2020
fe857c8
Changed schemas and error handling
FrankHassanabad Apr 18, 2020
9770dee
Merge branch 'master' into add-list-endpoints
FrankHassanabad Apr 18, 2020
a560db2
Changed access:list to be access:lists
FrankHassanabad Apr 18, 2020
ec01b14
Changes out the buildRouteValidation to the migrated version within SIEM
FrankHassanabad Apr 19, 2020
5936889
Fixed linter issues
FrankHassanabad Apr 19, 2020
7e149c5
Added lists to the CODEOWNERS file
FrankHassanabad Apr 19, 2020
fdb96e1
Added return validations
FrankHassanabad Apr 19, 2020
e11b210
Updated types to be more inline with more Elastic types
FrankHassanabad Apr 19, 2020
d7c5ca2
Merge branch 'master' into add-list-endpoints
FrankHassanabad Apr 19, 2020
caf8c70
Added meta to be possible on list and list item as well as restructur…
FrankHassanabad Apr 19, 2020
4badfe5
Merge branch 'master' into add-list-endpoints
FrankHassanabad Apr 20, 2020
4a2c7ef
Added linter rule to sort all the keys and just one test for create l…
FrankHassanabad Apr 20, 2020
79dad91
Added linter rule to sort the import statements
FrankHassanabad Apr 20, 2020
cc16171
Added some unit tests
FrankHassanabad Apr 20, 2020
809557c
Added more tests
FrankHassanabad Apr 20, 2020
e6a2f2e
Merge branch 'master' into add-list-endpoints
FrankHassanabad Apr 20, 2020
16b77f0
Removed the __mocks__ for mocks and fixed merge with master
FrankHassanabad Apr 20, 2020
cf3cd9a
More tests
FrankHassanabad Apr 21, 2020
8966dac
More tests and some renaming
FrankHassanabad Apr 21, 2020
1a4c2ec
More tests
FrankHassanabad Apr 21, 2020
0344014
Added another test
FrankHassanabad Apr 21, 2020
3b95567
Removed the "s" to be consistent and fix weird issues where some thin…
FrankHassanabad Apr 21, 2020
afd0073
Part 2 of removing "s" in most places for consistency
FrankHassanabad Apr 21, 2020
7416250
More tests
FrankHassanabad Apr 21, 2020
049d81a
Fixed mapping to not allow any dynamic element but rather just the ob…
FrankHassanabad Apr 22, 2020
9983363
More renames and more tests
FrankHassanabad Apr 22, 2020
7e286e8
Merge branch 'master' into add-list-endpoints
elasticmachine Apr 23, 2020
d0c0315
Merge branch 'master' into add-list-endpoints
elasticmachine Apr 23, 2020
3a89cc5
More unit tests and bug fixes
FrankHassanabad Apr 23, 2020
2f10efe
Merge branch 'add-list-endpoints' of github.com:FrankHassanabad/kiban…
FrankHassanabad Apr 23, 2020
6a09157
Merge branch 'master' into add-list-endpoints
FrankHassanabad Apr 23, 2020
9c34531
More tests, more linter rules
FrankHassanabad Apr 23, 2020
a842e07
More tests and small bug fixes
FrankHassanabad Apr 23, 2020
bb99813
More tests and cleaned up comments left over
FrankHassanabad Apr 23, 2020
0269ee2
Merge branch 'master' into add-list-endpoints
FrankHassanabad Apr 24, 2020
21c7762
Fixed the linter and updated with master
FrankHassanabad Apr 24, 2020
14f6f5c
Merge branch 'master' into add-list-endpoints
FrankHassanabad Apr 27, 2020
06c9d9a
Merge branch 'master' into add-list-endpoints
FrankHassanabad Apr 28, 2020
3cb4c27
Added feature flag to be enabled in the position off along with warni…
FrankHassanabad Apr 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,101 @@ module.exports = {
},
},

/**
* Lists overrides
*/
{
// typescript and javascript for front and back end
files: ['x-pack/plugins/lists/**/*.{js,ts,tsx}'],
plugins: ['eslint-plugin-node'],
env: {
mocha: true,
jest: true,
},
rules: {
'accessor-pairs': 'error',
'array-callback-return': 'error',
'no-array-constructor': 'error',
complexity: 'error',
'consistent-return': 'error',
'func-style': ['error', 'expression'],
'import/order': [
'error',
{
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
'newlines-between': 'always',
},
],
'sort-imports': [
'error',
{
ignoreDeclarationSort: true,
},
],
'node/no-deprecated-api': 'error',
'no-bitwise': 'error',
'no-continue': 'error',
'no-dupe-keys': 'error',
'no-duplicate-case': 'error',
'no-duplicate-imports': 'error',
'no-empty-character-class': 'error',
'no-empty-pattern': 'error',
'no-ex-assign': 'error',
'no-extend-native': 'error',
'no-extra-bind': 'error',
'no-extra-boolean-cast': 'error',
'no-extra-label': 'error',
'no-func-assign': 'error',
'no-implicit-globals': 'error',
'no-implied-eval': 'error',
'no-invalid-regexp': 'error',
'no-inner-declarations': 'error',
'no-lone-blocks': 'error',
'no-multi-assign': 'error',
'no-misleading-character-class': 'error',
'no-new-symbol': 'error',
'no-obj-calls': 'error',
'no-param-reassign': 'error',
'no-process-exit': 'error',
'no-prototype-builtins': 'error',
'no-return-await': 'error',
'no-self-compare': 'error',
'no-shadow-restricted-names': 'error',
'no-sparse-arrays': 'error',
'no-this-before-super': 'error',
'no-undef': 'error',
'no-unreachable': 'error',
'no-unsafe-finally': 'error',
'no-useless-call': 'error',
'no-useless-catch': 'error',
'no-useless-concat': 'error',
'no-useless-computed-key': 'error',
'no-useless-escape': 'error',
'no-useless-rename': 'error',
'no-useless-return': 'error',
'no-void': 'error',
'one-var-declaration-per-line': 'error',
'prefer-object-spread': 'error',
'prefer-promise-reject-errors': 'error',
'prefer-rest-params': 'error',
'prefer-spread': 'error',
'prefer-template': 'error',
'require-atomic-updates': 'error',
'symbol-description': 'error',
'vars-on-top': 'error',
'@typescript-eslint/explicit-member-accessibility': 'error',
'@typescript-eslint/no-this-alias': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-useless-constructor': 'error',
'@typescript-eslint/unified-signatures': 'error',
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/no-non-null-assertion': 'error',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look forward to having some of these over in the detections engine too :)

'@typescript-eslint/no-unused-vars': 'error',
'no-template-curly-in-string': 'error',
'sort-keys': 'error',
},
},

/**
* Lens overrides
*/
Expand Down
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@
/x-pack/test/detection_engine_api_integration @elastic/siem
/x-pack/test/api_integration/apis/siem @elastic/siem
/x-pack/plugins/case @elastic/siem
/x-pack/plugins/lists @elastic/siem

# Security Intelligence And Analytics
/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules @elastic/security-intelligence-analytics
/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules @elastic/security-intelligence-analytics
12 changes: 12 additions & 0 deletions x-pack/plugins/lists/common/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

/**
* Lists routes
*/
export const LIST_URL = `/api/lists`;
export const LIST_INDEX = `${LIST_URL}/index`;
export const LIST_ITEM_URL = `${LIST_URL}/items`;
7 changes: 7 additions & 0 deletions x-pack/plugins/lists/common/schemas/common/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export * from './schemas';
62 changes: 62 additions & 0 deletions x-pack/plugins/lists/common/schemas/common/schemas.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

/* eslint-disable @typescript-eslint/camelcase */

import * as t from 'io-ts';

import { NonEmptyString } from '../types/non_empty_string';

export const name = t.string;
export type Name = t.TypeOf<typeof name>;
export const nameOrUndefined = t.union([name, t.undefined]);
export type NameOrUndefined = t.TypeOf<typeof nameOrUndefined>;

export const description = t.string;
export type Description = t.TypeOf<typeof description>;
export const descriptionOrUndefined = t.union([description, t.undefined]);
export type DescriptionOrUndefined = t.TypeOf<typeof descriptionOrUndefined>;

export const list_id = NonEmptyString;
export const list_idOrUndefined = t.union([list_id, t.undefined]);
export type List_idOrUndefined = t.TypeOf<typeof list_idOrUndefined>;

export const item = t.string;
export const created_at = t.string; // TODO: Make this into an ISO Date string check
export const updated_at = t.string; // TODO: Make this into an ISO Date string check
export const updated_by = t.string;
export const created_by = t.string;
export const file = t.object;

export const id = NonEmptyString;
export type Id = t.TypeOf<typeof id>;
export const idOrUndefined = t.union([id, t.undefined]);
export type IdOrUndefined = t.TypeOf<typeof idOrUndefined>;

export const ip = t.string;
export const ipOrUndefined = t.union([ip, t.undefined]);

export const keyword = t.string;
export const keywordOrUndefined = t.union([keyword, t.undefined]);

export const value = t.string;
export const valueOrUndefined = t.union([value, t.undefined]);

export const tie_breaker_id = t.string; // TODO: Use UUID for this instead of a string for validation
export const _index = t.string;

export const type = t.keyof({ ip: null, keyword: null }); // TODO: Add the other data types here

export const typeOrUndefined = t.union([type, t.undefined]);
export type Type = t.TypeOf<typeof type>;

export const meta = t.object;
export type Meta = t.TypeOf<typeof meta>;
export const metaOrUndefined = t.union([meta, t.undefined]);
export type MetaOrUndefined = t.TypeOf<typeof metaOrUndefined>;

export const esDataTypeUnion = t.union([t.type({ ip }), t.type({ keyword })]);
export type EsDataTypeUnion = t.TypeOf<typeof esDataTypeUnion>;
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import * as t from 'io-ts';

import { _index } from '../common/schemas';

export const createEsBulkTypeSchema = t.exact(
t.type({
create: t.exact(t.type({ _index })),
})
);

export type CreateEsBulkTypeSchema = t.TypeOf<typeof createEsBulkTypeSchema>;
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

/* eslint-disable @typescript-eslint/camelcase */

import * as t from 'io-ts';

import {
created_at,
created_by,
esDataTypeUnion,
list_id,
metaOrUndefined,
tie_breaker_id,
updated_at,
updated_by,
} from '../common/schemas';

export const createEsListsItemsSchema = t.intersection([
t.exact(
t.type({
created_at,
created_by,
list_id,
meta: metaOrUndefined,
tie_breaker_id,
updated_at,
updated_by,
})
),
esDataTypeUnion,
]);

export type CreateEsListsItemsSchema = t.TypeOf<typeof createEsListsItemsSchema>;
10 changes: 10 additions & 0 deletions x-pack/plugins/lists/common/schemas/elastic_query/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
export * from './update_es_lists_schema';
export * from './index_es_lists_schema';
export * from './update_es_lists_items_schema';
export * from './create_es_lists_items_schema';
export * from './create_es_bulk_type';
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

/* eslint-disable @typescript-eslint/camelcase */

import * as t from 'io-ts';

import {
created_at,
created_by,
description,
metaOrUndefined,
name,
tie_breaker_id,
type,
updated_at,
updated_by,
} from '../common/schemas';

export const indexEsListsSchema = t.exact(
t.type({
created_at,
created_by,
description,
meta: metaOrUndefined,
name,
tie_breaker_id,
type,
updated_at,
updated_by,
})
);

export type IndexEsListsSchema = t.TypeOf<typeof indexEsListsSchema>;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

/* eslint-disable @typescript-eslint/camelcase */

import * as t from 'io-ts';

import { esDataTypeUnion, metaOrUndefined, updated_at, updated_by } from '../common/schemas';

export const updateEsListsItemsSchema = t.intersection([
t.exact(
t.type({
meta: metaOrUndefined,
updated_at,
updated_by,
})
),
esDataTypeUnion,
]);

export type UpdateEsListsItemsSchema = t.TypeOf<typeof updateEsListsItemsSchema>;
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

/* eslint-disable @typescript-eslint/camelcase */

import * as t from 'io-ts';

import {
descriptionOrUndefined,
metaOrUndefined,
nameOrUndefined,
updated_at,
updated_by,
} from '../common/schemas';

export const updateEsListsSchema = t.exact(
t.type({
description: descriptionOrUndefined,
meta: metaOrUndefined,
name: nameOrUndefined,
updated_at,
updated_by,
})
);

export type UpdateEsListsSchema = t.TypeOf<typeof updateEsListsSchema>;
8 changes: 8 additions & 0 deletions x-pack/plugins/lists/common/schemas/elastic_response/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export * from './search_es_lists_items_schema';
export * from './search_es_lists_schema';
Loading