Comments (7)
Implement[or use] a library that will sanitise the live code before executing it. Perhaps worth looking at existing editors such as CodePen and jsFiddle to determine if there are existing solutions before rolling our own.
from interactive-examples.
Codepen does this by running the example for a few seconds, then killing it if it is still running. For example, if you just write a pen like this:
for (let i = 0; i < 100000; i++) {
console.log("blah")
}
... you'll get the "infinite loop" error, and in the console a more nuanced message:
"[CodePen]: An infinite loop (or a loop taking too long) was detected, so we stopped its execution. Sorry!"
I guess to do this we would run it in a worker. Do you think this might also make us a bit happier about using eval, since the code wouldn't get access to the iframe's DOM?
from interactive-examples.
Adding release blocker label for the security question: is it acceptable for the editor to eval() user-entered JS, and if not which safer alternatives should we implement?
from interactive-examples.
Is this still a release blocker now that we are no longer using eval
?
from interactive-examples.
No :). If using Function addresses the security problems of eval, then this doesn't need to block.
from interactive-examples.
@wbamberg After having learned how codepen handles this, and that jsFiddle does not do anything to prevent users from running code like this, what do you say:
- Keep it in the backlog as a nice to have, maybe, possibly, some day based on user feedback or,
- Let's close this out and not worry about it.
Thanks!
from interactive-examples.
I am going to close this out. We can revisit in future should the need arise or a simple solution is found.
from interactive-examples.
Related Issues (20)
- [meta] Should we archive the wiki? HOT 1
- [meta] Ci can skip more types of changes HOT 1
- whitespace-example without whitespace included in code HOT 1
- [meta] CI runs on forks
- `::marker` class showing XML error HOT 2
- Prettier config deviates from mdn/content HOT 2
- Article element in a wrong implementation HOT 5
- :nth-child - update example to be inclusive HOT 5
- `npm install` has `2 vulnerabilities (1 moderate, 1 high)` HOT 2
- `1 moderate severity vulnerability` when running `npm install` HOT 2
- `Array.prototype.reduce()` demo requires horizontal scrolling HOT 7
- Expected output is wrong HOT 2
- Live example on the groups and backreferences page has inconsistent name HOT 3
- try it confusion HOT 2
- css.properties.backdrop-filter - The Firefox WebDev tool says invalid property name although it is running latest edition HOT 1
- Create an interactive example for `HWB()` HOT 5
- Example HTML Dialog HOT 3
- unnecessary css property in an interactive element HOT 3
- 'space-evenly' (and maybe others) in the demo looks odd given the use of grid-gap HOT 1
- Primary application A is nested with subapplication B, and subapplication B is nested with subapplication C. The font icon of subapplication C cannot be displayed HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from interactive-examples.