Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 76de3fb

Browse files
committed
Set rejectUnauthorized to true by default
Resolve CVE-2020-240-25 by setting rejectUnauthorized to true by default. Add configuration flag to override this to false if necessary. Add doc option to README.md
1 parent 16b8d4b commit 76de3fb

File tree

3 files changed

+48
-9
lines changed

3 files changed

+48
-9
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -595,12 +595,13 @@ When compiling a directory `--source-map` can either be a boolean value or a dir
595595

596596
node-sass supports different configuration parameters to change settings related to the sass binary such as binary name, binary path or alternative download path. Following parameters are supported by node-sass:
597597

598-
Variable name | .npmrc parameter | Process argument | Value
599-
-----------------|------------------|--------------------|------
600-
SASS_BINARY_NAME | sass_binary_name | --sass-binary-name | path
601-
SASS_BINARY_SITE | sass_binary_site | --sass-binary-site | URL
602-
SASS_BINARY_PATH | sass_binary_path | --sass-binary-path | path
603-
SASS_BINARY_DIR | sass_binary_dir | --sass-binary-dir | path
598+
Variable name | .npmrc parameter | Process argument | Value
599+
-------------------------|--------------------------|----------------------------|------
600+
SASS_BINARY_NAME | sass_binary_name | --sass-binary-name | path
601+
SASS_BINARY_SITE | sass_binary_site | --sass-binary-site | URL
602+
SASS_BINARY_PATH | sass_binary_path | --sass-binary-path | path
603+
SASS_BINARY_DIR | sass_binary_dir | --sass-binary-dir | path
604+
SASS_REJECT_UNAUTHORIZED | sass_reject_unauthorized | --sass-reject-unauthorized | value
604605

605606
These parameters can be used as environment variable:
606607

scripts/util/downloadoptions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var proxy = require('./proxy'),
1414
*/
1515
module.exports = function() {
1616
var options = {
17-
rejectUnauthorized: false,
17+
rejectUnauthorized: process.env.NODE_SASS_REJECT_UNAUTHORIZED !== '0',
1818
timeout: 60000,
1919
headers: {
2020
'User-Agent': userAgent(),

test/downloadoptions.js

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe('util', function() {
88
describe('without a proxy', function() {
99
it('should look as we expect', function() {
1010
var expected = {
11-
rejectUnauthorized: false,
11+
rejectUnauthorized: true,
1212
timeout: 60000,
1313
headers: {
1414
'User-Agent': ua(),
@@ -33,7 +33,7 @@ describe('util', function() {
3333

3434
it('should look as we expect', function() {
3535
var expected = {
36-
rejectUnauthorized: false,
36+
rejectUnauthorized: true,
3737
proxy: proxy,
3838
timeout: 60000,
3939
headers: {
@@ -57,6 +57,25 @@ describe('util', function() {
5757
delete process.env.HTTP_PROXY;
5858
});
5959

60+
it('should look as we expect', function() {
61+
var expected = {
62+
rejectUnauthorized: true,
63+
timeout: 60000,
64+
headers: {
65+
'User-Agent': ua(),
66+
},
67+
encoding: null,
68+
};
69+
70+
assert.deepStrictEqual(opts(), expected);
71+
});
72+
});
73+
74+
describe('with NODE_SASS_REJECT_UNAUTHORIZED set to false', function() {
75+
beforeEach(function() {
76+
process.env.NODE_SASS_REJECT_UNAUTHORIZED = '0';
77+
});
78+
6079
it('should look as we expect', function() {
6180
var expected = {
6281
rejectUnauthorized: false,
@@ -70,5 +89,24 @@ describe('util', function() {
7089
assert.deepStrictEqual(opts(), expected);
7190
});
7291
});
92+
93+
describe('with NODE_SASS_REJECT_UNAUTHORIZED set to true', function() {
94+
beforeEach(function() {
95+
process.env.NODE_SASS_REJECT_UNAUTHORIZED = '1';
96+
});
97+
98+
it('should look as we expect', function() {
99+
var expected = {
100+
rejectUnauthorized: true,
101+
timeout: 60000,
102+
headers: {
103+
'User-Agent': ua(),
104+
},
105+
encoding: null,
106+
};
107+
108+
assert.deepStrictEqual(opts(), expected);
109+
});
110+
});
73111
});
74112
});

0 commit comments

Comments
 (0)