Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Commit

Permalink
SIEM] Moves validation up to the common section (elastic#69315)
Browse files Browse the repository at this point in the history
## Summary

Moves validation up to the common section so it can be used by others in common for API boundary validation.
  • Loading branch information
FrankHassanabad authored Jun 16, 2020
1 parent 7518ae1 commit 736841d
Show file tree
Hide file tree
Showing 43 changed files with 128 additions and 190 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ describe('update_exception_list_item_schema', () => {

// TODO: Is it expected behavior for it not to auto-generate a uui or throw
// error if item_id is not passed in?
xtest('it should accept an undefined for "item_id" and auto generate a uuid', () => {
test.skip('it should accept an undefined for "item_id" and auto generate a uuid', () => {
const inputPayload = getUpdateExceptionListItemSchemaMock();
delete inputPayload.item_id;
const decoded = updateExceptionListItemSchema.decode(inputPayload);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ describe('exception_list_item_schema', () => {

// TODO: Should this throw an error? "namespace_type" gets auto-populated
// with default "single", is that desired behavior?
xtest('it should NOT accept an undefined for "namespace_type"', () => {
test.skip('it should NOT accept an undefined for "namespace_type"', () => {
const payload = getExceptionListItemSchemaMock();
delete payload.namespace_type;
const decoded = exceptionListItemSchema.decode(payload);
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/lists/common/siem_common_deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ export { DefaultUuid } from '../../security_solution/common/detection_engine/sch
export { DefaultStringArray } from '../../security_solution/common/detection_engine/schemas/types/default_string_array';
export { exactCheck } from '../../security_solution/common/exact_check';
export { getPaths, foldLeftRight } from '../../security_solution/common/test_utils';
export { validate } from '../../security_solution/common/validate';
export { formatErrors } from '../../security_solution/common/format_errors';
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@
import { IRouter } from 'kibana/server';

import { EXCEPTION_LIST_ITEM_URL } from '../../common/constants';
import {
buildRouteValidation,
buildSiemResponse,
transformError,
validate,
} from '../siem_server_deps';
import { buildRouteValidation, buildSiemResponse, transformError } from '../siem_server_deps';
import { validate } from '../../common/siem_common_deps';
import {
CreateExceptionListItemSchemaDecoded,
createExceptionListItemSchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@
import { IRouter } from 'kibana/server';

import { EXCEPTION_LIST_URL } from '../../common/constants';
import {
buildRouteValidation,
buildSiemResponse,
transformError,
validate,
} from '../siem_server_deps';
import { buildRouteValidation, buildSiemResponse, transformError } from '../siem_server_deps';
import { validate } from '../../common/siem_common_deps';
import {
CreateExceptionListSchemaDecoded,
createExceptionListSchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

import { IRouter } from 'kibana/server';

import { buildSiemResponse, transformError, validate } from '../siem_server_deps';
import { buildSiemResponse, transformError } from '../siem_server_deps';
import { validate } from '../../common/siem_common_deps';
import { LIST_INDEX } from '../../common/constants';
import { acknowledgeSchema } from '../../common/schemas';

Expand Down
8 changes: 2 additions & 6 deletions x-pack/plugins/lists/server/routes/create_list_item_route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@
import { IRouter } from 'kibana/server';

import { LIST_ITEM_URL } from '../../common/constants';
import {
buildRouteValidation,
buildSiemResponse,
transformError,
validate,
} from '../siem_server_deps';
import { buildRouteValidation, buildSiemResponse, transformError } from '../siem_server_deps';
import { createListItemSchema, listItemSchema } from '../../common/schemas';
import { validate } from '../../common/siem_common_deps';

import { getListClient } from '.';

Expand Down
8 changes: 2 additions & 6 deletions x-pack/plugins/lists/server/routes/create_list_route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@
import { IRouter } from 'kibana/server';

import { LIST_URL } from '../../common/constants';
import {
buildRouteValidation,
buildSiemResponse,
transformError,
validate,
} from '../siem_server_deps';
import { buildRouteValidation, buildSiemResponse, transformError } from '../siem_server_deps';
import { validate } from '../../common/siem_common_deps';
import { createListSchema, listSchema } from '../../common/schemas';

import { getListClient } from '.';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@
import { IRouter } from 'kibana/server';

import { EXCEPTION_LIST_ITEM_URL } from '../../common/constants';
import {
buildRouteValidation,
buildSiemResponse,
transformError,
validate,
} from '../siem_server_deps';
import { buildRouteValidation, buildSiemResponse, transformError } from '../siem_server_deps';
import { validate } from '../../common/siem_common_deps';
import {
DeleteExceptionListItemSchemaDecoded,
deleteExceptionListItemSchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@
import { IRouter } from 'kibana/server';

import { EXCEPTION_LIST_URL } from '../../common/constants';
import {
buildRouteValidation,
buildSiemResponse,
transformError,
validate,
} from '../siem_server_deps';
import { buildRouteValidation, buildSiemResponse, transformError } from '../siem_server_deps';
import { validate } from '../../common/siem_common_deps';
import {
DeleteExceptionListSchemaDecoded,
deleteExceptionListSchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
import { IRouter } from 'kibana/server';

import { LIST_INDEX } from '../../common/constants';
import { buildSiemResponse, transformError, validate } from '../siem_server_deps';
import { buildSiemResponse, transformError } from '../siem_server_deps';
import { validate } from '../../common/siem_common_deps';
import { acknowledgeSchema } from '../../common/schemas';

import { getListClient } from '.';
Expand Down
8 changes: 2 additions & 6 deletions x-pack/plugins/lists/server/routes/delete_list_item_route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@
import { IRouter } from 'kibana/server';

import { LIST_ITEM_URL } from '../../common/constants';
import {
buildRouteValidation,
buildSiemResponse,
transformError,
validate,
} from '../siem_server_deps';
import { buildRouteValidation, buildSiemResponse, transformError } from '../siem_server_deps';
import { validate } from '../../common/siem_common_deps';
import { deleteListItemSchema, listItemArraySchema, listItemSchema } from '../../common/schemas';

import { getListClient } from '.';
Expand Down
8 changes: 2 additions & 6 deletions x-pack/plugins/lists/server/routes/delete_list_route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@
import { IRouter } from 'kibana/server';

import { LIST_URL } from '../../common/constants';
import {
buildRouteValidation,
buildSiemResponse,
transformError,
validate,
} from '../siem_server_deps';
import { buildRouteValidation, buildSiemResponse, transformError } from '../siem_server_deps';
import { validate } from '../../common/siem_common_deps';
import { deleteListSchema, listSchema } from '../../common/schemas';

import { getListClient } from '.';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@
import { IRouter } from 'kibana/server';

import { EXCEPTION_LIST_ITEM_URL } from '../../common/constants';
import {
buildRouteValidation,
buildSiemResponse,
transformError,
validate,
} from '../siem_server_deps';
import { buildRouteValidation, buildSiemResponse, transformError } from '../siem_server_deps';
import { validate } from '../../common/siem_common_deps';
import {
FindExceptionListItemSchemaDecoded,
findExceptionListItemSchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@
import { IRouter } from 'kibana/server';

import { EXCEPTION_LIST_URL } from '../../common/constants';
import {
buildRouteValidation,
buildSiemResponse,
transformError,
validate,
} from '../siem_server_deps';
import { buildRouteValidation, buildSiemResponse, transformError } from '../siem_server_deps';
import { validate } from '../../common/siem_common_deps';
import {
FindExceptionListSchemaDecoded,
findExceptionListSchema,
Expand Down
8 changes: 2 additions & 6 deletions x-pack/plugins/lists/server/routes/find_list_item_route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@
import { IRouter } from 'kibana/server';

import { LIST_ITEM_URL } from '../../common/constants';
import {
buildRouteValidation,
buildSiemResponse,
transformError,
validate,
} from '../siem_server_deps';
import { buildRouteValidation, buildSiemResponse, transformError } from '../siem_server_deps';
import { validate } from '../../common/siem_common_deps';
import { findListItemSchema, foundListItemSchema } from '../../common/schemas';
import { decodeCursor } from '../services/utils';

Expand Down
8 changes: 2 additions & 6 deletions x-pack/plugins/lists/server/routes/find_list_route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@
import { IRouter } from 'kibana/server';

import { LIST_URL } from '../../common/constants';
import {
buildRouteValidation,
buildSiemResponse,
transformError,
validate,
} from '../siem_server_deps';
import { buildRouteValidation, buildSiemResponse, transformError } from '../siem_server_deps';
import { validate } from '../../common/siem_common_deps';
import { findListSchema, foundListSchema } from '../../common/schemas';
import { decodeCursor } from '../services/utils';

Expand Down
8 changes: 2 additions & 6 deletions x-pack/plugins/lists/server/routes/import_list_item_route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@ import { Readable } from 'stream';
import { IRouter } from 'kibana/server';

import { LIST_ITEM_URL } from '../../common/constants';
import {
buildRouteValidation,
buildSiemResponse,
transformError,
validate,
} from '../siem_server_deps';
import { buildRouteValidation, buildSiemResponse, transformError } from '../siem_server_deps';
import { validate } from '../../common/siem_common_deps';
import { importListItemQuerySchema, importListItemSchema, listSchema } from '../../common/schemas';

import { getListClient } from '.';
Expand Down
8 changes: 2 additions & 6 deletions x-pack/plugins/lists/server/routes/patch_list_item_route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@
import { IRouter } from 'kibana/server';

import { LIST_ITEM_URL } from '../../common/constants';
import {
buildRouteValidation,
buildSiemResponse,
transformError,
validate,
} from '../siem_server_deps';
import { buildRouteValidation, buildSiemResponse, transformError } from '../siem_server_deps';
import { validate } from '../../common/siem_common_deps';
import { listItemSchema, patchListItemSchema } from '../../common/schemas';

import { getListClient } from '.';
Expand Down
8 changes: 2 additions & 6 deletions x-pack/plugins/lists/server/routes/patch_list_route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@
import { IRouter } from 'kibana/server';

import { LIST_URL } from '../../common/constants';
import {
buildRouteValidation,
buildSiemResponse,
transformError,
validate,
} from '../siem_server_deps';
import { buildRouteValidation, buildSiemResponse, transformError } from '../siem_server_deps';
import { validate } from '../../common/siem_common_deps';
import { listSchema, patchListSchema } from '../../common/schemas';

import { getListClient } from '.';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@
import { IRouter } from 'kibana/server';

import { EXCEPTION_LIST_ITEM_URL } from '../../common/constants';
import {
buildRouteValidation,
buildSiemResponse,
transformError,
validate,
} from '../siem_server_deps';
import { buildRouteValidation, buildSiemResponse, transformError } from '../siem_server_deps';
import { validate } from '../../common/siem_common_deps';
import {
ReadExceptionListItemSchemaDecoded,
exceptionListItemSchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@
import { IRouter } from 'kibana/server';

import { EXCEPTION_LIST_URL } from '../../common/constants';
import {
buildRouteValidation,
buildSiemResponse,
transformError,
validate,
} from '../siem_server_deps';
import { buildRouteValidation, buildSiemResponse, transformError } from '../siem_server_deps';
import { validate } from '../../common/siem_common_deps';
import {
ReadExceptionListSchemaDecoded,
exceptionListSchema,
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/lists/server/routes/read_list_index_route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
import { IRouter } from 'kibana/server';

import { LIST_INDEX } from '../../common/constants';
import { buildSiemResponse, transformError, validate } from '../siem_server_deps';
import { buildSiemResponse, transformError } from '../siem_server_deps';
import { validate } from '../../common/siem_common_deps';
import { listItemIndexExistSchema } from '../../common/schemas';

import { getListClient } from '.';
Expand Down
8 changes: 2 additions & 6 deletions x-pack/plugins/lists/server/routes/read_list_item_route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@
import { IRouter } from 'kibana/server';

import { LIST_ITEM_URL } from '../../common/constants';
import {
buildRouteValidation,
buildSiemResponse,
transformError,
validate,
} from '../siem_server_deps';
import { buildRouteValidation, buildSiemResponse, transformError } from '../siem_server_deps';
import { listItemArraySchema, listItemSchema, readListItemSchema } from '../../common/schemas';
import { validate } from '../../common/siem_common_deps';

import { getListClient } from '.';

Expand Down
8 changes: 2 additions & 6 deletions x-pack/plugins/lists/server/routes/read_list_route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@
import { IRouter } from 'kibana/server';

import { LIST_URL } from '../../common/constants';
import {
buildRouteValidation,
buildSiemResponse,
transformError,
validate,
} from '../siem_server_deps';
import { buildRouteValidation, buildSiemResponse, transformError } from '../siem_server_deps';
import { validate } from '../../common/siem_common_deps';
import { listSchema, readListSchema } from '../../common/schemas';

import { getListClient } from '.';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@
import { IRouter } from 'kibana/server';

import { EXCEPTION_LIST_ITEM_URL } from '../../common/constants';
import {
buildRouteValidation,
buildSiemResponse,
transformError,
validate,
} from '../siem_server_deps';
import { buildRouteValidation, buildSiemResponse, transformError } from '../siem_server_deps';
import { validate } from '../../common/siem_common_deps';
import {
UpdateExceptionListItemSchemaDecoded,
exceptionListItemSchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@
import { IRouter } from 'kibana/server';

import { EXCEPTION_LIST_URL } from '../../common/constants';
import {
buildRouteValidation,
buildSiemResponse,
transformError,
validate,
} from '../siem_server_deps';
import { buildRouteValidation, buildSiemResponse, transformError } from '../siem_server_deps';
import { validate } from '../../common/siem_common_deps';
import {
UpdateExceptionListSchemaDecoded,
exceptionListSchema,
Expand Down
8 changes: 2 additions & 6 deletions x-pack/plugins/lists/server/routes/update_list_item_route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@
import { IRouter } from 'kibana/server';

import { LIST_ITEM_URL } from '../../common/constants';
import {
buildRouteValidation,
buildSiemResponse,
transformError,
validate,
} from '../siem_server_deps';
import { buildRouteValidation, buildSiemResponse, transformError } from '../siem_server_deps';
import { validate } from '../../common/siem_common_deps';
import { listItemSchema, updateListItemSchema } from '../../common/schemas';

import { getListClient } from '.';
Expand Down
Loading

0 comments on commit 736841d

Please sign in to comment.