From 2cab365e01df731a7019766ed145486b244b4a67 Mon Sep 17 00:00:00 2001 From: Kaz Date: Wed, 25 Jul 2018 17:16:55 +1000 Subject: [PATCH 1/3] fix issues with mongodb 3.x driver --- lib/mongodb-backend.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/mongodb-backend.js b/lib/mongodb-backend.js index e3eb8de..ed8c32e 100644 --- a/lib/mongodb-backend.js +++ b/lib/mongodb-backend.js @@ -65,7 +65,7 @@ MongoDBBackend.prototype = { this.db.collection(this.prefix + this.removeUnsupportedChar(collName),function(err,collection){ if(err instanceof Error) return cb(err); // Excluding bucket field from search result - collection.findOne(searchParams, {_bucketname: 0},function(err, doc){ + collection.findOne(searchParams, {projection: {_bucketname: 0}},function(err, doc){ if(err) return cb(err); if(! _.isObject(doc) ) return cb(undefined,[]); doc = fixKeys(doc); @@ -88,7 +88,7 @@ MongoDBBackend.prototype = { this.db.collection(this.prefix + this.removeUnsupportedChar(collName),function(err,collection){ if(err instanceof Error) return cb(err); // Excluding bucket field from search result - collection.find(searchParams, {_bucketname: 0}).toArray(function(err,docs){ + collection.find(searchParams, {projection: {_bucketname: 0}}).toArray(function(err,docs){ if(err instanceof Error) return cb(err); if( ! docs.length ) return cb(undefined, []); From 24fdb22e16957376c6d6a45fe24e8ba2d77c6526 Mon Sep 17 00:00:00 2001 From: Kaz Date: Thu, 26 Jul 2018 10:25:33 +1000 Subject: [PATCH 2/3] update referenced mongodb lib version to 3.x --- package.json | 2 +- test/runner.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 496e6c6..7f41127 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "async": "^2.1.4", "bluebird": "^3.0.2", "lodash": "^4.17.3", - "mongodb": "^2.0.47", + "mongodb": "^3.1.1", "redis": "^2.2.5" }, "devDependencies": { diff --git a/test/runner.js b/test/runner.js index 3092900..ed39689 100644 --- a/test/runner.js +++ b/test/runner.js @@ -7,7 +7,8 @@ describe('MongoDB - Default', function () { var self = this , mongodb = require('mongodb') - mongodb.connect('mongodb://localhost:27017/acltest',function(error, db) { + mongodb.connect('mongodb://localhost:27017/acltest',function(error, client) { + const db = client.db('acltest'); db.dropDatabase(function () { self.backend = new Acl.mongodbBackend(db, "acl") done() @@ -24,7 +25,8 @@ describe('MongoDB - useSingle', function () { var self = this , mongodb = require('mongodb') - mongodb.connect('mongodb://localhost:27017/acltest',function(error, db) { + mongodb.connect('mongodb://localhost:27017/acltest',function(error, client) { + const db = client.db('acltest'); db.dropDatabase(function () { self.backend = new Acl.mongodbBackend(db, "acl", true) done() From de327e9a1637340e90393c839998104e5a4d4af3 Mon Sep 17 00:00:00 2001 From: Kaz Date: Thu, 26 Jul 2018 10:55:59 +1000 Subject: [PATCH 3/3] update mocha to address https://nodesecurity.io/advisories/534 and https://nodesecurity.io/advisories/146 --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 7f41127..b80c101 100644 --- a/package.json +++ b/package.json @@ -22,11 +22,11 @@ "redis": "^2.2.5" }, "devDependencies": { - "mocha": "^3.2.0", - "chai": "^3.4.0" + "mocha": "^5.2.0", + "chai": "^4.1.2" }, "scripts": { - "test": "mocha test/runner.js --reporter spec", + "test": "mocha test/runner.js --reporter spec --exit", "cover": "istanbul cover -- _mocha test/runner.js --reporter spec" } }