From 719fa6953508783f8283ab2fc8e0857b0da2b9df Mon Sep 17 00:00:00 2001 From: Angela Chuang <6295984+angorayc@users.noreply.github.com> Date: Wed, 21 Apr 2021 00:18:28 +0100 Subject: [PATCH] [SecuritySolution] remove files that are not in used (#97740) * remove files that are not in used * remove files that are not in used --- .../plugins/security_solution/.gitattributes | 6 - x-pack/plugins/security_solution/package.json | 1 - .../server/lib/framework/types.ts | 2 - .../server/utils/build_query/field.mock.ts | 172 ------------------ .../server/utils/build_query/fields.test.ts | 27 --- .../server/utils/build_query/fields.ts | 34 ---- .../server/utils/build_query/index.ts | 1 - .../server/utils/typed_resolvers.ts | 108 ----------- 8 files changed, 351 deletions(-) delete mode 100644 x-pack/plugins/security_solution/.gitattributes delete mode 100644 x-pack/plugins/security_solution/server/utils/build_query/field.mock.ts delete mode 100644 x-pack/plugins/security_solution/server/utils/build_query/fields.test.ts delete mode 100644 x-pack/plugins/security_solution/server/utils/build_query/fields.ts delete mode 100644 x-pack/plugins/security_solution/server/utils/typed_resolvers.ts diff --git a/x-pack/plugins/security_solution/.gitattributes b/x-pack/plugins/security_solution/.gitattributes deleted file mode 100644 index 431f25be5e78e..0000000000000 --- a/x-pack/plugins/security_solution/.gitattributes +++ /dev/null @@ -1,6 +0,0 @@ -# Auto-collapse generated files in GitHub -# https://help.github.com/en/articles/customizing-how-changed-files-appear-on-github -x-pack/plugins/security_solution/server/graphql/types.ts linguist-generated=true -x-pack/plugins/security_solution/public/graphql/types.ts linguist-generated=true -x-pack/plugins/security_solution/public/graphql/introspection.json linguist-generated=true - diff --git a/x-pack/plugins/security_solution/package.json b/x-pack/plugins/security_solution/package.json index 211e6986e19a7..f35974d84164e 100644 --- a/x-pack/plugins/security_solution/package.json +++ b/x-pack/plugins/security_solution/package.json @@ -7,7 +7,6 @@ "scripts": { "extract-mitre-attacks": "node scripts/extract_tactics_techniques_mitre.js && node ../../../scripts/eslint ./public/detections/mitre/mitre_tactics_techniques.ts --fix", "build-beat-doc": "node scripts/beat_docs/build.js && node ../../../scripts/eslint ./server/utils/beat_schema/fields.ts --fix", - "build-graphql-types": "node scripts/generate_types_from_graphql.js", "cypress:open": "../../../node_modules/.bin/cypress open --config-file ./cypress/cypress.json", "cypress:open-as-ci": "node ../../../scripts/functional_tests --config ../../test/security_solution_cypress/visual_config.ts", "cypress:run": "../../../node_modules/.bin/cypress run --browser chrome --headless --spec ./cypress/integration/**/*.spec.ts --config-file ./cypress/cypress.json --reporter ../../../node_modules/cypress-multi-reporters --reporter-options configFile=./cypress/reporter_config.json; status=$?; ../../../node_modules/.bin/mochawesome-merge ../../../target/kibana-security-solution/cypress/results/mochawesome*.json > ../../../target/kibana-security-solution/cypress/results/output.json; ../../../node_modules/.bin/marge ../../../target/kibana-security-solution/cypress/results/output.json --reportDir ../../../target/kibana-security-solution/cypress/results; mkdir -p ../../../target/junit && cp ../../../target/kibana-security-solution/cypress/results/*.xml ../../../target/junit/ && exit $status;", diff --git a/x-pack/plugins/security_solution/server/lib/framework/types.ts b/x-pack/plugins/security_solution/server/lib/framework/types.ts index 34012f8f15d16..6665468a27125 100644 --- a/x-pack/plugins/security_solution/server/lib/framework/types.ts +++ b/x-pack/plugins/security_solution/server/lib/framework/types.ts @@ -20,8 +20,6 @@ import { } from '../../../common/search_strategy'; import { SourceConfiguration } from '../sources'; -export * from '../../utils/typed_resolvers'; - export const internalFrameworkRequest = Symbol('internalFrameworkRequest'); export interface FrameworkAdapter { diff --git a/x-pack/plugins/security_solution/server/utils/build_query/field.mock.ts b/x-pack/plugins/security_solution/server/utils/build_query/field.mock.ts deleted file mode 100644 index 3c8d1b4c1d6b3..0000000000000 --- a/x-pack/plugins/security_solution/server/utils/build_query/field.mock.ts +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { FieldNode } from 'graphql'; - -export const mockFields: FieldNode = { - kind: 'Field', - name: { - kind: 'Name', - value: 'Hosts', - }, - selectionSet: { - kind: 'SelectionSet', - selections: [ - { - kind: 'Field', - name: { - kind: 'Name', - value: 'totalCount', - }, - arguments: [], - directives: [], - }, - { - kind: 'Field', - name: { - kind: 'Name', - value: 'edges', - }, - arguments: [], - directives: [], - selectionSet: { - kind: 'SelectionSet', - selections: [ - { - kind: 'Field', - name: { - kind: 'Name', - value: 'host', - }, - arguments: [], - directives: [], - selectionSet: { - kind: 'SelectionSet', - selections: [ - { - kind: 'Field', - name: { - kind: 'Name', - value: '_id', - }, - arguments: [], - directives: [], - }, - { - kind: 'Field', - name: { - kind: 'Name', - value: 'name', - }, - arguments: [], - directives: [], - }, - { - kind: 'Field', - name: { - kind: 'Name', - value: 'os', - }, - arguments: [], - directives: [], - }, - { - kind: 'Field', - name: { - kind: 'Name', - value: 'version', - }, - arguments: [], - directives: [], - }, - { - kind: 'Field', - name: { - kind: 'Name', - value: 'firstSeen', - }, - arguments: [], - directives: [], - }, - ], - }, - }, - { - kind: 'Field', - name: { - kind: 'Name', - value: 'cursor', - }, - arguments: [], - directives: [], - selectionSet: { - kind: 'SelectionSet', - selections: [ - { - kind: 'Field', - name: { - kind: 'Name', - value: 'value', - }, - arguments: [], - directives: [], - }, - ], - }, - }, - ], - }, - }, - { - kind: 'Field', - name: { - kind: 'Name', - value: 'pageInfo', - }, - arguments: [], - directives: [], - selectionSet: { - kind: 'SelectionSet', - selections: [ - { - kind: 'Field', - name: { - kind: 'Name', - value: 'endCursor', - }, - arguments: [], - directives: [], - selectionSet: { - kind: 'SelectionSet', - selections: [ - { - kind: 'Field', - name: { - kind: 'Name', - value: 'value', - }, - arguments: [], - directives: [], - }, - ], - }, - }, - { - kind: 'Field', - name: { - kind: 'Name', - value: 'hasNextPage', - }, - arguments: [], - directives: [], - }, - ], - }, - }, - ], - }, -}; diff --git a/x-pack/plugins/security_solution/server/utils/build_query/fields.test.ts b/x-pack/plugins/security_solution/server/utils/build_query/fields.test.ts deleted file mode 100644 index b34a3f7ed63a6..0000000000000 --- a/x-pack/plugins/security_solution/server/utils/build_query/fields.test.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { mockFields } from './field.mock'; -import { getFields } from './fields'; - -describe('the ConfigurationSourcesAdapter', () => { - test('adds the default source when no sources are configured', async () => { - const expectedData = [ - 'totalCount', - 'edges.host._id', - 'edges.host.name', - 'edges.host.os', - 'edges.host.version', - 'edges.host.firstSeen', - 'edges.cursor.value', - 'pageInfo.endCursor.value', - 'pageInfo.hasNextPage', - ]; - - expect(getFields(mockFields)).toEqual(expectedData); - }); -}); diff --git a/x-pack/plugins/security_solution/server/utils/build_query/fields.ts b/x-pack/plugins/security_solution/server/utils/build_query/fields.ts deleted file mode 100644 index da7fb1e2af819..0000000000000 --- a/x-pack/plugins/security_solution/server/utils/build_query/fields.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { FieldNode, SelectionNode, SelectionSetNode } from 'graphql'; -import { isEmpty } from 'lodash/fp'; - -export const getFields = ( - data: SelectionSetNode | FieldNode, - fields: string[] = [], - postFields: string[] = [] -): string[] => { - if (data.kind === 'Field' && data.selectionSet && !isEmpty(data.selectionSet.selections)) { - return getFields(data.selectionSet, fields); - } else if (data.kind === 'SelectionSet') { - return data.selections.reduce((res: string[], item: SelectionNode) => { - if (item.kind === 'Field') { - const field: FieldNode = item as FieldNode; - if (field.name.kind === 'Name' && field.name.value.includes('kpi')) { - return [...res, field.name.value]; - } else if (field.selectionSet && !isEmpty(field.selectionSet.selections)) { - return getFields(field.selectionSet, res, postFields.concat(field.name.value)); - } - return [...res, [...postFields, field.name.value].join('.')]; - } - return res; - }, fields as string[]); - } - - return fields; -}; diff --git a/x-pack/plugins/security_solution/server/utils/build_query/index.ts b/x-pack/plugins/security_solution/server/utils/build_query/index.ts index 7e06b6dbaa89a..61c4831f7f72f 100644 --- a/x-pack/plugins/security_solution/server/utils/build_query/index.ts +++ b/x-pack/plugins/security_solution/server/utils/build_query/index.ts @@ -5,7 +5,6 @@ * 2.0. */ -export * from './fields'; export * from './filters'; export * from './merge_fields_with_hits'; export * from './calculate_timeseries_interval'; diff --git a/x-pack/plugins/security_solution/server/utils/typed_resolvers.ts b/x-pack/plugins/security_solution/server/utils/typed_resolvers.ts deleted file mode 100644 index 96156797892dc..0000000000000 --- a/x-pack/plugins/security_solution/server/utils/typed_resolvers.ts +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { GraphQLResolveInfo } from 'graphql'; - -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export type Resolver = ( - parent: Parent, - args: Args, - context: TContext, - info: GraphQLResolveInfo -) => Promise | Result; - -type ResolverResult = R | Promise; - -type AppResolverResult = - | Promise - | Promise<{ [P in keyof R]: () => Promise }> - | { [P in keyof R]: () => Promise } - | { [P in keyof R]: () => R[P] } - | R; - -export type ResultOf = Resolver_ extends Resolver> - ? Result - : never; - -export type SubsetResolverWithFields = R extends Resolver< - Array, - infer ParentInArray, - infer ContextInArray, - infer ArgsInArray -> - ? Resolver< - Array>>, - ParentInArray, - ContextInArray, - ArgsInArray - > - : R extends Resolver - ? Resolver>, Parent, Context, Args> - : never; - -export type SubsetResolverWithoutFields = R extends Resolver< - Array, - infer ParentInArray, - infer ContextInArray, - infer ArgsInArray -> - ? Resolver< - Array>>, - ParentInArray, - ContextInArray, - ArgsInArray - > - : R extends Resolver - ? Resolver>, Parent, Context, Args> - : never; - -export type ResolverWithParent = Resolver_ extends Resolver< - infer Result, - // eslint-disable-next-line @typescript-eslint/no-explicit-any - any, - infer Context, - infer Args -> - ? Resolver - : never; - -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export type AppResolver = Resolver< - AppResolverResult, - Parent, - Context, - Args ->; - -export type AppResolverOf = Resolver_ extends Resolver< - ResolverResult, - never, - infer ContextWithNeverParent, - infer ArgsWithNeverParent -> - ? AppResolver - : Resolver_ extends Resolver< - ResolverResult, - infer Parent, - infer Context, - infer Args - > - ? AppResolver - : never; - -export type AppResolverWithFields = AppResolverOf< - SubsetResolverWithFields ->; - -export type AppResolverWithoutFields = AppResolverOf< - SubsetResolverWithoutFields ->; - -export type ChildResolverOf = ResolverWithParent< - Resolver_, - ResultOf ->;