Skip to content

Commit 44ca60f

Browse files
Do not leak Object.prototype when checking for core modules
1 parent a01ddfb commit 44ca60f

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function versionIncluded(specifierValue) {
4444

4545
var data = require('./core.json');
4646

47-
var core = {};
47+
var core = Object.create(null);
4848
for (var mod in data) { // eslint-disable-line no-restricted-syntax
4949
if (Object.prototype.hasOwnProperty.call(data, mod)) {
5050
core[mod] = versionIncluded(data[mod]);

test/core.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ test('core modules', function (t) {
1010

1111
st.ok(!resolve.isCore('seq'));
1212
st.ok(!resolve.isCore('../'));
13+
14+
st.ok(!resolve.isCore('toString'));
15+
1316
st.end();
1417
});
1518

0 commit comments

Comments
 (0)