Skip to content

Conversation

@coderdan
Copy link
Contributor

No description provided.

SELECT * FROM users WHERE attrs @> '{"field": "value"}`;
```
#### `cs_ste_term_v1(val JSONB, epath TEXT)`
Copy link
Contributor

@CDThomas CDThomas Oct 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we make epath here json/jsonb as well? The motivation is that the JSON value would include all the info needed for generating the MAC so that Proxy doesn't need to sort out the table, column, etc based by looking at anything other than the param or literal used for the arg.

I think that we could aim to target text in SM2, but using JSON here similar to how encryption already works for other EQL functions would simplify the Proxy (MLP) logic.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, what's the return type of cs_ste_term_v1 ? ore_64_8_v1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think for now that makes the most sense. I considered adding a variant of cs_ste_term_v1 which also takes a term type so we can handle other types of index terms but for now this should be enough. Does that sounds reasonable?

}
```

`$.firstName` returns `[John]`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the returned value in an array?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to keep the same behaviour as standard JSONPath.
Screenshot 2024-10-15 at 2 10 53 PM

I used https://jsonpath.com/

Comment on lines +240 to +256
```rb
# Serialize a JSONB value bound to the users table column
term = User::ENCRYPTED_JSONB.serialize({field: "value"})
User.where("cs_ste_vec_v1(attrs) @> cs_ste_vec_v1(?)", term)
```

Which will execute on the server as:

```sql
SELECT * FROM users WHERE cs_ste_vec_v1(attrs) @> '53T8dtvW4HhofDp9BJnUkw';
```

And is the EQL equivalent of the following plaintext query.

```sql
SELECT * FROM users WHERE attrs @> '{"field": "value"}`;
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like this framing

@coderdan
Copy link
Contributor Author

Note to self: add the things that the simplified, eJSON path doesn't support.

@coderdan coderdan merged commit b335d40 into main Oct 15, 2024
@coderdan coderdan deleted the jsonb branch October 15, 2024 03:12
tobyhede pushed a commit that referenced this pull request Oct 27, 2025
Work on general purpose JSONB support
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.

4 participants