Skip to content
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

Merged
merged 1 commit into from
Feb 14, 2023

Conversation

jdalton
Copy link
Contributor

@jdalton jdalton commented Feb 14, 2023

feat: @W-12539773 add isNearMembraneProxyMaskedFunction()

}
const result = ReflectGet(target, key, receiver);
if (result !== undefined && isProxyMaskedSymbol) {
throw new TypeErrorCtor(ERR_ILLEGAL_PROPERTY_ACCESS);
Copy link
Contributor

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?

Copy link
Contributor Author

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).

Copy link
Contributor Author

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);
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@jdalton jdalton force-pushed the jdalton/is-masked branch 6 times, most recently from 8fd4722 to b1c3148 Compare February 14, 2023 20:12
@jdalton jdalton merged commit ef43516 into main Feb 14, 2023
@jdalton jdalton deleted the jdalton/is-masked branch February 14, 2023 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants