-
Notifications
You must be signed in to change notification settings - Fork 27
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
feat: @W-12539773 add isNearMembraneProxyMaskedFunction() #420
Conversation
9172f9a
to
df929cd
Compare
} | ||
const result = ReflectGet(target, key, receiver); | ||
if (result !== undefined && isProxyMaskedSymbol) { | ||
throw new TypeErrorCtor(ERR_ILLEGAL_PROPERTY_ACCESS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why throwing instead of just returning undefined
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this is a guard for when a user is faking this. Instead of silently failing when we detect this kind of level of forgery since it is for the identification of our masking and proxies we throw a hard error. No user code should ever be doing this (trying to pass off this symbol as their own).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Essentially before we were playing nice and when, in the case of forging we would simply return undefined
and not recognize it, but identification of masked and proxied values is becoming more critical (so we don't want to fail the check). Now there is no wiggle room for possible forgeries and if a user is trying to forge something we should error and say "No, don't do that".
defineProperty(target: ProxyTarget, key: PropertyKey, desc: PropertyDescriptor) { | ||
lastProxyTrapCalled = ProxyHandlerTraps.DefineProperty; | ||
if (key === LOCKER_NEAR_MEMBRANE_PROXY_MASKED_SYMBOL) { | ||
throw new TypeErrorCtor(ERR_ILLEGAL_PROPERTY_ACCESS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not just returning false
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a forgery guard.
8fd4722
to
b1c3148
Compare
b1c3148
to
4d64ea6
Compare
feat: @W-12539773 add
isNearMembraneProxyMaskedFunction()