Skip to content
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] fix endpoint list agent status logic #115286

Merged
merged 7 commits into from
Oct 19, 2021

Conversation

joeypoon
Copy link
Member

@joeypoon joeypoon commented Oct 15, 2021

Summary

Update endpoint list host status logic when hitting new united index.

For maintainers

@joeypoon joeypoon added v8.0.0 release_note:skip Skip the PR/issue when compiling release notes Team:Defend Workflows “EDR Workflows” sub-team of Security Solution auto-backport Deprecated - use backport:version if exact versions are needed v7.16.0 labels Oct 15, 2021
@joeypoon joeypoon requested a review from a team October 15, 2021 22:16
@joeypoon joeypoon marked this pull request as ready for review October 15, 2021 22:20
@joeypoon joeypoon requested a review from a team as a code owner October 15, 2021 22:20
@joeypoon joeypoon requested review from pzl and ashokaditya October 15, 2021 22:20
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-onboarding-and-lifecycle-mgt (Team:Onboarding and Lifecycle Mgt)

@joeypoon joeypoon enabled auto-merge (squash) October 16, 2021 00:31
@kevinlog
Copy link
Contributor

@elasticmachine merge upstream

Copy link
Member

@ashokaditya ashokaditya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 🐑

@academo
Copy link
Contributor

academo commented Oct 18, 2021

@joeypoon you can get rid of most of the non null assertions if you implement some predicate type guards (https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates)

If you are sure these objects will contain the information you need, you can for instance filter out the array with a predicate and then remove the null assertion.

@@ -522,10 +523,11 @@ async function queryUnitedIndex(
const agentPolicy = agentPoliciesMap[agent.policy_id!];
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const endpointPolicy = endpointPoliciesMap[agent.policy_id!];
const fleetAgentStatus = getAgentStatus(agent as Agent);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not part of this change, but if you add a type guard to doc and to agent you can remove all these null assertion.

@kevinlog
Copy link
Contributor

@elasticmachine merge upstream

@kevinlog
Copy link
Contributor

@elasticmachine merge upstream

@kevinlog
Copy link
Contributor

@elasticmachine merge upstream

@kevinlog
Copy link
Contributor

@elasticmachine merge upstream

@kevinlog
Copy link
Contributor

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.x

This backport PR will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Oct 19, 2021
@joeypoon joeypoon deleted the fix/endpoint-agent-status branch October 27, 2021 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed release_note:skip Skip the PR/issue when compiling release notes Team:Defend Workflows “EDR Workflows” sub-team of Security Solution v7.16.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants