-
Notifications
You must be signed in to change notification settings - Fork 237
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
Avoid using function constructor for alt format handling #12
Conversation
This allows rbush to be used where the Content Security Policy (or other) disallows the use of eval and related functions (e.g. browser extensions). Previously, the format supplied could contain function calls (e.g. `['.getMaxX()', ...]`). With this change, only property names are accepted - though they can be dot prefixed or bracket wrapped (e.g. '.maxX' or '[0]').
The tests and docs didn't show use of |
That's interesting, I've never heard about security policies blocking eval-like statements. Can you share more details on this? What was the original related issue that you encountered? This could be a nice change, but doesn't support more complex data scenarios (e.g. |
The security stuff was brought up in Leaflet too, so that's a valid point it seems. Leaflet/Leaflet#2209 An alternative solution (although requiring more verbose code) would be to make toBBox/compare methods public and don't run |
Yes, the Content Security Policy (CSP) for browser apps/extensions is the common case where Allowing people to override the FWIW, I couldn't find any significant difference in the benchmarks with and without this change. But I also didn't have the patience to run them enough times to get much confidence in the results :). |
@mourner here's an alternate implementation: https://github.com/tschaub/rbush/compare/less-evil-II This is quite a bit more verbose. If you do allow custom |
Nice, thanks! I meant that we could keep the current format handling (instead of removing it completely), but make it possible to bypass it in vulnerable cases such as developing an extension. Yeah, no need to slice the bbox — it was done this way for simplicity in format-handling code (I found no significant performance difference). |
Makes sense. I can update that branch. |
Ok, closing in favor of #14. Let me know if you had something else in mind. |
This allows rbush to be used where the Content Security Policy (or other) disallows the use of eval and related functions (e.g. browser extensions). Previously, the format supplied could contain function calls (e.g.
['.getMaxX()', ...]
). With this change, only property names are accepted - though they can be dot prefixed or bracket wrapped (e.g.'.maxX'
or'[0]'
).