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

[Security Solution][Notes] - fetch notes by saved object ids #193930

Merged

Conversation

PhilippeOberti
Copy link
Contributor

@PhilippeOberti PhilippeOberti commented Sep 24, 2024

Summary

This PR changes the behavior of the Timeline Notes tab to use the new note system. Everything is behind the securitySolutionNotesEnabled feature flag for now.
The goal of this was to not modify the current (old) Notes behavior. We will keep the code for at least one release after we switch the securitySolutionNotesEnabled on, to allow customers to use the old system needed.

Here are the main changes for the server side:

  • modified the getNote api to support filtering by savedObjectIds. This allows us to now search all the notes for a specific timeline
  • added unit tests

Here are the main changes for the UI side:

  • move the content of the NotesTabContentComponent into an new OldNotes component. The goal was to not change that code at all to stay on the safe side, and facilitate removing all the code when the time comes.
  • extract a lot of the notes components from the expandable flyout to the top level notes tab, and make them reusable for the new Timeline Notes tab:
    • the AddNote logic (markdown, attach to timeline and add note button)
    • the OpenTimeline logic to open the timeline from the expandable flyout
    • the DeleteNote logic to delete notes
    • the OpenFlyout logic to open the expandable flyout from the timeline notes page
  • change the UI for the AttachToTimeline logic:
    • added a new the callout component to replace the icon with tooltip. The callout displays a Save timeline button if the timeline is not saved, and replaces that button by a Attach to timeline checkbox once saved
    • the callout and checkbox are now only shown in the timeline flyout, between the markdown and the add button
  • change the timeline notes tab to force the users to save timeline if they want to attach a note to it
  • wrote a lot of unit tests

Timeline Notes tab

For unsaved timelines
unsaved timeline notes tab

For saved timelines
saved timeline notes tab

Timeline flyout Notes tab

For unsaved timelines
unsaved timeline flyout

For saved timelines
saved timeline flyout

SecuritySolution flyout Notes tab

normal flyout


Here's an example of a flow for the timeline notes tab

unsaved.timeline.notes.tab.mov

Here's an example of a flow for the SecuritySolution flyout

unsaved.timeline.flyout.mov

Here's an example for the SecuritySolution flyout

normal.flyout.mov

How to test

Keep in mind while testing this changes the following behaviors:

  • no changes should be visible unless the securitySolutionNotesEnabled feature flag is on
  • all previously saved timelines and related notes should be visible the exact same way once the securitySolutionNotesEnabled is turned on
  • creating notes with the new system (securitySolutionNotesEnabled turned on) should work in the old system (after browser refresh) with the securitySolutionNotesEnabled turned off

Checklist

#193098

@PhilippeOberti PhilippeOberti force-pushed the notes-fetch-by-saved-object-ids branch 3 times, most recently from 2872578 to 83e0262 Compare September 26, 2024 23:59
@PhilippeOberti PhilippeOberti added release_note:skip Skip the PR/issue when compiling release notes v9.0.0 Team:Threat Hunting:Investigations Security Solution Investigations Team v8.16.0 labels Sep 27, 2024
@PhilippeOberti PhilippeOberti marked this pull request as ready for review September 27, 2024 00:18
@PhilippeOberti PhilippeOberti requested review from a team as code owners September 27, 2024 00:18
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-threat-hunting-investigations (Team:Threat Hunting:Investigations)

Copy link
Contributor

@christineweng christineweng left a comment

Choose a reason for hiding this comment

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

Code looks good to me. Some comments from desk testing:

  1. Adding a note in notes tab does not update the count in tab
    image
    siem dev:
    image

  2. Add a note in notes tab in an unsaved timeline, then investigate a new alert in timeline, the note persists.
    Current behavior: after investigate a new alert in timeline, a new timeline is created and the previous note is lost

  3. Related to (2). Add a note in notes tab in an unsaved timeline, save the timeline, the note disappear from saved timeline. Any note created in an unsaved timeline attaches to the draft only

Screen.Recording.2024-09-27.at.12.53.50.PM.mov
  1. When creating a new timeline (via Create a timeline or from templates), there is nothing in notes tab but participant is there

image

  1. UI: Is the empty message kinda of redundant?
    image
    old notes
    image

