-
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
Migrate Host risk and User risk UI to ECS schema #140080
Conversation
7eb5992
to
a85509b
Compare
Pinging @elastic/security-threat-hunting (Team:Threat Hunting) |
Pinging @elastic/security-solution (Team: SecuritySolution) |
fad3f1d
to
f8bce6c
Compare
2c54e53
to
47a0b7d
Compare
...s/security_solution/public/common/components/event_details/cti_details/host_risk_summary.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/security_solution/public/hosts/pages/navigation/host_risk_tab_body.tsx
Outdated
Show resolved
Hide resolved
.../server/search_strategy/security_solution/factory/risk_score/kpi/query.kpi_risk_score.dsl.ts
Show resolved
Hide resolved
...lugins/security_solution/common/search_strategy/security_solution/risk_score/common/index.ts
Outdated
Show resolved
Hide resolved
...ns/security_solution/public/overview/components/entity_analytics/host_risk_score/columns.tsx
Outdated
Show resolved
Hide resolved
...ns/security_solution/public/overview/components/entity_analytics/host_risk_score/columns.tsx
Outdated
Show resolved
Hide resolved
...gins/security_solution/public/overview/components/entity_analytics/host_risk_score/index.tsx
Outdated
Show resolved
Hide resolved
...ns/security_solution/public/overview/components/entity_analytics/user_risk_score/columns.tsx
Outdated
Show resolved
Hide resolved
...ns/security_solution/public/overview/components/entity_analytics/user_risk_score/columns.tsx
Outdated
Show resolved
Hide resolved
...gins/security_solution/public/overview/components/entity_analytics/user_risk_score/index.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/security_solution/public/overview/components/host_overview/index.tsx
Outdated
Show resolved
Hide resolved
...solution/public/overview/components/overview_risky_host_links/risky_hosts_enabled_module.tsx
Show resolved
Hide resolved
const getListItemsFromHits = (items: HostsRiskScore[]): LinkPanelListItem[] => { | ||
return items.map(({ host, risk_stats: riskStats, risk: copy }) => ({ | ||
const getListItemsFromHits = (items: HostRiskScore[]): LinkPanelListItem[] => { | ||
return items.map(({ host }) => ({ | ||
title: host.name, |
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.
title: host.name, | |
title: get(item, RiskScoreFields.hostName), |
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.
get
isn't type-safe.
title: host.name, | ||
count: riskStats.risk_score, | ||
copy, | ||
count: host.risk.calculated_score_norm, |
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.
count: host.risk.calculated_score_norm, | |
count: get(item, RiskScoreFields.hostRiskScore), |
count: riskStats.risk_score, | ||
copy, | ||
count: host.risk.calculated_score_norm, | ||
copy: host.risk.calculated_level, |
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.
copy: host.risk.calculated_level, | |
copy: get(item, RiskScoreFields.hostRisk), |
@@ -106,7 +106,9 @@ export const UserOverview = React.memo<UserSummaryProps>( | |||
title: i18n.USER_RISK_SCORE, | |||
description: ( | |||
<> | |||
{userRiskData ? Math.round(userRiskData.risk_stats.risk_score) : getEmptyTagValue()} | |||
{userRiskData | |||
? Math.round(userRiskData.user.risk.calculated_score_norm) |
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.
? Math.round(userRiskData.user.risk.calculated_score_norm) | |
? Math.round(get(userRiskData, RiskScoreFields.userRiskScore)) |
@@ -115,7 +117,10 @@ export const UserOverview = React.memo<UserSummaryProps>( | |||
description: ( | |||
<> | |||
{userRiskData ? ( | |||
<RiskScore severity={userRiskData.risk as RiskSeverity} hideBackgroundColor /> | |||
<RiskScore | |||
severity={userRiskData.user.risk.calculated_level as RiskSeverity} |
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.
severity={userRiskData.user.risk.calculated_level as RiskSeverity} | |
severity={get(userRiskData, RiskScoreFields.userRisk)} |
x-pack/plugins/security_solution/public/users/components/user_risk_score_table/columns.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/security_solution/public/users/components/user_risk_score_table/columns.tsx
Outdated
Show resolved
Hide resolved
@@ -92,7 +92,7 @@ async function enhanceEdges( | |||
const hostsRiskByHostName: Record<string, string> | undefined = hostRiskData?.hits.hits.reduce( | |||
(acc, hit) => ({ | |||
...acc, | |||
[hit._source?.host.name ?? '']: hit._source?.risk, | |||
[hit._source?.host.name ?? '']: hit._source?.host.risk.calculated_level, |
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.
[hit._source?.host.name ?? '']: hit._source?.host.risk.calculated_level, | |
[hit._source?.host.name ?? '']: get(hit, `_source.${RiskScoreFields.hostRisk}`), |
.../server/search_strategy/security_solution/factory/risk_score/kpi/query.kpi_risk_score.dsl.ts
Outdated
Show resolved
Hide resolved
.../server/search_strategy/security_solution/factory/risk_score/kpi/query.kpi_risk_score.dsl.ts
Outdated
Show resolved
Hide resolved
.../server/search_strategy/security_solution/factory/risk_score/kpi/query.kpi_risk_score.dsl.ts
Outdated
Show resolved
Hide resolved
9b774a8
to
48842e7
Compare
💚 Build Succeeded
Metrics [docs]Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: cc @machadoum |
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.
security-engineering-productivity changes LGTM
@@ -24,12 +25,16 @@ export const buildKpiRiskScoreQuery = ({ | |||
aggs: { | |||
risk: { | |||
terms: { | |||
field: 'risk.keyword', | |||
field: | |||
entity === RiskScoreEntity.user ? RiskScoreFields.userRisk : RiskScoreFields.hostRisk, | |||
}, | |||
aggs: { | |||
unique_entries: { | |||
cardinality: { |
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.
@machadoum , Since we are already aggregating by a field such as RiskScoreFields.userRisk
or RiskScoreFields.hostRisk
, wouldn't cardinality be always 1 (i.e. unique_entries)
for that particular field? Is it intensional? See screenshot below.
Do you think below was the intention? Apologies if I have missed something.
{
"aggs": {
"risk": {
"terms": {
"field": "user.risk.calculated_score_norm"
}
},
"unique_entries": {
"cardinality": {
"field": "user.risk.calculated_score_norm"
}
}
}
}
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.
There is a mistake in the code above, unique_entries.cardinality.field
should be user.name
or host.name
. If the fields of the term aggregation and cardinality are the same, the result would always be 1
, but that is not the case. Here is a sample of the query that runs:
"aggs": {
"risk": {
"terms": {
"field": "host.risk.calculated_level"
},
"aggs": {
"unique_entries": {
"cardinality": {
"field": "host.name"
}
}
}
}
The terms
aggregation groups all entries by risk severity, and cardinality
counts how many users or hosts exist for each severity.
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.
Okay... this makes sense. My bad 😰
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.
PR checked-out and desk tested. User risk fields are populating without any issue. LGTM
Links:
issue
PR for transforms and dashboards
proposed ECS risk fields.
Summary
Migrate Host risk and User risk indices to the ECS schema
Affected components:
Add mocked data
TODO