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

Fix GetGraph bug #54

Merged
merged 1 commit into from
Sep 3, 2024
Merged

Fix GetGraph bug #54

merged 1 commit into from
Sep 3, 2024

Conversation

ronenh
Copy link
Contributor

@ronenh ronenh commented Sep 1, 2024

This fixes a model-inversion bug.

Given:

folder:
  relations:
    parent: folder
    owner: user
  permissions:
    is_owner: owner | parent->is_owner

doc:
  relations:
    parent: folder
    viewer: user | user:* | group#member
  permissions:
    can_view: viewer | parent->owner

The can_view premission isn't inverted correctly. A group#member can have the can_view permission, but only through the first term (viewer) because parent->is_owner can only be a user.
The problem is that the inversion logic attempts to create the inversion of parent->owner on group
(i.e. group#doc^can_view#member: doc_viewer#member | doc_owner#doc_parent) But group has no doc_owner relation because group#member isn't assignable tofolder#owner.

This fixes a model-inversion bug. Given:
```yaml
folder:
  relations:
    owner: user
  permissions:
    is_owner: owner | parent->is_owner

doc:
  relations:
    parent: folder
    viewer: user | user:* | group#member
  permissions:
    can_view: viewer | parent->owner
```

The `can_view` premission isn't inverted correctly.
A `group#member` can have the `can_view` permission, but only
through the first term (`viewer`) because `parent-owner` can only
be a `user`.
The problem is that the inversion logic attempts to create the inversion
of `parent->owner` on `group`
(i.e. `group#doc^can_view#member: doc_viewer#member | doc_owner#doc_parent`)
But `group` has no `doc_owner` relation because `group#member` isn't assignable
to`folder#owner`.
@coveralls
Copy link

Pull Request Test Coverage Report for Build 10658163919

Details

  • 4 of 6 (66.67%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.01%) to 60.819%

Changes Missing Coverage Covered Lines Changed/Added Lines %
graph/objects.go 0 2 0.0%
Totals Coverage Status
Change from base Build 10411785900: 0.01%
Covered Lines: 2808
Relevant Lines: 4617

💛 - Coveralls

@ronenh ronenh merged commit ab0caa9 into main Sep 3, 2024
2 checks passed
@ronenh ronenh deleted the fix-inverse branch September 3, 2024 11:51
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