Repository navigation
Commit 3eaeeb8
committed
feat(eql-bindings): query EQL v4 types through Stack Encrypt's typed query chain
Rust could store an EQL v4 type but query it only through a data plan:
no v4 type implemented `op::Answers`, so `cipher.query(op::Eq, v).on(&plan)`
did not compile on a plan for `TextEq`, while the Go SDK already had an
`Eq` method per equality type and `Matches` with `Verify` on `TextMatch`
(#1216). This gives Rust the same operators, with the same bytes (#1238).
eql-codegen writes into `v4/answers.rs`, for each producible type with a
query twin: `op::LabelledTarget` (it is sealed under the column a
two-segment label names), the twin's assembly, and one `op::Answers` impl
per operator. The operators come from the type's index
keys, the input the data path's `TargetDescriptor::operators` reads:
`"eq"` answers `Eq`, `"match"` answers `Matches`. It stops on any other
index, or more than one, so making an ordered type producible has to
extend the rule. The same rows give `ANSWERS`, which the `typed_queries`
test holds to `TargetDescriptor::operators()` for every type.
The file sits beside the target table rather than in it: `v4/targets.rs`
is built on Stack Encrypt's `dynamic` layer and needs the `targets`
feature, while a typed query needs neither, so `answers.rs` needs only
`stack-encrypt`.
The index each impl names is `TwinIndex<I, Q>`: Stack Encrypt's own index
`I` (the same spec and derivation), whose query term is written into the
twin `Q` with the column the query's label names, by the encodings the
stored values use. It answers only for the twin's own plaintext
(`QueryTwin::Plaintext`), so no plan can send one type's twin for another
type's value, and its `check_label` refuses a label that names no column
and any extension before any keyset is loaded: an extended query would be
derived under more than the column the twin stores, and match nothing.
Both refusals are a `QueryLabelError` in `Error::Other`, so a caller
matches the variant rather than the message.
`TextMatch` returns `MatchTwin<Q>`, which serializes as the twin and keeps
the query's tokens for `verify` and `target_limit` under `EqlMatch`.
`Hmac256` and `BloomFilter` now declare their indexes, so a type holding
one declares the index a query is checked against, and `EqlMatch`
implements `MatchCase`.
Tests: every typed query is the data path's `query_term` bytes and domain
(the float values the semantic baseline folds included), with the data
path's inputs built as frames of Rust values; `TextMatch`'s
`verify` and `target_limit` agree with the data path's; short text, a
non-column label and an extended query are refused before any keyset is
loaded; and compile-fail doctests for `op::Lt` on `TextEq`, `op::Matches`
on `IntegerEq`, `.via(Equality)` and another type's `TwinIndex` on a
`TextEq` plan, and `verify` on an exact term. The new module's example
runs as a test in the encryption crate.1 parent 2215991 commit 3eaeeb8
15 files changed
Lines changed: 1601 additions & 34 deletions
File tree
- .changeset
- packages/eql
- crates
- eql-bindings
- src
- encryption
- v4
- eql-codegen
- src
- tests
- tests/encryption
- tests
- common
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
12 | 36 | | |
13 | 37 | | |
14 | 38 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
188 | 247 | | |
189 | 248 | | |
190 | 249 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| 87 | + | |
| 88 | + | |
87 | 89 | | |
88 | 90 | | |
89 | 91 | | |
| |||
95 | 97 | | |
96 | 98 | | |
97 | 99 | | |
98 | | - | |
| 100 | + | |
99 | 101 | | |
100 | 102 | | |
101 | 103 | | |
| |||
127 | 129 | | |
128 | 130 | | |
129 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
130 | 146 | | |
131 | 147 | | |
132 | 148 | | |
| |||
235 | 251 | | |
236 | 252 | | |
237 | 253 | | |
238 | | - | |
| 254 | + | |
239 | 255 | | |
240 | 256 | | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
241 | 263 | | |
242 | 264 | | |
243 | 265 | | |
| |||
252 | 274 | | |
253 | 275 | | |
254 | 276 | | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
255 | 282 | | |
256 | 283 | | |
257 | 284 | | |
| |||
314 | 341 | | |
315 | 342 | | |
316 | 343 | | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
| 344 | + | |
331 | 345 | | |
332 | 346 | | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
333 | 365 | | |
334 | 366 | | |
335 | 367 | | |
| |||
350 | 382 | | |
351 | 383 | | |
352 | 384 | | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
353 | 390 | | |
354 | 391 | | |
355 | 392 | | |
| |||
0 commit comments