Skip to content

Commit f45d83f

Browse files
committed
fix: tighten export route validation and apply default export limits
Use exportIdSchema for the UI export status route instead of a loose string validator, matching the delete and download routes. Apply the defined DEFAULT_EXPORT_MAX_MESSAGES (500k) and DEFAULT_EXPORT_MAX_SIZE (10GB) constants as actual fallback defaults instead of allowing unlimited exports when settings are unconfigured.
1 parent eb14c69 commit f45d83f

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

lib/routes-ui.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ function applyRoutes(server, call) {
944944
failAction,
945945
params: Joi.object({
946946
account: Joi.string().max(256).required(),
947-
exportId: Joi.string().max(256).required()
947+
exportId: exportIdSchema
948948
})
949949
}
950950
}

workers/export.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@ const fs = require('fs');
99
const zlib = require('zlib');
1010
const { pipeline } = require('stream');
1111

12-
const { REDIS_PREFIX, EXPORT_COMPLETED_NOTIFY, EXPORT_FAILED_NOTIFY, DEFAULT_EXPORT_MAX_MESSAGE_SIZE } = require('../lib/consts');
12+
const {
13+
REDIS_PREFIX,
14+
EXPORT_COMPLETED_NOTIFY,
15+
EXPORT_FAILED_NOTIFY,
16+
DEFAULT_EXPORT_MAX_MESSAGE_SIZE,
17+
DEFAULT_EXPORT_MAX_MESSAGES,
18+
DEFAULT_EXPORT_MAX_SIZE
19+
} = require('../lib/consts');
1320
const { getDuration, readEnvValue, threadStats } = require('../lib/tools');
1421
const { webhooks: Webhooks } = require('../lib/webhooks');
1522
const settings = require('../lib/settings');
@@ -181,7 +188,7 @@ async function indexMessages(job, exportData) {
181188

182189
await Export.update(account, exportId, { foldersTotal: foldersToProcess.length });
183190

184-
const maxMessages = Number(await settings.get('exportMaxMessages')) || 0;
191+
const maxMessages = Number(await settings.get('exportMaxMessages')) || DEFAULT_EXPORT_MAX_MESSAGES;
185192

186193
logger.info({ msg: 'Starting export indexing', account, exportId, foldersToProcess: foldersToProcess.length, maxMessages: maxMessages || 'unlimited' });
187194

@@ -337,7 +344,7 @@ async function exportMessages(job, exportData) {
337344
const textType = exportData.textType || '*';
338345
const maxBytes = Number(exportData.maxBytes) || 5 * 1024 * 1024;
339346
const maxMessageSize = (await settings.get('exportMaxMessageSize')) || DEFAULT_EXPORT_MAX_MESSAGE_SIZE;
340-
const maxExportSize = Number(await settings.get('exportMaxSize')) || 0;
347+
const maxExportSize = Number(await settings.get('exportMaxSize')) || DEFAULT_EXPORT_MAX_SIZE;
341348
const isEncrypted = exportData.isEncrypted === '1';
342349

343350
const accountObject = new Account({

0 commit comments

Comments
 (0)