Skip to content

Commit 38f55d2

Browse files
authored
Merge pull request #1204 from cipherstash/test/eql-selector-review-followups
test(eql): review follow-ups to the SteVec selector derivation
2 parents fc591e3 + 039a961 commit 38f55d2

21 files changed

Lines changed: 4283 additions & 2140 deletions

‎AGENTS.md‎

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -570,17 +570,33 @@ monorepo, which is where the silent failures are.
570570
`fixtures::v3_doc_integer::field_op_selector` and
571571
`fixtures::v3_ste_vec::hello_op_selector`, which apply a written rule to the
572572
loaded fixture and fail, listing every candidate, when zero or several
573-
selectors match. `tests/sqlx/tests/selector_literal_guard.rs` fails on a
574-
random-looking standalone 32-hex run anywhere in the crate's source, SQL and
575-
escaped JSON strings included, and runs DB-free in `mise run test:schema` so
576-
fork PRs get it too; a forged selector must be
577-
visibly fake (`"00000000000000000000000000000001"`). The suite passes against
578-
any workspace. That a keyset and path still produce the same selector bytes is
579-
pinned separately, in the encryption test crate
573+
selectors match. The jsonb_entry matrix resolves the selector at runtime and
574+
queries the literal `payload -> '<sel>'::text` customers write.
575+
`tests/sqlx/tests/selector_literal_guard.rs` fails on a random-looking
576+
standalone 32-hex run, in any case, in any `.rs` file under the crate's `src/`
577+
and `tests/`, SQL and escaped JSON inside Rust strings included, and counts a
578+
string escape (`\n`, `\x`), a `0x` prefix or an integer suffix (`0x…u128`)
579+
as a boundary. It does not catch a selector split into pieces, such as a
580+
`[u8; 16]` array of `0x..` bytes; the generated
581+
`fixtures/*.sql` files hold real selectors and are not scanned. It runs
582+
DB-free in `mise run test:schema` so fork PRs get it too; a forged selector
583+
must be visibly fake (`"00000000000000000000000000000001"`). The suite passes
584+
against any workspace. That a keyset and path still produce the same selector
585+
bytes is pinned separately, in the encryption test crate
580586
(`packages/eql/tests/encryption/tests/ste_vec_selectors.rs`, regenerated only
581-
with `EQL_UPDATE_STE_VEC_SELECTORS=1`). It pins the cipherstash-client version
582-
the EQL workspace resolves; protect-ffi resolves its own from its own
583-
lockfile, so the pin covers protect-ffi's only while the two versions agree.
587+
with `EQL_UPDATE_STE_VEC_SELECTORS=1`, exactly `1`). It pins the index config
588+
production really sends for an EQL v3 JSON column, the unrewritten
589+
`prefix: "enabled"` sentinel included (#1203: a fix there changes every stored
590+
v3 JSON selector and is meant to fail the pin). It also records the fake index
591+
key it derives under: a changed key fails first, with a message naming it a
592+
stack-kms test-infrastructure change rather than a stored-data break. It pins
593+
the cipherstash-client and cipherstash-config (the crates that compute the
594+
selectors) the EQL workspace resolves; protect-ffi resolves its own from its
595+
own lockfile, and `scripts/__tests__/cipherstash-client-parity.test.mjs`
596+
(`pnpm run test:scripts`, every PR) fails when the two lockfiles disagree on
597+
the version, source or checksum of either, so a protect-ffi bump has to move the EQL pins with it. Primitive
598+
dependencies such as blake3 are not compared, and already differ at patch
599+
level.
584600
- **`FROZEN_PUBLISHERS` is what stops this repo publishing a package whose
585601
publisher lives elsewhere, and it is a mechanism, not a status.** `scripts/release-gate.mjs` carries a map of every
586602
package that lives here but is published from another repository. For each,

