Skip to content

Commit

Permalink
[Security Solution][Osquery] Enforce type imports (#135744)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashokaditya authored Jul 9, 2022
1 parent bfb1988 commit 6efef04
Show file tree
Hide file tree
Showing 2,828 changed files with 7,713 additions and 7,538 deletions.
9 changes: 9 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,14 @@ module.exports = {
'vars-on-top': 'error',
'@typescript-eslint/no-duplicate-imports': ['error'],
},
overrides: [
{
files: ['x-pack/plugins/security_solution/**/*.{js,mjs,ts,tsx}'],
rules: {
'@typescript-eslint/consistent-type-imports': 'error',
},
},
],
},
{
files: ['x-pack/plugins/cases/public/**/*.{js,mjs,ts,tsx}'],
Expand Down Expand Up @@ -1632,6 +1640,7 @@ module.exports = {
'prefer-arrow-callback': 'error',
'no-unused-vars': 'off',
'react/prop-types': 'off',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'off',
},
},
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/osquery/common/ecs/destination/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { GeoEcs } from '../geo';
import type { GeoEcs } from '../geo';

export interface DestinationEcs {
bytes?: number[];
Expand Down
44 changes: 22 additions & 22 deletions x-pack/plugins/osquery/common/ecs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@
* 2.0.
*/

import { AgentEcs } from './agent';
import { AuditdEcs } from './auditd';
import { DestinationEcs } from './destination';
import { DnsEcs } from './dns';
import { EndgameEcs } from './endgame';
import { EventEcs } from './event';
import { FileEcs } from './file';
import { GeoEcs } from './geo';
import { HostEcs } from './host';
import { NetworkEcs } from './network';
import { RuleEcs } from './rule';
import { SignalEcs } from './signal';
import { SourceEcs } from './source';
import { SuricataEcs } from './suricata';
import { TlsEcs } from './tls';
import { ZeekEcs } from './zeek';
import { HttpEcs } from './http';
import { UrlEcs } from './url';
import { UserEcs } from './user';
import { WinlogEcs } from './winlog';
import { ProcessEcs } from './process';
import { SystemEcs } from './system';
import type { AgentEcs } from './agent';
import type { AuditdEcs } from './auditd';
import type { DestinationEcs } from './destination';
import type { DnsEcs } from './dns';
import type { EndgameEcs } from './endgame';
import type { EventEcs } from './event';
import type { FileEcs } from './file';
import type { GeoEcs } from './geo';
import type { HostEcs } from './host';
import type { NetworkEcs } from './network';
import type { RuleEcs } from './rule';
import type { SignalEcs } from './signal';
import type { SourceEcs } from './source';
import type { SuricataEcs } from './suricata';
import type { TlsEcs } from './tls';
import type { ZeekEcs } from './zeek';
import type { HttpEcs } from './http';
import type { UrlEcs } from './url';
import type { UserEcs } from './user';
import type { WinlogEcs } from './winlog';
import type { ProcessEcs } from './process';
import type { SystemEcs } from './system';

export interface Ecs {
_id: string;
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/osquery/common/ecs/signal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { RuleEcs } from '../rule';
import type { RuleEcs } from '../rule';

export interface SignalEcs {
rule?: RuleEcs;
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/osquery/common/ecs/source/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { GeoEcs } from '../geo';
import type { GeoEcs } from '../geo';

export interface SourceEcs {
bytes?: number[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@

import * as t from 'io-ts';

import type { Description } from '../../common/schemas';
import {
id,
descriptionOrUndefined,
Description,
platformOrUndefined,
query,
versionOrUndefined,
interval,
ecsMappingOrUndefined,
} from '../../common/schemas';
import { RequiredKeepUndefined } from '../../../types';
import type { RequiredKeepUndefined } from '../../../types';

export const createSavedQueryRequestSchema = t.type({
id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import * as t from 'io-ts';
import { Either } from 'fp-ts/lib/Either';
import type { Either } from 'fp-ts/lib/Either';
import uuid from 'uuid';

import { NonEmptyString } from './non_empty_string';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import * as t from 'io-ts';
import { Either } from 'fp-ts/lib/Either';
import type { Either } from 'fp-ts/lib/Either';

/**
* Types the NonEmptyString as:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { IEsSearchResponse } from '@kbn/data-plugin/common';
import type { IEsSearchResponse } from '@kbn/data-plugin/common';

export type Maybe<T> = T | null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
*/

import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { IEsSearchResponse } from '@kbn/data-plugin/common';
import type { IEsSearchResponse } from '@kbn/data-plugin/common';

import { Inspect, Maybe, PageInfoPaginated } from '../../common';
import { RequestOptions, RequestOptionsPaginated } from '../..';
import type { Inspect, Maybe, PageInfoPaginated } from '../../common';
import type { RequestOptions, RequestOptionsPaginated } from '../..';

export type ActionEdges = estypes.SearchResponse<object>['hits']['hits'];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
* 2.0.
*/

import { IEsSearchResponse } from '@kbn/data-plugin/common';
import type { IEsSearchResponse } from '@kbn/data-plugin/common';

import { Inspect, Maybe, PageInfoPaginated } from '../../common';
import { RequestOptionsPaginated } from '../..';
import { Agent } from '../../../shared_imports';
import type { Inspect, Maybe, PageInfoPaginated } from '../../common';
import type { RequestOptionsPaginated } from '../..';
import type { Agent } from '../../../shared_imports';

export interface AgentsStrategyResponse extends IEsSearchResponse {
edges: Agent[];
Expand Down
12 changes: 6 additions & 6 deletions x-pack/plugins/osquery/common/search_strategy/osquery/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@
*/

import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { IEsSearchRequest } from '@kbn/data-plugin/common';
import { ESQuery } from '../../typed_json';
import {
import type { IEsSearchRequest } from '@kbn/data-plugin/common';
import type { ESQuery } from '../../typed_json';
import type {
ActionsStrategyResponse,
ActionsRequestOptions,
ActionDetailsStrategyResponse,
ActionDetailsRequestOptions,
ActionResultsStrategyResponse,
ActionResultsRequestOptions,
} from './actions';
import { AgentsStrategyResponse, AgentsRequestOptions } from './agents';
import { ResultsStrategyResponse, ResultsRequestOptions } from './results';
import type { AgentsStrategyResponse, AgentsRequestOptions } from './agents';
import type { ResultsStrategyResponse, ResultsRequestOptions } from './results';

import { DocValueFields, SortField, PaginationInputPaginated } from '../common';
import type { DocValueFields, SortField, PaginationInputPaginated } from '../common';

export * from './actions';
export * from './agents';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
*/

import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { IEsSearchResponse } from '@kbn/data-plugin/common';
import type { IEsSearchResponse } from '@kbn/data-plugin/common';

import { Inspect, Maybe, PageInfoPaginated, SortField } from '../../common';
import { RequestOptionsPaginated } from '../..';
import type { Inspect, Maybe, PageInfoPaginated, SortField } from '../../common';
import type { RequestOptionsPaginated } from '../..';

export type ResultEdges = estypes.SearchResponse<unknown>['hits']['hits'];

Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/osquery/common/typed_json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* 2.0.
*/

import { BoolQuery } from '@kbn/es-query';
import { JsonObject } from '@kbn/utility-types';
import type { BoolQuery } from '@kbn/es-query';
import type { JsonObject } from '@kbn/utility-types';

export type ESQuery =
| ESRangeQuery
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/osquery/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import {
import type {
PackagePolicy,
PackagePolicyInput,
PackagePolicyInputStream,
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/osquery/common/utility_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import * as runtimeTypes from 'io-ts';
import { ReactNode } from 'react';
import type { ReactNode } from 'react';

// This type is for typing EuiDescriptionList
export interface DescriptionList {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/osquery/common/utils/build_query/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { isEmpty, isString } from 'lodash/fp';

import { ESQuery } from '../../typed_json';
import type { ESQuery } from '../../typed_json';

export const createQueryFilterClauses = (filterQuery: ESQuery | string | undefined) =>
!isEmpty(filterQuery) ? [isString(filterQuery) ? JSON.parse(filterQuery) : filterQuery] : [];
5 changes: 3 additions & 2 deletions x-pack/plugins/osquery/cypress/tasks/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
*/

import * as yaml from 'js-yaml';
import Url, { UrlObject } from 'url';
import { ROLES } from '../test';
import type { UrlObject } from 'url';
import Url from 'url';
import type { ROLES } from '../test';

/**
* Credentials in the `kibana.dev.yml` config file will be used to authenticate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
getColorForAgentStatus,
getLabelForAgentStatus,
} from './services/agent_status';
import { ActionAgentStatus } from './types';
import type { ActionAgentStatus } from './types';

export const ActionAgentsStatusBadges = memo<{
agentStatus: { [k in ActionAgentStatus]: number };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { EuiColorPaletteDisplay } from '@elastic/eui';
import React, { useMemo } from 'react';

import { AGENT_STATUSES, getColorForAgentStatus } from './services/agent_status';
import { ActionAgentStatus } from './types';
import type { ActionAgentStatus } from './types';

const StyledEuiColorPaletteDisplay = styled(EuiColorPaletteDisplay)`
&.osquery-action-agent-status-bar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ import { useQuery } from 'react-query';

import { i18n } from '@kbn/i18n';
import { lastValueFrom } from 'rxjs';
import type { InspectResponse } from '../common/helpers';
import {
createFilter,
getInspectResponse,
InspectResponse,
generateTablePaginationOptions,
} from '../common/helpers';
import { useKibana } from '../common/lib/kibana';
import {
import type {
ResultEdges,
PageInfoPaginated,
OsqueryQueries,
ActionResultsRequestOptions,
ActionResultsStrategyResponse,
Direction,
} from '../../common/search_strategy';
import { ESTermQuery } from '../../common/typed_json';
import { OsqueryQueries } from '../../common/search_strategy';
import type { ESTermQuery } from '../../common/typed_json';
import { queryClient } from '../query_client';

import { useErrorToast } from '../common/hooks/use_error_toast';
Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/osquery/public/actions/use_action_details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import { i18n } from '@kbn/i18n';
import { lastValueFrom } from 'rxjs';
import { createFilter } from '../common/helpers';
import { useKibana } from '../common/lib/kibana';
import {
OsqueryQueries,
import type {
ActionDetailsRequestOptions,
ActionDetailsStrategyResponse,
} from '../../common/search_strategy';
import { ESTermQuery } from '../../common/typed_json';
import { OsqueryQueries } from '../../common/search_strategy';
import type { ESTermQuery } from '../../common/typed_json';
import { useErrorToast } from '../common/hooks/use_error_toast';

export interface ActionDetailsArgs {
Expand Down
8 changes: 4 additions & 4 deletions x-pack/plugins/osquery/public/actions/use_all_actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ import { useQuery } from 'react-query';

import { i18n } from '@kbn/i18n';
import { lastValueFrom } from 'rxjs';
import type { InspectResponse } from '../common/helpers';
import {
createFilter,
generateTablePaginationOptions,
getInspectResponse,
InspectResponse,
} from '../common/helpers';
import { useKibana } from '../common/lib/kibana';
import {
import type {
ActionEdges,
PageInfoPaginated,
OsqueryQueries,
ActionsRequestOptions,
ActionsStrategyResponse,
Direction,
} from '../../common/search_strategy';
import { ESTermQuery } from '../../common/typed_json';
import { OsqueryQueries } from '../../common/search_strategy';
import type { ESTermQuery } from '../../common/typed_json';

import { useErrorToast } from '../common/hooks/use_error_toast';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { mapKeys } from 'lodash';
import { useQuery } from 'react-query';

import { i18n } from '@kbn/i18n';
import { GetAgentPoliciesResponseItem } from '@kbn/fleet-plugin/common';
import type { GetAgentPoliciesResponseItem } from '@kbn/fleet-plugin/common';
import { useKibana } from '../common/lib/kibana';
import { useErrorToast } from '../common/hooks/use_error_toast';

Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/osquery/public/agents/agent_grouper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
*/

import { AgentGrouper } from './agent_grouper';
import { AGENT_GROUP_KEY, Group, GroupedAgent, GroupOptionValue } from './types';
import type { Group, GroupedAgent, GroupOptionValue } from './types';
import { AGENT_GROUP_KEY } from './types';
import uuid from 'uuid';
import { ALL_AGENTS_LABEL } from './translations';

Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/osquery/public/agents/agent_grouper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
AGENT_POLICY_LABEL,
AGENT_SELECTION_LABEL,
} from './translations';
import { AGENT_GROUP_KEY, Group, GroupOption, GroupedAgent } from './types';
import type { Group, GroupOption, GroupedAgent } from './types';
import { AGENT_GROUP_KEY } from './types';

const getColor = generateColorPicker();

Expand Down
Loading

0 comments on commit 6efef04

Please sign in to comment.