Fixed the eslint types and added the SIEM rules to the base of the project

This commit is contained in:
FrankHassanabad 2019-04-18 18:37:46 -06:00
parent 6b35ff1c86
commit 37d9095819
No known key found for this signature in database
GPG key ID: 0BC9DC0E0023FA5D
58 changed files with 139 additions and 142 deletions

View file

@ -391,6 +391,17 @@ module.exports = {
},
},
/**
* SIEM overrides
*/
{
files: ['x-pack/plugins/siem/**/*.ts'],
rules: {
'@typescript-eslint/no-explicit-any': 'error',
'import/order': 'error',
},
},
/**
* disable jsx-a11y for kbn-ui-framework
*/

View file

@ -129,6 +129,7 @@ declare module '@elastic/eui' {
hasDividers?: boolean;
itemLayoutAlign?: any;
compressed?: boolean;
fullWidth?: any;
};
export const EuiSuperSelect: React.SFC<EuiSuperSelectProps>;

View file

@ -6,6 +6,7 @@
export type JsonValue = null | boolean | number | string | JsonObject | JsonArray;
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface JsonArray extends Array<JsonValue> {}
export interface JsonObject {

View file

@ -12,7 +12,7 @@ import { getConfigSchema, initServerWithKibana, KbnServer } from './server/kiban
const APP_ID = 'siem';
export const APP_NAME = 'SIEM';
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function siem(kibana: any) {
return new kibana.Plugin({
id: APP_ID,

View file

@ -25,7 +25,7 @@ interface AutoSizerProps {
content?: boolean;
onResize?: (size: Measurements) => void;
children: (
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
args: { measureRef: (instance: HTMLElement | null) => any } & Measurements
) => React.ReactNode;
}

View file

@ -246,7 +246,7 @@ describe('Autocomplete', () => {
const wrapperAutocompleteField = wrapper.find(AutocompleteField);
wrapperAutocompleteField.setState({ selectedIndex: null });
const wrapperFixedEuiFieldSearch = wrapper.find(EuiFieldSearch);
// tslint:disable-next-line:no-any -- TODO: FixedEuiFieldSearch fails to import
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO: FixedEuiFieldSearch fails to import
(wrapperFixedEuiFieldSearch as any).props().onSearch();
expect(onSubmit).toHaveBeenCalled();
});

View file

@ -304,7 +304,7 @@ export const FixedEuiFieldSearch: React.SFC<
inputRef?: (element: HTMLInputElement | null) => void;
onSearch: (value: string) => void;
}
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
> = EuiFieldSearch as any;
const AutocompleteContainer = euiStyled.div`

View file

@ -107,7 +107,7 @@ const getEuiIconType = (suggestionType: string) => {
}
};
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const getEuiIconColor = (theme: any, suggestionType: string): string => {
switch (suggestionType) {
case 'field':

View file

@ -76,7 +76,9 @@ export const FlowTargetSelect = pure<FlowTargetSelectProps>(
: toggleTargetOptions(id, displayTextOverride)
}
valueOfSelected={selectedTarget}
onChange={newFlowTarget => onChangeTarget(newFlowTarget, updateFlowTargetAction)}
onChange={(newFlowTarget: FlowTarget) =>
onChangeTarget(newFlowTarget, updateFlowTargetAction)
}
isLoading={isLoading}
/>
)

View file

@ -4,7 +4,6 @@ exports[`Load More Table Component rendering it renders the default load more ta
<styled.div>
<EuiTitle
size="s"
textTransform="none"
>
<h3>
Hosts

View file

@ -49,10 +49,10 @@ interface BasicTableProps<T> {
loadMore: () => void;
itemsPerRow?: ItemsPerRow[];
onChange?: (criteria: Criteria) => void;
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
pageOfItems: any[];
sorting?: SortingBasicTable;
title: string | React.ReactNode;
title: string | React.ReactElement;
updateLimitPagination: (limit: number) => void;
}
@ -165,7 +165,9 @@ export class LoadMoreTable<T> extends React.PureComponent<BasicTableProps<T>, Ba
/>
</>
)}
<EuiTitle size="s">{title}</EuiTitle>
<EuiTitle size="s">
<>{title}</>
</EuiTitle>
<EuiBasicTable
items={pageOfItems}
columns={columns}

View file

@ -10,7 +10,7 @@ import { pure } from 'recompose';
import styled, { injectGlobal } from 'styled-components';
// SIDE EFFECT: the following `injectGlobal` overrides default styling in angular code that was not theme-friendly
// tslint:disable-next-line:no-unused-expression
// eslint-disable-next-line no-unused-expressions
injectGlobal`
.euiPanel-loading-hide-border {
border: none;

View file

@ -24,10 +24,10 @@ describe('FirstLastSeen Component', async () => {
const firstSeen = 'Apr 8, 2019 @ 16:09:40.692';
const lastSeen = 'Apr 8, 2019 @ 18:35:45.064';
// tslint:disable-next-line:no-console
// eslint-disable-next-line no-console
const originalError = console.error;
beforeAll(() => {
// tslint:disable-next-line:no-console
// eslint-disable-next-line no-console
console.error = (...args: string[]) => {
if (/Warning.*not wrapped in act/.test(args[0])) {
return;
@ -37,7 +37,7 @@ describe('FirstLastSeen Component', async () => {
});
afterAll(() => {
// tslint:disable-next-line:no-console
// eslint-disable-next-line no-console
console.error = originalError;
});

View file

@ -25,10 +25,10 @@ describe('Host Summary Component', () => {
// fixes this: https://github.com/facebook/react/pull/14853
// For us that mean we need to upgrade to 16.9.0
// and we will be able to do that when we are in master
// tslint:disable-next-line:no-console
// eslint-disable-next-line no-console
const originalError = console.error;
beforeAll(() => {
// tslint:disable-next-line:no-console
// eslint-disable-next-line no-console
console.error = (...args: string[]) => {
if (/Warning.*not wrapped in act/.test(args[0])) {
return;
@ -38,7 +38,7 @@ describe('Host Summary Component', () => {
});
afterAll(() => {
// tslint:disable-next-line:no-console
// eslint-disable-next-line no-console
console.error = originalError;
});

View file

@ -79,7 +79,7 @@ export const getEuiDescriptionList = (
return (
<React.Fragment key={`host-summary-${field}-${title}`}>
<EuiDescriptionListTitle>{title}</EuiDescriptionListTitle>
{/*Using EuiDescriptionListDescription throws off sizing of Draggable*/}
{/* Using EuiDescriptionListDescription throws off sizing of Draggable */}
<div>
{loading ? (
<EuiLoadingSpinner size="m" />

View file

@ -9,7 +9,7 @@ import styled from 'styled-components';
import { injectGlobal } from 'styled-components';
// SIDE EFFECT: the following `injectGlobal` overrides default styling in angular code that was not theme-friendly
// tslint:disable-next-line:no-unused-expression
// eslint-disable-next-line no-unused-expressions
injectGlobal`
div.app-wrapper {
background-color: rgba(0,0,0,0);

View file

@ -21,10 +21,10 @@ describe('FirstLastSeen Component', async () => {
// fixes this: https://github.com/facebook/react/pull/14853
// For us that mean we need to upgrade to 16.9.0
// and we will be able to do that when we are in master
// tslint:disable-next-line:no-console
// eslint-disable-next-line no-console
const originalError = console.error;
beforeAll(() => {
// tslint:disable-next-line:no-console
// eslint-disable-next-line no-console
console.error = (...args: string[]) => {
if (/Warning.*not wrapped in act/.test(args[0])) {
return;
@ -34,7 +34,7 @@ describe('FirstLastSeen Component', async () => {
});
afterAll(() => {
// tslint:disable-next-line:no-console
// eslint-disable-next-line no-console
console.error = originalError;
});

View file

@ -22,7 +22,7 @@ export type OnResize = (
export const resizeCursorStyle = 'col-resize';
export const globalResizeCursorClassName = 'global-resize-cursor';
// tslint:disable-next-line:no-unused-expression
// eslint-disable-next-line no-unused-expressions
injectGlobal`
.${globalResizeCursorClassName} {
* {

View file

@ -21,7 +21,7 @@ export const EVENTS_SELECT_WIDTH = 60; // px
// SIDE EFFECT: the following `injectGlobal` overrides
// the style of the select items
// tslint:disable-next-line:no-unused-expression
// eslint-disable-next-line
injectGlobal`
.eventsSelectItem {
width: 100% !important;

View file

@ -17,7 +17,7 @@ export const DEFAULT_COLUMN_MIN_WIDTH = 180; // px
/** The default minimum width of a column of type `date` */
export const DEFAULT_DATE_COLUMN_MIN_WIDTH = 240; // px
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const omitTypenameAndEmpty = (k: string, v: any): any | undefined =>
k !== '__typename' && v != null ? v : undefined;
@ -27,7 +27,7 @@ export const eventHasNotes = (noteIds: string[]): boolean => !isEmpty(noteIds);
export const getPinTooltip = ({
isPinned,
// tslint:disable-next-line:no-shadowed-variable
// eslint-disable-next-line no-shadow
eventHasNotes,
}: {
isPinned: boolean;

View file

@ -53,10 +53,13 @@ describe('GenericRowRenderer', () => {
});
test('should return false when action is set to some other value', () => {
auditd.event != null && auditd.event.action != null
? (auditd.event.action[0] = 'some other value')
: expect(auditd.event).toBeDefined();
expect(connectedToRenderer.isInstance(auditd)).toBe(false);
if (auditd.event != null && auditd.event.action != null) {
auditd.event.action[0] = 'some other value';
expect(connectedToRenderer.isInstance(auditd)).toBe(false);
} else {
// will fail and give you an error if either is not defined as a mock
expect(auditd.event).toBeDefined();
}
});
test('should render children normally if it does not have a auditd object', () => {
@ -129,10 +132,13 @@ describe('GenericRowRenderer', () => {
});
test('should return false when action is set to some other value', () => {
auditdFile.event != null && auditdFile.event.action != null
? (auditdFile.event.action[0] = 'some other value')
: expect(auditdFile.event).toBeDefined();
expect(fileToRenderer.isInstance(auditdFile)).toBe(false);
if (auditdFile.event != null && auditdFile.event.action != null) {
auditdFile.event.action[0] = 'some other value';
expect(fileToRenderer.isInstance(auditdFile)).toBe(false);
} else {
// will fail and give you an error if either is not defined as a mock
expect(auditdFile.event).toBeDefined();
}
});
test('should render children normally if it does not have a auditd object', () => {

View file

@ -54,26 +54,6 @@ describe('SessionUserHostWorkingDir', () => {
expect(wrapper.text()).toEqual('Session');
});
test('it renders with just eventId and contextId', () => {
const wrapper = mountWithIntl(
<TestProviders>
<EuiFlexItem grow={false} component="span">
<SessionUserHostWorkingDir
eventId="eventid-123"
contextId="contextid-123"
session={undefined}
hostName={undefined}
userName={undefined}
primary={undefined}
secondary={undefined}
workingDirectory={undefined}
/>
</EuiFlexItem>
</TestProviders>
);
expect(wrapper.text()).toEqual('Session');
});
test('it renders with only eventId, contextId, session', () => {
const wrapper = mountWithIntl(
<TestProviders>

View file

@ -53,12 +53,15 @@ describe('GenericRowRenderer', () => {
});
test('should return false when action is set to some other value', () => {
system.event != null && system.event.action != null
? (system.event.action[0] = 'some other value')
: expect(system.event).toBeDefined();
expect(connectedToRenderer.isInstance(system)).toBe(false);
if (system.event != null && system.event.action != null) {
system.event.action[0] = 'some other value';
expect(connectedToRenderer.isInstance(system)).toBe(false);
} else {
// if system.event or system.event.action is not defined in the mock
// then we will get an error here
expect(system.event).toBeDefined();
}
});
test('should render a system row', () => {
const children = connectedToRenderer.renderRow({
browserFields: mockBrowserFields,
@ -114,10 +117,12 @@ describe('GenericRowRenderer', () => {
});
test('should return false when action is set to some other value', () => {
systemFile.event != null && systemFile.event.action != null
? (systemFile.event.action[0] = 'some other value')
: expect(systemFile.event).toBeDefined();
expect(fileToRenderer.isInstance(systemFile)).toBe(false);
if (systemFile.event != null && systemFile.event.action != null) {
systemFile.event.action[0] = 'some other value';
expect(fileToRenderer.isInstance(systemFile)).toBe(false);
} else {
expect(systemFile.event).toBeDefined();
}
});
test('should render a system row', () => {

View file

@ -53,6 +53,10 @@ export const StarIcon = pure<{
timelineId: string;
updateIsFavorite: UpdateIsFavorite;
}>(({ isFavorite, timelineId: id, updateIsFavorite }) => (
// TODO: 1 error is: Visible, non-interactive elements with click handlers must have at least one keyboard listener
// TODO: 2 error is: Elements with the 'button' interactive role must be focusable
// TODO: Investigate this error
// eslint-disable-next-line
<div role="button" onClick={() => updateIsFavorite({ id, isFavorite: !isFavorite })}>
{isFavorite ? (
<EuiToolTip data-test-subj="timeline-favorite-filled-star-tool-tip" content={i18n.FAVORITE}>

View file

@ -40,7 +40,7 @@ type UpdateDescription = ({ id, description }: { id: string; description: string
// SIDE EFFECT: the following `injectGlobal` overrides `EuiPopover`
// and `EuiToolTip` global styles:
// tslint:disable-next-line:no-unused-expression
// eslint-disable-next-line no-unused-expressions
injectGlobal`
.euiPopover__panel.euiPopover__panel-isOpen {
z-index: 9900 !important;

View file

@ -28,7 +28,7 @@ import * as i18n from './translations';
const timelineSelectModeItemsClassName = 'timelineSelectModeItemsClassName';
// SIDE EFFECT: the following creates a global class selector
// tslint:disable-next-line:no-unused-expression
// eslint-disable-next-line no-unused-expressions
injectGlobal`
.${timelineSelectModeItemsClassName} {
width: 350px !important;

View file

@ -10,8 +10,6 @@ exports[`TruncatableText renders correctly against snapshot 1`] = `
<EuiText
className="c0"
grow={true}
size="m"
width="50px"
>
Hiding in plain sight

View file

@ -18,16 +18,16 @@ export interface QueryTemplateProps {
filterQuery?: ESQuery | string;
poll?: number;
}
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type FetchMoreOptionsArgs<TData, TVariables> = FetchMoreQueryOptions<any, any> &
FetchMoreOptions<TData, TVariables>;
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type PromiseApolloQueryResult = Promise<ApolloQueryResult<any>>;
export class QueryTemplate<
T extends QueryTemplateProps,
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
TData = any,
TVariables = OperationVariables
> extends React.PureComponent<T, TData, TVariables> {

View file

@ -1,4 +1,5 @@
/* tslint:disable */
/* eslint-disable */
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;

View file

@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
// eslint-disable-next-line max-classes-per-file
import { IModule, IScope } from 'angular';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
@ -32,9 +33,9 @@ export class AppKibanaFrameworkAdapter implements AppFrameworkAdapter {
private adapterService: KibanaAdapterServiceProvider;
private timezoneProvider: AppTimezoneProvider;
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
private rootComponent: React.ReactElement<any> | null = null;
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
private breadcrumbsComponent: React.ReactElement<any> | null = null;
constructor(uiModule: IModule, uiRoutes: KibanaUIRoutes, timezoneProvider: AppTimezoneProvider) {
@ -43,19 +44,19 @@ export class AppKibanaFrameworkAdapter implements AppFrameworkAdapter {
this.register(uiModule, uiRoutes);
}
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
public setUISettings = (key: string, value: any) => {
this.adapterService.callOrBuffer(({ config }) => {
config.set(key, value);
});
};
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
public render = (component: React.ReactElement<any>) => {
this.adapterService.callOrBuffer(() => (this.rootComponent = component));
};
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
public renderBreadcrumbs = (component: React.ReactElement<any>) => {
this.adapterService.callOrBuffer(() => (this.breadcrumbsComponent = component));
};
@ -125,7 +126,7 @@ export class AppKibanaFrameworkAdapter implements AppFrameworkAdapter {
kbnVersion: string,
Private: <Provider>(provider: Provider) => Provider,
// @ts-ignore: inject kibanaAdapter to force eager installation
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
kibanaAdapter: any
) => {
this.timezone = Private(this.timezoneProvider)();
@ -149,7 +150,6 @@ export class AppKibanaFrameworkAdapter implements AppFrameworkAdapter {
};
}
// tslint:disable-next-line: max-classes-per-file
class KibanaAdapterServiceProvider {
public serviceRefs: AppKibanaAdapterServiceRefs | null = null;
public bufferedCalls: Array<AppBufferedKibanaServiceCall<AppKibanaAdapterServiceRefs>> = [];

View file

@ -70,6 +70,10 @@ export class Clipboard extends React.PureComponent<Props, State> {
public render() {
const { toastLifeTimeMs = 5000 } = this.props;
// TODO: 1 error is: Visible, non-interactive elements with click handlers must have at least one keyboard listener
// TODO: 2 error is: Elements with the 'button' interactive role must be focusable
// TODO: Investigate this error
/* eslint-disable */
return (
<>
<div role="button" data-test-subj="clipboard" onClick={this.onClick}>
@ -82,6 +86,7 @@ export class Clipboard extends React.PureComponent<Props, State> {
/>
</>
);
/* eslint-enable */
}
private onClick = (event: React.MouseEvent<HTMLDivElement>) => {

View file

@ -43,7 +43,7 @@ export function compose(): AppFrontendLibs {
schema,
});
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const cache = new InMemoryCache((window as any).__APOLLO_CLIENT__);
const apolloClient = new ApolloClient({

View file

@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { IModule, IScope } from 'angular';
import { IScope } from 'angular';
import { NormalizedCacheObject } from 'apollo-cache-inmemory';
import ApolloClient from 'apollo-client';
import React from 'react';
@ -29,18 +29,14 @@ export interface AppFrameworkAdapter {
scaledDateFormat?: string;
timezone?: string;
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
setUISettings(key: string, value: any): void;
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
render(component: React.ReactElement<any>): void;
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
renderBreadcrumbs(component: React.ReactElement<any>): void;
}
export interface AppFrameworkAdapterConstructible {
new (uiModule: IModule, timezoneProvider: AppTimezoneProvider): AppFrameworkAdapter;
}
export interface AppObservableApiPostParams<RequestBody extends {} = {}> {
url: string;
body?: RequestBody;
@ -58,16 +54,16 @@ export interface AppObservableApi {
}
export interface AppUiKibanaAdapterScope extends IScope {
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
breadcrumbs: any[];
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
topNavMenu: any[];
}
export interface AppKibanaUIConfig {
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
get(key: string): any;
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
set(key: string, value: any): Promise<boolean>;
}

View file

@ -12,5 +12,5 @@ export const schemas = [...serverSchemas];
// this default export is used to feed the combined types to the gql-gen tool
// which generates the corresponding typescript types
// tslint:disable-next-line:no-default-export
// eslint-disable-next-line import/no-default-export
export default buildSchemaFromTypeDefinitions(schemas);

View file

@ -2,6 +2,7 @@
"flattenTypes": true,
"generatorConfig": {
"prepend": [
"/* eslint-disable */",
"/*",
" * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one",
" * or more contributor license agreements. Licensed under the Elastic License;",

View file

@ -3,6 +3,7 @@
"generatorConfig": {
"contextType": "SiemContext",
"prepend": [
"/* eslint-disable */",
"/*",
" * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one",
" * or more contributor license agreements. Licensed under the Elastic License;",

View file

@ -63,7 +63,7 @@ const convertToString = (value: object | number | boolean | string): string => {
return value.toString();
};
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const convertArrayToString = (values: any[]): string[] | string => {
if (Array.isArray(values)) {
return values.filter(item => item != null).map(item => convertArrayToString(item)) as string[];

View file

@ -68,10 +68,6 @@ describe('Test ToBooleanArray Scalar Resolver', () => {
expect(toBooleanArrayScalar.serialize(['true'])).toEqual([true]);
});
test('Test string with gibberish returning false', () => {
expect(toBooleanArrayScalar.serialize('some gibberish')).toEqual([false]);
});
test('Test number with 0 returning false', () => {
expect(toBooleanArrayScalar.serialize(0)).toEqual([false]);
});

View file

@ -64,7 +64,7 @@ const convertToBoolean = (value: object | number | boolean | string): boolean =>
}
};
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const convertArrayToBoolean = (values: any[]): boolean[] | boolean => {
if (Array.isArray(values)) {
return values

View file

@ -36,7 +36,7 @@ describe('Test ToDateArray Scalar Resolver', () => {
]);
});
test('Test Basic Date String in an array', () => {
test('Test Two Basic Date Strings in an array', () => {
expect(
toDateArrayScalar.serialize(['2019-04-16T03:14:13.704Z', '2019-05-16T03:14:13.704Z'])
).toEqual(['2019-04-16T03:14:13.704Z', '2019-05-16T03:14:13.704Z']);

View file

@ -58,7 +58,7 @@ const convertToDate = (value: object | number | boolean | string): string => {
}
};
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const convertArrayToDate = (values: any[]): string[] | string => {
if (Array.isArray(values)) {
return values.filter(item => item != null).map(item => convertArrayToDate(item)) as string[];

View file

@ -62,7 +62,7 @@ const convertToNumber = (value: object | number | boolean | string): number => {
}
};
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const convertArrayToNumber = (values: any[]): number[] | number => {
if (Array.isArray(values)) {
return values.filter(item => item != null).map(item => convertArrayToNumber(item)) as number[];

View file

@ -7,7 +7,6 @@
import { Logger } from '../../utils/logger';
import { SiemContext } from '../index';
/* tslint:disable */
export const mockSourceData = {
id: 'default',
configuration: {
@ -38,7 +37,6 @@ export const mockSourceData = {
],
},
};
/* tslint:enable */
export const getSourceQueryMock = (logger: Logger) => ({
source: (root: unknown, args: unknown, context: SiemContext) => {

View file

@ -9,12 +9,7 @@ import { SiemContext } from '../index';
import { mockSourceData } from './source.mock';
/* tslint:disable */
export const sourcesDataMock =
[
mockSourceData,
];
/* tslint:enable */
export const sourcesDataMock = [mockSourceData];
export const getAllSourcesQueryMock = (logger: Logger) => ({
allSources: (root: unknown, args: unknown, context: SiemContext) => {

View file

@ -1,4 +1,5 @@
/* tslint:disable */
/* eslint-disable */
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;

View file

@ -12,7 +12,7 @@ export class KibanaConfigurationAdapter<Configuration>
implements ConfigurationAdapter<Configuration> {
private readonly server: ServerWithConfig;
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
constructor(server: any) {
if (!isServerWithConfig(server)) {
throw new Error('Failed to find configuration on server.');
@ -46,11 +46,11 @@ export class KibanaConfigurationAdapter<Configuration>
}
interface ServerWithConfig {
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
config(): any;
}
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function isServerWithConfig(maybeServer: any): maybeServer is ServerWithConfig {
return (
Joi.validate(
@ -63,11 +63,11 @@ function isServerWithConfig(maybeServer: any): maybeServer is ServerWithConfig {
}
interface KibanaConfiguration {
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
get(key: string): any;
}
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function isKibanaConfiguration(maybeConfiguration: any): maybeConfiguration is KibanaConfiguration {
return (
Joi.validate(

View file

@ -22,7 +22,7 @@ export interface EventsRequestOptions extends RequestOptions {
}
export interface EventSource {
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[field: string]: any;
}
@ -30,7 +30,7 @@ export interface EventHit extends SearchHit {
sort: string[];
_source: EventSource;
aggregations: {
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[agg: string]: any;
};
}

View file

@ -32,8 +32,8 @@ export const graphqlHapi: Plugin<HapiGraphQLPluginOptions> = {
try {
const query =
request.method === 'post'
? (request.payload as Record<string, any>) // tslint:disable-line:no-any
: (request.query as Record<string, any>); // tslint:disable-line:no-any
? (request.payload as Record<string, any>) // eslint-disable-line @typescript-eslint/no-explicit-any
: (request.query as Record<string, any>); // eslint-disable-line @typescript-eslint/no-explicit-any
const gqlResponse = await runHttpQuery([request], {
method: request.method.toUpperCase(),
@ -87,7 +87,7 @@ export type HapiGraphiQLOptionsFunction = (
export interface HapiGraphiQLPluginOptions {
path: string;
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
route?: any;
graphiqlOptions: GraphiQL.GraphiQLData | HapiGraphiQLOptionsFunction;

View file

@ -36,12 +36,12 @@ export class KibanaBackendFrameworkAdapter implements FrameworkAdapter {
this.version = hapiServer.plugins.kibana.status.plugin.version;
}
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
public async callWithRequest(
req: FrameworkRequest<Legacy.Request>,
endpoint: string,
params: CallWithRequestParams,
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
...rest: any[]
) {
const internalRequest = req[internalFrameworkRequest];
@ -109,7 +109,7 @@ export class KibanaBackendFrameworkAdapter implements FrameworkAdapter {
throw new Error('Failed to access indexPatternsService for the request');
}
return this.server.indexPatternsServiceFactory({
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
callCluster: async (method: string, args: [GenericParams], ...rest: any[]) => {
const fieldCaps = await this.callWithRequest(
request,
@ -138,7 +138,7 @@ export function wrapRequest<InternalRequest extends WrappableRequest>(
interface ServerWithIndexPatternsServiceFactory extends Server {
indexPatternsServiceFactory(options: {
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
callCluster: (...args: any[]) => any;
}): FrameworkIndexPatternsService;
}
@ -146,5 +146,5 @@ interface ServerWithIndexPatternsServiceFactory extends Server {
const isServerWithIndexPatternsServiceFactory = (
server: Server
): server is ServerWithIndexPatternsServiceFactory =>
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
typeof (server as any).indexPatternsServiceFactory === 'function';

View file

@ -41,14 +41,14 @@ export interface FrameworkAdapter {
callWithRequest(
req: FrameworkRequest,
method: 'indices.getMapping',
options?: IndicesGetMappingParams
options?: IndicesGetMappingParams // eslint-disable-line
): Promise<MappingResponse>;
callWithRequest(
req: FrameworkRequest,
method: 'indices.getAlias' | 'indices.get',
method: 'indices.getAlias' | 'indices.get', // eslint-disable-line
options?: object
): Promise<DatabaseGetIndicesResponse>;
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
getIndexPatternsService(req: FrameworkRequest<any>): FrameworkIndexPatternsService;
}
@ -59,7 +59,7 @@ export interface FrameworkRequest<InternalRequest extends WrappableRequest = Wra
query: InternalRequest['query'];
}
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export interface WrappableRequest<Payload = any, Params = any, Query = any> {
payload: Payload;
params: Params;

View file

@ -98,7 +98,7 @@ describe('hosts elasticsearch_adapter', () => {
expect(data).toEqual(expected);
});
test('it formats a host with a source of name correctly', () => {
test('it formats a host with a source of id correctly', () => {
const fields: ReadonlyArray<string> = ['host.name'];
const data = formatHostEdgesData(fields, buckets);
const expected: HostsEdges = {

View file

@ -7,7 +7,6 @@
import { getOr } from 'lodash/fp';
import { KpiNetworkData } from '../../graphql/types';
// tslint:disable-next-line: prettier
import { FrameworkAdapter, FrameworkRequest, RequestBasicOptions } from '../framework';
import { TermAggregation } from '../types';

View file

@ -58,7 +58,7 @@ export class ElasticsearchSourceStatusAdapter implements SourceStatusAdapter {
}
const withDefaultIfNotFound = <DefaultValue>(defaultValue: DefaultValue) => (
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
error: any
): DefaultValue => {
if (error && error.status === 404) {

View file

@ -74,15 +74,15 @@ export interface SearchResponse<T> {
_version?: number;
_explanation?: Explanation;
fields?: string[];
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
highlight?: any;
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
inner_hits?: any;
matched_queries?: string[];
sort?: string[];
}>;
};
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
aggregations?: any;
}

View file

@ -55,7 +55,7 @@ describe('events elasticsearch_adapter', () => {
expect(merge2).toEqual({ node: { os: 'os-1', version: 'version-1' } });
});
test('it should merge two fields correctly', () => {
test('it should merge two fields correctly with values', () => {
const existing = { node: {} };
const merge1 = mergeFieldsWithHit('level1.value1', existing, mockFieldMap, mockHits);
const merge2 = mergeFieldsWithHit('level1.value2', merge1, mockFieldMap, mockHits);

View file

@ -10,7 +10,7 @@ const LOGGING_TAGS = ['siem'];
// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/hapi/v16/index.d.ts#L318
export type HapiLogger = (
tags: string | string[],
// tslint:disable-next-line:ban-types
// eslint-disable-next-line
data?: string | Object | Function,
timestamp?: number
) => void;

View file

@ -53,7 +53,7 @@ export type SubsetResolverWithoutFields<R, ExcludedFields extends string> = R ex
export type ResolverWithParent<Resolver_, Parent> = Resolver_ extends Resolver<
infer Result,
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
any,
infer Context,
infer Args
@ -61,7 +61,7 @@ export type ResolverWithParent<Resolver_, Parent> = Resolver_ extends Resolver<
? Resolver<Result, Parent, Context, Args>
: never;
// tslint:disable-next-line:no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type AppResolver<Result = any, Parent = any, Context = any, Args = any> = Resolver<
AppResolverResult<Result>,
Parent,

View file

@ -1,5 +0,0 @@
extends: ../../tslint.yaml
rules:
no-any: true
ordered-imports: [true, { 'grouped-imports': true }]