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

[SIEM] Import timeline fix #65448

Merged
merged 89 commits into from
Jun 27, 2020
Merged

Conversation

angorayc
Copy link
Contributor

@angorayc angorayc commented May 6, 2020

Summary

Screenshot 2020-06-18 at 09 14 13

This PR is to allow template timeline updated via import,
and fix the case we had in #64439

How to verify this PR:

  1. copy the json below and paste it onto a file
{"savedObjectId":null,"version":"WzM5LDFd","timelineType":"template","templateTimelineId":"49188240-6530-11ea-90dd-7d87cXavier","templateTimelineVersion":4,"columns":[{"indexes":null,"name":null,"columnHeaderType":"not-filtered","id":"@timestamp","searchable":null},{"indexes":null,"name":null,"columnHeaderType":"not-filtered","id":"message","searchable":null},{"indexes":null,"name":null,"columnHeaderType":"not-filtered","id":"event.category","searchable":null},{"indexes":null,"name":null,"columnHeaderType":"not-filtered","id":"event.action","searchable":null},{"indexes":null,"name":null,"columnHeaderType":"not-filtered","id":"host.name","searchable":null},{"indexes":null,"name":null,"columnHeaderType":"not-filtered","id":"source.ip","searchable":null},{"indexes":null,"name":null,"columnHeaderType":"not-filtered","id":"destination.ip","searchable":null},{"indexes":null,"name":null,"columnHeaderType":"not-filtered","id":"user.name","searchable":null}],"dataProviders":[],"description":"is Super","eventType":"all","filters":[],"kqlMode":"filter","kqlQuery":{"filterQuery":{"serializedQuery":"{\"bool\":{\"should\":[{\"exists\":{\"field\":\"host.name\"}}],\"minimum_should_match\":1}}","kuery":{"expression":"host.name: *","kind":"kuery"}}},"title":"My template timeline updated","dateRange":{"start":1584020448645,"end":1584106848645},"savedQueryId":null,"sort":{"columnId":"@timestamp","sortDirection":"desc"},"favorite":[{"favoriteDate":1584480703444,"keySearch":"WGF2aWVyTQ==","fullName":"xavier mouligneau","userName":"XavierM"}],"created":1588693289719,"createdBy":"XavierM","updated":1588693315060,"updatedBy":"XavierM","eventNotes":[{"noteId":"e3cf0900-8ee6-11ea-bff9-5be90e832634","version":"WzM0LDFd","eventId":"Cfwg1HABO74GafNORxyF","note":"pinned and event note","timelineId":"e37d8da0-8ee6-11ea-bff9-5be90e832634","created":1588693290295,"createdBy":"XavierM","updated":1588693290295,"updatedBy":"XavierM"},{"noteId":"e3cfcc50-8ee6-11ea-bff9-5be90e832634","version":"WzM1LDFd","eventId":"Cvwg1HABO74GafNORxyF","note":"event note 1","timelineId":"e37d8da0-8ee6-11ea-bff9-5be90e832634","created":1588693290295,"createdBy":"XavierM","updated":1588693290295,"updatedBy":"XavierM"}],"globalNotes":[{"noteId":"e3cebae0-8ee6-11ea-bff9-5be90e832634","version":"WzI2LDFd","note":"Global","timelineId":"e37d8da0-8ee6-11ea-bff9-5be90e832634","created":1588693290295,"createdBy":"XavierM","updated":1588693290295,"updatedBy":"XavierM"},{"noteId":"e3cf3010-8ee6-11ea-bff9-5be90e832634","version":"WzM2LDFd","note":"Note","timelineId":"e37d8da0-8ee6-11ea-bff9-5be90e832634","created":1588693290295,"createdBy":"XavierM","updated":1588693290295,"updatedBy":"XavierM"}],"pinnedEventIds":["Yfwg1HABO74GafNObyFv","Cfwg1HABO74GafNORxyF","Cvwg1HABO74GafNORxyF"]}
  1. save it as template_timeline.ndjson
  2. import in to timeline
  3. More tweak: [SIEM] Import timeline fix #65448 (comment)

