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] Filter editing causing Error: e.getName is not a function exception #164265

Closed
e40pud opened this issue Aug 21, 2023 · 10 comments
Assignees
Labels
bug Fixes for quality problems that affect the customer experience consider-next Team:Detection Engine Security Solution Detection Engine Area Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v8.11.0

Comments

@e40pud
Copy link
Contributor

e40pud commented Aug 21, 2023

Describe the bug:

Filter editing on rule's editing page can cause an exception:

Error: e.getName is not a function
    at getLabel (https://kibana-app.whitesector.inf.elasticnet.co/64715/bundles/plugin/unifiedSearch/1.0.0/unifiedSearch.chunk.1.js:1:32379)
    at Array.map (<anonymous>)
    at u (https://kibana-app.whitesector.inf.elasticnet.co/64715/bundles/plugin/unifiedSearch/1.0.0/unifiedSearch.chunk.1.js:1:24215)
    at ua (https://kibana-app.whitesector.inf.elasticnet.co/64715/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js:420:59279)
    at ec (https://kibana-app.whitesector.inf.elasticnet.co/64715/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js:420:115190)
    at Ic (https://kibana-app.whitesector.inf.elasticnet.co/64715/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js:420:99978)
    at Nc (https://kibana-app.whitesector.inf.elasticnet.co/64715/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js:420:99800)
    at Dc (https://kibana-app.whitesector.inf.elasticnet.co/64715/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js:420:99633)
    at wc (https://kibana-app.whitesector.inf.elasticnet.co/64715/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js:420:96466)
    at https://kibana-app.whitesector.inf.elasticnet.co/64715/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js:420:45201

After some investigation, we found that this happens here because indexPattern does not have a getName method.

The root cause is the incorrect type cast indexPatterns as DataView[] (from DataViewBase to DataView) that we do in several places around security solution code: 1, 2, 3, 4.

More details in slack https://elastic.slack.com/archives/CN7AD3605/p1692257845887359

Screenshots (if relevant):

20230817-0735-32.6812978.mp4
@e40pud e40pud added bug Fixes for quality problems that affect the customer experience triage_needed Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. labels Aug 21, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-solution (Team: SecuritySolution)

@MadameSheema MadameSheema added Team:Detections and Resp Security Detection Response Team Team:Detection Engine Security Solution Detection Engine Area labels Aug 21, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-detections-response (Team:Detections and Resp)

@e40pud
Copy link
Contributor Author

e40pud commented Aug 21, 2023

@kqualters-elastic suggested to fix this with the next steps:

  1. delete all the type casts
  2. convert all DataViewBase types to DataView, at the last possible place in the code we own, like we do here: so we aren't possibly passing the non-serializable class instance around in redux by mistake or something + reduce the size of component state/props

@MadameSheema
Copy link
Member

It would be great if we can fix this for 8.10 and 8.9.2 :)

@yctercero
Copy link
Contributor

I think this is going to be a bigger fix than it may seem, as in, it will touch a lot of files, We may need to discuss any risk in backporting.

@dhurley14
Copy link
Contributor

Have not been able to reproduce this so far. Neither on cloud nor locally. @aarju are you comfortable with providing an exported version of the rule? And a few more details that could be heplful.. Is that a data stream the rule is querying? Is this a rule that was created fresh in 8.9.0 or was the rule pre-existing prior to 8.9.0?

@dhurley14
Copy link
Contributor

Just clarifying - I agree the code referenced is not safe, but I would feel more comfortable knowing it was fixed correctly if I was able to reproduce the bug.

@yctercero
Copy link
Contributor

NOTE: #165262 went in as a fix but caused an infinite loop of calls to be made in rule creation and was reverted in #166176

@yctercero
Copy link
Contributor

Hey @dhurley14 ! Was this addressed by #166318 ?

@dhurley14
Copy link
Contributor

@yctercero I believe so! Been a while since I've seen this but I looked at the code and it seems the typeguard here should prevent the error from occurring: https://github.com/elastic/kibana/pull/166318/files#diff-e6442176bd5f8e996ee191a1b34c716e43c58ff4644adfcfca6dc98a386cb8caR41-R43

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience consider-next Team:Detection Engine Security Solution Detection Engine Area Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v8.11.0
Projects
Status: To do
Development

No branches or pull requests

5 participants