Skip to content
Merged
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
773 changes: 630 additions & 143 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/compass-aggregations/src/modules/pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ const toggleStageCollapse = (state, action) => {
const updateStagePreview = (state, action) => {
const newState = copyState(state);
newState[action.index].previewDocuments =
action.error === null ? action.documents : [];
action.error === null || action.error === undefined ? action.documents : [];
newState[action.index].error = action.error ? action.error.message : null;
newState[action.index].isLoading = false;
newState[action.index].isComplete = action.isComplete;
Expand Down
3 changes: 2 additions & 1 deletion packages/compass-deployment-awareness/.depcheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ ignores: [
"storage-mixin",
"uuid",
"webpack-bundle-analyzer",
"webpack-cli"
"webpack-cli",
"mongodb"
]
2 changes: 0 additions & 2 deletions packages/compass-deployment-awareness/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"peerDependencies": {
"hadron-react-buttons": "*",
"hadron-react-components": "*",
"mongodb": "^3.5.3",
"react": "^16.8.0",
"react-dom": "^16.8.0"
},
Expand Down Expand Up @@ -84,7 +83,6 @@
"less-loader": "^5.0.0",
"mocha": "^7.0.1",
"mocha-webpack": "^2.0.0-beta.0",
"mongodb": "^3.2.2",
"mongodb-connection-model": "^20.2.0",
"mongodb-data-service": "^20.2.1",
"mongodb-js-metrics": "^7.2.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import ReadPreference from 'mongodb/lib/core/topologies/read_preference.js';

const SINGLE = 'Single';
const REPLICA_SET_NO_PRIMARY = 'ReplicaSetNoPrimary';
const REPLICA_SET_WITH_PRIMARY = 'ReplicaSetWithPrimary';
Expand All @@ -22,18 +20,18 @@ const TOPOLOGY_TYPES = [
* replica set no primary.
*/
const REPLICA_SET_NO_PRIMARY_READABLE = [
ReadPreference.PRIMARY_PREFERRED,
ReadPreference.SECONDARY,
ReadPreference.SECONDARY_PREFERRED,
ReadPreference.NEAREST
'primaryPreferred',
'secondary',
'secondaryPreferred',
'nearest'
];

/**
* Readable read preferences with a topology of
* replica set with primary.
*/
const REPLICA_SET_WITH_PRIMARY_READABLE =
REPLICA_SET_NO_PRIMARY_READABLE.concat([ ReadPreference.PRIMARY ]);
REPLICA_SET_NO_PRIMARY_READABLE.concat([ 'primary' ]);

/**
* List of writable topology types.
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-indexes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"less-loader": "^5.0.0",
"mocha": "^7.0.1",
"mocha-webpack": "^2.0.0-beta.0",
"mongodb": "^3.5.2",
"mongodb": "4.0.0-beta.5",
"mongodb-connection-model": "^20.2.0",
"mongodb-data-service": "^20.2.1",
"mongodb-extended-json": "^1.11.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"less-loader": "^4.0.5",
"mocha": "^5.2.0",
"mocha-webpack": "^2.0.0-beta.0",
"mongodb": "^3.6.3",
"mongodb": "4.0.0-beta.5",
"mongodb-ace-autocompleter": "^0.6.0",
"mongodb-ace-mode": "^1.1.0",
"mongodb-ace-theme-query": "^1.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-shell/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
"mini-css-extract-plugin": "^0.8.0",
"mocha": "^5.2.0",
"mocha-webpack": "^2.0.0-beta.0",
"mongodb": "^3.6.3",
"mongodb": "4.0.0-beta.5",
"mongodb-connection-string-url": "^1.0.0",
"mongodb-reflux-store": "^0.0.1",
"node-loader": "^0.6.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,9 @@ export function adaptDriverV36ConnectionParams(
delete newDriverOptions.connectWithNoPrimary;
delete newDriverOptions.useNewUrlParser;

// `true` is not a valid tls checkServerIdentity option that seems to break
// driver 4
//
// TODO(NODE-3061): Remove when fixed on driver side
if (newDriverOptions.checkServerIdentity === true) {
delete newDriverOptions.checkServerIdentity;
}
// `checkServerIdentity` is properly handled as `tlsAllowInvalidHostnames` if passed as a boolean
newDriverOptions.tlsAllowInvalidHostnames = !newDriverOptions.checkServerIdentity;
delete newDriverOptions.checkServerIdentity;

// driver 4 doesn't support certificates as buffers, so let's copy paths
// back from model `driverOptions`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ describe('adaptDriverV36ConnectionParams', () => {
).to.not.contain.key('useNewUrlParser');
});

it('removes checkServerIdentity only if is explicitly set to true', () => {
it('converts checkServerIdentity to tlsAllowInvalidHostnames', () => {
expect(
adaptDriverV36ConnectionParams(LOCALHOST, { checkServerIdentity: true })[1]
).to.not.contain.key('useNewUrlParser');
).to.not.contain.key('checkServerIdentity');

expect(
adaptDriverV36ConnectionParams(LOCALHOST, { checkServerIdentity: false })[1]
.checkServerIdentity
).to.equal(false);
.tlsAllowInvalidHostnames
).to.equal(true);
});

it('keeps other options', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/compass/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@
"make-fetch-happen": "^8.0.14",
"marky": "^1.2.0",
"moment": "^2.10.6",
"mongodb": "^3.6.3",
"mongodb": "4.0.0-beta.5",
"mongodb-ace-autocompleter": "^0.6.0",
"mongodb-ace-mode": "^1.1.0",
"mongodb-ace-theme": "^1.1.0",
Expand Down
9 changes: 4 additions & 5 deletions packages/compass/src/app/migrations/legacy-connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ var AUTHENTICATION_TO_FIELD_NAMES = {
* >>> mongodb://arlo:w%40of@localhost:27017?slaveOk=true&authSource=admin
* console.log(c.driver_options)
* >>> { db: { readPreference: 'nearest' },
* replSet: { connectWithNoPrimary: true } }
* replSet: { } }
*/
assign(props, {
mongodb_username: {
Expand Down Expand Up @@ -364,7 +364,7 @@ var MONGODB_NAMESPACE_DEFAULT = 'test';
* >>> mongodb://arlo%252Fdog%2540krb5.mongodb.parts:w%40%40f@localhost:27017/kerberos?slaveOk=true&gssapiServiceName=mongodb&authMechanism=GSSAPI
* console.log(c.driver_options)
* >>> { db: { readPreference: 'nearest' },
* replSet: { connectWithNoPrimary: true } }
* replSet: { } }
*
* @enterprise
* @see http://bit.ly/mongodb-node-driver-kerberos
Expand Down Expand Up @@ -430,7 +430,7 @@ var KERBEROS_SERVICE_NAME_DEFAULT = 'mongodb';
* >>> mongodb://arlo:w%40of@localhost:27017/ldap?slaveOk=true&authMechanism=PLAIN
* console.log(c.driver_options)
* >>> { db: { readPreference: 'nearest' },
* replSet: { connectWithNoPrimary: true } }
* replSet: { } }
*
* @enterprise
* @see http://bit.ly/mongodb-node-driver-ldap
Expand Down Expand Up @@ -470,7 +470,7 @@ assign(props, {
* >>> mongodb://CN%253Dclient%252COU%253Darlo%252CO%253DMongoDB%252CL%253DPhiladelphia%252CST%253DPennsylvania%252CC%253DUS@localhost:27017?slaveOk=true&authMechanism=MONGODB-X509
* console.log(c.driver_options)
* >>> { db: { readPreference: 'nearest' },
* replSet: { connectWithNoPrimary: true } }
* replSet: { } }
*
* @see http://bit.ly/mongodb-node-driver-x509
* @see http://bit.ly/mongodb-x509
Expand Down Expand Up @@ -655,7 +655,6 @@ assign(props, {
* `MongoClient.connect(model.driver_url, model.driver_options)`.
*/
var DRIVER_OPTIONS_DEFAULT = {
connectWithNoPrimary: true
};

assign(derived, {
Expand Down
8 changes: 4 additions & 4 deletions packages/connection-model/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ console.log(c.driverUrl)
console.log(c.driverOptions)
>>> {
db: { readPreference: 'nearest' },
replSet: { connectWithNoPrimary: true }
replSet: { }
}
```

Expand All @@ -213,7 +213,7 @@ console.log(c.driverUrl)
console.log(c.driverOptions)
>>> {
db: { readPreference: 'nearest' },
replSet: { connectWithNoPrimary: true }
replSet: { }
}
```

Expand Down Expand Up @@ -247,7 +247,7 @@ console.log(c.driverUrl)
console.log(c.driverOptions)
>>> {
db: { readPreference: 'nearest' },
replSet: { connectWithNoPrimary: true }
replSet: { }
}
```

Expand Down Expand Up @@ -276,7 +276,7 @@ console.log(c.driverUrl)
console.log(c.driverOptions)
>>> {
db: { readPreference: 'nearest' },
replSet: { connectWithNoPrimary: true }
replSet: { }
}
```

Expand Down
2 changes: 1 addition & 1 deletion packages/connection-model/lib/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const {
omit
} = require('lodash');
const { MongoClient } = require('mongodb');
const { parseConnectionString } = require('mongodb/lib/core');
const { parseConnectionString } = require('mongodb3/lib/core');
const Connection = require('./extended-model');
const { default: SSHTunnel } = require('@mongodb-js/ssh-tunnel');

Expand Down
20 changes: 10 additions & 10 deletions packages/connection-model/lib/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const {
const AmpersandModel = require('ampersand-model');
const AmpersandCollection = require('ampersand-rest-collection');
const { ReadPreference } = require('mongodb');
const { parseConnectionString } = require('mongodb/lib/core');
const { parseConnectionString } = require('mongodb3/lib/core');
const dataTypes = require('./data-types');
const localPortGenerator = require('./local-port-generator');

Expand Down Expand Up @@ -46,7 +46,7 @@ const MONGODB_DATABASE_NAME_DEFAULT = 'admin';
const KERBEROS_SERVICE_NAME_DEFAULT = 'mongodb';
const SSL_DEFAULT = 'NONE';
const SSH_TUNNEL_DEFAULT = 'NONE';
const DRIVER_OPTIONS_DEFAULT = { connectWithNoPrimary: true };
const DRIVER_OPTIONS_DEFAULT = { };

/**
* Mappings from the old connection model properties to the new one.
Expand Down Expand Up @@ -197,7 +197,7 @@ assign(props, {
* console.log(c.driverUrl)
* >>> mongodb://arlo:w%40of@localhost:27017?slaveOk=true&authSource=admin
* console.log(c.driverOptions)
* >>> { db: { readPreference: 'nearest' }, replSet: { connectWithNoPrimary: true } }
* >>> { db: { readPreference: 'nearest' }, replSet: { } }
*/
assign(props, {
mongodbUsername: { type: 'string', default: undefined },
Expand Down Expand Up @@ -228,7 +228,7 @@ assign(props, {
* console.log(c.driverUrl)
* >>> mongodb://arlo%252Fdog%2540krb5.mongodb.parts@localhost:27017/kerberos?slaveOk=true&gssapiServiceName=mongodb&authMechanism=GSSAPI
* console.log(c.driverOptions)
* >>> { db: { readPreference: 'nearest' }, replSet: { connectWithNoPrimary: true } }
* >>> { db: { readPreference: 'nearest' }, replSet: { } }
*
* @enterprise
* @see http://bit.ly/mongodb-node-driver-kerberos
Expand Down Expand Up @@ -270,7 +270,7 @@ assign(props, {
* console.log(c.driverUrl)
* >>> mongodb://arlo:w%40of@localhost:27017/ldap?slaveOk=true&authMechanism=PLAIN
* console.log(c.driverOptions)
* >>> { db: { readPreference: 'nearest' }, replSet: { connectWithNoPrimary: true } }
* >>> { db: { readPreference: 'nearest' }, replSet: { } }
*
* @enterprise
* @see http://bit.ly/mongodb-node-driver-ldap
Expand Down Expand Up @@ -303,7 +303,7 @@ assign(props, {
* console.log(c.driverUrl)
* >>> mongodb://CN%253Dclient%252COU%253Darlo%252CO%253DMongoDB%252CL%253DPhiladelphia%252CST%253DPennsylvania%252CC%253DUS@localhost:27017?slaveOk=true&authMechanism=MONGODB-X509
* console.log(c.driverOptions)
* >>> { db: { readPreference: 'nearest' }, replSet: { connectWithNoPrimary: true } }
* >>> { db: { readPreference: 'nearest' }, replSet: { } }
*
* @see http://bit.ly/mongodb-node-driver-x509
* @see http://bit.ly/mongodb-x509
Expand Down Expand Up @@ -664,15 +664,15 @@ assign(derived, {
}

if (this.authStrategy === 'X509') {
opts.checkServerIdentity = false;
opts.tlsAllowInvalidHostnames = true;
opts.sslValidate = false;
}
} else if (this.sslMethod === 'UNVALIDATED') {
assign(opts, { checkServerIdentity: false, sslValidate: false });
assign(opts, { tlsAllowInvalidHostnames: true, sslValidate: false });
} else if (this.sslMethod === 'SYSTEMCA') {
assign(opts, { checkServerIdentity: true, sslValidate: true });
assign(opts, { tlsAllowInvalidHostnames: false, sslValidate: true });
} else if (this.sslMethod === 'IFAVAILABLE') {
assign(opts, { checkServerIdentity: false, sslValidate: true });
assign(opts, { tlsAllowInvalidHostnames: true, sslValidate: true });
}

// Assign and overwrite all extra options provided by user.
Expand Down
6 changes: 5 additions & 1 deletion packages/connection-model/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@
"test-ci": "npm run test",
"posttest-ci": "node ../../scripts/killall-mongo.js"
},
"peerDependencies": {
"mongodb": "4.x"
},
"dependencies": {
"@mongodb-js/ssh-tunnel": "^1.2.0",
"ampersand-model": "^8.0.0",
"ampersand-rest-collection": "^6.0.0",
"async": "^3.1.0",
"debug": "^4.1.1",
"lodash": "^4.17.15",
"mongodb": "^3.6.3",
"mongodb3": "npm:mongodb@^3.6.3",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we 'copy-paste' the parse-connection-string.js file and drop this one? We need to rework that to switch it to the new module anyway.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could... but I don't think we'd exactly want that to be the long-term solution here either, it's probably best to do some actual URL parsing based on mongodb-connection-string-url and then actually handle all the transformations here in the connection model directly (assuming that we keep mongodb-connection-model)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but I don't think we'd exactly want that to be the long-term solution here either

Yeah i was thinking the same, we should definitely use the mongodb-connection-string-url module instead.

"raf": "^3.4.1",
"ssh2": "^0.8.7",
"storage-mixin": "^4.2.0"
Expand All @@ -43,6 +46,7 @@
"eslint": "^7.25.0",
"eslint-config-mongodb-js": "^5.0.3",
"mocha": "^8.0.1",
"mongodb": "4.0.0-beta.5",
"mock-require": "^3.0.3",
"mongodb-runner": "^4.8.1",
"proxyquire": "^2.1.0",
Expand Down
Loading