-
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
Add @elastic/safer-lodash-set as an alternative to lodash.set #67452
Conversation
Pinging @elastic/uptime (Team:uptime) |
@elastic/siem-security-team I need your help verifying something in this PR: This PR adds a safer version of As far as I can see, the only place where we use any of those functions are in the SIEM plugin as evident by these ESLint errors:
Creating an For reference, here are the places where you use
kibana/x-pack/plugins/siem/server/lib/timeline/routes/utils/common.ts Lines 21 to 29 in b7e393d
|
@elastic/kibana-operations This PR adds a new package under the kibana/packages/kbn-safer-lodash-set/package.json Lines 11 to 12 in 3619c8e
I'm not sure if our CI system runs these tests automatically, or if I need to do something specific to ensure that the package tests are included in the regular CI run? |
Pinging @elastic/kibana-security (Team:Security) |
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.
Thanks for this, @watson!
While I'm reviewing the rest, I wanted to mention a couple comments I had left on the original review:
- Can we make sure that the existing lodash set tests are included in our test suite as well?
- We should provide type definitions as part of this package, so that consumers can have type safety without having to manually cast.
The tests you link to are actually from the upcoming v5.0.0 and currently doesn't actually work as far as I can see. The file isn't even in v4.x, in which all tests for all lodash functions are just in one huge file as all tests have been completely refactored in Here's a snippet from their
I took a look to see if we could somehow re-use this, but it can't be easily done. Not without rewriting all the setup and test-harness code at least. So I don't think it's worth it currently, what do you think?
Good idea 👍 |
Ah sorry, I failed to notice that |
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 for just the one spot that it references within security_solution
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.
maps/*
code review. lgtm. Thank you!
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.
Thanks for fixing the type issues with SIEM. LGTM 🏁
@elasticmachine merge upstream |
@elasticmachine merge upstream |
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 from the licensing perspective.
CI failure doesn't look related to the PR and seems master isn't stable either. Let's try again. |
@elasticmachine merge upstream |
💚 Build SucceededBuild metrics@kbn/optimizer bundle module count
async chunks size
miscellaneous assets size
page load bundle size
History
To update your PR or re-run it, just comment with: |
Okay, I see UPDATE: 7.x CI run didn't have any failures. |
7.x/7.9.0: 2764abe |
* master: [APM] Add error rates to Service Map popovers (elastic#69520) [Security Solution][Detection Engine] - Update exceptions logic (elastic#71512) [Security Solution] Full screen timeline, Collapse event (elastic#71786) [Security Solution][Exception Modal] Create endpoint exception list if it doesn't already exist (elastic#71807) [Detection Rules] Add 7.9 rules (elastic#71808) [Search] Add telemetry for data plugin search service (elastic#70677) Add @elastic/safer-lodash-set as an alternative to lodash.set (elastic#67452) [tests] Temporarily skipped to promote snapshot
* master: [APM] Add error rates to Service Map popovers (elastic#69520) [Security Solution][Detection Engine] - Update exceptions logic (elastic#71512) [Security Solution] Full screen timeline, Collapse event (elastic#71786) [Security Solution][Exception Modal] Create endpoint exception list if it doesn't already exist (elastic#71807) [Detection Rules] Add 7.9 rules (elastic#71808) [Search] Add telemetry for data plugin search service (elastic#70677) Add @elastic/safer-lodash-set as an alternative to lodash.set (elastic#67452) [tests] Temporarily skipped to promote snapshot
Thank you @azasypkin for all your help landing and backporting this PR 🙏 |
This PR adds new ESLint rules that instructs developers to not use
set
andsetWith
from thelodash
module, but instead use the equivalent functions from a new@elastic/safer-lodash-set
module.This new module is located in
packages/elastic-safer-lodash-set
. This module is going to be published to npm as well once everyone is happy with it.This PR both adds the ESLint rules, the
@elastic/safer-lodash-set
module, and updates any code that violates those new ESLint rules. Since we useset
/setWith
fromlodash
all over the code-base, this PR touches upon a lot of files. This can seem a bit daunting, but to ease the review process, you might want to first check out the files inside ofpackages/elastic-safer-lodash-set
. These can be viewed as a standalone module with its own documentation, tests, etc. So I suggest reading the README.md to get a better understanding of what it's doing.Todo
lodash/fp
ESLint errors (two files only: x-pack/plugins/siem/server/lib/hosts/elasticsearch_adapter.ts and x-pack/plugins/siem/server/lib/timeline/routes/utils/common.ts)LICENSE
file is okREADME.md
file to say it's not on npm and add"private": true
topackage.json