eventId?: string;
/**
*
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

missing a doc here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added in the last commit

@christineweng
Copy link
Contributor

@PhilippeOberti notice this when i was working on pinning:

  1. Investigate an event in timeline and save the timeline
  2. Go back to alerts table and add a note (should not have attach to timeline)

notice the timeline icon is automatically added when it is not supposed to

Screen.Recording.2024-09-30.at.1.31.22.PM.mov

@PhilippeOberti
Copy link
Contributor Author

PhilippeOberti commented Sep 30, 2024

@PhilippeOberti notice this when i was working on pinning:

  1. Investigate an event in timeline and save the timeline
  2. Go back to alerts table and add a note (should not have attach to timeline)

notice the timeline icon is automatically added when it is not supposed to

Thanks @christineweng this should be resolved in my last commit

@PhilippeOberti PhilippeOberti force-pushed the notes-fetch-by-saved-object-ids branch 3 times, most recently from 4c181ec to 87b73df Compare October 1, 2024 01:29
@PhilippeOberti
Copy link
Contributor Author

  1. Adding a note in notes tab does not update the count in tab

In the last commit I added the code to fetch notes in the tab title as well.

  1. Add a note in notes tab in an unsaved timeline, then investigate a new alert in timeline, the note persists.

The new behavior added in the last commit should prevent a user from being able to create a note in an unsaved timeline!

  1. Related to (2). Add a note in notes tab in an unsaved timeline, save the timeline, the note disappear from saved timeline. Any note created in an unsaved timeline attaches to the draft only

Same here, the last commit prevents a user from creating a note in an unsaved timeline.

  1. When creating a new timeline (via Create a timeline or from templates), there is nothing in notes tab but participant is there

If you try again now, you'll see that the title Participants is shown but nothing is below it, which I think is nicer than what we have today, where there is just an empty section and we don't really know why...

  1. UI: Is the empty message kinda of redundant?

I guess it could be, but last time I showed it to @ferenrigue I think she was OK with it. I'll bring it up again!

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
securitySolution 5931 5940 +9

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
securitySolution 20.5MB 20.5MB +37.0KB

History

  • 💛 Build #238247 was flaky 97289f08cd3982d392cc4fe10c7a059258f8bd87
  • 💔 Build #237570 failed 76de4efacd79030768b361c482a713598c7fe518
  • 💔 Build #237552 failed f07a522fb504c7abd6441853f1b69549550326c0

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

Copy link
Contributor

@christineweng christineweng left a comment

Choose a reason for hiding this comment

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

Desk tested and LGTM!🚀 The added save timeline button is much better at gating behaviors related to an unsaved timeline 👏

Non-blocking but i was finally able to recreate the error toast from timeline templates consistently:

  • Have a fresh unsaved timeline, create a new timeline from a template, click on notes icon, notice there is an error toast about null
  • I also see this happening occasionally with events in explore pages. But only the first time I click on the note icon
Screen.Recording.2024-10-01.at.3.31.39.PM.mov

@PhilippeOberti
Copy link
Contributor Author

Desk tested and LGTM!🚀 The added save timeline button is much better at gating behaviors related to an unsaved timeline 👏

Non-blocking but i was finally able to recreate the error toast from timeline templates consistently:

  • Have a fresh unsaved timeline, create a new timeline from a template, click on notes icon, notice there is an error toast about null
  • I also see this happening occasionally with events in explore pages. But only the first time I click on the note icon

Thanks for the steps to reproduce. I will get on it as soon as this PR is merged. It is behind a feature flag, and merging it will unblock some other work

@PhilippeOberti PhilippeOberti merged commit ca46f78 into elastic:main Oct 1, 2024
40 checks passed
@PhilippeOberti PhilippeOberti deleted the notes-fetch-by-saved-object-ids branch October 1, 2024 20:44
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/11133177317

@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Oct 1, 2024
…193930) (#194643)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Security Solution][Notes] - fetch notes by saved object ids
(#193930)](#193930)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Philippe
Oberti","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-01T20:44:41Z","message":"[Security
Solution][Notes] - fetch notes by saved object ids
(#193930)","sha":"ca46f784e5185bbce503171e6432e960c94f2586","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["backport","release_note:skip","v9.0.0","Team:Threat
Hunting:Investigations","v8.16.0"],"title":"[Security Solution][Notes] -
fetch notes by saved object
ids","number":193930,"url":"https://github.com/elastic/kibana/pull/193930","mergeCommit":{"message":"[Security
Solution][Notes] - fetch notes by saved object ids
(#193930)","sha":"ca46f784e5185bbce503171e6432e960c94f2586"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/193930","number":193930,"mergeCommit":{"message":"[Security
Solution][Notes] - fetch notes by saved object ids
(#193930)","sha":"ca46f784e5185bbce503171e6432e960c94f2586"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Philippe Oberti <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport release_note:skip Skip the PR/issue when compiling release notes Team:Threat Hunting:Investigations Security Solution Investigations Team v8.16.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants