-
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
[CTI] Adds Threat Intel Tab to Alert Summary Flyout #97185
Conversation
@elasticmachine merge upstream |
RE labels: I think you want |
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 is looking fantastic! We just need to add the first_seen
sorting on details and fix up a few minor UI things.
With this refactor it definitely feels like we're doing too much client-side data manipulation (independent of the JSON.parse
😅 ); it's likely not a huge performance concern as it's one alert, but the code is pretty hard to follow right now. I left some thoughts/pointers, but as always I'm happy to either a) pair on it together or b) be told I'm wrong 😄
return ( | ||
threatDetailsRows: ThreatDetailsRow[][]; | ||
}> = ({ threatDetailsRows }) => | ||
!threatDetailsRows[0] || threatDetailsRows[0].length === 0 ? ( |
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: I think isEmpty
would work here:
!threatDetailsRows[0] || threatDetailsRows[0].length === 0 ? ( | |
isEmpty(threatDetailsRows[0]) ? ( |
</EuiTitle> | ||
<StyledSpan> | ||
{i18n.IF_CTI_NOT_ENABLED} | ||
<a |
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.
Please use EuiLink
here, that'll add the "external link" indicator that you see elsewhere.
> | ||
}) => { | ||
const tooltipChild = linkFields.some((field) => field === fieldName) ? ( | ||
<a href={value} target="_blank" rel="noreferrer"> |
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.
Ditto here with EuiLink
import { getDataFromSourceHits } from '../../../../common/utils/field_formatters'; | ||
import { INDICATOR_DESTINATION_PATH } from '../../../../common/constants'; | ||
|
||
const linkFields = ['threat.indicator.event.url', 'threat.indicator.event.reference']; |
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.
More magic strings, we'll need to consolidate those once the row renderer is merged 👍
`; | ||
|
||
const StyledSpan = styled.span` | ||
color: ${euiPaletteGray(5)[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.
Is this going to work with both light and dark themes? We may want to pull a semantic color from the theme itself.
} | ||
`; | ||
|
||
const StyledDiv = styled.div` |
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:
const StyledDiv = styled.div` | |
const FlexDiv = styled.div` |
align-items: center; | ||
`; | ||
|
||
const StyledEuiIcon = styled(EuiIcon)` |
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 would try to give more semantic names to these styled components you're creating; a Styled
prefix doesn't tell someone looking at this code why it has the given CSS.
<StyledSpan> | ||
{i18n.IF_CTI_NOT_ENABLED} | ||
<a | ||
href="https://www.elastic.co/guide/en/beats/filebeat/7.12/filebeat-module-threatintel.html" |
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.
Check out the docLinks service for a more robust way to build this URI. I think docLinks.links.filebeat.base
might be it?
'last_seen', | ||
]; | ||
|
||
export const useThreatIntelTabs = ( |
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.
My first impression is that this hook is doing a lot 😅 , and it's only used in one place. The only state I see that makes it hook-worthy is the cached computations, is that correct?
If nothing else, we should try to decompose this to make it more reusable/recomposable if we do see this being used in the future. If we can abstract these data-manipulation pieces out into pure functions, then the hook is just a little logic and a few simple uses of useMemo
.
However this shakes out, some kind of tests around this would be nice as documentation to further support/encourage reuse, as well.
if (selectedTabId !== EventsViewType.summaryView) return rows; | ||
return threatData | ||
.reduce((acc, items) => { | ||
items.forEach(({ field, originalValue }) => { |
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 forEach
within the reduce seems indicative of us doing something unnecessary; is it perhaps that we're having to undo part of what getDataFromSourceHits
does above?
At a high level, this seems like what we need, data-manipulation-wise:
const summaryFields = ['threat.indicator.matched.atomic', 'etc.'];
const indicatorJSON = data.find(field === 'threat.indicator');
const indicatorFields = data.filter(isIndicatorField);
const threatSummaryRows = buildThreatSummaryRows(summaryFields, indicatorFieldsFields);
const threatDetailsRows = buildThreatDetailsRows(indicatorJSON, ALL_INDICATOR_FIELDS).sort('first_seen', 'desc');
Got a review request, but it seems that no changes are impacting core files. Do you want review on something specific, or were the changes triggering the review reverted? |
hey @pgayvallet, I have removed the small change I had made, so there should be nothing here for you. I do have a question for you though! So my change used to be the addition of a link to docLinks. This failed check_published_api_changes step of the build. In the logs, there were some instructions to fix the error
so I was wondering - if I were to add a new link in the future, once I run the script mentioned above, what exactly the commit message would be? Would it just be a major / minor / patch according to the release I would be targeting (for instance, minor for 7.13 in this change?) or is there a separate versioning I am not aware of? Would be happy to know. |
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! Excellent work.
@@ -19,10 +19,14 @@ export const INDICATOR_MATCHED_TYPE = `${INDICATOR_DESTINATION_PATH}.${MATCHED_T | |||
export const EVENT_DATASET = 'event.dataset'; | |||
export const EVENT_REFERENCE = 'event.reference'; | |||
export const PROVIDER = 'provider'; | |||
export const FIRSTSEEN = 'first_seen'; |
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:
export const FIRSTSEEN = 'first_seen'; | |
export const FIRST_SEEN = 'first_seen'; |
Not worth waiting for another build, though.
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.
_ seemed to indicate nesting level - leaving as is now, I can update in a later commit
`; | ||
|
||
const EmptyThreatDetailsViewComponent: React.FC<{}> = () => { | ||
const threatIntelDocsUrl = `${ |
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.
👍
eventId: string | ||
) => { | ||
return data | ||
.reduce((acc, { field, originalValue }) => { |
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: I think if you reoriented this as SORTED_THREAT_SUMMARY_FIELDS.map().filter()
you wouldn't need the 'insert at index' logic below.
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.
updated
💚 Build SucceededMetrics [docs]Module Count
Async chunks
History
To update your PR or re-run it, just comment with: cc @ecezalp |
💚 Backport successful
This backport PR will be merged automatically after passing CI. |
Summary
Updates Threat Summary & Threat Details features to match the updated designs.
no threat - summary
no threat - threat intel
threat - summary
threat - threat intel
Notes
Relates to elastic/security-team#961 - confidence field is passing through with no additional engineering as you can see from the last attached image above.
Checklist
Delete any items that are not applicable to this PR.
For maintainers