forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ported from OpenSUSE:nodejs8-8.17.0-lp152.147.1:CVE-2020-15095.patch Original commit message: From a9857b8f6869451ff058789c4631fadfde5bbcbc Mon Sep 17 00:00:00 2001 From: claudiahdz <[email protected]> Date: Thu, 25 Jun 2020 19:34:47 -0500 Subject: [PATCH] chore: remove auth info from logs Signed-off-by: Su Baocheng <[email protected]>
- Loading branch information
1 parent
f819620
commit dc2a976
Showing
5 changed files
with
40 additions
and
5 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
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,22 @@ | ||
const URL = require('url') | ||
|
||
// replaces auth info in an array | ||
// of arguments or in a strings | ||
function replaceInfo (arg) { | ||
const isArray = Array.isArray(arg) | ||
const isString = typeof arg === 'string' | ||
|
||
if (!isArray && !isString) return arg | ||
|
||
const args = isString ? arg.split(' ') : arg | ||
const info = args.map(arg => { | ||
try { | ||
const url = new URL(arg) | ||
return url.password === '' ? arg : arg.replace(url.password, '***') | ||
} catch (e) { return arg } | ||
}) | ||
|
||
return isString ? info.join(' ') : info | ||
} | ||
|
||
module.exports = replaceInfo |