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 3 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 { Express } from 'express';
import type http from 'http';
import type Sharp from 'sharp';
import { MetaTable, RootScopes } from '~/utils/globals';
import { AppModule } from '~/app.module';
import { isEE, T } from '~/utils';
import type Sharp from 'sharp';
dotenv.config();
@ -106,7 +106,9 @@ export default class Noco {
try {
this.sharp = (await import('sharp')).default;
} 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') {

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

@ -56,6 +56,8 @@ export default async function initDataSourceEncryption(_ncMeta = Noco.ncMeta) {
source.id,
);
successStatus.push(true);
logger.log(`Encrypted source ${source.alias}`);
}
const integrations = await ncMeta
@ -95,6 +97,7 @@ export default async function initDataSourceEncryption(_ncMeta = Noco.ncMeta) {
integration.id,
);
successStatus.push(true);
logger.log(`Encrypted integration config ${integration.title}`);
}
// 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
export default async function ({ ncMeta }: NcUpgraderCtx) {
logger.log('Starting decryption of sources and integrations');
let encryptionKey = process.env.NC_AUTH_JWT_SECRET;
if (!encryptionKey) {
@ -75,6 +77,7 @@ export default async function ({ ncMeta }: NcUpgraderCtx) {
config: decrypted,
})
.where('id', source.id);
logger.log(`Decrypted source ${source.id}`);
passed.push(true);
} catch (e) {
logger.error(`Failed to decrypt source ${source.id}`);
@ -100,6 +103,7 @@ export default async function ({ ncMeta }: NcUpgraderCtx) {
config: decrypted,
})
.where('id', integration.id);
logger.log(`Decrypted integration ${integration.id}`);
passed.push(true);
} catch (e) {
logger.error(`Failed to decrypt integration ${integration.id}`);

Loading…
Cancel
Save