Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ if (app.get('env') == 'development') {
app.use(errorHandler());
}

var token = 'SECRET_TOKEN_f8ed84e8f41e4146403dd4a6bbcea5e418d23a9';
console.log('token: ' + token);

http.createServer(app).listen(app.get('port'), function () {
console.log('Express server listening on port ' + app.get('port'));
});
11 changes: 11 additions & 0 deletions tests/hardcoded-token.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
var fs = require('fs');
var path = require('path');
var test = require('tap').test;

test('no hard-coded API token is defined or logged in app.js', function (t) {
var app = fs.readFileSync(path.join(__dirname, '..', 'app.js'), 'utf8');
t.notMatch(app, /SECRET_TOKEN/, 'no token literal in app.js');
t.notMatch(app, /token\s*=\s*['"`]/, 'no token assigned from a literal');
t.notMatch(app, /console\.log\([^)]*token/i, 'no token written to the log');
t.end();
});
Loading