@mongosh/cli-repl 1.3.1 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AUTHORS +1 -0
- package/lib/arg-parser.d.ts +1 -1
- package/lib/arg-parser.js +3 -2
- package/lib/arg-parser.js.map +1 -1
- package/lib/build-info.d.ts +5 -2
- package/lib/build-info.js +9 -8
- package/lib/build-info.js.map +1 -1
- package/lib/build-info.json +1 -1
- package/lib/cli-repl.d.ts +7 -6
- package/lib/cli-repl.js +28 -33
- package/lib/cli-repl.js.map +1 -1
- package/lib/crypt-library-paths.d.ts +10 -0
- package/lib/crypt-library-paths.js +80 -0
- package/lib/crypt-library-paths.js.map +1 -0
- package/lib/format-output.js +23 -3
- package/lib/format-output.js.map +1 -1
- package/lib/index.d.ts +1 -3
- package/lib/index.js +1 -5
- package/lib/index.js.map +1 -1
- package/lib/mongosh-repl.d.ts +2 -3
- package/lib/mongosh-repl.js +15 -38
- package/lib/mongosh-repl.js.map +1 -1
- package/lib/run.js +45 -10
- package/lib/run.js.map +1 -1
- package/lib/smoke-tests-fle.js +3 -3
- package/lib/smoke-tests.js +23 -6
- package/lib/smoke-tests.js.map +1 -1
- package/lib/tls-certificate-selector.d.ts +5 -0
- package/lib/tls-certificate-selector.js +46 -0
- package/lib/tls-certificate-selector.js.map +1 -0
- package/package.json +36 -21
- package/lib/arg-mapper.d.ts +0 -8
- package/lib/arg-mapper.js +0 -124
- package/lib/arg-mapper.js.map +0 -1
- package/lib/log-entry.d.ts +0 -10
- package/lib/log-entry.js +0 -31
- package/lib/log-entry.js.map +0 -1
- package/lib/mongocryptd-manager.d.ts +0 -30
- package/lib/mongocryptd-manager.js +0 -230
- package/lib/mongocryptd-manager.js.map +0 -1
package/lib/arg-mapper.js
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getTlsCertificateSelector = void 0;
|
|
7
|
-
const errors_1 = require("@mongosh/errors");
|
|
8
|
-
const lodash_set_1 = __importDefault(require("lodash.set"));
|
|
9
|
-
const MAPPINGS = {
|
|
10
|
-
apiDeprecationErrors: 'serverApi.deprecationErrors',
|
|
11
|
-
apiStrict: 'serverApi.strict',
|
|
12
|
-
apiVersion: 'serverApi.version',
|
|
13
|
-
awsAccessKeyId: 'autoEncryption.kmsProviders.aws.accessKeyId',
|
|
14
|
-
awsSecretAccessKey: 'autoEncryption.kmsProviders.aws.secretAccessKey',
|
|
15
|
-
awsSessionToken: 'autoEncryption.kmsProviders.aws.sessionToken',
|
|
16
|
-
awsIamSessionToken: 'authMechanismProperties.AWS_SESSION_TOKEN',
|
|
17
|
-
gssapiServiceName: 'authMechanismProperties.SERVICE_NAME',
|
|
18
|
-
sspiRealmOverride: 'authMechanismProperties.SERVICE_REALM',
|
|
19
|
-
sspiHostnameCanonicalization: { opt: 'authMechanismProperties.CANONICALIZE_HOST_NAME', fun: mapGSSAPIHostnameCanonicalization },
|
|
20
|
-
authenticationDatabase: 'authSource',
|
|
21
|
-
authenticationMechanism: 'authMechanism',
|
|
22
|
-
keyVaultNamespace: 'autoEncryption.keyVaultNamespace',
|
|
23
|
-
password: 'auth.password',
|
|
24
|
-
quiet: { opt: 'loggerLevel', val: 'error' },
|
|
25
|
-
retryWrites: 'retryWrites',
|
|
26
|
-
tls: 'tls',
|
|
27
|
-
tlsAllowInvalidCertificates: 'tlsAllowInvalidCertificates',
|
|
28
|
-
tlsAllowInvalidHostnames: 'tlsAllowInvalidHostnames',
|
|
29
|
-
tlsCAFile: 'tlsCAFile',
|
|
30
|
-
tlsCRLFile: 'sslCRL',
|
|
31
|
-
tlsCertificateKeyFile: 'tlsCertificateKeyFile',
|
|
32
|
-
tlsCertificateKeyFilePassword: 'tlsCertificateKeyFilePassword',
|
|
33
|
-
tlsUseSystemCA: 'useSystemCA',
|
|
34
|
-
username: 'auth.username',
|
|
35
|
-
verbose: { opt: 'loggerLevel', val: 'debug' }
|
|
36
|
-
};
|
|
37
|
-
function isExistingMappingKey(key, options) {
|
|
38
|
-
return MAPPINGS.hasOwnProperty(key) && options.hasOwnProperty(key);
|
|
39
|
-
}
|
|
40
|
-
function mapCliToDriver(options) {
|
|
41
|
-
const nodeOptions = {};
|
|
42
|
-
for (const cliOption of Object.keys(MAPPINGS)) {
|
|
43
|
-
if (isExistingMappingKey(cliOption, options)) {
|
|
44
|
-
const mapping = MAPPINGS[cliOption];
|
|
45
|
-
if (typeof mapping === 'object') {
|
|
46
|
-
const cliValue = options[cliOption];
|
|
47
|
-
if (cliValue) {
|
|
48
|
-
let newValue;
|
|
49
|
-
if ('val' in mapping) {
|
|
50
|
-
newValue = mapping.val;
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
newValue = mapping.fun(cliValue);
|
|
54
|
-
if (newValue === undefined) {
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
(0, lodash_set_1.default)(nodeOptions, mapping.opt, newValue);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
(0, lodash_set_1.default)(nodeOptions, mapping, options[cliOption]);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
const { version } = require('../package.json');
|
|
67
|
-
return {
|
|
68
|
-
...nodeOptions,
|
|
69
|
-
...getTlsCertificateSelector(options.tlsCertificateSelector),
|
|
70
|
-
driverInfo: { name: 'mongosh', version }
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
function getTlsCertificateSelector(selector) {
|
|
74
|
-
var _a, _b, _c;
|
|
75
|
-
if (!selector) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
const exportCertificateAndPrivateKey = getCertificateExporter();
|
|
79
|
-
if (!exportCertificateAndPrivateKey) {
|
|
80
|
-
throw new errors_1.MongoshUnimplementedError('--tlsCertificateSelector is not supported on this platform');
|
|
81
|
-
}
|
|
82
|
-
const match = selector.match(/^(?<key>\w+)=(?<value>.+)/);
|
|
83
|
-
if (!match || !['subject', 'thumbprint'].includes((_b = (_a = match.groups) === null || _a === void 0 ? void 0 : _a.key) !== null && _b !== void 0 ? _b : '')) {
|
|
84
|
-
throw new errors_1.MongoshInvalidInputError('--tlsCertificateSelector needs to include subject or thumbprint');
|
|
85
|
-
}
|
|
86
|
-
const { key, value } = (_c = match.groups) !== null && _c !== void 0 ? _c : {};
|
|
87
|
-
const search = key === 'subject' ? { subject: value } : { thumbprint: Buffer.from(value, 'hex') };
|
|
88
|
-
try {
|
|
89
|
-
const { passphrase, pfx } = exportCertificateAndPrivateKey(search);
|
|
90
|
-
return { passphrase, pfx };
|
|
91
|
-
}
|
|
92
|
-
catch (err) {
|
|
93
|
-
throw new errors_1.MongoshInvalidInputError(`Could not resolve certificate specification '${selector}': ${err === null || err === void 0 ? void 0 : err.message}`);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
exports.getTlsCertificateSelector = getTlsCertificateSelector;
|
|
97
|
-
function getCertificateExporter() {
|
|
98
|
-
if (process.env.TEST_OS_EXPORT_CERTIFICATE_AND_KEY_PATH) {
|
|
99
|
-
return require(process.env.TEST_OS_EXPORT_CERTIFICATE_AND_KEY_PATH);
|
|
100
|
-
}
|
|
101
|
-
try {
|
|
102
|
-
switch (process.platform) {
|
|
103
|
-
case 'win32':
|
|
104
|
-
return require('win-export-certificate-and-key');
|
|
105
|
-
case 'darwin':
|
|
106
|
-
return require('macos-export-certificate-and-key');
|
|
107
|
-
default:
|
|
108
|
-
return undefined;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
catch (_a) { }
|
|
112
|
-
return undefined;
|
|
113
|
-
}
|
|
114
|
-
function mapGSSAPIHostnameCanonicalization(value) {
|
|
115
|
-
if (value === '') {
|
|
116
|
-
return undefined;
|
|
117
|
-
}
|
|
118
|
-
if (value === 'true' || value === 'false') {
|
|
119
|
-
return value === 'true';
|
|
120
|
-
}
|
|
121
|
-
return value;
|
|
122
|
-
}
|
|
123
|
-
exports.default = mapCliToDriver;
|
|
124
|
-
//# sourceMappingURL=arg-mapper.js.map
|
package/lib/arg-mapper.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arg-mapper.js","sourceRoot":"","sources":["../src/arg-mapper.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAsF;AAEtF,4DAAkC;AAKlC,MAAM,QAAQ,GAAG;IACf,oBAAoB,EAAE,6BAA6B;IACnD,SAAS,EAAE,kBAAkB;IAC7B,UAAU,EAAE,mBAAmB;IAC/B,cAAc,EAAE,6CAA6C;IAC7D,kBAAkB,EAAE,iDAAiD;IACrE,eAAe,EAAE,8CAA8C;IAC/D,kBAAkB,EAAE,2CAA2C;IAC/D,iBAAiB,EAAE,sCAAsC;IACzD,iBAAiB,EAAE,uCAAuC;IAC1D,4BAA4B,EAAE,EAAE,GAAG,EAAE,gDAAgD,EAAE,GAAG,EAAE,iCAAiC,EAAE;IAC/H,sBAAsB,EAAE,YAAY;IACpC,uBAAuB,EAAE,eAAe;IACxC,iBAAiB,EAAE,kCAAkC;IACrD,QAAQ,EAAE,eAAe;IACzB,KAAK,EAAE,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,OAAO,EAAE;IAC3C,WAAW,EAAE,aAAa;IAC1B,GAAG,EAAE,KAAK;IACV,2BAA2B,EAAE,6BAA6B;IAC1D,wBAAwB,EAAE,0BAA0B;IACpD,SAAS,EAAE,WAAW;IACtB,UAAU,EAAE,QAAQ;IACpB,qBAAqB,EAAE,uBAAuB;IAC9C,6BAA6B,EAAE,+BAA+B;IAC9D,cAAc,EAAE,aAAa;IAC7B,QAAQ,EAAE,eAAe;IACzB,OAAO,EAAE,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,EA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AO,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAC;KACrE;IAED,IAAI;QACF,QAAQ,OAAO,CAAC,QAAQ,EAAE;YACxB,KAAK,OAAO;gBACV,OAAO,OAAO,CAAC,gCAAgC,CAAC,CAAC;YACnD,KAAK,QAAQ;gBACX,OAAO,OAAO,CAAC,kCAAkC,CAAC,CAAC;YACrD;gBACE,OAAO,SAAS,CAAC;SACpB;KACF;IAAC,WAAM,GAAmC;IAC3C,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,iCAAiC,CAAC,KAAa;IAGtD,IAAI,KAAK,KAAK,EAAE,EAAE;QAChB,OAAO,SAAS,CAAC;KAClB;IACD,IAAI,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,OAAO,EAAE;QACzC,OAAO,KAAK,KAAK,MAAM,CAAC;KACzB;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,kBAAe,cAAc,CAAC"}
|
package/lib/log-entry.d.ts
DELETED
package/lib/log-entry.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseAnyLogEntry = void 0;
|
|
4
|
-
function parseOldLogEntry(line) {
|
|
5
|
-
const re = /^(?<timestamp>\S*) *(?<severity>\S*) *(?<component>\S*) *\[(?<context>[^\]]+)\]\s*(?<message>.*)$/;
|
|
6
|
-
const match = line.trim().match(re);
|
|
7
|
-
if (!match) {
|
|
8
|
-
throw new Error(`Could not parse line ${JSON.stringify(line)}`);
|
|
9
|
-
}
|
|
10
|
-
return match.groups;
|
|
11
|
-
}
|
|
12
|
-
function parseAnyLogEntry(line) {
|
|
13
|
-
var _a;
|
|
14
|
-
try {
|
|
15
|
-
const newFormat = JSON.parse(line);
|
|
16
|
-
return {
|
|
17
|
-
id: newFormat.id,
|
|
18
|
-
timestamp: (_a = newFormat.t) === null || _a === void 0 ? void 0 : _a.$date,
|
|
19
|
-
severity: newFormat.s,
|
|
20
|
-
component: newFormat.c,
|
|
21
|
-
context: newFormat.ctx,
|
|
22
|
-
message: newFormat.msg,
|
|
23
|
-
attr: newFormat.attr
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
catch (_b) {
|
|
27
|
-
return parseOldLogEntry(line);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.parseAnyLogEntry = parseAnyLogEntry;
|
|
31
|
-
//# sourceMappingURL=log-entry.js.map
|
package/lib/log-entry.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"log-entry.js","sourceRoot":"","sources":["../src/log-entry.ts"],"names":[],"mappings":";;;AAkBA,SAAS,gBAAgB,CAAC,IAAY;IACpC,MAAM,EAAE,GAAG,mGAAmG,CAAC;IAC/G,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACpC,IAAI,CAAC,KAAK,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,wBAAwB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;KACjE;IACD,OAAO,KAAK,CAAC,MAA6B,CAAC;AAC7C,CAAC;AAQD,SAAgB,gBAAgB,CAAC,IAAY;;IAC3C,IAAI;QACF,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACnC,OAAO;YACL,EAAE,EAAE,SAAS,CAAC,EAAE;YAChB,SAAS,EAAE,MAAA,SAAS,CAAC,CAAC,0CAAE,KAAK;YAC7B,QAAQ,EAAE,SAAS,CAAC,CAAC;YACrB,SAAS,EAAE,SAAS,CAAC,CAAC;YACtB,OAAO,EAAE,SAAS,CAAC,GAAG;YACtB,OAAO,EAAE,SAAS,CAAC,GAAG;YACtB,IAAI,EAAE,SAAS,CAAC,IAAI;SACrB,CAAC;KACH;IAAC,WAAM;QACN,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC;KAC/B;AACH,CAAC;AAfD,4CAeC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { ChildProcess } from 'child_process';
|
|
3
|
-
import { Readable } from 'stream';
|
|
4
|
-
import type { MongoshBus } from '@mongosh/types';
|
|
5
|
-
import { LogEntry } from './log-entry';
|
|
6
|
-
import { ShellHomeDirectory } from './config-directory';
|
|
7
|
-
export declare function getMongocryptdPaths(): Promise<string[][]>;
|
|
8
|
-
declare type MongocryptdState = {
|
|
9
|
-
uri: string;
|
|
10
|
-
proc: ChildProcess;
|
|
11
|
-
interval: NodeJS.Timeout;
|
|
12
|
-
};
|
|
13
|
-
export declare class MongocryptdManager {
|
|
14
|
-
spawnPaths: string[][];
|
|
15
|
-
bus: MongoshBus;
|
|
16
|
-
path: string;
|
|
17
|
-
state: MongocryptdState | null;
|
|
18
|
-
idleShutdownTimeoutSecs: number;
|
|
19
|
-
constructor(spawnPaths: string[][], shellHomeDirectory: ShellHomeDirectory, bus: MongoshBus);
|
|
20
|
-
start(): Promise<{
|
|
21
|
-
mongocryptdURI: string;
|
|
22
|
-
mongocryptdBypassSpawn: true;
|
|
23
|
-
}>;
|
|
24
|
-
close: () => this;
|
|
25
|
-
createLogEntryIterator(stdout: Readable, pid: number): AsyncIterable<LogEntry>;
|
|
26
|
-
_spawnMongocryptdProcess(spawnPath: string[]): ChildProcess;
|
|
27
|
-
_spawn(): Promise<MongocryptdState>;
|
|
28
|
-
_cleanupOldMongocryptdDirectories(): Promise<void>;
|
|
29
|
-
}
|
|
30
|
-
export {};
|
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.MongocryptdManager = exports.getMongocryptdPaths = void 0;
|
|
7
|
-
const child_process_1 = require("child_process");
|
|
8
|
-
const fs_1 = require("fs");
|
|
9
|
-
const net_1 = require("net");
|
|
10
|
-
const path_1 = __importDefault(require("path"));
|
|
11
|
-
const readline_1 = __importDefault(require("readline"));
|
|
12
|
-
const stream_1 = require("stream");
|
|
13
|
-
const errors_1 = require("@mongosh/errors");
|
|
14
|
-
const service_provider_server_1 = require("@mongosh/service-provider-server");
|
|
15
|
-
const log_entry_1 = require("./log-entry");
|
|
16
|
-
async function getMongocryptdPaths() {
|
|
17
|
-
const bindir = path_1.default.dirname(process.execPath);
|
|
18
|
-
const result = [];
|
|
19
|
-
for await (const mongocryptdCandidate of [
|
|
20
|
-
path_1.default.resolve(bindir, '..', 'libexec', 'mongocryptd-mongosh'),
|
|
21
|
-
path_1.default.resolve(bindir, 'mongocryptd-mongosh'),
|
|
22
|
-
path_1.default.resolve(bindir, 'mongocryptd-mongosh.exe')
|
|
23
|
-
]) {
|
|
24
|
-
try {
|
|
25
|
-
await fs_1.promises.access(mongocryptdCandidate, fs_1.constants.X_OK);
|
|
26
|
-
result.push([mongocryptdCandidate]);
|
|
27
|
-
}
|
|
28
|
-
catch (_a) { }
|
|
29
|
-
}
|
|
30
|
-
return [...result, ['mongocryptd']];
|
|
31
|
-
}
|
|
32
|
-
exports.getMongocryptdPaths = getMongocryptdPaths;
|
|
33
|
-
class MongocryptdManager {
|
|
34
|
-
constructor(spawnPaths, shellHomeDirectory, bus) {
|
|
35
|
-
this.idleShutdownTimeoutSecs = 60;
|
|
36
|
-
this.close = () => {
|
|
37
|
-
process.removeListener('exit', this.close);
|
|
38
|
-
if (this.state) {
|
|
39
|
-
this.state.proc.kill();
|
|
40
|
-
clearInterval(this.state.interval);
|
|
41
|
-
this.state = null;
|
|
42
|
-
}
|
|
43
|
-
return this;
|
|
44
|
-
};
|
|
45
|
-
this.spawnPaths = spawnPaths;
|
|
46
|
-
this.path = shellHomeDirectory.localPath(`mongocryptd-${process.pid}-${(Math.random() * 100000) | 0}`);
|
|
47
|
-
this.bus = bus;
|
|
48
|
-
this.state = null;
|
|
49
|
-
}
|
|
50
|
-
async start() {
|
|
51
|
-
if (!this.state) {
|
|
52
|
-
[this.state] = await Promise.all([
|
|
53
|
-
this._spawn(),
|
|
54
|
-
this._cleanupOldMongocryptdDirectories()
|
|
55
|
-
]);
|
|
56
|
-
}
|
|
57
|
-
return {
|
|
58
|
-
mongocryptdURI: this.state.uri,
|
|
59
|
-
mongocryptdBypassSpawn: true
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
async *createLogEntryIterator(stdout, pid) {
|
|
63
|
-
for await (const line of readline_1.default.createInterface({ input: stdout })) {
|
|
64
|
-
if (!line.trim()) {
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
try {
|
|
68
|
-
const logEntry = (0, log_entry_1.parseAnyLogEntry)(line);
|
|
69
|
-
this.bus.emit('mongosh:mongocryptd-log', { pid, logEntry });
|
|
70
|
-
yield logEntry;
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
this.bus.emit('mongosh:mongocryptd-error', { pid, cause: 'parse', error });
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
_spawnMongocryptdProcess(spawnPath) {
|
|
79
|
-
const [executable, ...args] = [
|
|
80
|
-
...spawnPath,
|
|
81
|
-
'--idleShutdownTimeoutSecs', String(this.idleShutdownTimeoutSecs),
|
|
82
|
-
'--pidfilepath', path_1.default.join(this.path, 'mongocryptd.pid'),
|
|
83
|
-
'--port', '0',
|
|
84
|
-
...(process.platform !== 'win32' ? ['--unixSocketPrefix', this.path] : [])
|
|
85
|
-
];
|
|
86
|
-
const proc = (0, child_process_1.spawn)(executable, args, {
|
|
87
|
-
stdio: ['inherit', 'pipe', 'pipe']
|
|
88
|
-
});
|
|
89
|
-
proc.on('exit', (code, signal) => {
|
|
90
|
-
const logEntry = { exit: { code, signal } };
|
|
91
|
-
this.bus.emit('mongosh:mongocryptd-log', { pid: proc.pid, logEntry });
|
|
92
|
-
});
|
|
93
|
-
return proc;
|
|
94
|
-
}
|
|
95
|
-
async _spawn() {
|
|
96
|
-
var _a;
|
|
97
|
-
if (this.spawnPaths.length === 0) {
|
|
98
|
-
throw new errors_1.MongoshInternalError('No mongocryptd spawn path given');
|
|
99
|
-
}
|
|
100
|
-
await fs_1.promises.mkdir(this.path, { recursive: true, mode: 0o700 });
|
|
101
|
-
process.on('exit', this.close);
|
|
102
|
-
let proc = undefined;
|
|
103
|
-
let uri = '';
|
|
104
|
-
let lastError = undefined;
|
|
105
|
-
for (const spawnPath of this.spawnPaths) {
|
|
106
|
-
this.bus.emit('mongosh:mongocryptd-tryspawn', { spawnPath, path: this.path });
|
|
107
|
-
try {
|
|
108
|
-
proc = this._spawnMongocryptdProcess(spawnPath);
|
|
109
|
-
}
|
|
110
|
-
catch (error) {
|
|
111
|
-
lastError = error;
|
|
112
|
-
this.bus.emit('mongosh:mongocryptd-error', { cause: 'spawn', error });
|
|
113
|
-
continue;
|
|
114
|
-
}
|
|
115
|
-
proc.on('error', (error) => {
|
|
116
|
-
lastError = error;
|
|
117
|
-
this.bus.emit('mongosh:mongocryptd-error', { cause: 'spawn', error });
|
|
118
|
-
});
|
|
119
|
-
let stderr = '';
|
|
120
|
-
(_a = proc.stderr) === null || _a === void 0 ? void 0 : _a.setEncoding('utf8').on('data', chunk => { stderr += chunk; });
|
|
121
|
-
const { pid } = proc;
|
|
122
|
-
const logEntryStream = stream_1.Readable.from(this.createLogEntryIterator(proc.stdout, pid));
|
|
123
|
-
const { socket, port } = await filterLogStreamForSocketAndPort(logEntryStream);
|
|
124
|
-
if (!socket && port === -1) {
|
|
125
|
-
proc.kill();
|
|
126
|
-
this.bus.emit('mongosh:mongocryptd-error', { cause: 'nostdout', stderr });
|
|
127
|
-
continue;
|
|
128
|
-
}
|
|
129
|
-
logEntryStream.resume();
|
|
130
|
-
uri = !socket ? `mongodb://localhost:${port}` : `mongodb://${encodeURIComponent(socket)}`;
|
|
131
|
-
break;
|
|
132
|
-
}
|
|
133
|
-
if (!proc || !uri) {
|
|
134
|
-
throw lastError !== null && lastError !== void 0 ? lastError : new errors_1.MongoshInternalError('Could not successfully spawn mongocryptd');
|
|
135
|
-
}
|
|
136
|
-
const interval = setInterval(async () => {
|
|
137
|
-
let sp;
|
|
138
|
-
try {
|
|
139
|
-
sp = await service_provider_server_1.CliServiceProvider.connect(uri, {
|
|
140
|
-
serverSelectionTimeoutMS: this.idleShutdownTimeoutSecs * 1000
|
|
141
|
-
}, {}, this.bus);
|
|
142
|
-
await sp.runCommandWithCheck('admin', { isMaster: 1 });
|
|
143
|
-
}
|
|
144
|
-
catch (error) {
|
|
145
|
-
this.bus.emit('mongosh:mongocryptd-error', { cause: 'ping', error });
|
|
146
|
-
}
|
|
147
|
-
finally {
|
|
148
|
-
if (sp !== undefined) {
|
|
149
|
-
await sp.close(true);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}, this.idleShutdownTimeoutSecs * 1000 / 2);
|
|
153
|
-
interval.unref();
|
|
154
|
-
proc.unref();
|
|
155
|
-
return { uri, proc, interval };
|
|
156
|
-
}
|
|
157
|
-
async _cleanupOldMongocryptdDirectories() {
|
|
158
|
-
try {
|
|
159
|
-
const toBeRemoved = [];
|
|
160
|
-
for await (const dirent of await fs_1.promises.opendir(path_1.default.resolve(this.path, '..'))) {
|
|
161
|
-
if (dirent.name.startsWith('mongocryptd-') && dirent.isDirectory()) {
|
|
162
|
-
let size = 0;
|
|
163
|
-
try {
|
|
164
|
-
size = (await fs_1.promises.stat(path_1.default.join(dirent.name, 'mongocryptd.pid'))).size;
|
|
165
|
-
}
|
|
166
|
-
catch (err) {
|
|
167
|
-
if ((err === null || err === void 0 ? void 0 : err.code) !== 'ENOENT') {
|
|
168
|
-
throw err;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
if (size === 0) {
|
|
172
|
-
toBeRemoved.push(path_1.default.join(this.path, '..', dirent.name));
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
for (const dir of toBeRemoved) {
|
|
177
|
-
if (path_1.default.resolve(dir) !== path_1.default.resolve(this.path)) {
|
|
178
|
-
await fs_1.promises.rmdir(dir, { recursive: true });
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
catch (error) {
|
|
183
|
-
this.bus.emit('mongosh:mongocryptd-error', { cause: 'cleanup', error });
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
exports.MongocryptdManager = MongocryptdManager;
|
|
188
|
-
function getSocketFromLogEntry(logEntry) {
|
|
189
|
-
let match;
|
|
190
|
-
if (logEntry.id === 23015) {
|
|
191
|
-
if (!(0, net_1.isIP)(logEntry.attr.address)) {
|
|
192
|
-
return logEntry.attr.address;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
if (logEntry.id === undefined && (match = logEntry.message.match(/^Listening on (?<addr>.+)$/i))) {
|
|
196
|
-
const { addr } = match.groups;
|
|
197
|
-
if (!(0, net_1.isIP)(addr)) {
|
|
198
|
-
return addr;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
return '';
|
|
202
|
-
}
|
|
203
|
-
function getPortFromLogEntry(logEntry) {
|
|
204
|
-
var _a, _b;
|
|
205
|
-
let match;
|
|
206
|
-
if (logEntry.id === 23016) {
|
|
207
|
-
return logEntry.attr.port;
|
|
208
|
-
}
|
|
209
|
-
if (logEntry.id === undefined && (match = logEntry.message.match(/^waiting for connections on port (?<port>\d+)$/i))) {
|
|
210
|
-
return +((_b = (_a = match.groups) === null || _a === void 0 ? void 0 : _a.port) !== null && _b !== void 0 ? _b : '0');
|
|
211
|
-
}
|
|
212
|
-
return -1;
|
|
213
|
-
}
|
|
214
|
-
async function filterLogStreamForSocketAndPort(input) {
|
|
215
|
-
let port = -1;
|
|
216
|
-
let socket = '';
|
|
217
|
-
const inputDuplicate = input.pipe(new stream_1.PassThrough({ objectMode: true }));
|
|
218
|
-
for await (const logEntry of inputDuplicate) {
|
|
219
|
-
if (logEntry.component !== 'NETWORK' || logEntry.context !== 'listener') {
|
|
220
|
-
continue;
|
|
221
|
-
}
|
|
222
|
-
socket || (socket = getSocketFromLogEntry(logEntry));
|
|
223
|
-
port = getPortFromLogEntry(logEntry);
|
|
224
|
-
if (port !== -1) {
|
|
225
|
-
break;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
return { socket, port };
|
|
229
|
-
}
|
|
230
|
-
//# sourceMappingURL=mongocryptd-manager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mongocryptd-manager.js","sourceRoot":"","sources":["../src/mongocryptd-manager.ts"],"names":[],"mappings":";;;;;;AAAA,iDAAoD;AACpD,2BAA8D;AAC9D,6BAA2B;AAC3B,gDAAwB;AACxB,wDAAgC;AAChC,mCAA+C;AAC/C,4CAAuD;AACvD,8EAAsE;AAEtE,2CAAyD;AAOlD,KAAK,UAAU,mBAAmB;IACvC,MAAM,MAAM,GAAG,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC9C,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,IAAI,KAAK,EAAE,MAAM,oBAAoB,IAAI;QAEvC,cAAI,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,qBAAqB,CAAC;QAE5D,cAAI,CAAC,OAAO,CAAC,MAAM,EAAE,qBAAqB,CAAC;QAC3C,cAAI,CAAC,OAAO,CAAC,MAAM,EAAE,yBAAyB,CAAC;KAChD,EAAE;QACD,IAAI;YACF,MAAM,aAAE,CAAC,MAAM,CAAC,oBAAoB,EAAE,cAAW,CAAC,IAAI,CAAC,CAAC;YACxD,MAAM,CAAC,IAAI,CAAC,CAAE,oBAAoB,CAAE,CAAC,CAAC;SACvC;QAAC,WAAM,GAAsB;KAC/B;IACD,OAAO,CAAC,GAAG,MAAM,EAAE,CAAC,aAAa,C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