Error cases:

  1. Import a new timeline (Create timeline via import)

    • input validation:
      • timelineId has to be null / empty or a timelineId that doesn't exist in SO - if given a timelineId that's already exist, therefor throwing error: savedObjectId: "${id}" already exists
      • title must have - if not given, throw error: Title cannot be empty
      • version: has to be null (this is to reserve the possibility of version control for updating timeline in the future)
      • timelineType has to be null / default or not specified - if set to template, I'll assume it is trying to create a template
      • status has to be null / 'active' or not specified - we don't expose this field to exported file. So far we do not block the 'immutable' status as we need that when installing Elastic template. If status is given as draft, throw error Cannot create a draft timeline
  2. Import an existing timeline (Update existing timeline via import)

    • We don't allow updating existing timeline atm: therefor throwing error: savedObjectId: "${id}" already exists
  3. Import a new template (Create custom template via import)

    • input validation:
      • templateTimelineId has to be given a uuid that doesn't exist in SO, if given a timelineId that's already exist, therefor throwing error: savedObjectId: "${id}" already exists; if not given a templateTimelineId, throw error: Create template timeline without a template timeline ID is not allowed
      • title must have - if not given, throw error: Title cannot be empty
      • timelineType has to be template - if set to others, I'll assume it is trying to create a default timeline
      • status has to be null / 'active' or not specified - we don't expose this field to exported file. So far we do not block the 'immutable' status as we need that when installing Elastic template. If status is given as draft, throw error Cannot create a draft timeline
  4. Import an existing template

    • input validation:
      • timelineType has to be the same as existing template timeline, otherwise throw error: 'Update timelineType is not allowed'
      • status has to be the same as existing template timeline. Otherwise throw error Update status is not allowed
      • templateTimelineId has to be given a uuid that matches an exist in SO.
        • If not given: template timeline without a template timeline ID is not allowed
        • if given a timelineId that's not exist, therefor throwing error: CREATE template timeline with PATCH is not allowed, please use POST instead (Given template timeline doesn't exist)
        • given timelineId doesn't match: Timeline id doesn't match with existing template timeline
        • given templateTimelineVersion doesn't match: TimelineVersion conflict: The given version doesn not match with existing timeline

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@angorayc angorayc requested review from a team as code owners May 6, 2020 10:54
@angorayc angorayc added v7.8.0 v8.0.0 release_note:skip Skip the PR/issue when compiling release notes labels May 6, 2020
fix unit tests

apply failure checker

clean up error message

fix update template
@angorayc
Copy link
Contributor Author

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

user doesn't have permission to update head repository

@patrykkopycinski
Copy link
Contributor

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

user doesn't have permission to update head repository

@patrykkopycinski patrykkopycinski added bug Fixes for quality problems that affect the customer experience Team:SIEM labels May 19, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/siem (Team:SIEM)

angorayc and others added 3 commits May 19, 2020 19:13
…ne-fix

# Conflicts:
#	x-pack/plugins/siem/server/lib/timeline/routes/import_timelines_route.ts
}

