fix: Fix issue with key formatting introduced in 1.2.0 (#6896)

This commit is contained in:
Jon 2023-08-09 16:23:35 +01:00 committed by GitHub
parent 3d2f4406d7
commit 0e075c9cb5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 3 additions and 18 deletions

View file

@ -3,7 +3,6 @@ import { formatPrivateKey } from '@utils/utilities';
import mysql2 from 'mysql2/promise'; import mysql2 from 'mysql2/promise';
import type { Client, ConnectConfig } from 'ssh2'; import type { Client, ConnectConfig } from 'ssh2';
import { rm } from 'fs/promises';
import type { Mysql2Pool } from '../helpers/interfaces'; import type { Mysql2Pool } from '../helpers/interfaces';
@ -107,12 +106,6 @@ export async function createPool(
dstPort: credentials.port as number, dstPort: credentials.port as number,
}; };
if (sshAuthenticateWith === 'privateKey') {
sshClient.on('end', async () => {
await rm(tunnelConfig.privateKey as string);
});
}
const poolSetup = new Promise<mysql2.Pool>((resolve, reject) => { const poolSetup = new Promise<mysql2.Pool>((resolve, reject) => {
sshClient sshClient
.on('ready', () => { .on('ready', () => {

View file

@ -8,9 +8,6 @@ import type { Server } from 'net';
import { createServer } from 'net'; import { createServer } from 'net';
import pgPromise from 'pg-promise'; import pgPromise from 'pg-promise';
import { rm } from 'fs/promises';
import type { PgpDatabase } from '../helpers/interfaces'; import type { PgpDatabase } from '../helpers/interfaces';
async function createSshConnectConfig(credentials: IDataObject) { async function createSshConnectConfig(credentials: IDataObject) {
@ -143,9 +140,6 @@ export async function configurePostgres(
}); });
sshClient.on('end', async () => { sshClient.on('end', async () => {
if (tunnelConfig.privateKey) {
await rm(tunnelConfig.privateKey as string, { force: true });
}
if (proxy) proxy.close(); if (proxy) proxy.close();
}); });
}).catch((err) => { }).catch((err) => {

View file

@ -236,11 +236,9 @@ export function formatPrivateKey(privateKey: string): string {
const passRegex = /Proc-Type|DEK-Info/; const passRegex = /Proc-Type|DEK-Info/;
if (passRegex.test(part)) { if (passRegex.test(part)) {
part = part.replace(/:\s+/g, ':'); part = part.replace(/:\s+/g, ':');
formattedPrivateKey += part.replace(/\\n/g, '\n'); formattedPrivateKey += part.replace(/\\n/g, '\n').replace(/\s+/g, '\n');
formattedPrivateKey += part.replace(/\s+/g, '\n');
} else { } else {
formattedPrivateKey += part.replace(/\\n/g, '\n'); formattedPrivateKey += part.replace(/\\n/g, '\n').replace(/\s+/g, '\n');
formattedPrivateKey += part.replace(/\s+/g, '\n');
} }
} }
}); });

View file

@ -1,4 +1,4 @@
lockfileVersion: '6.0' lockfileVersion: '6.1'
settings: settings:
autoInstallPeers: true autoInstallPeers: true