-
Notifications
You must be signed in to change notification settings - Fork 19
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
rejectSomeDirectEvalExpressions is too aggressive #34
Comments
I believe it is possible, but terrifying to contemplate. Somewhere there's a thread between @SMotaal and me exploring a static verification + rewrite + enhanced proxy behavior that looks like it might be able to do this safely. However, the benefit it would produce would not pay for the gargantuan task of verifying that this pattern is actually safe. It would be a noble experiment, but not one we should accept back into the shim.
Necessary for (1) and must be combined with (1) to achieve the goal. Direct eval is hard to emulate without using direct eval.
If this is what I think you mean, I agree with (3). To restate: We should add an option, default off, that if on suppresses the rejection, allowing the previous indirect eval behavior.
I think the current behavior, where it defaults to rejection, is necessary for future compat. However, (3) for present kinda-compat by optional flag, with documentation, is a nice addition. (3) fits with my general stance on unifying the shims between the major players: Currently Agoric, Salesforce, MetaMask, Figma. We will each demand somewhat different detailed policy decisions. However, we should avoid having our differences in details force any of us to fork, if we can avoid this at reasonable cost. Best would be to accommodate such differences with proper policy mechanism separation, where the shims (and the std they shim) provides the mechanism, such that policy variations can be built on top. However, when we can't achieve this cleanly, as here, we should add an option enabling switching between plausible policy choices. In all cases, such options should default to the safer setting. |
Meaning, major users of the shim. We should of course also coordinate Moddable on their direct SES implementation. We should ensure that all of these will correspond together to a reasonable draft spec. |
Ok, I also think 3 is the way to do. Now, considering that this is a shim (not a polyfill [1]), I will propose that the execution of the shim code does not install the global import factory from "realms-shim";
globalThis.Realm = factory({ optionFoo: 1, optionBar: 2 });
const r = Realm.makeRootRealm(); Pros:
Cons:
[1]* a polyfill is supposed to be transparent and undetectable once executed, while a shim can have a custom initialization and can differ from the specification. |
any thoughts on the proposal? |
@caridy I think a somewhat different take here could be: import {Realm} from 'realms-shim/globals.js' My thinking here is that globals are the exported set of whitelisted globals and globals that would be exposed (but are not by the shim). This does not account for making multiple |
On the first question, I still favor (3): provide an option for suppressing the rejection behavior. On the polyfill vs shim issue, two questions: Given a polyfill, can one build a shim as a trivial wrapper around the polyfill? In your example import factory from "realms-shim";
globalThis.Realm = factory({ optionFoo: 1, optionBar: 2 });
const r = Realm.makeRootRealm(); The new realm |
yes, that's the normal progression from a shim to a polyfill. as for the other question, yes, that is correct. we can also be more aggressive and let the factory to set the |
I think the factory should remain a pure factory. Given this factoring between polyfill and shim, leave it to the shim to install the result of the polyfill factory. But I say this in ignorance of polyfill common practice. Altogether, I support this. |
Encountered an issue where the came from my own use of harden, and not SES's internal use of harden |
What transpilers are translating this line first? Might something be (0,eval)('this') into eval('this') ? If so, that is a horribly incorrect translation. If not, then I am confused |
When it comes to evaluate arbitrary code inside a realm, sometimes throwing when direct eval is used (intentionally or not), makes the adoption of the shim more complicated. Even though executing the direct eval declaration as indirect eval is terrible, sometimes that compromise is desirable (e.g.: legacy code).
As today, this is one of the remaining issues for us to use the shim as it is, instead, it forces us to fork and change the logic in:
https://github.com/Agoric/realms-shim/blob/master/src/sourceParser.js#L97
I see few options:
/cc @jdalton
The text was updated successfully, but these errors were encountered: