Skip to content
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

Biscuit v5 #217

Draft
wants to merge 35 commits into
base: main
Choose a base branch
from
Draft

Biscuit v5 #217

wants to merge 35 commits into from

Conversation

Geal
Copy link
Contributor

@Geal Geal commented May 12, 2024

This PR holds the upcoming changes for the v5 format:

  • raise the minimum schema version to 5

set the block version when using 3rd party blocks
divarvel and others added 9 commits May 12, 2024 16:04
* feat: add `reject if`

This acts like the opposite of `check if`: if there is a match, then authorization fails.

Using `reject if` raises the block version to 5

* fix: run rustfmt on datalog/mod.rs

The file contained trailing slashes that made rustfmt crash

---------

Co-authored-by: Geoffroy Couprie <[email protected]>
…220)

Context: biscuit-auth/biscuit#130

This introduces the `HeterogeneousEqual` and `HeterogeneousNotEqual` operations, which will not return an error when their operands have different types, contrary to the existing `Equal` and `NotEqual` operations.

**breaking change**: this does not change the execution of existing tokens, but changes the text representation of the language. `Equal` was `==` and is now `===`, `NotEqual` was `!=` and is now `!==`, `HeterogeneousEqual` is `==` and `HeterogeneousNotEqual` is `!=`

---------

Co-authored-by: Geoffroy Couprie <[email protected]>
Co-authored-by: Clément Delafargue <[email protected]>
Copy link

codspeed-hq bot commented May 26, 2024

CodSpeed Performance Report

Merging #217 will not alter performance

Comparing v5 (e59f41d) with main (bf2f22a)

Summary

✅ 12 untouched benchmarks

Copy link

codecov bot commented May 26, 2024

Codecov Report

Attention: Patch coverage is 83.03030% with 84 lines in your changes missing coverage. Please review.

Project coverage is 68.66%. Comparing base (bf2f22a) to head (0cc0189).

Files with missing lines Patch % Lines
biscuit-auth/src/datalog/expression.rs 77.77% 26 Missing ⚠️
biscuit-auth/src/format/convert.rs 81.65% 20 Missing ⚠️
biscuit-auth/src/datalog/mod.rs 80.70% 11 Missing ⚠️
biscuit-parser/src/builder.rs 47.61% 11 Missing ⚠️
biscuit-auth/src/token/authorizer.rs 30.00% 7 Missing ⚠️
biscuit-auth/src/token/builder.rs 84.44% 7 Missing ⚠️
biscuit-auth/examples/testcases.rs 98.88% 1 Missing ⚠️
biscuit-parser/src/parser.rs 97.56% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #217      +/-   ##
==========================================
+ Coverage   67.27%   68.66%   +1.39%     
==========================================
  Files          25       25              
  Lines        5274     5655     +381     
==========================================
+ Hits         3548     3883     +335     
- Misses       1726     1772      +46     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Geal and others added 16 commits May 26, 2024 22:19
This introduces the closure operations to the Biscuit language, first with the `.all()` and `.any()` operations to add conditions on the elements of a set.

It is now possible to use expressions with the following format:
```
check if [1,2,3].all($p -> $p > 0);
check if [1,2,3].any($p -> $p > 2);
```

Co-authored-by: Geoffroy Couprie <[email protected]>
While the incrementing integer for version numbers is fine for the protobuf encoding, it has been a headache when communicating with other people.

A `major.minor` scheme seems better for understanding, and helps communicate the scope of changes a bit better.

There was a bug in version checks that relied on `BISCUIT_MAX_VERSION` to check the version for specific features. This does not play well with version upgrades.

So this commit fixes both issues:

- use explicit 3.x version number for datalog features
- use explicit version numbers for feature checks, instead of relying on the max version

It also improves a bit on some error messages that were a bit cryptic, by clearly specifying the version in which specific features were implemented.
Datalog parameters are managed lazily: upon building a rule, referenced parameter are collected in a map. Setting them only updates the map, and the actual AST is only updated as needed (such as in Display impls, or when converting to datalog data structures).

Expressions used to be linear, but closures introduced the possibility of recursive expressions, so the code inside closure bodies was ignored both when collecting parameters, and when applying them.

This caused an issue because some parts of the code assume that unbound parameters are handled beforehand, and panic upon encountering them.
…losures

fix: recursively collect and apply parameters in closures
In #231 the v3/4/5 naming was removed, in favor of v3.0/3.1/3.2/3.3.

A few functions were forgotten in this renaming.
feat: add `.type()` unary method
This adds support for the array and map types, supporting more structured datalog terms, that we can generate from JSON data and explore through datalog expressions. The map type allows integers strings and parameters as key. This tries to enforce that all array elements are of the same type, but this is not very strict at the moment, it does not look at lower levels of composite types.

**breaking changes**:
- in the Datalog language, sets will now be delimited
by '{' and '}' instead of '[' and ]'. Arrays are now delimited by '['
and ']'
- parameter names now need to start with a letter

---------

Co-authored-by: Clement Delafargue <[email protected]>
* more explicit test assert

* update run limits
divarvel and others added 9 commits November 4, 2024 14:17
The breaking change in syntax for sets made this sample use arrays instead of sets, raising the minimal version
It is not v5 blocks, it’s v6 blocks, and other v6 samples don’t mention the block version (samples will later be split by minimum datalog version)
…mple

fix heterogeneous testcase and rebuild samples
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.

3 participants