Extending Number.prototype

5 views
Skip to first unread message

Jordan Last

unread,
Mar 30, 2015, 9:26:05 AM3/30/15
to google-ca...@googlegroups.com
For my project it would be really nice to add methods to Number.prototype (or Object.prototype, but preferably Number.prototype), but Caja does not seem to allow it. I've been fiddling a bit with the built source code, but I can't seem to figure it out. Is there a safe way to do this?

Mark S. Miller

unread,
Mar 30, 2015, 11:22:54 AM3/30/15
to Google Caja Discuss
The site hosting Caja determines the properties of the accessible primordial objects, i.e., the objects such as Number.prototype, that all Caja guest objects get implicit access to. The default includes all properties specified by EcmaScript 5 (ES5) plus some other ES6 and some de facto properties, as enumerated at

If you are writing guest code to run on someone else's host, then you are subject to their decisions about what should be included. If you are the host, you *can* add your enhancements to Number.prototype, by loading these prior to loading Caja, and by enumerating your enhancements in whitelist.js. 

However, we encourage you not to. If you do, please be careful! All mutually suspicious code loaded into that Caja context (frame/realm) share access to these enhancements of your's, so it becomes your responsibility to ensure that these enhancements do not introduce vulnerabilities.

If you explain the nature of the enhancements you'd like to add to Number.prototype, we could help advise on the vulnerability issues that adding these might introduce.




On Mon, Mar 30, 2015 at 9:26 AM, Jordan Last <jordan.mi...@gmail.com> wrote:
For my project it would be really nice to add methods to Number.prototype (or Object.prototype, but preferably Number.prototype), but Caja does not seem to allow it. I've been fiddling a bit with the built source code, but I can't seem to figure it out. Is there a safe way to do this?

--

---
You received this message because you are subscribed to the Google Groups "Google Caja Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-caja-dis...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
    Cheers,
    --MarkM
Reply all
Reply to author
Forward
0 new messages