GithubHelp home page GithubHelp logo

Comments (8)

svaarala avatar svaarala commented on June 17, 2024

Internal properties should also be aligned with ES6 Symbols:

from duktape.

svaarala avatar svaarala commented on June 17, 2024

Prototype branch with a draft that hides internal properties from Ecmascript code but allows user C code to access them:

This should suffice for sandboxing, but:

  • The branch adds an extra flags field to property methods which is of course additional overhead (quite useful for other things too, though).
  • It's easy for a user C function to bypass the sandboxing by doing a property lookup using an Ecmascript-supplied key. So it might be better to have an entirely separate C API call to access an internal property (perhaps aligned to the ES6 symbols, e.g. duk_get_prop_symbol() or similar).

from duktape.

fatcerberus avatar fatcerberus commented on June 17, 2024

I suppose this means Duktape 2.0 will include support for Symbols as well? :)

from duktape.

svaarala avatar svaarala commented on June 17, 2024

Not necessarily, but if changes are made to the internal property model, there should at least be a plan how symbols will be implemented without needing another incompatible change :)

from duktape.

svaarala avatar svaarala commented on June 17, 2024

I'll move this to 3.0.0 because the symbol support is still experimental and making this change makes more sense when that behavior is finalized.

from duktape.

fatcerberus avatar fatcerberus commented on June 17, 2024

The only Ecmascript binding remaining that can create hidden symbols is Duktape.dec() right? So removing the Duktape binding should be enough of a stopgap until this is implemented.

from duktape.

svaarala avatar svaarala commented on June 17, 2024

Actually no, Duktape.dec() creates a plain buffer as its output right now (maybe changing to Uint8Array to use standard types); one could create a similar buffer by other means. When you convert that buffer to a string, an encoding is applied just like with any other buffer.

from duktape.

svaarala avatar svaarala commented on June 17, 2024

So the remaining risk is C code that pushes unvalidated / un-encoded data using duk_push_string() and creates a hidden Symbol by accident. That's avoided cleanly if C code always encodes/validates strings it pushes to be CESU-8; any other formats will create weirdly behaving strings in any case.

from duktape.

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.