‎packages/eql/Cargo.lock‎

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/eql/tests/encryption/Cargo.toml‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,14 @@ postgres = "0.19"
3232
# depend on lives in cipherstash-client, which protect-ffi encrypts through.
3333
# Its `JsonIndexer` runs offline over a supplied index key. The same exact pin
3434
# tests/sqlx names, so this workspace's lockfile gains no second copy.
35-
# protect-ffi resolves cipherstash-client from its own workspace and lockfile,
36-
# so the pin covers the version named here, not necessarily the one protect-ffi
37-
# ships: a protect-ffi bump is covered once this line moves to match it.
38-
cipherstash-client = "=0.42.0"
35+
# protect-ffi resolves cipherstash-client from its own workspace and lockfile;
36+
# scripts/__tests__/cipherstash-client-parity.test.mjs fails on every PR where
37+
# the two lockfiles disagree on cipherstash-client or cipherstash-config (the
38+
# crates that compute selectors), so a protect-ffi bump must move this line
39+
# (and tests/sqlx's) with it, and the pin then covers the versions of those two
40+
# crates protect-ffi ships. Primitive dependencies such as blake3 are not
41+
# compared.
42+
cipherstash-client = "=0.42.3"
3943
# The tampering test decodes a stored body, changes one byte and re-encodes
4044
# it. The same line eql-bindings uses, so the lockfile gains no second copy.
4145
base64 = "0.22"

‎packages/eql/tests/encryption/tests/ste_vec_selectors.rs‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,13 @@
3131
//! document covers every JSON shape the indexer branches on: numbers (integer
3232
//! and float), a string, a bool, null, a nested object and an array.
3333
//!
34-
//! What it pins is the cipherstash-client version this EQL workspace resolves.
35-
//! protect-ffi, which writes customers' documents, resolves cipherstash-client
36-
//! from its own workspace and lockfile, so a protect-ffi bump is covered only
37-
//! once this workspace moves to the same version.
34+
//! What it pins is the cipherstash-client and cipherstash-config (which parses
35+
//! the index config) this EQL workspace resolves. protect-ffi, which writes
36+
//! customers' documents, resolves both from its own workspace and lockfile.
37+
//! `scripts/__tests__/cipherstash-client-parity.test.mjs` fails on every PR
38+
//! where the two lockfiles disagree on either, so the versions pinned here are
39+
//! the ones protect-ffi ships. Primitive dependencies such as blake3 (the
40+
//! selector MAC) are not compared.
3841
//!
3942
//! Regenerate with `EQL_UPDATE_STE_VEC_SELECTORS=1` (exactly `1`; any other
4043
//! value, `0` included, regenerates nothing), deliberately not the crate's

‎packages/eql/tests/sqlx/Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jsonschema = { version = "0.46.4", default-features = false }
1717
# The published client is the encryption oracle for fixtures and fresh e2e
1818
# queries. Pin it exactly so its SteVec envelope cannot drift independently of
1919
# the strict bindings and SQL contract tested in this repository.
20-
cipherstash-client = { version = "=0.42.0", features = ["tokio"] }
20+
cipherstash-client = { version = "=0.42.3", features = ["tokio"] }
2121
# chrono is already in the tree transitively (cipherstash-client / ore-rs); pin
2222
# it as a direct dependency so the harness can name `chrono::NaiveDate` for the
2323
# `date` scalar (Encode/Decode/Type come from the sqlx `chrono` feature above).

‎packages/eql/tests/sqlx/README.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ from the fixture it loaded.
104104
Each states a rule that singles out one selector and fails, listing every
105105
candidate, when zero or several match (`src/fixtures/ste_vec_selector.rs`).
106106
`tests/selector_literal_guard.rs` fails if a selector-shaped hex literal is
107-
added to `src/` or `tests/`. A forged selector in a literal-payload test must
107+
added to a `.rs` file under `src/` or `tests/`, including SQL and escaped JSON
108+
inside Rust strings. The generated `fixtures/*.sql` files hold real selectors
109+
and are not scanned. A forged selector in a literal-payload test must
108110
be visibly fake (for example `"00000000000000000000000000000001"`).
109111

110112
## Writing Tests

0 commit comments

Comments
 (0)