-
-
Notifications
You must be signed in to change notification settings - Fork 185
Do not leak Object.prototype when checking for core modules #203
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
Do not leak Object.prototype when checking for core modules #203
Conversation
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.
I'm not sure why toString
resolution would have changed; https://github.com/browserify/resolve/blob/master/lib/core.js#L49 should already prevent any prototype leaks - meaning that this change should not be needed to make the test here pass.
The test I added in this PR fails without the patch. It's because https://github.com/browserify/resolve/blob/master/lib/core.js#L49 isn't enough, because |
Gotcha. In that case, can we instead fix Line 4 in cfd0bb8
isCore function on the main export)
|
Already done in e5b0494! |
e5b0494
to
8da1a8f
Compare
…ore modules [New] add `is-core` export
8da1a8f
to
c448d08
Compare
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.
adding is-core
makes this technically semver-minor :-) will merge into both master and 1.x, and release shortly.
Thanks! Btw, upgrading this package in |
hm, these go back prettttty far :-) but thanks, would be appreciated. |
…ore modules [New] add `is-core` export See #203.
v1.13.0 released. |
var core = require('./core'); | ||
|
||
module.exports = function isCore(x) { | ||
return Object.prototype.hasOwnProperty.call(core, x); |
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.
unfortunately this introduced a bug into v1.13.0 (see #231), by changing this from a "truthy" check, to a "presence" check - and the "core" object relies on true
/false
to differentiate between a core module in some version of node, versus a core module in the current version of node. This was inadvertently fixed when I extracted this logic into https://npmjs.com/is-core-module.
Context:
I'm trying to use Yarn 2 (with PnP) in Babel.
Babel depends on
browserify
, which depends onbrowser-resolve
which depends on an older version ofresolve
without PnP support (1.1.7).I tried to upgrade
resolve
inbrowser-resolve
, but a test started failing because it checked fortoString
resolution.Since this worked in
resolve
1.1.7, was the behavior changed on purpose?