Skip to content

Bring the rekey command (#112) into master - #114

Merged
travist merged 5 commits into
masterfrom
improve-clone-performance-and-bug-fixes
Oct 28, 2026
Merged

travist merged 5 commits into
masterfrom
improve-clone-performance-and-bug-fixes

Conversation

@travist

@travist travist commented Oct 28, 2026

Copy link
Copy Markdown
Member

#112 was stacked on #111 and still targeted improve-clone-performance-and-bug-fixes when it was merged, so it landed on that branch after #111 had already gone into master. This brings it the rest of the way.

What this adds to master

Everything from #112:

  • The new formio rekey command (commands/rekey.js, src/Rekeyer.js), which re-encrypts project settings and encrypted submission data with a new DB_SECRET.
  • Clone fixes: encrypted fields inside datagrid/editgrid rows are re-encrypted, custom submission collections use the server's naming, and revisions of custom collections are cloned.
  • The crypto helpers moved to src/encryption.js, and the connection helpers to src/db.js.
  • The review fixes from 083638a: rekey no longer holds idle cursors, revisions left in submissionrevisions are re-keyed, encrypted values an API returns as JSON are re-encrypted, absolute --ca/--cert paths work, idList ignores repeated ids, and the encryption wrappers were removed from Cloner.

Testing

🤖 Generated with Claude Code

travist and others added 5 commits October 24, 2026 14:29
- Re-encrypt encrypted fields within the rows of a datagrid or editgrid.
  The encrypted paths were looked up as flat paths (data.grid.field)
  against array data, so those values silently kept the source secret.
  The form is now walked against the submission data itself.
- Name custom submission collections the way the server does, with
  everything but letters and digits stripped from the project and
  collection names. Projects with a dash in their name had their
  submissions cloned where the server never reads them.
- Clone the revisions of a custom collection from and to its
  <collection>_revisions collection instead of submissionrevisions.
- Warn when the destination still holds submissions in a collection an
  earlier clone misnamed.
- Move the crypto helpers to src/encryption.js and the connection
  helpers to src/db.js. decrypt() no longer logs every failed attempt.
- Remove src/eachComponentAsync.js, which is no longer used.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Re-encrypt the project settings and encrypted submission data of a
database with a new DB_SECRET, for example after a clone was run with
the wrong --dst-db-secret.

    formio rekey <mongo_url> --new-db-secret NEW \
      --old-db-secret OLD1 [--old-db-secret OLD2] [--dry-run]

- Settings are re-encrypted with the new DB_SECRET. Field values are
  re-encrypted with the project's own secret when it has one, otherwise
  with the new DB_SECRET, the same way the server picks the key.
- Each value is first tried with its target secret and left alone when
  it already opens, so the command can be re-run until nothing is left.
  Otherwise every old secret is tried, and the re-encrypted value is
  read back before it is written.
- Covers fields within datagrid and editgrid rows and containers,
  custom submission collections, and submission revisions (unless
  --no-submission-revisions).
- Writes only apply when the stored ciphertext is unchanged since it
  was read, so a value edited mid-run is never overwritten.
- Values no secret can open, and projects whose settings cannot be
  decrypted, are reported and left as they are, and the command exits
  with an error.

The server's own DB_SECRET_OLD rotation is not a substitute: it misses
nested values, skips falsy values and revisions, and runs its field
updates without awaiting them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…y-command

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- rekey kept the projects and forms cursors open while it re-keyed the
  submissions of each form. On a large database the server closes an idle
  cursor, and the rekey stopped part way. It now lists the ids first and
  reads each project and form on its own.
- rekey never re-keyed the revisions of a custom collection that earlier
  clones wrote to the default submissionrevisions collection. It now
  re-keys them where they are and says so.
- Encrypted values an API returns as JSON serialized Buffers were skipped
  with no message when cloning from an API source. They are now read and
  re-encrypted like any other encrypted value.
- An absolute --ca or --cert path was prefixed with the working directory.
- idList (which now ignores repeated ids) and the legacy collection name
  live in src/db.js, shared by Cloner and Rekeyer.
- Removed the encrypt/decrypt/legacyKey wrappers and defaultSaltLength from
  Cloner, which call src/encryption.js directly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add the rekey command; fix clone encryption of nested fields and custom collection names
@travist
travist merged commit dab6b14 into master Oct 28, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant