|
|
|
Created:
15 years, 4 months ago by metaweta Modified:
15 years, 3 months ago CC:
google-caja-discuss_googlegroups.com, tvcutsem_vub.ac.be Base URL:
http://google-caja.googlecode.com/svn/trunk/ Visibility:
Public. |
DescriptionAdds object proxies.
Patch Set 1 #
Total comments: 14
Patch Set 2 : Adds object proxies. #
Total comments: 9
Patch Set 3 : Adds object proxies. #
Total comments: 2
Patch Set 4 : Adds object proxies. #
Total comments: 10
Patch Set 5 : Adds object proxies. #
Total comments: 1
Patch Set 6 : Adds object proxies. #Patch Set 7 : Adds object proxies. #Patch Set 8 : Adds object proxies. #
Total comments: 14
Patch Set 9 : Adds object proxies. #
Total comments: 1
Patch Set 10 : Adds object proxies. #Patch Set 11 : Adds object proxies. #Patch Set 12 : Adds object proxies. #Patch Set 13 : Adds object proxies. #Patch Set 14 : Adds object proxies. #Patch Set 15 : Adds object proxies. #
Total comments: 5
Patch Set 16 : Adds object proxies. #
Total comments: 5
Patch Set 17 : Adds object proxies. #
Total comments: 5
Patch Set 18 : Adds object proxies. #Patch Set 19 : Adds object proxies. #Patch Set 20 : Adds object proxies. #Patch Set 21 : Adds object proxies. #
Total comments: 2
MessagesTotal messages: 30
Talk to me about fixing proxies. http://codereview.appspot.com/4701044/diff/1/src/com/google/caja/es53.js File src/com/google/caja/es53.js (right): http://codereview.appspot.com/4701044/diff/1/src/com/google/caja/es53.js#newc... src/com/google/caja/es53.js:134: * Per-object properties: Perhaps we should divide this list into those that are overridden by proxies and those which aren't? http://codereview.appspot.com/4701044/diff/1/src/com/google/caja/es53.js#newc... src/com/google/caja/es53.js:146: * {@code obj.v___(p)} = {@code obj.[[Get]](p)} Since we check below whether obj.v___ === deferredV, it may be worth documenting here that this value has that special significance? http://codereview.appspot.com/4701044/diff/1/src/com/google/caja/es53.js#newc... src/com/google/caja/es53.js:154: * {@code obj.freeze___()} freezes the object; on proxies invokes Have pe___ and freeze___. Need seal___ as well. http://codereview.appspot.com/4701044/diff/1/src/com/google/caja/es53.js#newc... src/com/google/caja/es53.js:216: // configurable, and the thisect itself is not extensible. typo: "thisect". Also below. Due to a "s/obj/this/" ? http://codereview.appspot.com/4701044/diff/1/src/com/google/caja/es53.js#newc... src/com/google/caja/es53.js:2751: if (!O.HasOwnProperty___(P)) { The earlier one inlined guestHasOwnProperty for speed. Should this likewise inline HasOwnProperty___ for speed? Does it no longer need to? http://codereview.appspot.com/4701044/diff/1/src/com/google/caja/es53.js#newc... src/com/google/caja/es53.js:3631: if (result === void 0) { throw new TypeError("Unable to freeze."); } If we move this test into the freeze___ method of proxies, we get to avoid this test for normal objects. http://codereview.appspot.com/4701044/diff/1/src/com/google/caja/es53.js#newc... src/com/google/caja/es53.js:3639: throw new TypeError('Only objects may be frozen.'); Should be "may be made non-extensible" http://codereview.appspot.com/4701044/diff/1/src/com/google/caja/es53.js#newc... src/com/google/caja/es53.js:3642: if (result === void 0) { Likewise, we could move this test into the pe___ method of proxies, saving a test in the normal case. http://codereview.appspot.com/4701044/diff/3001/src/com/google/caja/es53.js File src/com/google/caja/es53.js (right): http://codereview.appspot.com/4701044/diff/3001/src/com/google/caja/es53.js#n... src/com/google/caja/es53.js:3561: if (!result) { throw new TypeError('Unable to seal.'); } Likewise move test to seal___ method of proxies. http://codereview.appspot.com/4701044/diff/3001/src/com/google/caja/es53.js#n... src/com/google/caja/es53.js:4950: proxy.freeze___ = proxy.pe___ = proxy.seal___ = function () { I don't see how this implements any of the needed semantics beyond invoking the fix trap.
Sign in to reply to this message.
http://codereview.appspot.com/4701044/diff/3001/src/com/google/caja/es53.js File src/com/google/caja/es53.js (right): http://codereview.appspot.com/4701044/diff/3001/src/com/google/caja/es53.js#n... src/com/google/caja/es53.js:4694: return !!(dis.getPropertyDescriptor_m___ === dis ? The fastpath test for *_m___ is only a test for truthiness, not own-ness. Applies many places. http://codereview.appspot.com/4701044/diff/3001/src/com/google/caja/es53.js#n... src/com/google/caja/es53.js:4706: // Test if the old "reviver" parameter was passed s/reviver/receiver/. Interesting idea. http://codereview.appspot.com/4701044/diff/3001/src/com/google/caja/es53.js#n... src/com/google/caja/es53.js:4727: // Test if the old "reviver" property was passed receiver
Sign in to reply to this message.
http://codereview.appspot.com/4701044/diff/3001/src/com/google/caja/es53.js File src/com/google/caja/es53.js (right): http://codereview.appspot.com/4701044/diff/3001/src/com/google/caja/es53.js#n... src/com/google/caja/es53.js:4694: return !!(dis.getPropertyDescriptor_m___ === dis ? On 2011/07/14 05:01:01, Mark S. Miller wrote: > The fastpath test for *_m___ is only a test for truthiness, not own-ness. > Applies many places. Done. Also fixed the comment in the header and fastpathMethod. http://codereview.appspot.com/4701044/diff/3001/src/com/google/caja/es53.js#n... src/com/google/caja/es53.js:4706: // Test if the old "reviver" parameter was passed On 2011/07/14 05:01:01, Mark S. Miller wrote: > s/reviver/receiver/. Interesting idea. Done. http://codereview.appspot.com/4701044/diff/3001/src/com/google/caja/es53.js#n... src/com/google/caja/es53.js:4727: // Test if the old "reviver" property was passed On 2011/07/14 05:01:01, Mark S. Miller wrote: > receiver Done. http://codereview.appspot.com/4701044/diff/3001/src/com/google/caja/es53.js#n... src/com/google/caja/es53.js:4950: proxy.freeze___ = proxy.pe___ = proxy.seal___ = function () { On 2011/07/13 23:06:19, Mark S. Miller wrote: > I don't see how this implements any of the needed semantics beyond invoking the > fix trap. It doesn't. I totally spaced on that one. Now done.
Sign in to reply to this message.
http://codereview.appspot.com/4701044/diff/8001/src/com/google/caja/es53.js File src/com/google/caja/es53.js (right): http://codereview.appspot.com/4701044/diff/8001/src/com/google/caja/es53.js#n... src/com/google/caja/es53.js:2757: if (!O[P + '_v___']) { This looks like an own-or-inherited check, i.e., an "in" check. If the context has already ruled out the inherited case by the time we get here, I'm missing it, so it at least deserves a comment.
Sign in to reply to this message.
http://codereview.appspot.com/4701044/diff/13001/src/com/google/caja/es53.js File src/com/google/caja/es53.js (right): http://codereview.appspot.com/4701044/diff/13001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:2757: if (O.hasOwnProperty(P + '_v___')) { Did you drop a "not"?
Sign in to reply to this message.
http://codereview.appspot.com/4701044/diff/13001/src/com/google/caja/es53.js File src/com/google/caja/es53.js (right): http://codereview.appspot.com/4701044/diff/13001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:4788: names.filter(filter) : Is filter virtualized? http://codereview.appspot.com/4701044/diff/13001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:4840: validateHandler(handler); Is this validation in the spec? It doesn't actually provide any hard safety, since a handler could mutate itself after validation so that it would no longer validate. But this still may be a good idea for catching bugs early. If so, perhaps some way to issue a warning or make the validation optional or something? At least a comment to explain why we're deviating from the spec? OTOH, for the sake of our own implementation limitation gotcha, we do need to validate that proto and all objects it inherits from are not proxies and are not extensible. http://codereview.appspot.com/4701044/diff/13001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:4841: var proxy = {}; proxy must inherit from proto. http://codereview.appspot.com/4701044/diff/13001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:4852: if ('get_v___' in handler) { No, you musn't test cajole('get' in handler) to test the presence of the get trap, or you break the double lifting trick. Rather, you should test the value of cajole(handler.get), IIRC, to see whether it's callable. If so, then the get trap is considered present and you trap to it. Otherwise you use the default. This problem is repeated below. http://codereview.appspot.com/4701044/diff/13001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:4853: return (handler.get_m___ === handler ? Another mistaken formulation of the _m___ fastpath. Please recheck the whole file. I see other occurrences of this problem.
Sign in to reply to this message.
http://codereview.appspot.com/4701044/diff/8001/src/com/google/caja/es53.js File src/com/google/caja/es53.js (right): http://codereview.appspot.com/4701044/diff/8001/src/com/google/caja/es53.js#n... src/com/google/caja/es53.js:2757: if (!O[P + '_v___']) { On 2011/07/14 22:59:09, Mark S. Miller wrote: > This looks like an own-or-inherited check, i.e., an "in" check. If the context > has already ruled out the inherited case by the time we get here, I'm missing > it, so it at least deserves a comment. Done.
Sign in to reply to this message.
http://codereview.appspot.com/4701044/diff/18001/src/com/google/caja/es53.js File src/com/google/caja/es53.js (right): http://codereview.appspot.com/4701044/diff/18001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:2755: // Inline HasOwnProperty___. Works with proxies because GetOwnProperty___ The comment is now stale.
Sign in to reply to this message.
http://codereview.appspot.com/4701044/diff/13001/src/com/google/caja/es53.js File src/com/google/caja/es53.js (right): http://codereview.appspot.com/4701044/diff/13001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:4788: names.filter(filter) : On 2011/07/15 04:59:13, Mark S. Miller wrote: > Is filter virtualized? No to both filters. The method filter is just a method on whatever object handler.getPropertyNames() returns. The function filter is defined immediately above. I also removed the own check in the fastpath. http://codereview.appspot.com/4701044/diff/13001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:4840: validateHandler(handler); On 2011/07/15 04:59:13, Mark S. Miller wrote: > Is this validation in the spec? It doesn't actually provide any hard safety, > since a handler could mutate itself after validation so that it would no longer > validate. But this still may be a good idea for catching bugs early. If so, > perhaps some way to issue a warning or make the validation optional or > something? At least a comment to explain why we're deviating from the spec? > > OTOH, for the sake of our own implementation limitation gotcha, we do need to > validate that proto and all objects it inherits from are not proxies and are not > extensible. The spec says "handler is an object that at minimum implements the following API". This check obviously just catches bugs early; the worst that could happen if the handler modifies itself is that it tries to look up a method on the handler and doesn't find it. http://codereview.appspot.com/4701044/diff/13001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:4841: var proxy = {}; On 2011/07/15 04:59:13, Mark S. Miller wrote: > proxy must inherit from proto. Done. http://codereview.appspot.com/4701044/diff/13001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:4853: return (handler.get_m___ === handler ? On 2011/07/15 04:59:13, Mark S. Miller wrote: > Another mistaken formulation of the _m___ fastpath. Please recheck the whole > file. I see other occurrences of this problem. There are no more instances of "_m___ ===".
Sign in to reply to this message.
Fixed up a bunch of the semantics, adding guards etc.
Sign in to reply to this message.
What should we do about asFirstClass? I don't think there's a value we can compare the f___ property to that will work on functions cross frame. Should we put an ok___ property on all whitelisted and tame functions?
Sign in to reply to this message.
http://codereview.appspot.com/4701044/diff/29001/src/com/google/caja/es53.js File src/com/google/caja/es53.js (right): http://codereview.appspot.com/4701044/diff/29001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:3563: var keys = ownKeys(O), len = keys.length; I think both freeze___ and seal___ look correct. But why do they loop through their own properties in different ways? Since they both need to make the same set of properties non-configurable, it would make the equivalence easier to understand if they used the same iteration logic. Likewise for minor but unnecessary naming differences like "P" vs "j", "O" vs "this", and turning extensibility off at the beginning vs the end.
Sign in to reply to this message.
http://codereview.appspot.com/4701044/diff/29001/src/com/google/caja/es53.js File src/com/google/caja/es53.js (right): http://codereview.appspot.com/4701044/diff/29001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:4711: return desc.get.f___(safeDis(proxy), []); Since desc is untrusted (it came from cajoled code), desc.get could be an accessor, or desc itself may be a proxy. In either case, the expression above for obtaining the value of desc.get is correct, but the obtained value should be used here (e.g. "getter.f___(...") rather than asking the same question twice and assuming stable answers. Likewise perhaps at other places below; I haven't checked.
Sign in to reply to this message.
http://codereview.appspot.com/4701044/diff/29001/src/com/google/caja/es53.js File src/com/google/caja/es53.js (right): http://codereview.appspot.com/4701044/diff/29001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:4804: var desc = dis.getPropertyDescriptor_m___ ? Not that it will typically make a difference, but http://wiki.ecmascript.org/doku.php?id=harmony:proxies#trap_defaults says you should call getOwnPropertyDescriptor here, and the difference is observable.
Sign in to reply to this message.
http://codereview.appspot.com/4701044/diff/29001/src/com/google/caja/es53.js File src/com/google/caja/es53.js (right): http://codereview.appspot.com/4701044/diff/29001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:4711: return desc.get.f___(safeDis(proxy), []); On 2011/07/20 00:12:02, Mark S. Miller wrote: > Since desc is untrusted (it came from cajoled code), desc.get could be an > accessor, or desc itself may be a proxy. In either case, the expression above > for obtaining the value of desc.get is correct, but the obtained value should be > used here (e.g. "getter.f___(...") rather than asking the same question twice > and assuming stable answers. > > Likewise perhaps at other places below; I haven't checked. I was surprised to find that the proxies default handlers page actually specified that desc.get and desc.set each be obtained twice, which seems wrong for the above reasons. At http://wiki.ecmascript.org/doku.php?id=harmony:proxies&rev=1310650763&do=diff I revised it to ask each of these once. Tom, does this change seem right to you? Was there a reason other than brevity why the previous code asked each question twice? I notice that this code is prefaced with a disclaimer that it is normative. Where is the normative expression of these default trap behaviors? Does it ask these once or twice?
Sign in to reply to this message.
http://codereview.appspot.com/4701044/diff/29001/src/com/google/caja/es53.js File src/com/google/caja/es53.js (right): http://codereview.appspot.com/4701044/diff/29001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:4827: if (!h || typeof h !== 'object') { Can a handler not be a function? http://codereview.appspot.com/4701044/diff/29001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:4839: ' to be a function, not ' + trapType); (typeof X === 'function') does not test whether X is a function; it tests whether X is callable. Go figure ;). http://codereview.appspot.com/4701044/diff/29001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:4856: proxy = beget(proto); We need to validate that proto, and all the objects it inherits from, are non-extensible non-proxies. Otherwise, our proxy implementation technique doesn't work. And even if we, there's one more thing we need to do here in order for our proxy implementation to work: We need to override the fastpath flags of all inherited properties to set the fastpath to false. That way, an attempt to access those properties will not bypass the proxy intercepts.
Sign in to reply to this message.
http://codereview.appspot.com/4701044/diff/29001/src/com/google/caja/es53.js File src/com/google/caja/es53.js (right): http://codereview.appspot.com/4701044/diff/29001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:3563: var keys = ownKeys(O), len = keys.length; On 2011/07/19 23:11:39, Mark S. Miller wrote: > I think both freeze___ and seal___ look correct. But why do they loop through > their own properties in different ways? Since they both need to make the same > set of properties non-configurable, it would make the equivalence easier to > understand if they used the same iteration logic. > > Likewise for minor but unnecessary naming differences like "P" vs "j", "O" vs > "this", and turning extensibility off at the beginning vs the end. Done. http://codereview.appspot.com/4701044/diff/29001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:4711: return desc.get.f___(safeDis(proxy), []); On 2011/07/20 00:12:02, Mark S. Miller wrote: > Since desc is untrusted (it came from cajoled code), desc.get could be an > accessor, or desc itself may be a proxy. In either case, the expression above > for obtaining the value of desc.get is correct, but the obtained value should be > used here (e.g. "getter.f___(...") rather than asking the same question twice > and assuming stable answers. > > Likewise perhaps at other places below; I haven't checked. Done. http://codereview.appspot.com/4701044/diff/29001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:4711: return desc.get.f___(safeDis(proxy), []); On 2011/07/20 00:37:53, Mark S. Miller wrote: > On 2011/07/20 00:12:02, Mark S. Miller wrote: > > Since desc is untrusted (it came from cajoled code), desc.get could be an > > accessor, or desc itself may be a proxy. In either case, the expression above > > for obtaining the value of desc.get is correct, but the obtained value should > be > > used here (e.g. "getter.f___(...") rather than asking the same question twice > > and assuming stable answers. > > > > Likewise perhaps at other places below; I haven't checked. > > I was surprised to find that the proxies default handlers page actually > specified that desc.get and desc.set each be obtained twice, which seems wrong > for the above reasons. At > http://wiki.ecmascript.org/doku.php?id=harmony:proxies&rev=1310650763&do=diff I > revised it to ask each of these once. I'm following these semantics. http://codereview.appspot.com/4701044/diff/29001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:4827: if (!h || typeof h !== 'object') { On 2011/07/20 00:54:42, Mark S. Miller wrote: > Can a handler not be a function? Got rid of validateHandler, since we're now failing late and it couldn't provide a guarantee anyway. http://codereview.appspot.com/4701044/diff/29001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:4839: ' to be a function, not ' + trapType); On 2011/07/20 00:54:42, Mark S. Miller wrote: > (typeof X === 'function') does not test whether X is a function; it tests > whether X is callable. Go figure ;). Done. http://codereview.appspot.com/4701044/diff/29001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:4856: proxy = beget(proto); On 2011/07/20 00:54:42, Mark S. Miller wrote: > We need to validate that proto, and all the objects it inherits from, are > non-extensible non-proxies. Otherwise, our proxy implementation technique > doesn't work. > > And even if we, there's one more thing we need to do here in order for our proxy > implementation to work: We need to override the fastpath flags of all inherited > properties to set the fastpath to false. That way, an attempt to access those > properties will not bypass the proxy intercepts. Done.
Sign in to reply to this message.
http://codereview.appspot.com/4701044/diff/37001/src/com/google/caja/es53.js File src/com/google/caja/es53.js (right): http://codereview.appspot.com/4701044/diff/37001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:4852: if (!proto.ne___) { This ensures only that *any* the objects the proxy would inherit from are non-extensible. It needs to ensure that *all* ..
Sign in to reply to this message.
http://codereview.appspot.com/4701044/diff/44001/src/com/google/caja/es53.js File src/com/google/caja/es53.js (right): http://codereview.appspot.com/4701044/diff/44001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:4849: if (isIn('get', handler)) { Can't do 'in' test to test for presence of trap in handler. must [[get]] and then simply check the obtained value. Otherwise we break double-lifting trick. http://codereview.appspot.com/4701044/diff/44001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:5038: if (proto === void 0) { if (proto === void 0 || proto === null) { since null is a valid value in the original API. Are we capturing gotchas anywhere? The fact that we turn absent parent into Object.prototype is an ES5/3 gotcha.
Sign in to reply to this message.
http://codereview.appspot.com/4701044/diff/44001/src/com/google/caja/es53.js File src/com/google/caja/es53.js (right): http://codereview.appspot.com/4701044/diff/44001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:4849: if (isIn('get', handler)) { On 2011/07/22 17:45:24, Mark S. Miller wrote: > Can't do 'in' test to test for presence of trap in handler. must [[get]] and > then simply check the obtained value. Otherwise we break double-lifting trick. Done. http://codereview.appspot.com/4701044/diff/44001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:5038: if (proto === void 0) { On 2011/07/22 17:45:24, Mark S. Miller wrote: > if (proto === void 0 || proto === null) { > since null is a valid value in the original API. > Are we capturing gotchas anywhere? The fact that we turn absent parent into > Object.prototype is an ES5/3 gotcha. Done.
Sign in to reply to this message.
Mike, when you fix a problem, please fix all occurrences of the problem. http://codereview.appspot.com/4701044/diff/45004/src/com/google/caja/es53.js File src/com/google/caja/es53.js (right): http://codereview.appspot.com/4701044/diff/45004/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:4867: if (isIn('get', handler)) { And this of course. And it should be checking 'set', not 'get'. http://codereview.appspot.com/4701044/diff/45004/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:4918: if (isIn('enumerate', handler)) { And this. http://codereview.appspot.com/4701044/diff/45004/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:4938: if (isIn('keys', handler)) { And this. http://codereview.appspot.com/4701044/diff/45004/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:5009: if (isIn('has', handler)) { And this. http://codereview.appspot.com/4701044/diff/45004/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:5023: if (isIn('hasOwn', handler)) { And this.
Sign in to reply to this message.
http://codereview.appspot.com/4701044/diff/44001/src/com/google/caja/es53.js File src/com/google/caja/es53.js (right): http://codereview.appspot.com/4701044/diff/44001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:4849: if (isIn('get', handler)) { On 2011/07/22 17:45:24, Mark S. Miller wrote: > Can't do 'in' test to test for presence of trap in handler. must [[get]] and > then simply check the obtained value. Otherwise we break double-lifting trick. Actually, isIn defers to HasProperty___ which proxies override. But I've rewritten it here and below.
Sign in to reply to this message.
On Fri, Jul 22, 2011 at 12:14 PM, <erights@google.com> wrote: > Mike, when you fix a problem, please fix all occurrences of the problem. Already did. -- Mike Stay - metaweta@gmail.com http://www.cs.auckland.ac.nz/~mike http://reperiendi.wordpress.com
Sign in to reply to this message.
On 2011/07/22 19:14:44, Mark S. Miller wrote: > Mike, when you fix a problem, please fix all occurrences of the problem. Sorry, was looking at wrong version.
Sign in to reply to this message.
Snapshotted with a fix to the ne___ bug (I fixed it in the function proxy cl I'm working on but forgot to put it in the original) and added a test. On Fri, Jul 22, 2011 at 12:18 PM, <erights@google.com> wrote: > On 2011/07/22 19:14:44, Mark S. Miller wrote: >> >> Mike, when you fix a problem, please fix all occurrences of the > > problem. > > Sorry, was looking at wrong version. > > http://codereview.appspot.com/4701044/ > -- Mike Stay - metaweta@gmail.com http://www.cs.auckland.ac.nz/~mike http://reperiendi.wordpress.com
Sign in to reply to this message.
Except for the issue below, especially the things that trigger a fix trap, LGTM. I'll be in this afternoon. Let's go over pe___, seal___, and freeze___ in person. http://codereview.appspot.com/4701044/diff/49001/src/com/google/caja/es53.js File src/com/google/caja/es53.js (right): http://codereview.appspot.com/4701044/diff/49001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:4927: result.DefineOwnProperty___(names[i], { enumerable: true }); 'names' is untrusted (it was obtained from an untrusted handler). But the code here assumes that names[i] is the same value that was just validated by "assertValidPropertyName(names[i]);" above. http://codereview.appspot.com/4701044/diff/49001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:4956: delete proxy.fixing___; Since the "throw new TypeError" on the following line can be caught by an untrusted handler, I'm suspicious of this deletion. Rather, I think this flag should only be deleted by unwinding the original setting of the flag, below. If the semantics says otherwise, please let me know. It may be a bug in the semantics. http://codereview.appspot.com/4701044/diff/49001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:4963: delete proxy.fixing___; I suspect we need to put the fix call above into the try block of a try/finally and put this delete into its finally block. http://codereview.appspot.com/4701044/diff/49001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:4968: delete proxy[i]; This delete will fail for any i that aren't own properties of the proxy. In non-strict code, that's technically ok, but it would be good for ES5/3 to be compatible with strict. For that reason as well as general clarity, we should guard this with an own check. http://codereview.appspot.com/4701044/diff/49001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:4976: return proxy; The initiaization of the proxy from the descMap looks good. But for pe___ you need to then set the ne___ flag. For seal___ and freeze___, you additionally need to seal and freeze it.
Sign in to reply to this message.
On Fri, Jul 22, 2011 at 12:38 PM, <erights@google.com> wrote: > Except for the issue below, especially the things that trigger a fix > trap, LGTM. I'll be in this afternoon. Let's go over pe___, seal___, and > freeze___ in person. > Just found out I'm about to be busy on phone. Don't know for how long. Will let u know when call is over. -- Cheers, --MarkM
Sign in to reply to this message.
Modulo the names[i] problem below, LGTM. http://codereview.appspot.com/4701044/diff/49002/src/com/google/caja/es53.js File src/com/google/caja/es53.js (right): http://codereview.appspot.com/4701044/diff/49002/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:4924: assertValidPropertyName(names[i]); This still has the double use of "names[i]" problem. Also, we're not even coercing the validated value to a string first, so the evil handler could give us a var str = 'valid'; var sneaky = { toString() { var result = str; str = 'evil__'; return result; } }; sneaky object as names[i]. http://codereview.appspot.com/4701044/diff/49002/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:4944: result.push('' + names[i]); Exactly, yes.
Sign in to reply to this message.
http://codereview.appspot.com/4701044/diff/29001/src/com/google/caja/es53.js File src/com/google/caja/es53.js (right): http://codereview.appspot.com/4701044/diff/29001/src/com/google/caja/es53.js#... src/com/google/caja/es53.js:4711: return desc.get.f___(safeDis(proxy), []); On 2011/07/20 00:37:53, Mark S. Miller wrote: > On 2011/07/20 00:12:02, Mark S. Miller wrote: > > Since desc is untrusted (it came from cajoled code), desc.get could be an > > accessor, or desc itself may be a proxy. In either case, the expression above > > for obtaining the value of desc.get is correct, but the obtained value should > be > > used here (e.g. "getter.f___(...") rather than asking the same question twice > > and assuming stable answers. > > > > Likewise perhaps at other places below; I haven't checked. > > I was surprised to find that the proxies default handlers page actually > specified that desc.get and desc.set each be obtained twice, which seems wrong > for the above reasons. At > http://wiki.ecmascript.org/doku.php?id=harmony:proxies&rev=1310650763&do=diff I > revised it to ask each of these once. > > Tom, does this change seem right to you? Was there a reason other than brevity > why the previous code asked each question twice? I notice that this code is > prefaced with a disclaimer that it is normative. Where is the normative > expression of these default trap behaviors? Does it ask these once or twice? The way the non-normative default traps are expressed on the wiki page, your change is correct. If |proxy| were added as an optional last argument to all traps, and the fundamental trap were invoked through |proxy| rather than via a self-send through |this|, then the change would not have been necessary as the descriptor would have been normalized. The default traps on the proxies wiki page are non-normative precisely because of issues like this. That said, the normative behavior (specified on the proxies_semantics wiki page) falls back on the [[Get]] behavior for Object (ES5 8.12.3), which only asks the question once (and only on a normalized property descriptor object).
Sign in to reply to this message.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
