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

[Defend workflows] Replace differenceWith with xorWith and remove the helper #157966

Merged
merged 3 commits into from
May 17, 2023

Conversation

tomsonpl
Copy link
Contributor

@tomsonpl tomsonpl commented May 17, 2023

While using differenceWith we had to manually check for the empty array, otherwise it didn't return the difference. xorWith does this for us while returning the symmetric difference.

@tomsonpl tomsonpl added chore release_note:skip Skip the PR/issue when compiling release notes Team:Defend Workflows “EDR Workflows” sub-team of Security Solution v8.9.0 labels May 17, 2023
@tomsonpl tomsonpl requested a review from maximpn May 17, 2023 08:59
@tomsonpl tomsonpl self-assigned this May 17, 2023
@tomsonpl tomsonpl requested a review from a team as a code owner May 17, 2023 08:59
Copy link
Contributor

@maximpn maximpn left a comment

Choose a reason for hiding this comment

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

@tomsonpl it's a good simplification 👍 Don't forget to add the PR description.

@@ -95,9 +96,10 @@ export const validateResponseActionsPermissions = async (

const endpointAuthz = await securitySolution.getEndpointAuthz();

const differences = findDifferenceInArrays<ResponseAction, RuleResponseAction>(
const differences = xorWith<ResponseAction | RuleResponseAction>(
Copy link
Contributor

Choose a reason for hiding this comment

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

Can it infer the type ResponseAction | RuleResponseAction without explicitly providing it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it would infer the type if two arrays were of the same types, but in this case I had to specify these.

@@ -95,9 +96,10 @@ export const validateResponseActionsPermissions = async (

const endpointAuthz = await securitySolution.getEndpointAuthz();

const differences = findDifferenceInArrays<ResponseAction, RuleResponseAction>(
const differences = xorWith<ResponseAction | RuleResponseAction>(
Copy link
Member

Choose a reason for hiding this comment

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

I like this better indeed. I was going to suggest xorWith earlier but didn't want to ask you to change too much. 🎉 Thanks for updating this. I think you should name the varaible symmetricDifference anyway. Maybe, also leave a comment above that says finds elements that are not in either array, so one doesn't have to look up the function to understand what this does.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was a very good point, thank you @ashokaditya :)

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.

🚀 🚢

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Unknown metric groups

ESLint disabled line counts

id before after diff
enterpriseSearch 19 21 +2
securitySolution 400 404 +4
total +6

Total ESLint disabled count

id before after diff
enterpriseSearch 20 22 +2
securitySolution 480 484 +4
total +6

History

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

cc @tomsonpl

@tomsonpl tomsonpl merged commit 9abdd90 into elastic:main May 17, 2023
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting chore release_note:skip Skip the PR/issue when compiling release notes Team:Defend Workflows “EDR Workflows” sub-team of Security Solution v8.9.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants