-
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
[RAC] [Observability] [Security Solution] Use correct url to management app for observability cases, use normalized ids #108775
Merged
kqualters-elastic
merged 4 commits into
elastic:master
from
kqualters-elastic:fix-cases-links-observability
Aug 17, 2021
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
345e7f8
Use correct url to management app for observability cases, use normal…
kqualters-elastic f969a1c
Update failing test
kqualters-elastic 6e01a1a
Merge branch 'master' into fix-cases-links-observability
kqualters-elastic 29cec69
Load alert details data to render flyout in case detail view
kqualters-elastic 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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -8,9 +8,11 @@ import { isEmpty } from 'lodash'; | |||||
import { useState, useCallback, useMemo, SyntheticEvent } from 'react'; | ||||||
import { useLocation } from 'react-router-dom'; | ||||||
import { useDispatch } from 'react-redux'; | ||||||
import { ALERT_RULE_ID, ALERT_RULE_NAME, ALERT_RULE_UUID } from '@kbn/rule-data-utils'; | ||||||
import { useKibana } from '../../../../../src/plugins/kibana_react/public'; | ||||||
import { Case, SubCase } from '../../../cases/common'; | ||||||
import { TimelinesStartServices } from '../types'; | ||||||
import { TimelineItem } from '../../common/'; | ||||||
import { tGridActions } from '../store/t_grid'; | ||||||
import { useDeepEqualSelector } from './use_selector'; | ||||||
import { createUpdateSuccessToaster } from '../components/actions/timeline/cases/helpers'; | ||||||
|
@@ -83,7 +85,6 @@ export const useAddToCase = ({ | |||||
}: AddToCaseActionProps): UseAddToCase => { | ||||||
const eventId = event?.ecs._id ?? ''; | ||||||
const eventIndex = event?.ecs._index ?? ''; | ||||||
const rule = event?.ecs.signal?.rule; | ||||||
const dispatch = useDispatch(); | ||||||
// TODO: use correct value in standalone or integrated. | ||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||||||
|
@@ -154,6 +155,7 @@ export const useAddToCase = ({ | |||||
updateCase?: (newCase: Case) => void | ||||||
) => { | ||||||
dispatch(tGridActions.setOpenAddToNewCase({ id: eventId, isOpen: false })); | ||||||
const { ruleId, ruleName } = normalizedEventFields(event); | ||||||
if (postComment) { | ||||||
await postComment({ | ||||||
caseId: theCase.id, | ||||||
|
@@ -162,16 +164,16 @@ export const useAddToCase = ({ | |||||
alertId: eventId, | ||||||
index: eventIndex ?? '', | ||||||
rule: { | ||||||
id: rule?.id != null ? rule.id[0] : null, | ||||||
name: rule?.name != null ? rule.name[0] : null, | ||||||
id: ruleId, | ||||||
name: ruleName, | ||||||
}, | ||||||
owner: appId, | ||||||
}, | ||||||
updateCase, | ||||||
}); | ||||||
} | ||||||
}, | ||||||
[eventId, eventIndex, rule, appId, dispatch] | ||||||
[eventId, eventIndex, appId, dispatch, event] | ||||||
); | ||||||
const onCaseSuccess = useCallback( | ||||||
async (theCase: Case) => { | ||||||
|
@@ -239,3 +241,17 @@ export const useAddToCase = ({ | |||||
isCreateCaseFlyoutOpen, | ||||||
}; | ||||||
}; | ||||||
|
||||||
export function normalizedEventFields(event?: TimelineItem) { | ||||||
const ruleId = event && event.data.find(({ field }) => field === ALERT_RULE_ID); | ||||||
const ruleUuid = event && event.data.find(({ field }) => field === ALERT_RULE_UUID); | ||||||
const ruleName = event && event.data.find(({ field }) => field === ALERT_RULE_NAME); | ||||||
const ruleIdValue = ruleId && ruleId.value && ruleId.value[0]; | ||||||
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. is it possible value could have a length of 0? perhaps consider :
Suggested change
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. It shouldn't as far as I know, if it ever blows up I'll come back to this 🤣 |
||||||
const ruleUuidValue = ruleUuid && ruleUuid.value && ruleUuid.value[0]; | ||||||
const ruleNameValue = ruleName && ruleName.value && ruleName.value[0]; | ||||||
const idToUse = ruleIdValue ? ruleIdValue : ruleUuidValue; | ||||||
return { | ||||||
ruleId: idToUse ?? null, | ||||||
ruleName: ruleNameValue ?? null, | ||||||
}; | ||||||
} |
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.
👌🏾