Coder Social home page Coder Social logo

Comments (7)

schalkneethling avatar schalkneethling commented on June 19, 2024

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.

wbamberg avatar wbamberg commented on June 19, 2024

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.

wbamberg avatar wbamberg commented on June 19, 2024

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.

schalkneethling avatar schalkneethling commented on June 19, 2024

Is this still a release blocker now that we are no longer using eval?

from interactive-examples.

wbamberg avatar wbamberg commented on June 19, 2024

No :). If using Function addresses the security problems of eval, then this doesn't need to block.

from interactive-examples.

schalkneethling avatar schalkneethling commented on June 19, 2024

@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:

  1. Keep it in the backlog as a nice to have, maybe, possibly, some day based on user feedback or,
  2. Let's close this out and not worry about it.

Thanks!

from interactive-examples.

schalkneethling avatar schalkneethling commented on June 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.