-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
[Osquery] Add to timeline button #128596
Merged
Merged
[Osquery] Add to timeline button #128596
Changes from 8 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
9a0ea9f
[wip]
tomsonpl ef1bcd4
fix timeline rerender and change action_id
tomsonpl 635af17
Merge branch 'main' into osquery-add-to-timeline
kibanamachine e483a17
fix zindex issue
tomsonpl 2d4b13b
Merge branch 'osquery-add-to-timeline' of github.com:tomsonpl/kibana …
tomsonpl 0b3d977
fix eslint
tomsonpl b06a58f
add timeline e2e test to alerts
tomsonpl 9b33c21
Merge branch 'main' into osquery-add-to-timeline
kibanamachine 2bdb838
Merge branch 'main' into osquery-add-to-timeline
kibanamachine d7cccf6
Merge branch 'main' into osquery-add-to-timeline
kibanamachine 2650b51
Add timeline to row (by _id)
tomsonpl 24649a5
Merge branch 'main' into osquery-add-to-timeline
tomsonpl 1e86af8
Resolev conflicts - remove hideFullscreen
tomsonpl 99bdaeb
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine cb087ec
fix tests
tomsonpl 1a00d81
Merge remote-tracking branch 'origin/osquery-add-to-timeline' into os…
tomsonpl b77290c
fix tests
tomsonpl 5caef62
Merge branch 'main' into osquery-add-to-timeline
tomsonpl afc5980
Merge branch 'main' into osquery-add-to-timeline
tomsonpl 3c66905
refactor payload destructuring
tomsonpl bcf8613
Merge branch 'main' into osquery-add-to-timeline
tomsonpl 0742331
fix after merge
tomsonpl dbe1048
fix tests
tomsonpl faaaced
Merge branch 'main' into osquery-add-to-timeline
kibanamachine 6717b51
Merge branch 'main' into osquery-add-to-timeline
kibanamachine 7cbda37
remove go back button from osquery flyout
tomsonpl 81ebe56
Merge remote-tracking branch 'origin/osquery-add-to-timeline' into os…
tomsonpl 8cead6b
Merge branch 'main' into osquery-add-to-timeline
kibanamachine ad9c19c
fix tests
tomsonpl dae6719
Merge remote-tracking branch 'origin/osquery-add-to-timeline' into os…
tomsonpl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,13 +5,20 @@ | |
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import React, { useCallback } from 'react'; | ||
import styled from 'styled-components'; | ||
import { EuiFlyout, EuiFlyoutFooter, EuiFlyoutBody, EuiFlyoutHeader } from '@elastic/eui'; | ||
import { | ||
EuiFlyout, | ||
EuiFlyoutFooter, | ||
EuiFlyoutBody, | ||
EuiFlyoutHeader, | ||
EuiButtonEmpty, | ||
} from '@elastic/eui'; | ||
import { useKibana } from '../../../common/lib/kibana'; | ||
import { OsqueryEventDetailsFooter } from './osquery_flyout_footer'; | ||
import { OsqueryEventDetailsHeader } from './osquery_flyout_header'; | ||
import { ACTION_OSQUERY } from './translations'; | ||
import { DataProvider } from '../../../timelines/components/timeline/data_providers/data_provider'; | ||
|
||
const OsqueryActionWrapper = styled.div` | ||
padding: 8px; | ||
|
@@ -22,11 +29,43 @@ export interface OsqueryFlyoutProps { | |
onClose: () => void; | ||
} | ||
|
||
export const OsqueryFlyout: React.FC<OsqueryFlyoutProps> = ({ agentId, onClose }) => { | ||
const TimelineComponent = React.memo((props) => { | ||
return <EuiButtonEmpty {...props} size="xs" />; | ||
}); | ||
TimelineComponent.displayName = 'TimelineComponent'; | ||
|
||
export const OsqueryFlyoutComponent: React.FC<OsqueryFlyoutProps> = ({ agentId, onClose }) => { | ||
const { | ||
services: { osquery }, | ||
services: { osquery, timelines }, | ||
} = useKibana(); | ||
|
||
const { getAddToTimelineButton } = timelines.getHoverActions(); | ||
|
||
const handleAddToTimeline = useCallback( | ||
(actionId: string) => { | ||
const providerA: DataProvider = { | ||
and: [], | ||
enabled: true, | ||
excluded: false, | ||
id: actionId, | ||
kqlQuery: '', | ||
name: actionId, | ||
queryMatch: { | ||
field: 'action_id', | ||
value: actionId, | ||
operator: ':', | ||
}, | ||
}; | ||
|
||
return getAddToTimelineButton({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should have at least a unit test to check the flyout is rendered correctly according to the props and then check if add to timeline was executed with the right options. |
||
dataProvider: providerA, | ||
field: actionId, | ||
ownFocus: false, | ||
Component: TimelineComponent, | ||
}); | ||
}, | ||
[getAddToTimelineButton] | ||
); | ||
// @ts-expect-error | ||
const { OsqueryAction } = osquery; | ||
return ( | ||
|
@@ -45,7 +84,7 @@ export const OsqueryFlyout: React.FC<OsqueryFlyoutProps> = ({ agentId, onClose } | |
</EuiFlyoutHeader> | ||
<EuiFlyoutBody> | ||
<OsqueryActionWrapper data-test-subj="flyout-body-osquery"> | ||
<OsqueryAction agentId={agentId} formType="steps" /> | ||
<OsqueryAction agentId={agentId} formType="steps" addToTimeline={handleAddToTimeline} /> | ||
</OsqueryActionWrapper> | ||
</EuiFlyoutBody> | ||
<EuiFlyoutFooter> | ||
|
@@ -55,4 +94,4 @@ export const OsqueryFlyout: React.FC<OsqueryFlyoutProps> = ({ agentId, onClose } | |
); | ||
}; | ||
|
||
OsqueryFlyout.displayName = 'OsqueryFlyout'; | ||
export const OsqueryFlyout = React.memo(OsqueryFlyoutComponent); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I see below that this flyout has a form in it, did you verify that all the select dropdowns etc that render in this form, namely EuiSuperSelect options and anything that renders itself via a portal (not sure of everything) render correctly? I noticed recently that any element that renders itself in a portal and has a parent that is also in a portal, when it tries to determine it's own stacking context cannot have a z-index higher than 2000 or something. https://codesandbox.io/s/crimson-voice-zq510u?file=/demo.js for a demo. Mentioned this to eui but they didn't seem to think it's a bug, personally I do, https://github.com/elastic/eui/blob/main/src/services/popover/popover_positioning.ts#L743 for an element in a portal will not do what it should.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, I don't know yet, but will take a look at this and get back to you. Big thanks! :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I double checked and it seems to be working just fine. Selects too :)
The only thing is the Global NavBar that doesnt really work when any of the additional flyouts is opened.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we checked one more time, and apparently it works fine on Alerts, but messes up one of the flyouts in Osquery itself.
Thanks for pointing this out :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the issue is fixed here #130944