Implement non-eval based Vega execution path
See original GitHub issueFor security reasons, many modern web sites lock down their Content Security Policy with the script no-eval CSP rule, which prevents the new Function() code. Vega heavily relies on the dynamically generated expressions. While this may provide some performance benefits, it would be good to have a possibly-slower expression interpreter alternative (configurable).
As an experiment, I have created an alternative sandbox approach, but this might not be suitable to some complex apps: https://github.com/nyurik/csp-vega-test
Issue Analytics
- State:
- Created 6 years ago
- Reactions:9
- Comments:19 (8 by maintainers)
Top Results From Across the Web
Path Mark | Vega
Property Type Description
x Number The primary x‑coordinate in pixels.
x2 Number The secondary x‑coordinate in pixels.
width Number The width of the mark in pixels,...
Read more >Vega Vulnerability Scanner - Subgraph OS
Vega can help you find and validate SQL Injection, Cross-Site Scripting (XSS), inadvertently disclosed sensitive information, and other vulnerabilities. It is ...
Read more >Drugs, abuse and a drive to kill: Zane Floyd's path to Nevada ...
The jury found Floyd guilty of four first-degree murders with use of a ... In the 1980s and '90s, drugs were commonplace in...
Read more >The Twisted Path to Oklahoma's Looming Execution Spree
One week before he was killed in the death chamber at the Oklahoma State Penitentiary, Donald Grant asked a woman named Sue Hosch...
Read more >South Carolina Supreme Court halts state's plan for firing ...
Though Moore elected execution by firing squad earlier this month, ... South Carolina is one of eight states that still use the electric ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

The (safe) use of a
Functionconstructor underlies multiple Vega features, including not only expressions, but also compilation of visual encoding procedures. It’s unlikely that we (at UW) will focus efforts on building an alternative interpreter for these functions. However, we’re certainly open to reviewing 3rd party contributions.In Vega 3,
Functionconstructor calls arise due to a single line in the vega-runtime repository. Future extensions might start there, replacing the use ofFunction.applywith a custom JS parser/evaluator.For background context, the Vega parser generates output JS code for expressions and visual encoders, included within an output dataflow graph description. The runtime (typically invoked from vega-view) parses this description into a dataflow instance, including instantiation of functions.
Given the effort and potential performance implications of such changes, I recommend first following a sandbox approach if feasible.
This sounds like it will indeed be safer, but it will result in much more code being run through the expression language framework than is minimally necessary. That is what I am seeing after your changes to encode/entry.js:
In my previous comment, I gave an example of how expressions which would be generated to create a color (like that one) could instead be factored out into a function (makeColorStyle) that could be pre-compiled as part of the library. This would also be just as safe as running the equivalent expression text through the expression language framework, but it would result in much faster runtime performance since the interpreter would not have to be operating over that part of the code.