Skip to content

Commit 4e966ae

Browse files
author
Lucas Thomas
committed
SF-3437 Mask HTTP Authorization Header
1 parent 5dc1c33 commit 4e966ae

File tree

3 files changed

+12
-29
lines changed

3 files changed

+12
-29
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
node_modules
2-
npm-debug.log
2+
npm-debug.log
3+
.idea
4+
*.iml

lib/error.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var url = require('url'),
1010

1111
module.exports = {
1212
/**
13-
* Check for duplicate error messages. If the same error message logged more than configurated limit in one minute
13+
* Check for duplicate error messages. If the same error message logged more than configured limit in one minute
1414
* don't push it to the queue
1515
*/
1616
checkErrorLimitMessage : function checkErrorLimitMessage(ex) {
@@ -46,7 +46,7 @@ module.exports = {
4646
result = {},
4747
lastElement = trace[trace.length - 1];
4848

49-
if (not_direct && !exc.excCaught) {
49+
if (not_direct) {
5050
if (lastElement.CodeFileName === 'module.js') {
5151
result.SrcMethod = trace[trace.length - 2].Method;
5252
result.SrcLine = trace[trace.length - 2].LineNum;
@@ -103,9 +103,12 @@ module.exports = {
103103
PostData: helpers.getPostData(req)
104104
};
105105

106-
if (req.headers.cookie) {
107-
ex.WebRequestDetail.Headers.cookie = CONFIG.COOKIE_MASK;
108-
}
106+
// mask certain headers so data is not sent to Stackify
107+
["cookie", "authorization"].forEach(function(elm){
108+
if (req.headers[elm]) {
109+
ex.WebRequestDetail.Headers[elm] = CONFIG.COOKIE_MASK;
110+
}
111+
});
109112
}
110113

111114
return ex;

lib/helpers.js

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ var stackTrace = require('stack-trace'),
22

33
path = require('path'),
44
os = require('os'),
5-
qs = require('querystring'),
65

76
CONFIG = require('../config/config');
87

@@ -185,25 +184,4 @@ module.exports.getHeaders = function getHeaders() {
185184
'X-Stackify-Key': CONFIG.APIKEY,
186185
'X-Stackify-PV': CONFIG.X_STACKIFY_PV
187186
};
188-
};
189-
/*
190-
*** Function for getting post data from the request
191-
*/
192-
module.exports.getPostData = function getPostData (req) {
193-
return (function() {
194-
if (request.method == 'POST') {
195-
var body = '';
196-
request.on('data', function (data) {
197-
body += data;
198-
199-
// Too much POST data, kill the connection!
200-
if (body.length > 1e6)
201-
request.connection.destroy();
202-
});
203-
request.on('end', function () {
204-
var json = qs.parse(body);
205-
req.body = json;
206-
});
207-
}
208-
}());
209-
};
187+
};

0 commit comments

Comments
 (0)