Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.9] [Security Solution] Update filter (#73350) #73783

Merged
merged 1 commit into from
Jul 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 18 additions & 24 deletions x-pack/plugins/security_solution/public/graphql/introspection.json
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,6 @@
"type": { "kind": "ENUM", "name": "TimelineType", "ofType": null },
"defaultValue": null
},
{
"name": "templateTimelineType",
"description": "",
"type": { "kind": "ENUM", "name": "TemplateTimelineType", "ofType": null },
"defaultValue": null
},
{
"name": "status",
"description": "",
Expand Down Expand Up @@ -10981,24 +10975,6 @@
],
"possibleTypes": null
},
{
"kind": "ENUM",
"name": "TemplateTimelineType",
"description": "",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": [
{
"name": "elastic",
"description": "",
"isDeprecated": false,
"deprecationReason": null
},
{ "name": "custom", "description": "", "isDeprecated": false, "deprecationReason": null }
],
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "ResponseTimelines",
Expand Down Expand Up @@ -13166,6 +13142,24 @@
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{
"kind": "ENUM",
"name": "TemplateTimelineType",
"description": "",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": [
{
"name": "elastic",
"description": "",
"isDeprecated": false,
"deprecationReason": null
},
{ "name": "custom", "description": "", "isDeprecated": false, "deprecationReason": null }
],
"possibleTypes": null
}
],
"directives": [
Expand Down
13 changes: 5 additions & 8 deletions x-pack/plugins/security_solution/public/graphql/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,11 +397,6 @@ export enum SortFieldTimeline {
created = 'created',
}

export enum TemplateTimelineType {
elastic = 'elastic',
custom = 'custom',
}

export enum NetworkDirectionEcs {
inbound = 'inbound',
outbound = 'outbound',
Expand All @@ -428,6 +423,11 @@ export enum FlowDirection {
biDirectional = 'biDirectional',
}

export enum TemplateTimelineType {
elastic = 'elastic',
custom = 'custom',
}

export type ToStringArrayNoNullable = any;

export type ToIFieldSubTypeNonNullable = any;
Expand Down Expand Up @@ -2334,8 +2334,6 @@ export interface GetAllTimelineQueryArgs {

timelineType?: Maybe<TimelineType>;

templateTimelineType?: Maybe<TemplateTimelineType>;

status?: Maybe<TimelineStatus>;
}
export interface AuthenticationsSourceArgs {
Expand Down Expand Up @@ -4435,7 +4433,6 @@ export namespace GetAllTimeline {
sort?: Maybe<SortTimeline>;
onlyUserFavorite?: Maybe<boolean>;
timelineType?: Maybe<TimelineType>;
templateTimelineType?: Maybe<TemplateTimelineType>;
status?: Maybe<TimelineStatus>;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const StatefulRecentTimelinesComponent = React.memo<Props>(

const { fetchAllTimeline, timelines, loading } = useGetAllTimeline();
const timelineType = TimelineType.default;
const { templateTimelineType, timelineStatus } = useTimelineStatus({ timelineType });
const { timelineStatus } = useTimelineStatus({ timelineType });
useEffect(() => {
fetchAllTimeline({
pageInfo: {
Expand All @@ -100,9 +100,8 @@ const StatefulRecentTimelinesComponent = React.memo<Props>(
onlyUserFavorite: filterBy === 'favorites',
status: timelineStatus,
timelineType,
templateTimelineType,
});
}, [fetchAllTimeline, filterBy, timelineStatus, timelineType, templateTimelineType]);
}, [fetchAllTimeline, filterBy, timelineStatus, timelineType]);

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ export const StatefulOpenTimelineComponent = React.memo<OpenTimelineOwnProps>(
});
const {
timelineStatus,
templateTimelineType,
templateTimelineFilter,
installPrepackagedTimelines,
} = useTimelineStatus({
Expand All @@ -147,7 +146,6 @@ export const StatefulOpenTimelineComponent = React.memo<OpenTimelineOwnProps>(
},
onlyUserFavorite: onlyFavorites,
timelineType,
templateTimelineType,
status: timelineStatus,
});
}, [
Expand All @@ -159,7 +157,6 @@ export const StatefulOpenTimelineComponent = React.memo<OpenTimelineOwnProps>(
sortDirection,
timelineType,
timelineStatus,
templateTimelineType,
onlyFavorites,
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ describe('SelectableTimeline', () => {
status: null,
onlyUserFavorite: false,
timelineType: TimelineType.default,
templateTimelineType: null,
};
beforeAll(() => {
mount(<SelectableTimeline {...props} />);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ const SelectableTimelineComponent: React.FC<SelectableTimelineProps> = ({
onlyUserFavorite: onlyFavorites,
status: null,
timelineType,
templateTimelineType: null,
});
}, [fetchAllTimeline, onlyFavorites, pageSize, searchTimelineValue, timelineType]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export const allTimelinesQuery = gql`
$sort: SortTimeline
$onlyUserFavorite: Boolean
$timelineType: TimelineType
$templateTimelineType: TemplateTimelineType
$status: TimelineStatus
) {
getAllTimeline(
Expand All @@ -22,7 +21,6 @@ export const allTimelinesQuery = gql`
sort: $sort
onlyUserFavorite: $onlyUserFavorite
timelineType: $timelineType
templateTimelineType: $templateTimelineType
status: $status
) {
totalCount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
TimelineType,
TimelineTypeLiteralWithNull,
TimelineStatusLiteralWithNull,
TemplateTimelineTypeLiteralWithNull,
} from '../../../../common/types/timeline';

export interface AllTimelinesArgs {
Expand Down Expand Up @@ -55,7 +54,6 @@ export interface AllTimelinesVariables {
sort: SortTimeline;
status: TimelineStatusLiteralWithNull;
timelineType: TimelineTypeLiteralWithNull;
templateTimelineType: TemplateTimelineTypeLiteralWithNull;
}

export const ALL_TIMELINE_QUERY_ID = 'FETCH_ALL_TIMELINES';
Expand Down Expand Up @@ -121,7 +119,6 @@ export const useGetAllTimeline = (): AllTimelinesArgs => {
sort,
status,
timelineType,
templateTimelineType,
}: AllTimelinesVariables) => {
let didCancel = false;
const abortCtrl = new AbortController();
Expand All @@ -138,7 +135,6 @@ export const useGetAllTimeline = (): AllTimelinesArgs => {
sort,
status,
timelineType,
templateTimelineType,
};
const response = await apolloClient.query<
GetAllTimeline.Query,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ export const createTimelineResolvers = (
args.search || null,
args.sort || null,
args.status || null,
args.timelineType || null,
args.templateTimelineType || null
args.timelineType || null
);
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,6 @@ export const timelineSchema = gql`
immutable
}

enum TemplateTimelineType {
elastic
custom
}

enum RowRendererId {
auditd
auditd_file
Expand Down Expand Up @@ -321,7 +316,7 @@ export const timelineSchema = gql`

extend type Query {
getOneTimeline(id: ID!): TimelineResult!
getAllTimeline(pageInfo: PageInfoTimeline, search: String, sort: SortTimeline, onlyUserFavorite: Boolean, timelineType: TimelineType, templateTimelineType: TemplateTimelineType, status: TimelineStatus): ResponseTimelines!
getAllTimeline(pageInfo: PageInfoTimeline, search: String, sort: SortTimeline, onlyUserFavorite: Boolean, timelineType: TimelineType, status: TimelineStatus): ResponseTimelines!
}

extend type Mutation {
Expand Down
14 changes: 5 additions & 9 deletions x-pack/plugins/security_solution/server/graphql/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,11 +399,6 @@ export enum SortFieldTimeline {
created = 'created',
}

export enum TemplateTimelineType {
elastic = 'elastic',
custom = 'custom',
}

export enum NetworkDirectionEcs {
inbound = 'inbound',
outbound = 'outbound',
Expand All @@ -430,6 +425,11 @@ export enum FlowDirection {
biDirectional = 'biDirectional',
}

export enum TemplateTimelineType {
elastic = 'elastic',
custom = 'custom',
}

export type ToStringArrayNoNullable = any;

export type ToIFieldSubTypeNonNullable = any;
Expand Down Expand Up @@ -2336,8 +2336,6 @@ export interface GetAllTimelineQueryArgs {

timelineType?: Maybe<TimelineType>;

templateTimelineType?: Maybe<TemplateTimelineType>;

status?: Maybe<TimelineStatus>;
}
export interface AuthenticationsSourceArgs {
Expand Down Expand Up @@ -2814,8 +2812,6 @@ export namespace QueryResolvers {

timelineType?: Maybe<TimelineType>;

templateTimelineType?: Maybe<TemplateTimelineType>;

status?: Maybe<TimelineStatus>;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,22 @@ set -e
# Uses a default if no argument is specified
STATUS=${1:-active}
TIMELINE_TYPE=${2:-default}
TEMPLATE_TIMELINE_TYPE=${3:-custom}

# Example get all timelines:
# ./timelines/find_timeline_by_filter.sh active

# Example get all prepackaged timeline templates:
# ./timelines/find_timeline_by_filter.sh immutable template elastic
# ./timelines/find_timeline_by_filter.sh immutable template

# Example get all custom timeline templates:
# ./timelines/find_timeline_by_filter.sh active template custom
# ./timelines/find_timeline_by_filter.sh active template

curl -s -k \
-H "Content-Type: application/json" \
-H 'kbn-xsrf: 123' \
-u ${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD} \
-X POST "${KIBANA_URL}${SPACE_URL}/api/solutions/security/graphql" \
-d '{"operationName":"GetAllTimeline","variables":{"onlyUserFavorite":false,"pageInfo":{"pageIndex":1,"pageSize":10},"search":"","sort":{"sortField":"updated","sortOrder":"desc"},"status":"'$STATUS'","timelineType":"'$TIMELINE_TYPE'","templateTimelineType":"'$TEMPLATE_TIMELINE_TYPE'"},"query":"query GetAllTimeline($pageInfo: PageInfoTimeline!, $search: String, $sort: SortTimeline, $onlyUserFavorite: Boolean, $timelineType: TimelineType, $templateTimelineType: TemplateTimelineType, $status: TimelineStatus) {\n getAllTimeline(pageInfo: $pageInfo, search: $search, sort: $sort, onlyUserFavorite: $onlyUserFavorite, timelineType: $timelineType, templateTimelineType: $templateTimelineType, status: $status) {\n totalCount\n defaultTimelineCount\n templateTimelineCount\n elasticTemplateTimelineCount\n customTemplateTimelineCount\n favoriteCount\n timeline {\n savedObjectId\n description\n favorite {\n fullName\n userName\n favoriteDate\n __typename\n }\n eventIdToNoteIds {\n eventId\n note\n timelineId\n noteId\n created\n createdBy\n timelineVersion\n updated\n updatedBy\n version\n __typename\n }\n notes {\n eventId\n note\n timelineId\n timelineVersion\n noteId\n created\n createdBy\n updated\n updatedBy\n version\n __typename\n }\n noteIds\n pinnedEventIds\n status\n title\n timelineType\n templateTimelineId\n templateTimelineVersion\n created\n createdBy\n updated\n updatedBy\n version\n __typename\n }\n __typename\n }\n}\n"}' \
-d '{"operationName":"GetAllTimeline","variables":{"onlyUserFavorite":false,"pageInfo":{"pageIndex":1,"pageSize":10},"search":"","sort":{"sortField":"updated","sortOrder":"desc"},"status":"'$STATUS'","timelineType":"'$TIMELINE_TYPE'"},"query":"query GetAllTimeline($pageInfo: PageInfoTimeline!, $search: String, $sort: SortTimeline, $onlyUserFavorite: Boolean, $timelineType: TimelineType, $status: TimelineStatus) {\n getAllTimeline(pageInfo: $pageInfo, search: $search, sort: $sort, onlyUserFavorite: $onlyUserFavorite, timelineType: $timelineType, status: $status) {\n totalCount\n defaultTimelineCount\n templateTimelineCount\n elasticTemplateTimelineCount\n customTemplateTimelineCount\n favoriteCount\n timeline {\n savedObjectId\n description\n favorite {\n fullName\n userName\n favoriteDate\n __typename\n }\n eventIdToNoteIds {\n eventId\n note\n timelineId\n noteId\n created\n createdBy\n timelineVersion\n updated\n updatedBy\n version\n __typename\n }\n notes {\n eventId\n note\n timelineId\n timelineVersion\n noteId\n created\n createdBy\n updated\n updatedBy\n version\n __typename\n }\n noteIds\n pinnedEventIds\n status\n title\n timelineType\n templateTimelineId\n templateTimelineVersion\n created\n createdBy\n updated\n updatedBy\n version\n __typename\n }\n __typename\n }\n}\n"}' \
| jq .


Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ curl -s -k \
"sortOrder": "desc"
},
"status": "active",
"timelineType": null,
"templateTimelineType": null
"timelineType": null
},
"query": "query GetAllTimeline($pageInfo: PageInfoTimeline!, $search: String, $sort: SortTimeline, $onlyUserFavorite: Boolean, $timelineType: TimelineType, $templateTimelineType: TemplateTimelineType, $status: TimelineStatus) {\n getAllTimeline(pageInfo: $pageInfo, search: $search, sort: $sort, onlyUserFavorite: $onlyUserFavorite, timelineType: $timelineType, templateTimelineType: $templateTimelineType, status: $status) {\n totalCount\n defaultTimelineCount\n templateTimelineCount\n elasticTemplateTimelineCount\n customTemplateTimelineCount\n favoriteCount\n timeline {\n savedObjectId\n description\n favorite {\n fullName\n userName\n favoriteDate\n __typename\n }\n eventIdToNoteIds {\n eventId\n note\n timelineId\n noteId\n created\n createdBy\n timelineVersion\n updated\n updatedBy\n version\n __typename\n }\n notes {\n eventId\n note\n timelineId\n timelineVersion\n noteId\n created\n createdBy\n updated\n updatedBy\n version\n __typename\n }\n noteIds\n pinnedEventIds\n status\n title\n timelineType\n templateTimelineId\n templateTimelineVersion\n created\n createdBy\n updated\n updatedBy\n version\n __typename\n }\n __typename\n }\n}\n"
"query": "query GetAllTimeline($pageInfo: PageInfoTimeline!, $search: String, $sort: SortTimeline, $onlyUserFavorite: Boolean, $timelineType: TimelineType, $status: TimelineStatus) {\n getAllTimeline(pageInfo: $pageInfo, search: $search, sort: $sort, onlyUserFavorite: $onlyUserFavorite, timelineType: $timelineType, status: $status) {\n totalCount\n defaultTimelineCount\n templateTimelineCount\n elasticTemplateTimelineCount\n customTemplateTimelineCount\n favoriteCount\n timeline {\n savedObjectId\n description\n favorite {\n fullName\n userName\n favoriteDate\n __typename\n }\n eventIdToNoteIds {\n eventId\n note\n timelineId\n noteId\n created\n createdBy\n timelineVersion\n updated\n updatedBy\n version\n __typename\n }\n notes {\n eventId\n note\n timelineId\n timelineVersion\n noteId\n created\n createdBy\n updated\n updatedBy\n version\n __typename\n }\n noteIds\n pinnedEventIds\n status\n title\n timelineType\n templateTimelineId\n templateTimelineVersion\n created\n createdBy\n updated\n updatedBy\n version\n __typename\n }\n __typename\n }\n}\n"
}' | jq .

Loading