-
Notifications
You must be signed in to change notification settings - Fork 76
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
Polyfilling HostEnsureCanCompileStrings #120
Comments
HostEnsureCanCompileStrings
.
I like the Function constructor polyfill. Can we check if this doesn't break existing code? As for 'eval', I'm afraid that polyfilling it will introduce tricky functional bugs in the applications using the polyfill. I'm not yet convinced this is the right way to go; it might be more fitting to just mention that this is a known gap for the polyfill, and assume that |
Do you want to try out a canary project with the patch?
To make sure I understand, So our polyfill security caveats could recommend banning |
I have tried proxying I use a Function proxy to restrict dynamic code loading to certain modules in Node.js. That works with a bunch of legacy Node.js code. |
OK, that works for Function(). To make sure I understand the That's an implementation concern and I'm OK for the polyfill to cover less sinks than the native implementation if the alternative is to break applications in confusing ways. That said, for now I think we have to pause this anyway - as the Chrome implementation doesn't yet cover |
https://mikesamuel.github.io/proposal-hostensurecancompilestrings-passthru/ aims to address the lack of context in the host. |
I moved the spec-centric issues to #207. I propose we postpone the polyfilling until after the spec issues are resolved. We won't be able to polyfill everything, so I'm thinking on whether we should attempt to in the TT polyfill, given that we'd likely run into performance, or some stack trace introspection issues. To demonstrate feasibility, we can probably create a Babel plugin. WDYT, @mikesamuel ? |
@koto, +1 |
Collecting issues for polyfilling https://wicg.github.io/trusted-types/dist/spec/#string-compilation
IIUC, this is meant to require TrustedScript inputs to
new Function
andeval
.We would need to change the behavior of
new Function(x)
without changing basic identities like(function () {}) instanceof Function
.https://gist.github.com/mikesamuel/4f3696975ec47d09de50dc3f4328dfe9 does that by creating a proxy over
Function
that traps[[Construct]]
and[[Apply]]
.The polyfill should also preserve the
eval
function /eval
operator distinction from:window.eval
does PerformEval with direct=falseeval
uses direct=trueand direct affects whether the lexical environment (step 9) is the top of the stack or the global environment.
This difference can be seen in
This is trickier because a bare
eval(...)
is only the eval operator when step 4.a of the bare function call finds thateval
in scope is the same as the Realm's originaleval
value:We could fake that by reassigning
global.eval
while being careful to not open a window for recursive calls toeval
in the script body by prepending something to the script body, but that would still not get the wrapper function off the top of the environment stack.The text was updated successfully, but these errors were encountered: