Skip to content

Commit

Permalink
Fix case and security_solution types
Browse files Browse the repository at this point in the history
  • Loading branch information
patrykkopycinski committed Jun 7, 2020
1 parent 4a4bd7f commit 6b920ab
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion x-pack/plugins/case/server/routes/api/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ export const flattenCaseSavedObject = ({
version: savedObject.version ?? '0',
comments: flattenCommentSavedObjects(comments),
totalComment,
connector_id: savedObject.attributes.connector_id ?? caseConfigureConnectorId,
...savedObject.attributes,
connector_id: savedObject.attributes.connector_id ?? caseConfigureConnectorId,
});

export const transformComments = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const file_name = t.string;
* TODO: Right now the filters is an "unknown", when it could more than likely
* become the actual ESFilter as a type.
*/
export const filters = t.array(t.unknown); // Filters are not easily type-able yet
export const filters = t.array(t.record(t.string, t.unknown)); // Filters are not easily type-able yet

/**
* Params is an "object", since it is a type of AlertActionParams which is action templates.
Expand All @@ -32,7 +32,7 @@ export const filters = t.array(t.unknown); // Filters are not easily type-able y
export const action_group = t.string;
export const action_id = t.string;
export const action_action_type_id = t.string;
export const action_params = t.object;
export const action_params = t.record(t.string, t.union([t.string, t.array(t.string)]));
export const action = t.exact(
t.type({
group: action_group,
Expand Down Expand Up @@ -75,7 +75,7 @@ export const machine_learning_job_id = t.string;
* TODO: Strip away extra information and possibly even "freeze" this object
* so we have tighter control over 3rd party data structures.
*/
export const meta = t.object;
export const meta = t.record(t.string, t.string);
export const max_signals = PositiveIntegerGreaterThanZero;
export const name = t.string;
export const risk_score = RiskScore;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
*/

import { ESTermQuery } from '../../../../../common/typed_json';
import { NarrowDateRange } from '../../../components/ml/types';
import {
AnomaliesHostTableProps,
AnomaliesNetworkTableProps,
NarrowDateRange,
} from '../../../components/ml/types';
import { UpdateDateRange } from '../../../components/charts/common';
import { SetQuery } from '../../../../hosts/pages/navigation/types';
import { FlowTarget } from '../../../../graphql/types';
import { HostsType } from '../../../../hosts/store/model';
import { NetworkType } from '../../../../network/store//model';
import { AnomaliesHostTable } from '../../../components/ml/tables/anomalies_host_table';
import { AnomaliesNetworkTable } from '../../../components/ml/tables/anomalies_network_table';

interface QueryTabBodyProps {
type: HostsType | NetworkType;
Expand All @@ -21,7 +23,14 @@ interface QueryTabBodyProps {

export type AnomaliesQueryTabBodyProps = QueryTabBodyProps & {
anomaliesFilterQuery?: object;
AnomaliesTableComponent: typeof AnomaliesHostTable | typeof AnomaliesNetworkTable;
AnomaliesTableComponent: React.NamedExoticComponent<
| (AnomaliesHostTableProps & {
type: HostsType & NetworkType;
})
| (AnomaliesNetworkTableProps & {
type: HostsType & NetworkType;
})
>;
deleteQuery?: ({ id }: { id: string }) => void;
endDate: number;
flowTarget?: FlowTarget;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { defaults } from 'lodash/fp';
import { defaultsDeep } from 'lodash/fp';
import { LegacyEndpointEvent } from '../../../common/endpoint/types';

type DeepPartial<T> = { [K in keyof T]?: DeepPartial<T[K]> };
Expand All @@ -15,7 +15,7 @@ type DeepPartial<T> = { [K in keyof T]?: DeepPartial<T[K]> };
* The other fields are populated by the function unless provided in 'parts'
*/
export function mockProcessEvent(parts: DeepPartial<LegacyEndpointEvent>): LegacyEndpointEvent {
return defaults(
return defaultsDeep(
{
endgame: {
event_timestamp: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export const searchAfterAndBulkCreate = async ({
try {
logger.debug(`sortIds: ${sortId}`);
const {
// @ts-ignore https://github.com/microsoft/TypeScript/issues/35546
searchResult,
searchDuration,
}: { searchResult: SignalSearchResponse; searchDuration: string } = await singleSearchAfter({
Expand Down Expand Up @@ -140,7 +141,7 @@ export const searchAfterAndBulkCreate = async ({

// filter out the search results that match with the values found in the list.
// the resulting set are valid signals that are not on the allowlist.
const filteredEvents =
const filteredEvents: SignalSearchResponse =
listClient != null
? await filterEventsAgainstList({
listClient,
Expand Down

0 comments on commit 6b920ab

Please sign in to comment.