Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(release): verify published tags after the staging cleanup

Yudhi Armyndharis73713221fcb6
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 9e81a2d8e..e870e901d 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -804,7 +804,12 @@ jobs:
verify-published:
name: Verify published tags (anonymous)
runs-on: ubuntu-latest
- needs: [docker, promote]
+ # After cleanup-staging, not beside it: GHCR's package-versions API is eventually consistent, so
+ # that job can read a version whose release tags are not listed yet and delete the version the
+ # release just published. This check is the net for exactly that, so it has to run last. It is a
+ # best-effort job, so gate on promote rather than on its result.
+ needs: [docker, promote, cleanup-staging]
+ if: always() && needs.promote.result == 'success'
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4
diff --git a/src/engine/auth-dir-paths.spec.ts b/src/engine/auth-dir-paths.spec.ts
index ee01db541..576d07738 100644
--- a/src/engine/auth-dir-paths.spec.ts
+++ b/src/engine/auth-dir-paths.spec.ts
@@ -82,9 +82,7 @@ describe('engine auth directory paths', () => {
});
it('throws ENOENT for a missing base directory, so a caller can tell it from a failure', () => {
- expect(() => readAuthDirEntries(path.join(tmpRoot, 'absent'))).toThrow(
- expect.objectContaining({ code: 'ENOENT' }),
- );
+ expect(() => readAuthDirEntries(path.join(tmpRoot, 'absent'))).toThrow(/ENOENT/);
});
});
});
diff --git a/src/engine/interfaces/whatsapp-engine.interface.ts b/src/engine/interfaces/whatsapp-engine.interface.ts
index 6230285e3..6cd6b39d5 100644
--- a/src/engine/interfaces/whatsapp-engine.interface.ts
+++ b/src/engine/interfaces/whatsapp-engine.interface.ts
@@ -854,9 +854,10 @@ export interface EngineEventCallbacks {
*
* Unlike the other callbacks, this one is NOT guarded on the engine still being live: a logout
* that captured the engine registers its destructive promise even as a concurrent stop()/delete()
- * evicts that engine, because the rm it ends in targets the session NAME's auth dir and would
- * otherwise race a (re)created session under that same name. The lifecycle tracks the promise
- * (keyed by the immutable captured session NAME) so start()/delete()/executeReconnect can wait
+ * evicts that engine, because the rm it ends in targets this session's auth dir and would
+ * otherwise race a (re)created session under that same name. The directory is keyed by the session
+ * id; the lifecycle tracks the promise under the immutable captured session NAME, which is unique
+ * per live row and so covers that directory, so start()/delete()/executeReconnect can wait
* (bounded, fail-closed) for it to settle before touching that path.
*
* Adapters that never remove credentials on their own (e.g. Baileys until a later task wires its
diff --git a/src/modules/infra/table-importers.spec.ts b/src/modules/infra/table-importers.spec.ts
new file mode 100644
index 000000000..ca759fd49
--- /dev/null
+++ b/src/modules/infra/table-importers.spec.ts
@@ -0,0 +1,29 @@
+import { TABLE_IMPORTERS } from './table-importers';
+
+/**
+ * The sessions importer is the one restore path that writes a value later used to build an on-disk
+ * auth-directory path, and it bypasses CreateSessionDto. Both columns matter: the id keys the
+ * directory, the name is matched against the legacy one. A row carrying a traversal in either must
+ * be skipped with a reason rather than inserted.
+ */
+describe('sessions table importer', () => {
+ const sessions = TABLE_IMPORTERS.find(importer => importer.key === 'sessions');
+ const row = (overrides: Record<string, unknown>): Record<string, unknown> => ({
+ id: '0a941dac-a965-45e7-b318-74ae8be134f0',
+ name: 'my-bot',
+ status: 'created',
+ ...overrides,
+ });
+
+ it('accepts a row whose id and name are both safe path keys', () => {
+ expect(sessions?.skip?.(row({}) as never)).toBeNull();
+ });
+
+ it('skips a row whose id would traverse out of the auth directory', () => {
+ expect(sessions?.skip?.(row({ id: '../../etc' }) as never)).toMatch(/unsafe id/);
+ });
+
+ it('skips a row whose name would traverse out of the auth directory', () => {
+ expect(sessions?.skip?.(row({ name: '../alice' }) as never)).toMatch(/unsafe name/);
+ });
+});
diff --git a/src/modules/infra/table-importers.ts b/src/modules/infra/table-importers.ts
index cbbea189c..45f0c6bab 100644
--- a/src/modules/infra/table-importers.ts
+++ b/src/modules/infra/table-importers.ts
@@ -65,11 +65,15 @@ export const TABLE_IMPORTERS: AnyTableImporter[] = [
sql: `INSERT INTO sessions (id, name, status, phone, "pushName", config, "proxyUrl", "proxyType", "connectedAt", "lastActiveAt", "createdAt", "updatedAt")
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)`,
id: (session: SessionRow) => session.id,
- // A session name is still weighed against the on-disk auth directories (the boot migration and
- // the legacy purge on delete), so an unvalidated imported name (this path bypasses
- // CreateSessionDto) could traverse the filesystem. Skip + warn instead of throwing, so one bad
- // row doesn't 500 the whole restore.
+ // Both columns reach an auth-directory path: the id keys the directory itself, and the name is
+ // still weighed against it (the boot migration and the legacy purge on delete). An unvalidated
+ // imported value (this path bypasses CreateSessionDto) could traverse the filesystem, and an
+ // unsafe id would only surface later as a refused start. Skip + warn instead of throwing, so one
+ // bad row doesn't 500 the whole restore.
skip: (session: SessionRow) => {
+ if (!isSafeSessionName(session.id)) {
+ return `Skipped session ${JSON.stringify(session.id)}: unsafe id`;
+ }
if (isSafeSessionName(session.name)) return null;
return `Skipped session ${session.id}: unsafe name ${JSON.stringify(session.name)}`;
},