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
14 changes: 7 additions & 7 deletions config/build.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ const EXECUTABLE_PATH = path.join(OUTPUT_DIR, process.platform === 'win32' ? 'mo

/**
* The path to the downloaded csfe shared library.
* We use the name mongosh_csfle_v1 to avoid conflicts with users
* potentially installing the 'proper' csfle shared library.
* We use the name mongosh_crypt_v1 to avoid conflicts with users
* potentially installing the 'proper' crypt shared library.
*/
const CSFLE_LIBRARY_PATH = path.resolve(TMP_DIR, 'mongosh_csfle_v1.' + SHARED_LIBRARY_SUFFIX);
const CRYPT_LIBRARY_PATH = path.resolve(TMP_DIR, 'mongosh_crypt_v1.' + SHARED_LIBRARY_SUFFIX);

/**
* Build info JSON data file.
Expand Down Expand Up @@ -119,7 +119,7 @@ module.exports = {
repo: 'mongosh'
},
artifactUrlFile: process.env.ARTIFACT_URL_FILE,
csfleLibraryPath: CSFLE_LIBRARY_PATH,
cryptSharedLibPath: CRYPT_LIBRARY_PATH,
packageInformation: {
binaries: [
{
Expand All @@ -134,11 +134,11 @@ module.exports = {
}
},
{
sourceFilePath: CSFLE_LIBRARY_PATH,
sourceFilePath: CRYPT_LIBRARY_PATH,
category: 'lib',
license: {
sourceFilePath: path.resolve(__dirname, '..', 'packaging', 'LICENSE-csfle'),
packagedFilePath: 'LICENSE-csfle',
sourceFilePath: path.resolve(__dirname, '..', 'packaging', 'LICENSE-crypt-library'),
packagedFilePath: 'LICENSE-crypt-library',
debCopyright: COPYRIGHT,
debIdentifier: 'Proprietary',
rpmIdentifier: 'Proprietary'
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
"lerna": "^4.0.0",
"mocha": "^7.1.2",
"mongodb": "^4.6.0",
"mongodb-download-url": "^1.2.1",
"mongodb-download-url": "^1.2.2",
"mongodb-js-precommit": "^2.0.0",
"nock": "^13.0.11",
"node-codesign": "^0.3.3",
Expand Down
5 changes: 4 additions & 1 deletion packages/arg-parser/src/arg-mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ const MAPPINGS: {
awsSecretAccessKey: (i, v) => setAWSKMS(i, 'secretAccessKey', v),
awsSessionToken: (i, v) => setAWSKMS(i, 'sessionToken', v),
awsIamSessionToken: (i, v) => setAuthMechProp(i, 'AWS_SESSION_TOKEN', v),
csfleLibraryPath: (i, v) => setAutoEncryptExtra(i, 'csflePath', v),
// @ts-expect-error AutoEncryption options have been renamed, drop the (outer) csflePath call after the next release
csfleLibraryPath: (i, v) => setAutoEncryptExtra(setAutoEncryptExtra(i, 'cryptSharedLibPath', v), 'csflePath', v),
// @ts-expect-error AutoEncryption options have been renamed, drop the (outer) csflePath call after the next release
cryptSharedLibPath: (i, v) => setAutoEncryptExtra(setAutoEncryptExtra(i, 'cryptSharedLibPath', v), 'csflePath', v),
gssapiServiceName: (i, v) => setAuthMechProp(i, 'SERVICE_NAME', v),
sspiRealmOverride: (i, v) => setAuthMechProp(i, 'SERVICE_REALM', v),
sspiHostnameCanonicalization:
Expand Down
1 change: 1 addition & 0 deletions packages/arg-parser/src/cli-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface CliOptions {
awsSecretAccessKey?: string;
awsSessionToken?: string;
csfleLibraryPath?: string;
cryptSharedLibPath?: string;
db?: string;
eval?: string;
gssapiServiceName?: string;
Expand Down
8 changes: 4 additions & 4 deletions packages/build/src/compile/signable-compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ export class SignableCompiler {
path: await findModulePath('service-provider-server', 'os-dns-native'),
requireRegexp: /\bos_dns_native\.node$/
};
const csfleLibraryVersionAddon = {
path: await findModulePath('cli-repl', 'mongodb-csfle-library-version'),
requireRegexp: /\bmongodb_csfle_library_version\.node$/
const cryptLibraryVersionAddon = {
path: await findModulePath('cli-repl', 'mongodb-crypt-library-version'),
requireRegexp: /\bmongodb_crypt_library_version\.node$/
};
// Warning! Until https://jira.mongodb.org/browse/MONGOSH-990,
// packages/service-provider-server *also* has a copy of these.
Expand Down Expand Up @@ -137,7 +137,7 @@ export class SignableCompiler {
fleAddon,
osDnsAddon,
kerberosAddon,
csfleLibraryVersionAddon
cryptLibraryVersionAddon
].concat(winCAAddon ? [
winCAAddon
] : []).concat(winConsoleProcessListAddon ? [
Expand Down
2 changes: 1 addition & 1 deletion packages/build/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export interface Config {
};
isPatch?: boolean;
triggeringGitTag?: string;
csfleLibraryPath: string;
cryptSharedLibPath: string;
packageInformation?: PackageInformation;
artifactUrlFile?: string;
manpage?: ManPageConfig;
Expand Down
2 changes: 1 addition & 1 deletion packages/build/src/config/redact-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function redactConfig(config: Config): Partial<Config> {
repo: config.repo,
isPatch: config.isPatch,
packageInformation: config.packageInformation,
csfleLibraryPath: config.csfleLibraryPath,
cryptSharedLibPath: config.cryptSharedLibPath,
artifactUrlFile: config.artifactUrlFile,
isDryRun: config.isDryRun
};
Expand Down
12 changes: 6 additions & 6 deletions packages/build/src/download-mongodb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export async function downloadMongoDb(tmpdir: string, targetVersionSemverSpecifi

await fs.mkdir(tmpdir, { recursive: true });
if (targetVersionSemverSpecifier === 'latest-alpha') {
return await doDownload(tmpdir, !!options.csfle, 'latest-alpha', lookupDownloadUrl);
return await doDownload(tmpdir, !!options.crypt_shared, 'latest-alpha', lookupDownloadUrl);
}

if (/-community$/.test(targetVersionSemverSpecifier)) {
Expand All @@ -35,15 +35,15 @@ export async function downloadMongoDb(tmpdir: string, targetVersionSemverSpecifi

return await doDownload(
tmpdir,
!!options.csfle,
!!options.crypt_shared,
targetVersionSemverSpecifier + (wantsEnterprise ? '-enterprise' : '-community'),
() => lookupDownloadUrl());
}

const downloadPromises: Record<string, Promise<string>> = {};
async function doDownload(
tmpdir: string,
isCsfle: boolean,
isCryptLibrary: boolean,
version: string,
lookupDownloadUrl: () => Promise<string>) {
const downloadTarget = path.resolve(
Expand All @@ -53,7 +53,7 @@ async function doDownload(
return downloadPromises[downloadTarget] ??= (async() => {
const bindir = path.resolve(
downloadTarget,
isCsfle && process.platform !== 'win32' ? 'lib' : 'bin');
isCryptLibrary && process.platform !== 'win32' ? 'lib' : 'bin');
try {
await fs.stat(bindir);
console.info(`Skipping download because ${downloadTarget} exists`);
Expand All @@ -71,10 +71,10 @@ async function doDownload(
const response = await fetch(url);
await promisify(pipeline)(
response.body,
tar.x({ cwd: downloadTarget, strip: isCsfle ? 0 : 1 })
tar.x({ cwd: downloadTarget, strip: isCryptLibrary ? 0 : 1 })
);
} else {
await download(url, downloadTarget, { extract: true, strip: isCsfle ? 0 : 1 });
await download(url, downloadTarget, { extract: true, strip: isCryptLibrary ? 0 : 1 });
}

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,36 @@ import { promises as fs, constants as fsConstants } from 'fs';
import { downloadMongoDb, DownloadOptions } from '../download-mongodb';
import { BuildVariant, getDistro, getArch } from '../config';

export async function downloadCsfleLibrary(variant: BuildVariant | 'host'): Promise<string> {
export async function downloadCryptLibrary(variant: BuildVariant | 'host'): Promise<string> {
const opts: DownloadOptions = {};
opts.arch = variant === 'host' ? undefined : getArch(variant);
opts.distro = variant === 'host' ? undefined : lookupReleaseDistro(variant);
opts.enterprise = true;
opts.csfle = true;
console.info('mongosh: downloading latest csfle shared library for inclusion in package:', JSON.stringify(opts));
opts.crypt_shared = true;
console.info('mongosh: downloading latest crypt shared library for inclusion in package:', JSON.stringify(opts));

let libdir = '';
const csfleTmpTargetDir = path.resolve(__dirname, '..', '..', '..', '..', 'tmp', 'csfle-store', variant);
const cryptTmpTargetDir = path.resolve(__dirname, '..', '..', '..', '..', 'tmp', 'crypt-store', variant);
// Download mongodb for latest server version. Fall back to the 6.0.0-rcX
// version if no stable version is available.
let error: Error | undefined;
for (const version of [ 'stable', '>= 6.0.0-rc5' ]) {
try {
libdir = await downloadMongoDb(csfleTmpTargetDir, version, opts);
libdir = await downloadMongoDb(cryptTmpTargetDir, version, opts);
break;
} catch (e: any) {
error = e;
}
}
if (!libdir) throw error;
const csfleLibrary = path.join(
const cryptLibrary = path.join(
libdir,
(await fs.readdir(libdir)).find(filename => filename.match(/^mongo_csfle_v1\.(so|dylib|dll)$/)) as string
(await fs.readdir(libdir)).find(filename => filename.match(/^mongo_crypt_v1\.(so|dylib|dll)$/)) as string
);
// Make sure that the binary exists and is readable.
await fs.access(csfleLibrary, fsConstants.R_OK);
console.info('mongosh: downloaded', csfleLibrary);
return csfleLibrary;
await fs.access(cryptLibrary, fsConstants.R_OK);
console.info('mongosh: downloaded', cryptLibrary);
return cryptLibrary;
}

function lookupReleaseDistro(variant: BuildVariant): string {
Expand Down
8 changes: 4 additions & 4 deletions packages/build/src/packaging/run-package.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { constants as fsConstants, promises as fs } from 'fs';
import path from 'path';
import { Config, validateBuildVariant } from '../config';
import { downloadCsfleLibrary } from './download-csfle-library';
import { downloadCryptLibrary } from './download-crypt-library';
import { downloadManpage } from './download-manpage';
import { notarizeArtifact } from './notary-service';
import { createPackage, PackageFile } from './package';
Expand All @@ -12,10 +12,10 @@ export async function runPackage(
const distributionBuildVariant = config.distributionBuildVariant;
validateBuildVariant(distributionBuildVariant);

await fs.mkdir(path.dirname(config.csfleLibraryPath), { recursive: true });
await fs.mkdir(path.dirname(config.cryptSharedLibPath), { recursive: true });
await fs.copyFile(
await downloadCsfleLibrary(distributionBuildVariant),
config.csfleLibraryPath,
await downloadCryptLibrary(distributionBuildVariant),
config.cryptSharedLibPath,
fsConstants.COPYFILE_FICLONE);

const { manpage } = config;
Expand Down
2 changes: 1 addition & 1 deletion packages/build/test/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const dummyConfig: Config = Object.freeze({
bundleEntrypointInput: 'bundleEntrypointInput',
bundleSinglefileOutput: 'bundleSinglefileOutput',
executablePath: 'executablePath',
csfleLibraryPath: 'csfleLibraryPath',
cryptSharedLibPath: 'cryptSharedLibPath',
outputDir: 'outputDir',
buildInfoFilePath: 'buildInfoFilePath',
project: 'project',
Expand Down
38 changes: 19 additions & 19 deletions packages/cli-repl/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/cli-repl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@
"chai-as-promised": "^7.1.1",
"lodash": "^4.17.21",
"moment": "^2.29.1",
"mongodb-csfle-library-dummy": "^1.0.1"
"mongodb-crypt-library-dummy": "^1.0.2"
},
"optionalDependencies": {
"get-console-process-list": "^1.0.4",
"macos-export-certificate-and-key": "^1.1.1",
"win-export-certificate-and-key": "^1.1.1",
"mongodb-csfle-library-version": "^1.0.2"
"mongodb-crypt-library-version": "^1.0.3"
}
}
1 change: 1 addition & 0 deletions packages/cli-repl/src/arg-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const OPTIONS = {
'awsSessionToken',
'awsIamSessionToken',
'csfleLibraryPath',
'cryptSharedLibPath',
'db',
'eval',
'gssapiHostName',
Expand Down
Loading