Browse Source

Merge pull request #9608 from nocodb/nc-refactor/add-logs

refactor: Add logs for encryption - upgrader and init logic
pull/9612/head
Pranav C 2 months ago committed by GitHub
parent
commit
100225246c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      packages/nocodb/src/Noco.ts
  2. 3
      packages/nocodb/src/helpers/initDataSourceEncryption.ts
  3. 4
      packages/nocodb/src/version-upgrader/upgraders/0225002_ncDatasourceDecrypt.ts

6
packages/nocodb/src/Noco.ts

@ -12,10 +12,10 @@ import type { MetaService } from '~/meta/meta.service';
import type { IEventEmitter } from '~/modules/event-emitter/event-emitter.interface'; import type { IEventEmitter } from '~/modules/event-emitter/event-emitter.interface';
import type { Express } from 'express'; import type { Express } from 'express';
import type http from 'http'; import type http from 'http';
import type Sharp from 'sharp';
import { MetaTable, RootScopes } from '~/utils/globals'; import { MetaTable, RootScopes } from '~/utils/globals';
import { AppModule } from '~/app.module'; import { AppModule } from '~/app.module';
import { isEE, T } from '~/utils'; import { isEE, T } from '~/utils';
import type Sharp from 'sharp';
dotenv.config(); dotenv.config();
@ -106,7 +106,9 @@ export default class Noco {
try { try {
this.sharp = (await import('sharp')).default; this.sharp = (await import('sharp')).default;
} catch { } catch {
console.error('Sharp is not available for your platform, thumbnail generation will be skipped'); console.error(
'Sharp is not available for your platform, thumbnail generation will be skipped',
);
} }
if (process.env.NC_WORKER_CONTAINER === 'true') { if (process.env.NC_WORKER_CONTAINER === 'true') {

3
packages/nocodb/src/helpers/initDataSourceEncryption.ts

@ -56,6 +56,8 @@ export default async function initDataSourceEncryption(_ncMeta = Noco.ncMeta) {
source.id, source.id,
); );
successStatus.push(true); successStatus.push(true);
logger.log(`Encrypted source ${source.alias}`);
} }
const integrations = await ncMeta const integrations = await ncMeta
@ -95,6 +97,7 @@ export default async function initDataSourceEncryption(_ncMeta = Noco.ncMeta) {
integration.id, integration.id,
); );
successStatus.push(true); successStatus.push(true);
logger.log(`Encrypted integration config ${integration.title}`);
} }
// if all failed, throw error // if all failed, throw error

4
packages/nocodb/src/version-upgrader/upgraders/0225002_ncDatasourceDecrypt.ts

@ -29,6 +29,8 @@ const decryptConfig = async (encryptedConfig: string, secret: string) => {
// decrypt datasource details in source table and integration table // decrypt datasource details in source table and integration table
export default async function ({ ncMeta }: NcUpgraderCtx) { export default async function ({ ncMeta }: NcUpgraderCtx) {
logger.log('Starting decryption of sources and integrations');
let encryptionKey = process.env.NC_AUTH_JWT_SECRET; let encryptionKey = process.env.NC_AUTH_JWT_SECRET;
if (!encryptionKey) { if (!encryptionKey) {
@ -75,6 +77,7 @@ export default async function ({ ncMeta }: NcUpgraderCtx) {
config: decrypted, config: decrypted,
}) })
.where('id', source.id); .where('id', source.id);
logger.log(`Decrypted source ${source.id}`);
passed.push(true); passed.push(true);
} catch (e) { } catch (e) {
logger.error(`Failed to decrypt source ${source.id}`); logger.error(`Failed to decrypt source ${source.id}`);
@ -100,6 +103,7 @@ export default async function ({ ncMeta }: NcUpgraderCtx) {
config: decrypted, config: decrypted,
}) })
.where('id', integration.id); .where('id', integration.id);
logger.log(`Decrypted integration ${integration.id}`);
passed.push(true); passed.push(true);
} catch (e) { } catch (e) {
logger.error(`Failed to decrypt integration ${integration.id}`); logger.error(`Failed to decrypt integration ${integration.id}`);

Loading…
Cancel
Save