From 3dcb3062f5e2713345164156702b8753628782c9 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 6 Dec 2023 16:38:03 +0000 Subject: [PATCH] Adding a check to make sure that encryption does not execute upon directories, as well as adding copy to warn that attachments are not encrypted. --- .../backend-core/src/security/encryption.ts | 6 ++++++ .../src/components/start/ExportAppModal.svelte | 18 +++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/packages/backend-core/src/security/encryption.ts b/packages/backend-core/src/security/encryption.ts index 7a8cfaf04a..45ed566a92 100644 --- a/packages/backend-core/src/security/encryption.ts +++ b/packages/backend-core/src/security/encryption.ts @@ -73,6 +73,9 @@ export async function encryptFile( const outputFileName = `${filename}.enc` const filePath = join(dir, filename) + if (fs.lstatSync(filePath).isDirectory()) { + throw new Error("Unable to encrypt directory") + } const inputFile = fs.createReadStream(filePath) const outputFile = fs.createWriteStream(join(dir, outputFileName)) @@ -110,6 +113,9 @@ export async function decryptFile( outputPath: string, secret: string ) { + if (fs.lstatSync(inputPath).isDirectory()) { + throw new Error("Unable to encrypt directory") + } const { salt, iv } = await getSaltAndIV(inputPath) const inputFile = fs.createReadStream(inputPath, { start: SALT_LENGTH + IV_LENGTH, diff --git a/packages/builder/src/components/start/ExportAppModal.svelte b/packages/builder/src/components/start/ExportAppModal.svelte index c05306c679..9a3a83aa89 100644 --- a/packages/builder/src/components/start/ExportAppModal.svelte +++ b/packages/builder/src/components/start/ExportAppModal.svelte @@ -13,7 +13,7 @@ export let app export let published let includeInternalTablesRows = true - let encypt = true + let encrypt = true let password = null const validation = createValidationStore() @@ -27,9 +27,9 @@ $: stepConfig = { [Step.CONFIG]: { title: published ? "Export published app" : "Export latest app", - confirmText: encypt ? "Continue" : exportButtonText, + confirmText: encrypt ? "Continue" : exportButtonText, onConfirm: () => { - if (!encypt) { + if (!encrypt) { exportApp() } else { currentStep = Step.SET_PASSWORD @@ -109,13 +109,13 @@ text="Export rows from internal tables" bind:value={includeInternalTablesRows} /> - + - {#if !encypt} - - {/if} + {/if} {#if currentStep === Step.SET_PASSWORD}