-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace
request-debug
with request-logger
- Loading branch information
Pedro Branco
committed
Jan 12, 2017
1 parent
e205b2d
commit ef43342
Showing
12 changed files
with
83 additions
and
82 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 was deleted.
Oops, something went wrong.
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,26 @@ | ||
|
||
/** | ||
* Module dependencies. | ||
*/ | ||
|
||
import { isString } from 'lodash'; | ||
|
||
/** | ||
* Instances. | ||
*/ | ||
|
||
const replacement = /(api_key=)([^&])*/; | ||
|
||
/** | ||
* Export `RequestObfuscator`. | ||
*/ | ||
|
||
export function obfuscate(request) { | ||
// Obfuscate the API key on `uri`. | ||
request.uri = request.uri.replace(replacement, '$1*****'); | ||
|
||
// Obfuscate the API key on `body`. | ||
if (isString(request.body)) { | ||
request.body = request.body.replace(replacement, '$1*****'); | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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,40 @@ | ||
|
||
/** | ||
* Module dependencies. | ||
*/ | ||
|
||
import _ from 'lodash'; | ||
import { obfuscate } from '../../src/logging/request-obfuscator'; | ||
|
||
/** | ||
* Test `RequestObfuscator`. | ||
*/ | ||
|
||
describe('RequestObfuscator', () => { | ||
describe('obfuscate()', () => { | ||
it('should strip credentials from query string', () => { | ||
const request = { | ||
id: '354f8341-eb27-4c91-a8f7-a30e303a0976', | ||
method: 'GET', | ||
uri: 'foo=bar&api_key=foobar' | ||
}; | ||
|
||
obfuscate(request); | ||
|
||
request.should.eql(_.defaults({ uri: 'foo=bar&api_key=*****' }, request)); | ||
}); | ||
|
||
it('should strip credentials from request `body`', () => { | ||
const request = { | ||
body: 'foo=bar&api_key=foobar', | ||
id: '354f8341-eb27-4c91-a8f7-a30e303a0976', | ||
method: 'GET', | ||
uri: 'foo=bar&api_key=foobar' | ||
}; | ||
|
||
obfuscate(request); | ||
|
||
request.should.eql(_.defaults({ body: 'foo=bar&api_key=*****' }, request)); | ||
}); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.