-
Notifications
You must be signed in to change notification settings - Fork 212
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
fix(marshal): reject getters in pass-by-ref, even if it returns a function #2438
Conversation
I suggest using const descs = getOwnPropertyDescriptors(val);
Object.entries(descs).forEach(([key, desc]) => {
assert(!desc.get, X`cannot serialize objects with getters like ${q(String(key))} in ${val}`); |
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.
LGTM
@dckc Using |
The new comments at agoric-sdk/packages/zoe/src/objArrayConversion.js Lines 59 to 79 in 97c1bc3
is a good example both of how tricky all this is in JavaScript, and how great it is that our pass-by-copy objects avoid these hazards. |
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.
The changes look good
…ction The prohibit-accessors check was improved by using `!('get' in descs[key])`. This should catch properties with a setter but not a getter, which will have a descriptor with `get: undefined`. Although this happens to be caught elsewhere, (because such a property reads as a non-function, triggering the "cannot serialize objects with non-methods" clause. closes #2436
3d4ddba
to
f5ec70e
Compare
This doesn't pass the typescript check yet, because it complains that I'm using a (potential) Symbol to do a property lookup:
But that's exactly what I need to do: I want to reject getters in Symbol-named properties too. I don't need to look at the property name (pass-by-reference doesn't care), so want something that returns key+value tuples like
Object.entries().forEach([_key, desc] ..
, except thatObject.entries
ignores Symbol-named properties, as doesObject.values()
.Any ideas how I can appease typescript?