Bump mongoose from 5.8.0 to 5.10.7 (#8046)

* Bump mongoose from 5.8.0 to 5.10.7

Bumps [mongoose](https://github.com/Automattic/mongoose) from 5.8.0 to 5.10.7.
- [Release notes](https://github.com/Automattic/mongoose/releases)
- [Changelog](https://github.com/Automattic/mongoose/blob/master/History.md)
- [Commits](https://github.com/Automattic/mongoose/compare/5.8.0...5.10.7)

Signed-off-by: dependabot[bot] <support@github.com>

* Do not use empty username or password in mongo connection

Signed-off-by: Alexandre Bodin <bodin.alex@gmail.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Alexandre Bodin <bodin.alex@gmail.com>
This commit is contained in:
dependabot[bot] 2020-10-02 09:27:46 +02:00 committed by GitHub
parent dbfde36360
commit 048e6fd3af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 52 deletions

View File

@ -82,7 +82,7 @@ mongo_test: &mongo_test
- mkdir -p ./data/db/27000
- ./mongodb-linux-x86_64-3.6.6/bin/mongod --fork --dbpath ./data/db/27017 --syslog --port 27017
env:
- DB_STRING='--dbclient=mongo --dbhost=localhost --dbport=27017 --dbname=strapi_test --dbusername= --dbpassword='
- DB_STRING='--dbclient=mongo --dbhost=localhost --dbport=27017 --dbname=strapi_test'
before_script:
- yarn build

View File

@ -35,6 +35,16 @@ const defaults = {
const isMongooseConnection = ({ connector }) => connector === 'mongoose';
const createConnectionURL = opts => {
const { protocol, auth, host, port } = opts;
return {
toString() {
return `${protocol}://${auth}${host}${port}/`;
},
};
};
module.exports = function(strapi) {
function initialize() {
const { connections } = strapi.config;
@ -86,18 +96,19 @@ module.exports = function(strapi) {
connectOptions.useNewUrlParser = true;
connectOptions.dbName = database;
connectOptions.useCreateIndex = true;
connectOptions.useUnifiedTopology = useUnifiedTopology || 'false';
connectOptions.useUnifiedTopology = useUnifiedTopology || true;
try {
/* FIXME: for now, mongoose doesn't support srv auth except the way including user/pass in URI.
* https://github.com/Automattic/mongoose/issues/6881 */
await instance.connect(
uri ||
`mongodb${isSrv ? '+srv' : ''}://${username}:${encodeURIComponent(password)}@${host}${
!isSrv ? ':' + port : ''
}/`,
connectOptions
);
const connectionURL = createConnectionURL({
protocol: `mongodb${isSrv ? '+srv' : ''}`,
port: isSrv ? '' : `:${port}`,
host,
auth: username ? `${username}:${encodeURIComponent(password)}@` : '',
});
const connectionString = uri || connectionURL.toString();
await instance.connect(connectionString, connectOptions);
} catch (error) {
const err = new Error(`Error connecting to the Mongo database. ${error.message}`);
delete err.stack;

View File

@ -16,7 +16,7 @@
"main": "./lib",
"dependencies": {
"lodash": "4.17.19",
"mongoose": "5.8.0",
"mongoose": "5.10.7",
"mongoose-float": "^1.0.4",
"mongoose-long": "^0.2.1",
"pluralize": "^8.0.0",

View File

@ -8,8 +8,8 @@ module.exports = ({ env }) => ({
srv: env.bool('DATABASE_SRV', <%= settings.srv %>),
port: env.int('DATABASE_PORT', <%= settings.port %>),
database: env('DATABASE_NAME', '<%= settings.database %>'),
username: env('DATABASE_USERNAME', '<%= settings.username %>'),
password: env('DATABASE_PASSWORD', '<%= settings.password %>'),
username: env('DATABASE_USERNAME', <% if (settings.username) { %>'<%= settings.username %>'<% } else { %>null<% } %>),
password: env('DATABASE_PASSWORD', <% if (settings.password) { %>'<%= settings.password %>'<% } else { %>null<% } %>),
},
options: {
authenticationDatabase: env('AUTHENTICATION_DATABASE', <% if (options.authenticationDatabase) { %>'<%= options.authenticationDatabase %>'<% } else { %>null<% } %>),

View File

@ -4839,7 +4839,7 @@ bser@2.1.1:
dependencies:
node-int64 "^0.4.0"
bson@^1.1.1, bson@^1.1.4, bson@~1.1.1:
bson@^1.1.4:
version "1.1.5"
resolved "https://registry.yarnpkg.com/bson/-/bson-1.1.5.tgz#2aaae98fcdf6750c0848b0cba1ddec3c73060a34"
integrity sha512-kDuEzldR21lHciPQAIulLs1LZlCXdLziXI6Mb/TDkwXhb//UORJNPXgcRs2CuO4H0DcMkpfT3/ySsP3unoZjBg==
@ -12782,17 +12782,6 @@ moment-timezone@^0.5.21, moment-timezone@^0.5.31:
resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.0.tgz#fcbef955844d91deb55438613ddcec56e86a3425"
integrity sha512-z6IJ5HXYiuxvFTI6eiQ9dm77uE0gyy1yXNApVHqTcnIKfY9tIwEjlzsZ6u1LQXvVgKeTnv9Xm7NDvJ7lso3MtA==
mongodb@3.3.5:
version "3.3.5"
resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-3.3.5.tgz#38d531013afede92b0dd282e3b9f3c08c9bdff3b"
integrity sha512-6NAv5gTFdwRyVfCz+O+KDszvjpyxmZw+VlmqmqKR2GmpkeKrKFRv/ZslgTtZba2dc9JYixIf99T5Gih7TIWv7Q==
dependencies:
bson "^1.1.1"
require_optional "^1.0.1"
safe-buffer "^5.1.2"
optionalDependencies:
saslprep "^1.0.0"
mongodb@3.6.2:
version "3.6.2"
resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-3.6.2.tgz#1154a4ac107bf1375112d83a29c5cf97704e96b6"
@ -12821,27 +12810,10 @@ mongoose-long@^0.2.1:
resolved "https://registry.yarnpkg.com/mongoose-long/-/mongoose-long-0.2.1.tgz#2d4f560430338bfbe7129e31a543c497a2d6a4db"
integrity sha512-cbzEW5rShz8MxoTMFUidf13KObGkauA4ILeR3XcIdI7VLzMXwwXy///gLAbN2fD6vYy2ZAMDnCopQrCkNH9VNQ==
mongoose@5.8.0:
version "5.8.0"
resolved "https://registry.yarnpkg.com/mongoose/-/mongoose-5.8.0.tgz#ddbfd6849632ed5840ec3e5faeaab1945bb3b650"
integrity sha512-+VqrLGmHoDW/72yaXgiXSF7E/JcZ8Iyt7etrd4x3+Bj0z7k6GHHUBgGHP5ySPoG4J412RFuvHqx6xEOIuUrcfQ==
dependencies:
bson "~1.1.1"
kareem "2.3.1"
mongodb "3.3.5"
mongoose-legacy-pluralize "1.0.2"
mpath "0.6.0"
mquery "3.2.2"
ms "2.1.2"
regexp-clone "1.0.0"
safe-buffer "5.1.2"
sift "7.0.1"
sliced "1.0.1"
mongoose@^5.5.13:
version "5.10.6"
resolved "https://registry.yarnpkg.com/mongoose/-/mongoose-5.10.6.tgz#36faeb363627e7aac5c209a6d43368a8c6f3354f"
integrity sha512-p32oja2ydzFMS0K4P7G408Kagju6Qz/LmiAFAcP6BqnIi1McLTd6VZ3+ZQtQmaHM7w8iNupLLambCrsPKNJpYw==
mongoose@5.10.7, mongoose@^5.5.13:
version "5.10.7"
resolved "https://registry.yarnpkg.com/mongoose/-/mongoose-5.10.7.tgz#5590037f4d9078f4d4edac5c77f27b53829b1c94"
integrity sha512-oiofFrD4I5p3PhJXn49QyrU1nX5CY01qhPkfMMrXYPhkfGLEJVwFVO+0PsCxD91A2kQP+d/iFyk5U8e86KI8eQ==
dependencies:
bson "^1.1.4"
kareem "2.3.1"
@ -12872,11 +12844,6 @@ move-concurrently@^1.0.1:
rimraf "^2.5.4"
run-queue "^1.0.3"
mpath@0.6.0:
version "0.6.0"
resolved "https://registry.yarnpkg.com/mpath/-/mpath-0.6.0.tgz#aa922029fca4f0f641f360e74c5c1b6a4c47078e"
integrity sha512-i75qh79MJ5Xo/sbhxrDrPSEG0H/mr1kcZXJ8dH6URU5jD/knFxCVqVC/gVSW7GIXL/9hHWlT9haLbCXWOll3qw==
mpath@0.7.0:
version "0.7.0"
resolved "https://registry.yarnpkg.com/mpath/-/mpath-0.7.0.tgz#20e8102e276b71709d6e07e9f8d4d0f641afbfb8"