-
Notifications
You must be signed in to change notification settings - Fork 72
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(ses): Handle well-known symbol look-alikes #1114
Conversation
if (wellKnownSymbol) { | ||
return wellKnownSymbol; | ||
} else { | ||
return `Unique${String(prop)}`; |
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.
It would be nice to document the nature of UniqueSymbol(…)
(and string representation of property keys in general) somewhere, although I'm not sure where.
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.
t.is( | ||
ArrayProto[RogueSymbolIterator], | ||
undefined, | ||
`Well-known Symbol look-alike should have been removed`, |
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.
Should there also be an assertion about SymbolIterator
, e.g. that it is not removed from an object where it is expected?
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.
done in 8fc6c2b
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, thanks!
9d2b638
to
6f6fffb
Compare
packages/ses/src/commons.js
Outdated
@@ -72,6 +72,8 @@ export const { | |||
toStringTag: toStringTagSymbol, | |||
iterator: iteratorSymbol, | |||
matchAll: matchAllSymbol, | |||
keyFor: SymbolKeyFor, | |||
for: SymbolFor, |
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.
Elsewhere, as in arrayPrototype
, there’s precedent for camelCase over PascalCase.
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.
Actually thinking about this more, that means we don't differentiate between static and proto methods?
Edit: answering my own question, with examples like reflectSet
, the answer seem to be "no".
6f6fffb
to
899a957
Compare
899a957
to
5139dad
Compare
While working on fixing the
async_hooks
issue, I realized that the whitelisting mechanism for well-known symbols can be tricked into accepting a unique symbol that just has the description of the expected well-known symbol, but is actually unique.This PR changes the whitelist parsing logic to generate a map of well-known symbols from the intrinsics and the permit list (similar to marshal's logic), and checks that a symbol matches the well-known symbol when found in the permits of an object. It does so by returning a name in the shape of
UniqueSymbol(description)
when finding a symbol that isn't well-known, and only returning the@@name
if the symbol is found in the map. This technically would allow unique symbols to be permitted on intrinsics if named similarly (there is technically a chance of collision with string props, but that was already the case with the@@
prefix anyway).Added a unit test for this (renaming the existing test, which seemed to be testing a different file). Verified manually that before the fix, the test would fail (didn't create separate commit with failing test)