-
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Return value instead of the getter function for rewritten intrinsics #5
Comments
This is also something SES does, and it presents a problem, because an environment that starts out with specified data properties being accessor properties is not a spec-compliant javascript environment. I agree that explicitly listing either every intrinsic that's a data property, or every one that's an accessor, would address this problem, but we'd still be accounting for a broken environment. SES handles this by only turning things into getters when strictly necessary - which is not the case for Reflect.apply, for example. Perhaps WeChat miniprogram could use SES rather than incorrectly reinventing a solution for the problem of safely running code? |
cc @erights @kriskowal for visibility |
Does the value returned by the getter vary? I don’t think there’s a problem with cc @erights for review. |
I believe the taming through accessors is currently only necessary to handle the override mistake, and in a perfect world, we could freeze intrinsics without triggering it. That said, any modifications to the shape of the intrinsics should be reflected onto
My guess is that a 3rd option would actually work in most cases: pretend that they all exist. E.g. the replacement would have answers for all of |
If it’s going to lie, it should patch gOPD and gOPDs on Object/Reflect too, so that they can’t discover the lie. |
Yes. The thing about shimming is that the resulting environment ideally does not differ in any observable way from the environment being emulated. |
If that shimming was done successfully and thoroughly, then this library would treat it like a data property, no? |
As stated above, the accessors installed by the SES-shim Btw, for each of these accessors, the getter installed by the SES-shim also has an Currently, at https://github.com/endojs/endo/blob/master/packages/ses/src/enablements.js , the SES-shim provides three levels of compensation for the override mistake: |
Something else to note is that eventually the getIntrinsic proposal is highly likely to differentiate a data, get, and set property, at which point this package would follow suit - in other words, if gOPD betrays that it’s an accessor, then it will only be accessible that way. Thus, i think that the only solution here is that whenever SES converts a data property to an accessor, it makes gOPD and friends lie and pretend it’s a data property. |
Under some environments like WeChat Mini Program, built-in intrinsics are rewritten to prevent further modification. And the over-written code use getter/setter to hook property access and setting.
For example, when calling
GetIntrinsic('%Reflect.apply%')
it will return the override getter function instead of the apply function itself. That will cause many TypeError during the initialization of thees-extract
module.One possible fix is to list all native properties that use the getter/setter, e.g.
Map.prototype.size
. Only when getting such properties, return the getter. Otherwise,GetIntrinsic
always return the value return fromget()
.The text was updated successfully, but these errors were encountered: