-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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] Populate alert status auditing fields #171589
[Security Solution] Populate alert status auditing fields #171589
Conversation
Pinging @elastic/security-detections-response (Team:Detections and Resp) |
Pinging @elastic/security-solution (Team: SecuritySolution) |
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.
Obs UX Changes LGTM !!
The ResponseOps changes besides the alert table changes LGTM. I'd like to have someone from RAM review the alert table changes since I'm not sure what the ramifications of those changes are. @XavierM ? |
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.
LGTM!
const getUpdateSignalStatusScript = (status: SetSignalsStatusSchemaDecoded['status']) => ({ | ||
source: `if (ctx._source['${ALERT_WORKFLOW_STATUS}'] != null) { | ||
ctx._source['${ALERT_WORKFLOW_STATUS}'] = '${status}' | ||
const getUpdateSignalStatusScript = ( |
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.
This only returns user profiles that are enabled
right? Is a profile enabled automatically on login? Would there be a case of someone being logged onto the UI with a disabled profile and so this status is not logged?
@@ -39,6 +42,7 @@ import { ALERTS_URL } from '../../../urls/navigation'; | |||
|
|||
// FLAKY: https://github.com/elastic/kibana/issues/169091 |
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.
I have a PR trying to fix the flake, just haven't gotten back to it yet! #171676
Hey @marshallmain - sorry I just got to doing a very quick overview today. I plan to pull down and test tomorrow. Could we add the new PR checklist to the description? Thanks so much! |
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 for adding this in the table and the alert details flyout @marshallmain!
I left a few small comments.
Also I'm thinking that this could be a good candidate for some Cypress tests? We already have everything setup for you, and even have one test for each action performed on the alert (this one when closing an alert and that one when acknowledging an alert). You probably would have to update the page filters to show the changed alert, reopen the flyout and test that the new section correctly shows up under the About
section. Wdyt?
(I tried manually once a test was finished and it worked, so we should be able to do this programmatically without any issues). I'm happy to help out on this if you need!
I also have a question regarding the UI. Was adding this new section validated by UIUX? It seems a bit weird to me, and I would have thought instead to add something in the header next to the already existing status component (by probably updating this status.tsx file).
Finally, when the Mitre Attack component is rendered, the spacing is a bit small between mitre attack and this new status component. The challenge is both these are conditionally rendered. What do you think about removing this <EuiSpacer size="m" />
here and add one <EuiSpacer size="m" />
at the top of both the mitre_attack component and your new alert_status? That way the spacing will always look nice, when the components are visible or not.
import { useBulkGetUserProfiles } from '../../../../common/components/user_profiles/use_bulk_get_user_profiles'; | ||
import { PreferenceFormattedDate } from '../../../../common/components/formatted_date'; | ||
|
||
export const AlertStatus: FC = () => { |
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.
can you please add a short documentation here, just to be consistent with all the other components in the document_details
folder?
const statusUpdatedBy = searchHit.fields?.['kibana.alert.workflow_user'] as string; | ||
const statusUpdatedAt = searchHit.fields?.['kibana.alert.workflow_status_updated_at']; |
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.
any reason for not using getFieldsData along side our x-pack/plugins/security_solution/public/flyout/document_details/shared/utils.tsx like we use in the rest of the document_details flyout code?
The getFieldsData
is available from the useRightPanelContext
you're already using.
It would be
const { getFieldsData } = useRightPanelContext();
const statusUpdatedBy = getField(getFieldsData('kibana.alert.workflow_user'));
const statusUpdatedAt = getField(getFieldsData('kibana.alert.workflow_status_updated_at'));
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.
I figured getting the raw data from the searchHit was simple enough, I can change it though
@@ -43,6 +43,10 @@ const MITRE_ATTACK_TEST_ID = `${PREFIX}MitreAttack` as const; | |||
export const MITRE_ATTACK_TITLE_TEST_ID = `${MITRE_ATTACK_TEST_ID}Title` as const; | |||
export const MITRE_ATTACK_DETAILS_TEST_ID = `${MITRE_ATTACK_TEST_ID}Details` as const; | |||
|
|||
export const WORKFLOW_STATUS_TEST_ID = `${PREFIX}WorkflowStatus` as const; |
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.
nit but this one doesn't need to be exported
Is there a specific person that needs to approve changes to the flyout? I avoided adding it to the header because it looked cluttered to me already and adding status history information didn't seem to fit with the rest of the basic info that's displayed in the header. I'm working on making the other suggested changes to the flyout, thanks for the review! |
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Canvas Sharable Runtime
Page load bundle
Unknown metric groupsAPI count
References to deprecated APIs
History
To update your PR or re-run it, just comment with: |
@marshallmain: @ferenrigue owns the flyout design but she is on vacation right now. We could ask @codearos but if you want we can merge this as is and I'm happy to make small UI changes later once UIUX comes up with a solution they like? |
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.
LGTM for the Threat Hunting Investigations team, thanks for making the changes @marshallmain
…nge to flyout (#205224) ## Summary Over a year ago, [this PR](#171589) added some information to the alert details flyout, to show when an alert's status (`closed`, `open` or `aknowledged`) had been modified last and by which user. Shortly after, [this follow up PR](#172888) removed the UI from the alert details flyout, as the information wasn't extremely important and was taking some valuable vertical space, pushing down below the `Highlighted fields` section, that users were finding very important. A few months later, we added the ability to persist which of the top sections (`About`, `Investigation`, `Visualizations`, `Insights` and `Response`) were collapsed or expanded. That way the user wouldn't have to always collapse or expand sections they would often don't need. This PR brings back the alert's last status changes to the `About` section, as the vertical space is no longer a big issues, because users can now collapse the entire `About` section. #### If data is not present, the last change UI is not shown ![Screenshot 2024-12-27 at 3 46 14 PM](https://github.com/user-attachments/assets/24e033d7-fb15-496a-97be-ecf78996d243) #### If the correct data is shown: ![Screenshot 2024-12-27 at 3 50 12 PM](https://github.com/user-attachments/assets/a13f54d8-1804-4baf-a12b-5203beb4f92d) ### How to test - have a few alerts in the alerts table - open the alert details flyout for one alert and change the status (button in the header) - verify that the last status change section is shown in the `About` section ### Checklist - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
…nge to flyout (elastic#205224) ## Summary Over a year ago, [this PR](elastic#171589) added some information to the alert details flyout, to show when an alert's status (`closed`, `open` or `aknowledged`) had been modified last and by which user. Shortly after, [this follow up PR](elastic#172888) removed the UI from the alert details flyout, as the information wasn't extremely important and was taking some valuable vertical space, pushing down below the `Highlighted fields` section, that users were finding very important. A few months later, we added the ability to persist which of the top sections (`About`, `Investigation`, `Visualizations`, `Insights` and `Response`) were collapsed or expanded. That way the user wouldn't have to always collapse or expand sections they would often don't need. This PR brings back the alert's last status changes to the `About` section, as the vertical space is no longer a big issues, because users can now collapse the entire `About` section. #### If data is not present, the last change UI is not shown ![Screenshot 2024-12-27 at 3 46 14 PM](https://github.com/user-attachments/assets/24e033d7-fb15-496a-97be-ecf78996d243) #### If the correct data is shown: ![Screenshot 2024-12-27 at 3 50 12 PM](https://github.com/user-attachments/assets/a13f54d8-1804-4baf-a12b-5203beb4f92d) ### How to test - have a few alerts in the alerts table - open the alert details flyout for one alert and change the status (button in the header) - verify that the last status change section is shown in the `About` section ### Checklist - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios (cherry picked from commit a4b1975)
…us change to flyout (#205224) (#205835) # Backport This will backport the following commits from `main` to `8.x`: - [[Security Solution][Alert details] - bring back last alert status change to flyout (#205224)](#205224) <!--- 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":"2025-01-08T04:50:44Z","message":"[Security Solution][Alert details] - bring back last alert status change to flyout (#205224)\n\n## Summary\r\n\r\nOver a year ago, [this\r\nPR](#171589) added some\r\ninformation to the alert details flyout, to show when an alert's status\r\n(`closed`, `open` or `aknowledged`) had been modified last and by which\r\nuser.\r\nShortly after, [this follow up\r\nPR](#172888) removed the UI from\r\nthe alert details flyout, as the information wasn't extremely important\r\nand was taking some valuable vertical space, pushing down below the\r\n`Highlighted fields` section, that users were finding very important.\r\n\r\nA few months later, we added the ability to persist which of the top\r\nsections (`About`, `Investigation`, `Visualizations`, `Insights` and\r\n`Response`) were collapsed or expanded. That way the user wouldn't have\r\nto always collapse or expand sections they would often don't need.\r\n\r\nThis PR brings back the alert's last status changes to the `About`\r\nsection, as the vertical space is no longer a big issues, because users\r\ncan now collapse the entire `About` section.\r\n\r\n#### If data is not present, the last change UI is not shown\r\n![Screenshot 2024-12-27 at 3 46\r\n14 PM](https://github.com/user-attachments/assets/24e033d7-fb15-496a-97be-ecf78996d243)\r\n\r\n#### If the correct data is shown:\r\n![Screenshot 2024-12-27 at 3 50\r\n12 PM](https://github.com/user-attachments/assets/a13f54d8-1804-4baf-a12b-5203beb4f92d)\r\n\r\n### How to test\r\n\r\n- have a few alerts in the alerts table\r\n- open the alert details flyout for one alert and change the status\r\n(button in the header)\r\n- verify that the last status change section is shown in the `About`\r\nsection\r\n\r\n### Checklist\r\n\r\n- [x] Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"a4b1975fced9f5fd6c408401d19b79650a4fc56d","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["v9.0.0","release_note:feature","Team:Threat Hunting:Investigations","backport:version","v8.18.0"],"title":"[Security Solution][Alert details] - bring back last alert status change to flyout","number":205224,"url":"https://github.com/elastic/kibana/pull/205224","mergeCommit":{"message":"[Security Solution][Alert details] - bring back last alert status change to flyout (#205224)\n\n## Summary\r\n\r\nOver a year ago, [this\r\nPR](#171589) added some\r\ninformation to the alert details flyout, to show when an alert's status\r\n(`closed`, `open` or `aknowledged`) had been modified last and by which\r\nuser.\r\nShortly after, [this follow up\r\nPR](#172888) removed the UI from\r\nthe alert details flyout, as the information wasn't extremely important\r\nand was taking some valuable vertical space, pushing down below the\r\n`Highlighted fields` section, that users were finding very important.\r\n\r\nA few months later, we added the ability to persist which of the top\r\nsections (`About`, `Investigation`, `Visualizations`, `Insights` and\r\n`Response`) were collapsed or expanded. That way the user wouldn't have\r\nto always collapse or expand sections they would often don't need.\r\n\r\nThis PR brings back the alert's last status changes to the `About`\r\nsection, as the vertical space is no longer a big issues, because users\r\ncan now collapse the entire `About` section.\r\n\r\n#### If data is not present, the last change UI is not shown\r\n![Screenshot 2024-12-27 at 3 46\r\n14 PM](https://github.com/user-attachments/assets/24e033d7-fb15-496a-97be-ecf78996d243)\r\n\r\n#### If the correct data is shown:\r\n![Screenshot 2024-12-27 at 3 50\r\n12 PM](https://github.com/user-attachments/assets/a13f54d8-1804-4baf-a12b-5203beb4f92d)\r\n\r\n### How to test\r\n\r\n- have a few alerts in the alerts table\r\n- open the alert details flyout for one alert and change the status\r\n(button in the header)\r\n- verify that the last status change section is shown in the `About`\r\nsection\r\n\r\n### Checklist\r\n\r\n- [x] Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"a4b1975fced9f5fd6c408401d19b79650a4fc56d"}},"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/205224","number":205224,"mergeCommit":{"message":"[Security Solution][Alert details] - bring back last alert status change to flyout (#205224)\n\n## Summary\r\n\r\nOver a year ago, [this\r\nPR](#171589) added some\r\ninformation to the alert details flyout, to show when an alert's status\r\n(`closed`, `open` or `aknowledged`) had been modified last and by which\r\nuser.\r\nShortly after, [this follow up\r\nPR](#172888) removed the UI from\r\nthe alert details flyout, as the information wasn't extremely important\r\nand was taking some valuable vertical space, pushing down below the\r\n`Highlighted fields` section, that users were finding very important.\r\n\r\nA few months later, we added the ability to persist which of the top\r\nsections (`About`, `Investigation`, `Visualizations`, `Insights` and\r\n`Response`) were collapsed or expanded. That way the user wouldn't have\r\nto always collapse or expand sections they would often don't need.\r\n\r\nThis PR brings back the alert's last status changes to the `About`\r\nsection, as the vertical space is no longer a big issues, because users\r\ncan now collapse the entire `About` section.\r\n\r\n#### If data is not present, the last change UI is not shown\r\n![Screenshot 2024-12-27 at 3 46\r\n14 PM](https://github.com/user-attachments/assets/24e033d7-fb15-496a-97be-ecf78996d243)\r\n\r\n#### If the correct data is shown:\r\n![Screenshot 2024-12-27 at 3 50\r\n12 PM](https://github.com/user-attachments/assets/a13f54d8-1804-4baf-a12b-5203beb4f92d)\r\n\r\n### How to test\r\n\r\n- have a few alerts in the alerts table\r\n- open the alert details flyout for one alert and change the status\r\n(button in the header)\r\n- verify that the last status change section is shown in the `About`\r\nsection\r\n\r\n### Checklist\r\n\r\n- [x] Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"a4b1975fced9f5fd6c408401d19b79650a4fc56d"}},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Philippe Oberti <[email protected]>
…nge to flyout (elastic#205224) ## Summary Over a year ago, [this PR](elastic#171589) added some information to the alert details flyout, to show when an alert's status (`closed`, `open` or `aknowledged`) had been modified last and by which user. Shortly after, [this follow up PR](elastic#172888) removed the UI from the alert details flyout, as the information wasn't extremely important and was taking some valuable vertical space, pushing down below the `Highlighted fields` section, that users were finding very important. A few months later, we added the ability to persist which of the top sections (`About`, `Investigation`, `Visualizations`, `Insights` and `Response`) were collapsed or expanded. That way the user wouldn't have to always collapse or expand sections they would often don't need. This PR brings back the alert's last status changes to the `About` section, as the vertical space is no longer a big issues, because users can now collapse the entire `About` section. #### If data is not present, the last change UI is not shown ![Screenshot 2024-12-27 at 3 46 14 PM](https://github.com/user-attachments/assets/24e033d7-fb15-496a-97be-ecf78996d243) #### If the correct data is shown: ![Screenshot 2024-12-27 at 3 50 12 PM](https://github.com/user-attachments/assets/a13f54d8-1804-4baf-a12b-5203beb4f92d) ### How to test - have a few alerts in the alerts table - open the alert details flyout for one alert and change the status (button in the header) - verify that the last status change section is shown in the `About` section ### Checklist - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
…nge to flyout (elastic#205224) ## Summary Over a year ago, [this PR](elastic#171589) added some information to the alert details flyout, to show when an alert's status (`closed`, `open` or `aknowledged`) had been modified last and by which user. Shortly after, [this follow up PR](elastic#172888) removed the UI from the alert details flyout, as the information wasn't extremely important and was taking some valuable vertical space, pushing down below the `Highlighted fields` section, that users were finding very important. A few months later, we added the ability to persist which of the top sections (`About`, `Investigation`, `Visualizations`, `Insights` and `Response`) were collapsed or expanded. That way the user wouldn't have to always collapse or expand sections they would often don't need. This PR brings back the alert's last status changes to the `About` section, as the vertical space is no longer a big issues, because users can now collapse the entire `About` section. #### If data is not present, the last change UI is not shown ![Screenshot 2024-12-27 at 3 46 14 PM](https://github.com/user-attachments/assets/24e033d7-fb15-496a-97be-ecf78996d243) #### If the correct data is shown: ![Screenshot 2024-12-27 at 3 50 12 PM](https://github.com/user-attachments/assets/a13f54d8-1804-4baf-a12b-5203beb4f92d) ### How to test - have a few alerts in the alerts table - open the alert details flyout for one alert and change the status (button in the header) - verify that the last status change section is shown in the `About` section ### Checklist - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
This PR populates the existing
kibana.alert.workflow_user
field in the alerts-as-data mappings with theprofile_uid
of the last user to modify the status of the alert. It also adds a new field,kibana.alert.workflow_status_updated_at
, to track the last time the workflow status was updated and populates it with a timestamp.Similar to the alert assignment PR,
workflow_user
renders in the table with a user avatar instead of the rawprofile_uid
value stored in the alert. The filter in/out buttons on the row cell automatically add a filter that uses the raw value so that filtering works correctly.Due to limitations of Kibana's user profile implementation,
workflow_user
is only populated if a user changes the alert status using the alert status route (POST /api/detection_engine/signals/status
) within an interactive session, i.e. logs in rather than passes credentials with each API request (related issue).Alerts table
Alert details
Checklist
kibana.alert.workflow_user
andkibana.alert.workflow_status_updated_at
) security-docs#4325