-
Couldn't load subscription status.
- Fork 8.5k
[Cloud Security] Show related alert's when fetching CDR graph #224783
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
Changes from all commits
8a24d97
c3bb2e7
9214242
48a0cb0
606f051
ed9205b
92a7117
caa5b25
8e82b5c
460ab62
b6e9c7b
1e484e4
356fea4
c4d5f57
f379f27
2be5e57
a57c3a9
f2ddbd7
aaed013
8e14441
664dfa1
7dc5aec
cf31f60
200734a
d94c2e0
b5d2fff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,18 @@ export const isEntityNode = (node: NodeViewModel) => | |
| export const isStackedLabel = (node: NodeViewModel): boolean => | ||
| !(node.shape === 'label' && Boolean(node.parentId)); | ||
|
|
||
| /** | ||
| * Type guard: Returns true if node.documentsData is a non-empty array. | ||
| * This only narrows node.documentsData to a non-empty array, not to a specific document type. | ||
| */ | ||
| export const hasNodeDocumentsData = ( | ||
| node: NodeViewModel | ||
| ): node is NodeViewModel & { | ||
| documentsData: [NodeDocumentDataViewModel, ...NodeDocumentDataViewModel[]]; | ||
| } => { | ||
| return Array.isArray(node.documentsData) && node.documentsData.length > 0; | ||
| }; | ||
|
|
||
| /** | ||
| * Returns the node document mode, or 'na' if documentsData is missing or empty. | ||
| * When this function returns a value other than 'na', documentsData is guaranteed to be a non-empty array. | ||
|
|
@@ -41,7 +53,7 @@ export const getNodeDocumentMode = ( | |
| } | ||
|
|
||
| // Single alert contains both event's document data and alert's document data. | ||
| if (node.documentsData.find((doc) => doc.type === 'alert') && node.documentsData.length < 2) { | ||
| if (node.documentsData.find((doc) => doc.type === 'alert') && node.documentsData.length <= 2) { | ||
| return 'single-alert'; | ||
| } else if (node.documentsData.length === 1 && node.documentsData[0].type === 'event') { | ||
| return 'single-event'; | ||
|
|
@@ -57,14 +69,24 @@ export const getNodeDocumentMode = ( | |
| }; | ||
|
|
||
| /** | ||
| * Type guard: Returns true if node.documentsData is a non-empty array. | ||
| * This only narrows node.documentsData to a non-empty array, not to a specific document type. | ||
| * Returns the single document data for a node if it is in single-* mode. | ||
| * If the node is not in one of these modes, or if it has no documentsData, it returns undefined. | ||
| */ | ||
| export function hasNodeDocumentsData(node: NodeViewModel): node is NodeViewModel & { | ||
| documentsData: [NodeDocumentDataViewModel, ...NodeDocumentDataViewModel[]]; | ||
| } { | ||
| return Array.isArray(node.documentsData) && node.documentsData.length > 0; | ||
| } | ||
| export const getSingleDocumentData = ( | ||
| node: NodeViewModel | ||
| ): NodeDocumentDataViewModel | undefined => { | ||
| const mode = getNodeDocumentMode(node); | ||
| if (!hasNodeDocumentsData(node) || (mode !== 'single-alert' && mode !== 'single-event')) { | ||
| return undefined; | ||
| } | ||
|
|
||
| // For single-alert we might have both event and alert documents. We prefer to return the alert document if it exists. | ||
| const documentData = | ||
|
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. so we are going to store in the documentsData array the event itself which we get from the log-* and also the alert we found in the alerts-* index? 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.
correct
correct, that wasn't changed as part of this PR 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. |
||
| node.documentsData.find((doc) => doc.type === 'alert') ?? | ||
| node.documentsData.find((doc) => doc.type === 'event'); | ||
|
|
||
| return documentData; | ||
| }; | ||
|
|
||
| const FETCH_GRAPH_FAILED_TEXT = i18n.translate( | ||
| 'securitySolutionPackages.csp.graph.investigation.errorFetchingGraphData', | ||
|
|
||

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.
@kfirpeled why did you change it to
<=2?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.
in a single alert use case, you can have a correlated event that the alert was triggered upon. So eventually you will have 2 documents data