Repository navigation
fix(eql-bindings): TextMatch stores the empty filter for text that cuts no token #2054
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
coderdan
wants to merge
3
commits into
next
Choose a base branch
from
fix/text-match-empty-filter
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+303
−213
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| --- | ||
| '@cipherstash/eql': minor | ||
| --- | ||
|
|
||
| **In EQL v4, a match filter follows one rule in every type.** The types are `TextMatch`, `TextSearch` and `TextSearchOre`. Some text cuts no match token: an empty string, one letter, or separators alone. | ||
|
|
||
| - **Stored values.** `eql-bindings` now stores such text in `TextMatch` with the empty filter, `"bf": []`, as it does in the two search types. Before, `TextMatch` refused the value. The three types store one filter type, `v4::terms::BloomFilter`. The type `v4::terms::SearchBloomFilter` is removed. No release has it. | ||
| - **Queries.** `eql_v4.match_term` over an `eql_v4.query_text_match` operand now raises (`invalid_parameter_value`) when the operand's `bf` is missing, JSON `null` or an empty array. The search query domains already raise this way. So `col @@ $1` raises on such an operand, where it could match the stored values with an empty filter. `eql-bindings` never builds such an operand: it refuses a query of text that cuts no token. | ||
|
|
||
| No `@@` query finds a stored empty filter. The empty filter tells anyone who can read the column that the value cuts no token. | ||
|
|
||
| The `eql_v3` functions do not change. Only the unreleased `v4` module and the EQL v4 SQL change. |
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -115,6 +115,45 @@ func TestV4FieldsSealToTheirEQLTypesAndOpenBack(t *testing.T) { | |
| } | ||
| } | ||
|
|
||
| // A TextMatch field stores text that cuts no match token (one letter, an | ||
| // empty string, or separators alone) with the empty filter, as a | ||
| // TextSearch field does: a match filter is built the same way in every | ||
| // type. The value opens to the text that went in. A Matches query of such | ||
| // text is refused (TestV4QueriesMatchTheRustFixture). | ||
| func TestV4TextMatchStoresTextThatCutsNoToken(t *testing.T) { | ||
| c := deterministicEQLClient(t) | ||
| ctx := context.Background() | ||
| cipher := c.DefaultKeyset() | ||
|
|
||
| short := []testusers.Profile{ | ||
| {ID: 1, Name: "A", Email: "[email protected]"}, | ||
| {ID: 2, Name: "", Email: "[email protected]"}, | ||
| {ID: 3, Name: " ", Email: "[email protected]"}, | ||
| } | ||
| encrypted, err := testusers.EncryptProfile(ctx, cipher, short) | ||
| if err != nil { | ||
| t.Fatalf("storing text that cuts no token in a TextMatch: %v", err) | ||
| } | ||
| for i, e := range encrypted { | ||
| keys, terms := keysAndTerms(t, e.Name) | ||
| if keys != "bf,c,i,v" { | ||
| t.Errorf("stored keys for %q %s, want bf,c,i,v", short[i].Name, keys) | ||
| } | ||
| if string(terms["bf"]) != "[]" { | ||
| t.Errorf("stored filter for %q is %s, want []", short[i].Name, terms["bf"]) | ||
| } | ||
| } | ||
| decrypted, err := testusers.DecryptProfile(ctx, cipher, encrypted) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| for i := range short { | ||
| if decrypted[i] != short[i] { | ||
| t.Errorf("row %d: %+v, want %+v", i, decrypted[i], short[i]) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // bloom is the set of filter positions in a TextMatch value or query. | ||
| func bloom(t *testing.T, value []byte) map[int]bool { | ||
| t.Helper() | ||
|
|
||
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit. Line 108 of this file still says the opposite.
Line 108, in the section on the
matchindex, reads: "An EQLTextMatchfield is stricter: see below." This line now says aTextMatchfield stores such text. The matching sentence inlanguages/golang/encrypt/README.mdwas updated. Line 108 here was missed.I checked the file, and the finding is correct. Fix: line 108 says that a
TextMatchfield follows the same rule.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 6845026. Line 108 now says that an EQL
TextMatchfield follows the same rule.