Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
test(storage): pin the import cap defaults the migration guide states
Yudhi Armyndharisadd4d49b9d33
diff --git a/src/common/storage/storage-transfer.spec.ts b/src/common/storage/storage-transfer.spec.tsindex 7a8ff90f1..edbbee057 100644--- a/src/common/storage/storage-transfer.spec.ts+++ b/src/common/storage/storage-transfer.spec.ts@@ -44,7 +44,14 @@ jest.mock('archiver', () => {return { TarArchive };});-import { createExportStream, ExportFileSource, importFromStream } from './storage-transfer';+import {+ createExportStream,+ DEFAULT_IMPORT_MAX_BYTES,+ DEFAULT_IMPORT_MAX_ENTRIES,+ DEFAULT_IMPORT_MAX_TOTAL_BYTES,+ ExportFileSource,+ importFromStream,+} from './storage-transfer';const FILE_BYTES = 256 * 1024;const files = Array.from({ length: 12 }, (_, i) => `media/file-${String.fromCharCode(97 + i)}.bin`);@@ -364,3 +371,13 @@ describe('createExportStream and the per-entry import cap', () => {expect(warn).toHaveBeenCalledWith(expect.stringContaining(`(${FILE_BYTES} bytes)`));});});++// docs/14, .env.example and the upgrade notes state these figures, and an operator sizes an import+// against them: a drifted default changes what an import is allowed to extract without a word.+describe('storage import caps', () => {+ it('ship at the documented defaults', () => {+ expect(DEFAULT_IMPORT_MAX_BYTES).toBe(209_715_200);+ expect(DEFAULT_IMPORT_MAX_ENTRIES).toBe(100_000);+ expect(DEFAULT_IMPORT_MAX_TOTAL_BYTES).toBe(10_737_418_240);+ });+});diff --git a/src/common/storage/storage-transfer.ts b/src/common/storage/storage-transfer.tsindex b0e5ead61..60439dba4 100644--- a/src/common/storage/storage-transfer.ts+++ b/src/common/storage/storage-transfer.ts@@ -6,11 +6,11 @@ import { Readable, PassThrough, Transform, pipeline } from 'stream';import { LoggerService } from '../services/logger.service';/** Per-entry buffer cap for an import (200 MiB — 4× the inbound media cap). Bounds a decompression bomb. */-const DEFAULT_IMPORT_MAX_BYTES = 200 * 1024 * 1024;+export const DEFAULT_IMPORT_MAX_BYTES = 200 * 1024 * 1024;/** Max number of entries an import archive may contain. Bounds an entry-count DoS. */-const DEFAULT_IMPORT_MAX_ENTRIES = 100_000;+export const DEFAULT_IMPORT_MAX_ENTRIES = 100_000;/** Cap on the bytes one import extracts in total (10 GiB). The two caps above still allow terabytes. */-const DEFAULT_IMPORT_MAX_TOTAL_BYTES = 10 * 1024 * 1024 * 1024;+export const DEFAULT_IMPORT_MAX_TOTAL_BYTES = 10 * 1024 * 1024 * 1024;/*** True when a storage read failed because the object is simply not there.