Skip to content

Commit

Permalink
Merge pull request #41 from balderdashy/upgrades
Browse files Browse the repository at this point in the history
Upgrade dependencies to resolve potential vulnerabilities & deprecation warnings
  • Loading branch information
rachaelshaw authored May 24, 2019
2 parents 98cce7d + fd20a5f commit 4e1fb5b
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 72 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@
language: node_js

node_js:
- "4"
- "5"
- "6"
- "7"
- "8"
- "10"
- "node"

branches:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ npm install
To run all the tests, start a local redis server on port 6380 and then run the tests using mocha:

```sh
redis-server --port 6380
redis-server --port 6380 --requirepass 'secret'
npm test
```

Expand Down
7 changes: 2 additions & 5 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@
# Test against these versions of Node.js.
environment:
matrix:
- nodejs_version: "0.10"
- nodejs_version: "0.12"
- nodejs_version: "4"
- nodejs_version: "5"
- nodejs_version: "6"
- nodejs_version: "7"
- nodejs_version: "8"
- nodejs_version: "10"

# Install scripts. (runs after repo cloning)
install:
Expand Down
8 changes: 4 additions & 4 deletions lib/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ module.exports = function ToConfigure(app) {
try {
var parsedUrl = Urls.parse({
url: app.config.sockets.adapterOptions.url
}).execSync();
}).now();
app.config.sockets.adapterOptions.host = parsedUrl.hostname;
app.config.sockets.adapterOptions.port = parsedUrl.port||0;
app.config.sockets.adapterOptions.db = parseInt(parsedUrl.path.replace('/', '')) || 0;
app.config.sockets.adapterOptions.user = parsedUrl.auth.split(':')[0]||undefined;
app.config.sockets.adapterOptions.pass = parsedUrl.auth.split(':')[1]||undefined;
app.config.sockets.adapterOptions.db = _.isString(parsedUrl.path) ? parseInt(parsedUrl.path.replace('/', '')) : 0;
app.config.sockets.adapterOptions.user = _.isString(parsedUrl.auth) ? parsedUrl.auth.split(':')[0] : undefined;
app.config.sockets.adapterOptions.pass = _.isString(parsedUrl.auth) ? parsedUrl.auth.split(':')[1] : undefined;

}
catch (e){
Expand Down
11 changes: 6 additions & 5 deletions lib/prepare-driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ module.exports = function (app){
var pathToAdapterDependency = adapterDef.modulePath;

// Create a Redis connection manager
var url = adapterConfig.url || Redis.createConnectionUrl(_.pick(adapterConfig, ['host', 'port', 'pass', 'db'])).execSync();
var url = adapterConfig.url || Redis.createConnectionUrl(_.pick(adapterConfig, ['host', 'port', 'pass', 'db'])).now();

// Create a Redis connection manager.
Redis.createManager({
connectionString: url,
meta: _.extend({return_buffers: true}, _.omit(adapterConfig, ['host', 'port', 'pass', 'db', 'url'])),
meta: _.omit(adapterConfig, ['host', 'port', 'pass', 'db', 'url']),
// Handle failures on the connection.
onUnexpectedFailure: function(err) {
// If Sails is already on the way out, ignore the Redis issue.
Expand Down Expand Up @@ -72,13 +72,14 @@ module.exports = function (app){
async.each(['pub', 'sub'], function (clientName, next) {

// If this client was preconfigured, skip creating it.
if (adapterConfig[clientName + 'Client']) { return next(); }
if (adapterConfig[clientName + 'Client']) {
return next();
}

// Use the manager to create a new Redis connection.
Redis.getConnection({
manager: createManagerResult.manager,
meta: (adapterConfig[clientName + 'ClientName'] || clientName) + ' ' + app.config.port
}).exec({
}).switch({
failed: function(err) { return next(err.error); },
error: next,
success: function(result) {
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
"@sailshq/lodash": "^3.10.2",
"async": "2.0.1",
"flaverr": "^1.0.0",
"machinepack-redis": "^1.1.1",
"machinepack-urls": "^3.1.1",
"semver": "4.3.6",
"socket.io": "2.0.3",
"machinepack-redis": "^2.0.3",
"machinepack-urls": "^6.0.2-0",
"proxy-addr": "1.1.5",
"semver": "4.3.6",
"socket.io": "2.2.0",
"uid2": "0.0.3"
},
"devDependencies": {
"ioredis": "2.4.0",
"machinepack-fs": "^3.0.0",
"machinepack-http": "^3.1.2",
"machinepack-http": "^8.0.0",
"mocha": "3.1.0",
"redis": "2.6.3",
"sails": "^1.0.0-12",
Expand Down
10 changes: 4 additions & 6 deletions test/serve-client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,9 @@ describe('with `serveClient` config enabled', function (){

// Send an HTTP request and receive the response.
Http.sendHttpRequest({
url: '/socket.io/socket.io.js',
baseUrl: 'http://localhost:1600',
url: 'http://localhost:1600/socket.io/socket.io.js',
method: 'get'
}).exec({
}).switch({
// An unexpected error occurred.
error: function(err) {
return done(err);
Expand All @@ -84,10 +83,9 @@ describe('with `serveClient` config enabled', function (){

// Send an HTTP request and receive the response.
Http.sendHttpRequest({
url: '/socket.io/socket.io.js',
baseUrl: 'http://localhost:1601',
url: 'http://localhost:1601/socket.io/socket.io.js',
method: 'get'
}).exec({
}).switch({
// An unexpected error occurred.
error: function(err) {
return done(err);
Expand Down
2 changes: 1 addition & 1 deletion test/with-redis.bus.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var Sails = require('sails').Sails;
var SocketIORedisAdapter = require('socket.io-redis');
var lifecycle = require('./helpers/lifecycle.helper');

describe('with redis -- bus', function (){
(require('os').platform() === 'win32' ? describe.skip : describe)('with redis -- bus', function (){

before(lifecycle.setup);
after(lifecycle.teardown);
Expand Down
2 changes: 1 addition & 1 deletion test/with-redis.customClients.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var ioredis = require('ioredis');
var redis = require('redis');
var lifecycle = require('./helpers/lifecycle.helper');

describe('with redis -- custom clients', function (){
(require('os').platform() === 'win32' ? describe.skip : describe)('with redis -- custom clients', function (){

var appConfig;
var pubClient, subClient, adminPubClient, adminSubClient;
Expand Down
71 changes: 35 additions & 36 deletions test/with-redis.errors.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var Sails = require('sails').Sails;
var SocketIORedisAdapter = require('socket.io-redis');
var lifecycle = require('./helpers/lifecycle.helper');

describe('with redis -- errors', function (){
(require('os').platform() === 'win32' ? describe.skip : describe)('with redis -- errors', function (){

before(lifecycle.setup);
after(lifecycle.teardown);
Expand Down Expand Up @@ -99,53 +99,53 @@ describe('with redis -- errors', function (){

});

// Skipping this test for now since apparently Redis allows you to use crazy DB indexes upon connection!
// i.e. even if you only have it set up for 16 dbs, you can do redis://localhost:6379/99999, and it will
// just silently connect you to db 0 instead.
// See: https://github.com/antirez/redis/issues/3410
// FUTURE: Check # of available DBs after connection and if its < then the value configured for db, bail
// or log a warning.
xit('Should fail to lift Sails when attempting to connect with a db value that is > than the # of databases on the Redis server', function(done) {
// // Skipping this test for now since apparently Redis allows you to use crazy DB indexes upon connection!
// // i.e. even if you only have it set up for 16 dbs, you can do redis://localhost:6379/99999, and it will
// // just silently connect you to db 0 instead.
// // See: https://github.com/antirez/redis/issues/3410
// // FUTURE: Check # of available DBs after connection and if its < then the value configured for db, bail
// // or log a warning.
// xit('Should fail to lift Sails when attempting to connect with a db value that is > than the # of databases on the Redis server', function(done) {

Sails().lift({
log: { level: 'silent' },
// Sails().lift({
// log: { level: 'silent' },

globals: false,
// globals: false,

hooks: {
// Inject the sockets hook in this repo into this Sails app
sockets: require('../')
},
// hooks: {
// // Inject the sockets hook in this repo into this Sails app
// sockets: require('../')
// },

loadHooks: ['moduleloader', 'userconfig', 'http', 'sockets'],
// loadHooks: ['moduleloader', 'userconfig', 'http', 'sockets'],

// Configure the socket.io-redis adapter
sockets: {
adapter: 'socket.io-redis',
adapterModule: SocketIORedisAdapter,
// // Configure the socket.io-redis adapter
// sockets: {
// adapter: 'socket.io-redis',
// adapterModule: SocketIORedisAdapter,

// Configure port to match .travis.yml
port: 6380,
// // Configure port to match .travis.yml
// port: 6380,

// Should fail, because by default Redis only has 16 dbs
db: 99,
// // Should fail, because by default Redis only has 16 dbs
// db: 99,

// Configure password to match .travis.yml
pass: 'secret',
// // Configure password to match .travis.yml
// pass: 'secret',

}
}, function(err) {
// }
// }, function(err) {

if (err) {
assert.equal(err.code, 'E_INVALID_DB_INDEX', 'Got wrong kind of error: ' + util.inspect(err, {depth: null}));
return done();
}
// if (err) {
// assert.equal(err.code, 'E_INVALID_DB_INDEX', 'Got wrong kind of error: ' + util.inspect(err, {depth: null}));
// return done();
// }

return done(new Error('Should have failed to lift!'));
// return done(new Error('Should have failed to lift!'));

});
// });

});
// });

it('Should fail to lift when incorrect password is supplied', function(done) {

Expand Down Expand Up @@ -210,7 +210,6 @@ describe('with redis -- errors', function (){
// Configure port to match .travis.yml
port: 6380,

// Should fail, because by default Redis only has 16 dbs
db: 2,

}
Expand Down
6 changes: 1 addition & 5 deletions test/with-redis.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@ var Sails = require('sails').Sails;
var SocketIORedisAdapter = require('socket.io-redis');
var lifecycle = require('./helpers/lifecycle.helper');

// TODO:
// figure out how to make this run on Travis
// (need a local redis)


describe('with redis', function (){
(require('os').platform() === 'win32' ? describe.skip : describe)('with redis', function (){

before(lifecycle.setup);
after(lifecycle.teardown);
Expand Down

0 comments on commit 4e1fb5b

Please sign in to comment.