Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(infra): clear legacy S3 keys on local storage
Yudhi Armyndharis8c0a4f912bd5
diff --git a/src/modules/infra/config-sections.spec.ts b/src/modules/infra/config-sections.spec.tsindex c7631f6a6..993c8cdfa 100644--- a/src/modules/infra/config-sections.spec.ts+++ b/src/modules/infra/config-sections.spec.ts@@ -250,3 +250,22 @@ it.each([true, false])('writes explicitly chosen database TLS under an externalDATABASE_SSL_REJECT_UNAUTHORIZED: 'false',});});++const credentialNames = [+ ['S3_ACCESS_KEY_ID', 'S3_SECRET_ACCESS_KEY'],+ ['S3_ACCESS_KEY', 'S3_SECRET_KEY'],+] as const;++it.each(credentialNames)('removes inactive S3 credentials %s and %s when selecting local storage', (access, secret) => {+ const existing = {+ STORAGE_TYPE: 's3',+ S3_ENDPOINT: 'https://s3.old.example',+ [access]: 'StoredKey123456',+ [secret]: 'StoredSecret1234567890',+ };+ const ctx = context();++ applyStorageSection({ type: 'local' }, existing, ctx);++ expect(savedValues(existing, ctx)).toEqual({ STORAGE_TYPE: 'local', MINIO_BUILTIN: 'false' });+});diff --git a/src/modules/infra/config-sections.ts b/src/modules/infra/config-sections.tsindex cb703522e..befc28051 100644--- a/src/modules/infra/config-sections.ts+++ b/src/modules/infra/config-sections.ts@@ -246,7 +246,15 @@ export function applyStorageSection(updates.STORAGE_LOCAL_PATH = storage.localPath || './data/media';}// Switching to local: drop stale S3 keys.- for (const k of ['S3_ENDPOINT', 'S3_ACCESS_KEY_ID', 'S3_SECRET_ACCESS_KEY', 'S3_BUCKET', 'S3_REGION']) {+ for (const k of [+ 'S3_ENDPOINT',+ 'S3_ACCESS_KEY_ID',+ 'S3_SECRET_ACCESS_KEY',+ 'S3_ACCESS_KEY',+ 'S3_SECRET_KEY',+ 'S3_BUCKET',+ 'S3_REGION',+ ]) {staleKeys.add(k);}} else {diff --git a/src/modules/infra/infra-status.controller.spec.ts b/src/modules/infra/infra-status.controller.spec.tsindex 474c0d053..d708bd889 100644--- a/src/modules/infra/infra-status.controller.spec.ts+++ b/src/modules/infra/infra-status.controller.spec.ts@@ -373,6 +373,9 @@ describe('InfraStatusController.getStatus envPinned', () => {saver.applyConfigSections(payload as SaveConfigDto, {}, ctx);[...Object.keys(ctx.updates), ...ctx.staleKeys].forEach(key => written.add(key));}+ // Removing legacy aliases changes the canonical credential fields, which are the ones the form writes.+ written.delete('S3_ACCESS_KEY');+ written.delete('S3_SECRET_KEY');// Every compose forward is pinned beside them, so a reported key no save writes would show up too.recordPinnedEnvKeys(Object.fromEntries([...BLANK_SHADOWED_ENV_KEYS, ...written].map(key => [key, 'x'])));