Repository navigation
feat(stack-encrypt): JSON operators Contains, ContainedBy and AtPath #1209
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
Merged
Merged
Changes from all commits
Commits
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
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
10 changes: 10 additions & 0 deletions
10
packages/stack-encrypt/tests/ui/op_at_path_inherits_fidelity.rs
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,10 @@ | ||
| //! An accessor is held to its leaf's requirement: `AtPath<Matches>` needs a | ||
| //! probabilistic term, as `Matches` does, so an exact term cannot answer it. | ||
| use stack_encrypt::op::{self, TermFor}; | ||
| use stack_encrypt::sem::EqualityTerm; | ||
|
|
||
| fn answers<Op: op::Operator, T: TermFor<Op>>() {} | ||
|
|
||
| fn main() { | ||
| answers::<op::AtPath<op::Matches>, EqualityTerm>(); | ||
| } |
21 changes: 21 additions & 0 deletions
21
packages/stack-encrypt/tests/ui/op_at_path_inherits_fidelity.stderr
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,21 @@ | ||
| error[E0277]: `EqualityTerm` cannot answer `AtPath<stack_encrypt::op::Matches>` | ||
| --> tests/ui/op_at_path_inherits_fidelity.rs:9:40 | ||
| | | ||
| 9 | answers::<op::AtPath<op::Matches>, EqualityTerm>(); | ||
| | ^^^^^^^^^^^^ this query term does not meet the operator's requirement | ||
| | | ||
| = help: the trait `Probabilistic` is not implemented for `EqualityTerm` | ||
| = note: a term that answers `op::Matches` must implement `op::Probabilistic` | ||
| help: the trait `Probabilistic` is implemented for `MatchQuery<O>` | ||
| --> src/sem/mod.rs | ||
| | | ||
| | impl<O: MatchConfig> crate::op::Probabilistic for MatchQuery<O> { | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| = note: required for `EqualityTerm` to implement `TermFor<stack_encrypt::op::Matches>` | ||
| = note: 1 redundant requirement hidden | ||
| = note: required for `EqualityTerm` to implement `TermFor<AtPath<stack_encrypt::op::Matches>>` | ||
| note: required by a bound in `answers` | ||
| --> tests/ui/op_at_path_inherits_fidelity.rs:6:33 | ||
| | | ||
| 6 | fn answers<Op: op::Operator, T: TermFor<Op>>() {} | ||
| | ^^^^^^^^^^^ required by this bound in `answers` |
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,11 @@ | ||
| //! `AtPath` applies a leaf operator at a path: containment compares whole | ||
| //! documents, and an accessor already has a path, so neither is an | ||
| //! operator under `AtPath`. | ||
| use stack_encrypt::op; | ||
|
|
||
| fn operator<Op: op::Operator>(_: Op) {} | ||
|
|
||
| fn main() { | ||
| operator(op::AtPath(op::Contains)); | ||
| operator(op::AtPath(op::AtPath(op::Eq))); | ||
| } |
49 changes: 49 additions & 0 deletions
49
packages/stack-encrypt/tests/ui/op_at_path_not_a_leaf.stderr
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,49 @@ | ||
| error[E0277]: `Contains` is not a leaf operator, so it cannot be applied at a path | ||
| --> tests/ui/op_at_path_not_a_leaf.rs:9:25 | ||
| | | ||
| 9 | operator(op::AtPath(op::Contains)); | ||
| | -------- ^^^^^^^^^^^^ `op::AtPath` takes a leaf operator | ||
| | | | ||
| | required by a bound introduced by this call | ||
| | | ||
| = help: the trait `Leaf` is not implemented for `Contains` | ||
| = note: `op::AtPath` applies `op::Eq`, `Lt`, `Lte`, `Gt`, `Gte`, `Between` or `Matches` at a path; `op::Contains` and `op::ContainedBy` compare whole documents, and an accessor does not nest | ||
| = help: the following other types implement trait `Leaf`: | ||
| Between | ||
| Gt | ||
| Gte | ||
| Lt | ||
| Lte | ||
| stack_encrypt::op::Eq | ||
| stack_encrypt::op::Matches<C> | ||
| = note: required for `AtPath<Contains>` to implement `Operator` | ||
| note: required by a bound in `operator` | ||
| --> tests/ui/op_at_path_not_a_leaf.rs:6:17 | ||
| | | ||
| 6 | fn operator<Op: op::Operator>(_: Op) {} | ||
| | ^^^^^^^^^^^^ required by this bound in `operator` | ||
|
|
||
| error[E0277]: `AtPath<stack_encrypt::op::Eq>` is not a leaf operator, so it cannot be applied at a path | ||
| --> tests/ui/op_at_path_not_a_leaf.rs:10:25 | ||
| | | ||
| 10 | operator(op::AtPath(op::AtPath(op::Eq))); | ||
| | -------- ^^^^^^^^^^^^^^^^^^ `op::AtPath` takes a leaf operator | ||
| | | | ||
| | required by a bound introduced by this call | ||
| | | ||
| = help: the trait `Leaf` is not implemented for `AtPath<stack_encrypt::op::Eq>` | ||
| = note: `op::AtPath` applies `op::Eq`, `Lt`, `Lte`, `Gt`, `Gte`, `Between` or `Matches` at a path; `op::Contains` and `op::ContainedBy` compare whole documents, and an accessor does not nest | ||
| = help: the following other types implement trait `Leaf`: | ||
| Between | ||
| Gt | ||
| Gte | ||
| Lt | ||
| Lte | ||
| stack_encrypt::op::Eq | ||
| stack_encrypt::op::Matches<C> | ||
| = note: required for `AtPath<AtPath<stack_encrypt::op::Eq>>` to implement `Operator` | ||
| note: required by a bound in `operator` | ||
| --> tests/ui/op_at_path_not_a_leaf.rs:6:17 | ||
| | | ||
| 6 | fn operator<Op: op::Operator>(_: Op) {} | ||
| | ^^^^^^^^^^^^ required by this bound in `operator` |
6 changes: 3 additions & 3 deletions
6
packages/stack-encrypt/tests/ui/op_between_takes_a_pair.stderr
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 |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| //! The JSON operators are declared and answered by no index: this crate has | ||
| //! no JSON index, so a containment query and a query at a path do not | ||
| //! compile on any plan. | ||
| use stack_encrypt::kms::FakeDataKeySource; | ||
| use stack_encrypt::op; | ||
| use stack_encrypt::{Equality, Plan, StackCipher}; | ||
|
|
||
| async fn query(cipher: &StackCipher<FakeDataKeySource>) { | ||
| let profile_plan = Plan::context("users/profile") | ||
| .with::<String, _>(Equality) | ||
| .build() | ||
| .unwrap(); | ||
| let _ = cipher.query(op::Contains, "{}").on(&profile_plan); | ||
| let _ = cipher | ||
| .query(op::AtPath(op::Eq), &("$.address.city", "Sydney")) | ||
| .on(&profile_plan); | ||
| } | ||
|
|
||
| fn main() {} |
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.
Uh oh!
There was an error while loading. Please reload this page.