Repository navigation
Conversation
Nothing showed that data written by Stack 1.x (EQL v3) can move to EQL v4 and keep answering the same queries. The two versions come from different producers (cipherstash-client and Stack Encrypt), use different ciphertext formats and derive search terms differently, so the migration has to decrypt and re-encrypt every value. No test did that. The new suite runs the customer-shaped migration in one table, against live ZeroKMS and Postgres with EQL v3 and v4 installed side by side. It writes v3 with protect-ffi (the engine Stack 1.x encrypts through), adds a v4 column beside each v3 one, backfills by decrypting and re-encrypting, then checks that equality, ORE range, ORE and OPE ordering, and match queries return the same rows from both columns. It also checks that every v4 value decrypts to the original plaintext, and that the v4 columns still answer after the v3 columns are dropped and the v4 ones renamed into their place. Three hazards are pinned: a v3 payload cast into a v4 column fails the domain CHECK, relabelling `v` to 4 gives a value Stack Encrypt refuses to open, and a v3 query operand against a v4 column silently matches nothing. No TypeScript SDK writes v4 yet, so the suite re-encrypts through a small Rust stdin/stdout codec, an example in the EQL encryption test crate, that dispatches by EQL type name through eql_bindings::encryption::targets over live ZeroKMS. That needs stack-encrypt's `http` feature in that crate. The suite's `mise run setup` now also builds the v4 bundle from the in-tree EQL source and builds the codec, and the CI workflow caches the EQL Rust build and watches the inputs those two steps read.
|
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Proves that data written by Stack 1.x can be moved to the new EQL v4 format and keeps answering the same database queries. EQL is the format CipherStash uses to store encrypted values in Postgres. v3 is what Stack 1.x writes today; v4 is what the new Stack Encrypt engine writes. The two use different ciphertext and search-term formats, so moving data means decrypting and re-encrypting every value. Until now no test did that.
First of two stacked PRs. The second covers EQL v2 (Protect.js) data, and is stacked on this one.
Changes
New live test:
integration-tests/tests/migrate-v3-to-v4.test.ts(11 tests). It runs the migration a customer would run, in one table, against real ZeroKMS (the key service) and Postgres with EQL v3 and v4 installed together:@cipherstash/stack1.x encrypts through.customers/email, notcustomers/email_v4), so the rename doesn't break them.It also pins three mistakes:
vto 4 on a v3 payload gives a value Stack Encrypt refuses to open;v4 encoder:
packages/eql/tests/encryption/examples/v4_codec.rs. No TypeScript SDK writes v4 yet, so the test sends plaintexts to a small Rust program that reads JSON on stdin and writes JSON on stdout. It encrypts, builds query terms and decrypts througheql_bindings::encryption::targets, the same by-name entry point the Go SDK uses, against live ZeroKMS. To build a cipher from environment credentials, the test crate turns on stack-encrypt'shttpfeature, which adds lines topackages/eql/Cargo.lock. The crate's existing tests still use fake key sources. The TypeScript side istests/v4-codec.ts.Setup and CI
integration-tests/tasks.toml:eql:v4:installbuilds the v4 SQL bundle from the in-tree EQL source and installs it.eql:v4:codecbuilds the encoder. Both are part ofmise run setup..github/workflows/integration-protect-ffi.yml: adds a Rust cache for the EQL workspace and path filters for the inputs those two tasks read.packages/eql/crates/**is deliberately absent:wasm-build-inputs-paths-filter.test.mjsforbids it here, andtest-eql.ymlalready covers it.scripts/__tests__/tests-workflow-gate.test.mjs: records whyv4-codec.tsmay readpackages/eql/target. Only the ungated live workflow runs it.AGENTS.md: the integration suite section now covers v4 and the encoder.No changeset: only test code changed. The integration-tests package is private and the EQL test crate is
publish = false.Verification
Run locally against live ZeroKMS and the suite's Docker Postgres with EQL v2, v3 and v4 installed:
vitest run tests/migrate-v3-to-v4.test.ts tests/postgres-v3.test.ts tests/postgres.test.ts: 25/25 passed, including all 11 new tests.pnpm run test:scripts: 85 files passed.src/lintWiring.test.tsandsrc/integrationSuiteCi.test.ts: passed.cargo test --locked -p eql-encryption-tests: passed.cargo clippy -D warningson the example: clean.cargo fmt --check: clean.mise run eql:v4:installrun twice against the same database: both runs succeed.pnpm run typecheckin integration-tests: clean. Biome: no new findings.The CI run of
integration-protect-ffi.ymlon this PR is the first time the setup runs on a fresh runner.Related
Refs #1436 (the Protect.js → Stack 1.x DynamoDB compatibility suite this extends).
Review notes
v4_codec.rs.