Skip to content

Commit aa332a5

Browse files
authored
fix: __proto__ copy (#2)
1 parent ddefb57 commit aa332a5

File tree

6 files changed

+65
-30
lines changed

6 files changed

+65
-30
lines changed

.github/workflows/nodejs.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
4+
name: Node.js CI
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
- master
11+
pull_request:
12+
branches:
13+
- main
14+
- master
15+
schedule:
16+
- cron: '0 2 * * *'
17+
18+
jobs:
19+
build:
20+
runs-on: ${{ matrix.os }}
21+
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
node-version: [6, 8, 10, 12, 14, 16]
26+
os: [ubuntu-latest, windows-latest, macos-latest]
27+
28+
steps:
29+
- name: Checkout Git Source
30+
uses: actions/checkout@v2
31+
32+
- name: Use Node.js ${{ matrix.node-version }}
33+
uses: actions/setup-node@v1
34+
with:
35+
node-version: ${{ matrix.node-version }}
36+
37+
- name: Install Dependencies
38+
run: npm i -g npminstall@latest-3 && npminstall
39+
40+
- name: Continuous Integration
41+
run: npm run ci
42+
43+
- name: Code Coverage
44+
uses: codecov/codecov-action@v1
45+
with:
46+
token: ${{ secrets.CODECOV_TOKEN }}

.travis.yml

-12
This file was deleted.

appveyor.yml

-16
This file was deleted.

index.js

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ module.exports = function extend() {
4747

4848
// Extend the base object
4949
for (name in options) {
50+
if (name === '__proto__') continue;
51+
5052
src = target[name];
5153
copy = options[name];
5254

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"dependencies": {},
2626
"devDependencies": {
2727
"covert": "^1.1.0",
28-
"egg-ci": "^1.5.0",
2928
"eslint": "^3.2.2",
3029
"eslint-config-egg": "^3.2.0",
3130
"tape": "^4.6.0"
@@ -35,6 +34,7 @@
3534
"index.js"
3635
],
3736
"ci": {
38-
"version": "4, 6, 7"
37+
"type": "github",
38+
"version": "6, 8, 10, 12, 14, 16"
3939
}
4040
}

test/index.js

+15
Original file line numberDiff line numberDiff line change
@@ -619,3 +619,18 @@ test('works without Array.isArray', function (t) {
619619
Array.isArray = savedIsArray;
620620
t.end();
621621
});
622+
623+
test('fix __proto__ copy', function (t) {
624+
var r = extend(true, {}, JSON.parse('{"__proto__": {"polluted": "yes"}}'));
625+
t.deepEqual(
626+
JSON.stringify(r),
627+
'{}',
628+
'It should not copy __proto__'
629+
);
630+
t.deepEqual(
631+
''.polluted,
632+
undefined,
633+
'It should not affect object prototype'
634+
);
635+
t.end();
636+
});

0 commit comments

Comments
 (0)