Skip to content

Commit 128ca79

Browse files
authored
chore(deps): bump mongosh, devtools-connect, mongodb-client-encryption (#3160)
* chore(deps): bump mongosh, devtools-connect, mongodb-client-encryption * fixup: rename shared library option, add ts-expect-error * fixup: adjust csfle collection tracker tests and crypt library logging * fixup: update asar unpack list * fixup: add ticket link
1 parent a2191e1 commit 128ca79

File tree

9 files changed

+286
-281
lines changed

9 files changed

+286
-281
lines changed

package-lock.json

Lines changed: 189 additions & 188 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/compass-e2e-tests/tests/logging.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@ describe('Logging and Telemetry integration', function () {
147147
s: 'I',
148148
c: 'COMPASS-MAIN',
149149
id: 1_001_000_125,
150-
ctx: 'CSFLE',
151-
msg: 'Found CSFLE library',
150+
ctx: 'AutoEncryption',
151+
msg: 'Found MongoDB Crypt library',
152152
attr: (actual: any) => {
153-
expect(actual.csfleLibraryPath).to.be.a('string');
154-
expect(actual.csfleLibraryPath).to.include('mongo_csfle_v1');
153+
expect(actual.cryptSharedLibPath).to.be.a('string');
154+
expect(actual.cryptSharedLibPath).to.include('mongo_crypt_v1');
155155
},
156156
},
157157
{

packages/compass-shell/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@
4646
"@leafygreen-ui/code": "^9.4.0",
4747
"@mongodb-js/compass-logging": "^0.12.0",
4848
"@mongodb-js/mongodb-redux-common": "^1.12.0",
49-
"@mongosh/browser-repl": "^1.4.2",
50-
"@mongosh/logging": "^1.4.2",
51-
"@mongosh/node-runtime-worker-thread": "^1.4.2",
52-
"@mongosh/service-provider-core": "^1.4.2"
49+
"@mongosh/browser-repl": "^1.5.0",
50+
"@mongosh/logging": "^1.5.0",
51+
"@mongosh/node-runtime-worker-thread": "^1.5.0",
52+
"@mongosh/service-provider-core": "^1.5.0"
5353
},
5454
"peerDependencies": {
5555
"@mongodb-js/compass-components": "^0.15.0",

packages/compass/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
"**/win-export-certificate-and-key/**",
111111
"**/macos-export-certificate-and-key/**",
112112
"**/system-ca/**",
113-
"**/mongo_csfle_v1.*"
113+
"**/mongo_crypt_v1.*"
114114
]
115115
},
116116
"rebuild": {
@@ -160,11 +160,11 @@
160160
"email": "[email protected]"
161161
},
162162
"dependencies": {
163-
"@mongosh/node-runtime-worker-thread": "^1.4.2",
163+
"@mongosh/node-runtime-worker-thread": "^1.5.0",
164164
"clipboard": "^2.0.6",
165165
"kerberos": "^2.0.0",
166166
"keytar": "^7.7.0",
167-
"mongodb-client-encryption": "^2.2.0-alpha.0",
167+
"mongodb-client-encryption": "^2.2.0-alpha.1",
168168
"os-dns-native": "^1.2.0",
169169
"system-ca": "^1.0.2"
170170
},

packages/compass/scripts/download-csfle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const download = async(url, destDir) => {
8484
} catch {
8585
artifactInfo = await getDownloadURL({
8686
...downloadOptions,
87-
version: '>= 6.0.0-rc4'
87+
version: '>= 6.0.0-rc8'
8888
});
8989
}
9090

packages/compass/src/main/setup-csfle-library.ts

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,63 +20,41 @@ function processPath(p: string): string {
2020

2121
export async function setupCSFLELibrary(): Promise<void> {
2222
const errors: Error[] = [];
23-
let csfleLibraryPath;
24-
if (!csfleLibraryPath) {
23+
let cryptSharedLibPath;
24+
if (!cryptSharedLibPath) {
2525
// This is not a loop so that the require() parts receive literal strings
2626
// in order for webpack to process them properly
2727
try {
2828
const candidate = processPath(require('../deps/csfle/bin/mongo_crypt_v1.dll'));
2929
await fs.access(candidate);
30-
csfleLibraryPath = candidate;
30+
cryptSharedLibPath = candidate;
3131
} catch (err: any) {
3232
errors.push(err);
3333
}
3434
try {
3535
const candidate = processPath(require('../deps/csfle/lib/mongo_crypt_v1.so'));
3636
await fs.access(candidate);
37-
csfleLibraryPath = candidate;
37+
cryptSharedLibPath = candidate;
3838
} catch (err: any) {
3939
errors.push(err);
4040
}
4141
try {
4242
const candidate = processPath(require('../deps/csfle/lib/mongo_crypt_v1.dylib'));
4343
await fs.access(candidate);
44-
csfleLibraryPath = candidate;
45-
} catch (err: any) {
46-
errors.push(err);
47-
}
48-
// Drop these as soon as the rename has been completed.
49-
try {
50-
const candidate = processPath(require('../deps/csfle/bin/mongo_csfle_v1.dll'));
51-
await fs.access(candidate);
52-
csfleLibraryPath = candidate;
53-
} catch (err: any) {
54-
errors.push(err);
55-
}
56-
try {
57-
const candidate = processPath(require('../deps/csfle/lib/mongo_csfle_v1.so'));
58-
await fs.access(candidate);
59-
csfleLibraryPath = candidate;
60-
} catch (err: any) {
61-
errors.push(err);
62-
}
63-
try {
64-
const candidate = processPath(require('../deps/csfle/lib/mongo_csfle_v1.dylib'));
65-
await fs.access(candidate);
66-
csfleLibraryPath = candidate;
44+
cryptSharedLibPath = candidate;
6745
} catch (err: any) {
6846
errors.push(err);
6947
}
7048
}
71-
if (!csfleLibraryPath) {
72-
log.error(mongoLogId(1_001_000_124), 'CSFLE', 'No CSFLE library available', {
49+
if (!cryptSharedLibPath) {
50+
log.error(mongoLogId(1_001_000_124), 'AutoEncryption', 'No MongoDB Crypt library available', {
7351
errors: errors.map(err => err.message)
7452
});
7553
} else {
76-
log.info(mongoLogId(1_001_000_125), 'CSFLE', 'Found CSFLE library', {
77-
csfleLibraryPath,
54+
log.info(mongoLogId(1_001_000_125), 'AutoEncryption', 'Found MongoDB Crypt library', {
55+
cryptSharedLibPath,
7856
externalOverride: process.env.COMPASS_CRYPT_LIBRARY_PATH
7957
});
80-
process.env.COMPASS_CRYPT_LIBRARY_PATH ??= csfleLibraryPath;
58+
process.env.COMPASS_CRYPT_LIBRARY_PATH ??= cryptSharedLibPath;
8159
}
8260
}

packages/data-service/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@
6060
},
6161
"dependencies": {
6262
"@mongodb-js/compass-logging": "^0.12.0",
63-
"@mongodb-js/devtools-connect": "^1.3.1",
63+
"@mongodb-js/devtools-connect": "^1.4.3",
6464
"@mongodb-js/ssh-tunnel": "^1.7.0",
6565
"async": "^3.2.0",
6666
"debug": "4.3.0",
6767
"lodash": "^4.17.20",
6868
"mongodb-build-info": "^1.3.0",
69-
"mongodb-client-encryption": "^2.2.0-alpha.0",
69+
"mongodb-client-encryption": "^2.2.0-alpha.1",
7070
"mongodb-connection-model": "^21.17.0",
7171
"mongodb-connection-string-url": "^2.5.2",
7272
"mongodb-index-model": "^3.11.0",

packages/data-service/src/connect-mongo-client.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ export default async function connectMongoClientCompass(
4545
...options.autoEncryption,
4646
extraOptions: {
4747
...options.autoEncryption?.extraOptions,
48-
csflePath: process.env.COMPASS_CRYPT_LIBRARY_PATH,
48+
// @ts-expect-error next driver release has types
49+
cryptSharedLibPath: process.env.COMPASS_CRYPT_LIBRARY_PATH,
4950
},
5051
};
5152
}

packages/data-service/src/csfle-collection-tracker.spec.ts

Lines changed: 71 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
import type { CSFLECollectionTracker } from './csfle-collection-tracker';
2-
import { CSFLECollectionTrackerImpl } from './csfle-collection-tracker';
32
import { expect } from 'chai';
4-
import type { DataService } from './data-service';
3+
import type { DataService, DataServiceImpl } from './data-service';
54
import type { AutoEncryptionOptions, MongoClient } from 'mongodb';
6-
import { UUID } from 'bson';
5+
import type { Binary } from 'bson';
76
import connect from './connect';
87

98
describe('CSFLECollectionTracker', function () {
109
const DECRYPTED_KEYS = Symbol.for('@@mdb.decryptedKeys');
11-
const SOME_UUID1 = new UUID(
12-
'00000000-0000-4000-8000-000000000001'
13-
).toBinary();
14-
const SOME_UUID2 = new UUID(
15-
'00000000-0000-4000-8000-000000000002'
16-
).toBinary();
1710
const ALGO_DET = 'AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic';
1811

1912
let dataService: DataService;
@@ -33,8 +26,22 @@ describe('CSFLECollectionTracker', function () {
3326
});
3427

3528
async function createTracker(
36-
autoEncryption: AutoEncryptionOptions = {}
37-
): Promise<[CSFLECollectionTracker, DataService]> {
29+
autoEncryption:
30+
| AutoEncryptionOptions
31+
| ((keys: [Binary, Binary]) => AutoEncryptionOptions) = {}
32+
): Promise<[CSFLECollectionTracker, DataService, Binary, Binary]> {
33+
if (typeof autoEncryption === 'function') {
34+
// This autoEncryption config depends on the keys, so we first need
35+
// to set up the keys with one DataService instance,
36+
// then create the 'real' DataService instance.
37+
const [, tempDataService, someKey1, someKey2] = await createTracker({});
38+
await tempDataService.disconnect();
39+
const [tracker, dataService] = await createTracker(
40+
autoEncryption([someKey1, someKey2])
41+
);
42+
return [tracker, dataService, someKey1, someKey2];
43+
}
44+
3845
const dataService = await connect({
3946
connectionString: 'mongodb://localhost:27018',
4047
fleOptions: {
@@ -43,16 +50,21 @@ describe('CSFLECollectionTracker', function () {
4350
kmsProviders: { local: { key: 'A'.repeat(128) } },
4451
keyVaultNamespace: `${dbName}.kv`,
4552
extraOptions: {
46-
csflePath: process.env.COMPASS_CRYPT_LIBRARY_PATH,
53+
// @ts-expect-error next driver release has types
54+
cryptSharedLibPath: process.env.COMPASS_CRYPT_LIBRARY_PATH,
4755
},
4856
...autoEncryption,
4957
},
5058
},
5159
});
52-
const crudClient = (dataService as any)._initializedClient('CRUD');
60+
// It can be useful to have one or two pre-defined keys in the key vault.
61+
const someKey1 = (await dataService.createDataKey('local')) as Binary;
62+
const someKey2 = (await dataService.createDataKey('local')) as Binary;
5363
return [
54-
new CSFLECollectionTrackerImpl(dataService, crudClient),
64+
(dataService as DataServiceImpl).getCSFLECollectionTracker(),
5565
dataService,
66+
someKey1,
67+
someKey2,
5668
];
5769
}
5870

@@ -134,7 +146,7 @@ describe('CSFLECollectionTracker', function () {
134146

135147
context('with client-side FLE1 schema info', function () {
136148
beforeEach(async function () {
137-
[tracker, dataService] = await createTracker({
149+
[tracker, dataService] = await createTracker(([SOME_UUID1]) => ({
138150
schemaMap: {
139151
[`${dbName}.test1`]: {
140152
properties: {
@@ -168,7 +180,7 @@ describe('CSFLECollectionTracker', function () {
168180
},
169181
},
170182
},
171-
});
183+
}));
172184
});
173185

174186
it('correctly returns whether updates are allowed', async function () {
@@ -190,16 +202,18 @@ describe('CSFLECollectionTracker', function () {
190202

191203
context('with client-side FLE2 schema info', function () {
192204
beforeEach(async function () {
193-
[tracker, dataService] = await createTracker({
194-
encryptedFieldsMap: {
195-
[`${dbName}.test2`]: {
196-
fields: [{ path: 'a', keyId: SOME_UUID1, bsonType: 'string' }],
197-
},
198-
[`${dbName}.test3`]: {
199-
fields: [{ path: 'n.a', keyId: SOME_UUID2, bsonType: 'string' }],
205+
[tracker, dataService] = await createTracker(
206+
([SOME_UUID1, SOME_UUID2]) => ({
207+
encryptedFieldsMap: {
208+
[`${dbName}.test2`]: {
209+
fields: [{ path: 'a', keyId: SOME_UUID1, bsonType: 'string' }],
210+
},
211+
[`${dbName}.test3`]: {
212+
fields: [{ path: 'n.a', keyId: SOME_UUID2, bsonType: 'string' }],
213+
},
200214
},
201-
},
202-
});
215+
})
216+
);
203217
});
204218

205219
it('correctly returns whether updates are allowed', async function () {
@@ -220,12 +234,15 @@ describe('CSFLECollectionTracker', function () {
220234
});
221235

222236
context('with server-side FLE1 schema info', function () {
237+
let SOME_UUID1;
223238
beforeEach(async function () {
224-
[tracker, dataService] = await createTracker();
225-
const crudClient: MongoClient = (dataService as any)._initializedClient(
226-
'CRUD'
227-
);
228-
await crudClient.db(dbName).createCollection('test1', {
239+
[tracker, dataService, SOME_UUID1] = await createTracker();
240+
// TODO: This might/should be the CRUD client, but that doesn't
241+
// work -- https://jira.mongodb.org/browse/MONGOCRYPT-436 tracks this.
242+
const metadataClient: MongoClient = (
243+
dataService as any
244+
)._initializedClient('META');
245+
await metadataClient.db(dbName).createCollection('test1', {
229246
validator: {
230247
$jsonSchema: {
231248
properties: {
@@ -235,7 +252,7 @@ describe('CSFLECollectionTracker', function () {
235252
},
236253
});
237254

238-
await crudClient.db(dbName).createCollection('test2', {
255+
await metadataClient.db(dbName).createCollection('test2', {
239256
validator: {
240257
$jsonSchema: {
241258
properties: {
@@ -251,7 +268,7 @@ describe('CSFLECollectionTracker', function () {
251268
},
252269
});
253270

254-
await crudClient.db(dbName).createCollection('test3', {
271+
await metadataClient.db(dbName).createCollection('test3', {
255272
validator: {
256273
$jsonSchema: {
257274
properties: {
@@ -290,18 +307,22 @@ describe('CSFLECollectionTracker', function () {
290307
});
291308

292309
context('with server-side FLE2 schema info', function () {
310+
let SOME_UUID1, SOME_UUID2;
293311
beforeEach(async function () {
294-
[tracker, dataService] = await createTracker();
295-
const crudClient: MongoClient = (dataService as any)._initializedClient(
296-
'CRUD'
297-
);
298-
await crudClient.db(dbName).createCollection('test2', {
312+
[tracker, dataService, SOME_UUID1, SOME_UUID2] = await createTracker();
313+
// Creating the collections needs to be done through the non-FLE-aware
314+
// client here, because newer libmongocrypt versions also fetch
315+
// collection infos when doing createCollection commands.
316+
const metaDataClient: MongoClient = (
317+
dataService as any
318+
)._initializedClient('META');
319+
await metaDataClient.db(dbName).createCollection('test2', {
299320
encryptedFields: {
300321
fields: [{ path: 'a', keyId: SOME_UUID1, bsonType: 'string' }],
301322
},
302323
});
303324

304-
await crudClient.db(dbName).createCollection('test3', {
325+
await metaDataClient.db(dbName).createCollection('test3', {
305326
encryptedFields: {
306327
fields: [{ path: 'n.a', keyId: SOME_UUID2, bsonType: 'string' }],
307328
},
@@ -360,7 +381,7 @@ describe('CSFLECollectionTracker', function () {
360381
dataService.findOneAndUpdate(
361382
`${dbName}.test2`,
362383
{},
363-
{ $set: { a: 2 } },
384+
{ $set: { a: '2' } },
364385
{},
365386
resolve
366387
);
@@ -384,7 +405,7 @@ describe('CSFLECollectionTracker', function () {
384405
dataService.findOneAndUpdate(
385406
`${dbName}.test2`,
386407
{},
387-
{ $set: { a: 2 } },
408+
{ $set: { a: '2' } },
388409
{},
389410
resolve
390411
);
@@ -419,14 +440,18 @@ describe('CSFLECollectionTracker', function () {
419440
});
420441

421442
context('with client-side and server-side FLE2 schema info', function () {
443+
let SOME_UUID2;
444+
422445
beforeEach(async function () {
423-
[tracker, dataService] = await createTracker({
424-
encryptedFieldsMap: {
425-
[`${dbName}.test3`]: {
426-
fields: [{ path: 'n.a', keyId: SOME_UUID2, bsonType: 'string' }],
446+
[tracker, dataService, SOME_UUID2] = await createTracker(
447+
([SOME_UUID2]) => ({
448+
encryptedFieldsMap: {
449+
[`${dbName}.test3`]: {
450+
fields: [{ path: 'n.a', keyId: SOME_UUID2, bsonType: 'string' }],
451+
},
427452
},
428-
},
429-
});
453+
})
454+
);
430455
const crudClient: MongoClient = (dataService as any)._initializedClient(
431456
'CRUD'
432457
);

0 commit comments

Comments
 (0)