public getVersion() {
return this.version;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it support template timelines?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, timeline_input is a generic input for both timeline and template.
When we init this object for template, we send templateTimelineVersion instead of version
https://github.com/angorayc/kibana/blob/af212242578580adf9e460ec7c4db6dd4d2dd01c/x-pack/plugins/siem/server/lib/timeline/routes/update_timelines_route.ts#L58

@angorayc
Copy link
Contributor Author

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

user doesn't have permission to update head repository

@XavierM
Copy link
Contributor

XavierM commented Jun 25, 2020

in this picture below, we are having two bugs

  1. I should be able to add a global not in template timeline, only if it is immutable I cannot
  2. The second msg is cut off

image

@angorayc
Copy link
Contributor Author

in this picture below, we are having two bugs

  1. I should be able to add a global note in template timeline, only if it is immutable I cannot
  2. The second msg is cut off

image

Seems that the behaviour of add Note button is as expected. I checked on siem-dev, the add Note is disabled until we type something in the text box.

But sure, I'll fix item 2. in another PR.

@angorayc
Copy link
Contributor Author

angorayc commented Jun 25, 2020

Todos in follow up PR: #69972

  • More unit test
  • Happy path in integration test
  • Properly delete immutable timeline (check if it is linked to rules and handle it properly)
  • Internal api for on boarding template timeline
  • The error message from importing timeline should be more obvious, the import modal should not be closed if it fails.
  • Update wordings for error messages.
  • Update design for Template's callout message.
  • Remove disableTemplate from constant.
  • Fix known issue: Unexpected errors occurs when creating template timeline via import without templateTimelineId / templateTimelineVersion.
  • Decide land on Elastic template or Custom template or no filter by default

@angorayc angorayc mentioned this pull request Jun 25, 2020
11 tasks
@angorayc
Copy link
Contributor Author

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

user doesn't have permission to update head repository

Copy link
Contributor

@patrykkopycinski patrykkopycinski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to import the timeline template smoothly now! LGTM 💪
image

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

@kbn/optimizer bundle module count

id value diff baseline
securitySolution 788 +1 787

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@angorayc angorayc merged commit f4e7f14 into elastic:master Jun 27, 2020
angorayc added a commit to angorayc/kibana that referenced this pull request Jun 27, 2020
* fix import timeline and clean up

fix unit tests

apply failure checker

clean up error message

fix update template

* add unit tests

* clean up common libs

* rename variables

* add unit tests

* fix types

* Fix imports

* rename file

* poc

* fix unit test

* review

* cleanup fallback values

* cleanup

* check if title exists

* fix unit test

* add unit test

* lint error

* put the flag for disableTemplate into common

* add immutiable

* fix unit

* check templateTimelineVersion only when update via import

* update template timeline via import with response

* add template filter

* add filter count

* add filter numbers

* rename

* enable pin events and note under active status

* disable comment and pinnedEvents for template timelines

* add timelineType for openTimeline

* enable note icon for template

* add timeline type for propertyLeft

* fix types

* duplicate elastic template

* update schema

* fix status check

* fix import

* add templateTimelineType

* disable note for immutable timeline

* fix unit

* fix error message

* fix update

* fix types

* rollback change

* rollback change

* fix create template timeline

* add i18n for error message

* fix unit test

* fix wording and disable delete btn for immutable timeline

* fix unit test provider

* fix types

* fix toaster

* fix notes and pins

* add i18n

* fix selected items

* set disableTemplateto true

* move templateInfo to helper

* review + imporvement

* fix review

* fix types

* fix types

Co-authored-by: Patryk Kopycinski <[email protected]>
Co-authored-by: Xavier Mouligneau <[email protected]>
# Conflicts:
#	x-pack/plugins/security_solution/public/timelines/store/timeline/epic.ts
angorayc added a commit that referenced this pull request Jun 27, 2020
* fix import timeline and clean up

fix unit tests

apply failure checker

clean up error message

fix update template

* add unit tests

* clean up common libs

* rename variables

* add unit tests

* fix types

* Fix imports

* rename file

* poc

* fix unit test

* review

* cleanup fallback values

* cleanup

* check if title exists

* fix unit test

* add unit test

* lint error

* put the flag for disableTemplate into common

* add immutiable

* fix unit

* check templateTimelineVersion only when update via import

* update template timeline via import with response

* add template filter

* add filter count

* add filter numbers

* rename

* enable pin events and note under active status

* disable comment and pinnedEvents for template timelines

* add timelineType for openTimeline

* enable note icon for template

* add timeline type for propertyLeft

* fix types

* duplicate elastic template

* update schema

* fix status check

* fix import

* add templateTimelineType

* disable note for immutable timeline

* fix unit

* fix error message

* fix update

* fix types

* rollback change

* rollback change

* fix create template timeline

* add i18n for error message

* fix unit test

* fix wording and disable delete btn for immutable timeline

* fix unit test provider

* fix types

* fix toaster

* fix notes and pins

* add i18n

* fix selected items

* set disableTemplateto true

* move templateInfo to helper

* review + imporvement

* fix review

* fix types

* fix types

Co-authored-by: Patryk Kopycinski <[email protected]>
Co-authored-by: Xavier Mouligneau <[email protected]>
# Conflicts:
#	x-pack/plugins/security_solution/public/timelines/store/timeline/epic.ts
gmmorris added a commit to gmmorris/kibana that referenced this pull request Jun 29, 2020
* master: (59 commits)
  [Lens] Fix broken test (elastic#70117)
  [SIEM] Import timeline fix (elastic#65448)
  [SECURITY SOLUTION][INGEST] UX update for ingest manager edit/create datasource for endpoint (elastic#70079)
  [Telemetry] Collector Schema (elastic#64942)
  [Endpoint] Add Endpoint empty states for onboarding (elastic#69626)
  Hide unused resolver buttons (elastic#70112)
  [Security] `Investigate in Resolver` Timeline Integration (elastic#70111)
  [Discover] Improve styling of graphs in sidebar (elastic#69440)
  [Metrics UI] Fix EuiTheme type issue (elastic#69735)
  skip failing suite (elastic#70104) (elastic#70103)
  [ENDPOINT] Hide the Timeline Flyout while on the Management Pages (elastic#69998)
  [SIEM][CASE] Persist callout when dismissed (elastic#68372)
  [SIEM][Exceptions] - Cleaned up and updated exception list item comment structure (elastic#69532)
  [Maps] remove indexing state from redux (elastic#69765)
  Add API integration test for deleting data streams. (elastic#70020)
  renames SIEM to Security Solution (elastic#70070)
  Adding saved_objects_page in OSS (elastic#69900)
  [Lens] Use accordion menus in field list for available and empty fields (elastic#68871)
  Dynamic uiActions & license support (elastic#68507)
  [SIEM] Update readme for timeline apis (elastic#67038)
  ...
gmmorris added a commit to gmmorris/kibana that referenced this pull request Jun 29, 2020
…bana into alerting/consumer-based-rbac

* 'alerting/consumer-based-rbac' of github.com:gmmorris/kibana: (25 commits)
  [Lens] Fix broken test (elastic#70117)
  [SIEM] Import timeline fix (elastic#65448)
  [SECURITY SOLUTION][INGEST] UX update for ingest manager edit/create datasource for endpoint (elastic#70079)
  [Telemetry] Collector Schema (elastic#64942)
  [Endpoint] Add Endpoint empty states for onboarding (elastic#69626)
  Hide unused resolver buttons (elastic#70112)
  [Security] `Investigate in Resolver` Timeline Integration (elastic#70111)
  [Discover] Improve styling of graphs in sidebar (elastic#69440)
  [Metrics UI] Fix EuiTheme type issue (elastic#69735)
  skip failing suite (elastic#70104) (elastic#70103)
  [ENDPOINT] Hide the Timeline Flyout while on the Management Pages (elastic#69998)
  [SIEM][CASE] Persist callout when dismissed (elastic#68372)
  [SIEM][Exceptions] - Cleaned up and updated exception list item comment structure (elastic#69532)
  [Maps] remove indexing state from redux (elastic#69765)
  Add API integration test for deleting data streams. (elastic#70020)
  renames SIEM to Security Solution (elastic#70070)
  Adding saved_objects_page in OSS (elastic#69900)
  [Lens] Use accordion menus in field list for available and empty fields (elastic#68871)
  Dynamic uiActions & license support (elastic#68507)
  [SIEM] Update readme for timeline apis (elastic#67038)
  ...
@MindyRS MindyRS added the Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. label Sep 23, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-solution (Team: SecuritySolution)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience release_note:skip Skip the PR/issue when compiling release notes Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:SIEM v7.9.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants