This repository has been archived by the owner on Jul 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set rejectUnauthorized to true by default (#3149)
Resolve CVE-2020-240-25 by setting rejectUnauthorized to true by default. Add configuration flag to override this to false if necessary. extract rejectUnauthorized download option to its own file. Add doc option to README.md.
- Loading branch information
1 parent
e80d4af
commit 0a21792
Showing
4 changed files
with
121 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
var pkg = require('../../package.json'); | ||
|
||
/** | ||
* Get the value of a CLI argument | ||
* | ||
* @param {String} name | ||
* @param {Array} args | ||
* @api private | ||
*/ | ||
function getArgument(name, args) { | ||
var flags = args || process.argv.slice(2), | ||
index = flags.lastIndexOf(name); | ||
|
||
if (index === -1 || index + 1 >= flags.length) { | ||
return null; | ||
} | ||
|
||
return flags[index + 1]; | ||
} | ||
|
||
/** | ||
* Get the value of reject-unauthorized | ||
* If environment variable SASS_REJECT_UNAUTHORIZED is non-zero, | ||
* .npmrc variable sass_reject_unauthorized or | ||
* process argument --sass-reject_unauthorized is provided, | ||
* set rejectUnauthorized to true | ||
* Else set to false by default | ||
* | ||
* @return {Boolean} The value of rejectUnauthorized | ||
* @api private | ||
*/ | ||
module.exports = function() { | ||
var rejectUnauthorized = false; | ||
|
||
if (getArgument('--sass-reject-unauthorized')) { | ||
rejectUnauthorized = getArgument('--sass-reject-unauthorized'); | ||
} else if (process.env.SASS_REJECT_UNAUTHORIZED !== '0') { | ||
rejectUnauthorized = true; | ||
} else if (process.env.npm_config_sass_reject_unauthorized) { | ||
rejectUnauthorized = process.env.npm_config_sass_reject_unauthorized; | ||
} else if (pkg.nodeSassConfig && pkg.nodeSassConfig.rejectUnauthorized) { | ||
rejectUnauthorized = pkg.nodeSassConfig.rejectUnauthorized; | ||
} | ||
|
||
return rejectUnauthorized; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters