Giter VIP home page Giter VIP logo

Comments (4)

ymc9 avatar ymc9 commented on August 25, 2024 3

This seems like a prisma issue then. What are your thoughts on zenstack optimising queries? Is it out of scope?

{"where":{"OR":[{"OR":[{"gym":{"members":{"some":{"AND":[{"OR":[]},{"OR":[{"role":{"equals":"ADMIN"}},{"role":{"equals":"TRAINER"}}]}]}}}}]}]}}
{"where":{"OR":[{"OR":[{"gym":{"members":{"some":{"AND":[false,{"OR":[{"role":{"equals":"ADMIN"}},{"role":{"equals":"TRAINER"}}]}]}}}}]}]}}
{"where":{"OR":[{"OR":[{"gym":{"members":{"some":false}}}]}]}}
{"where":{"OR":[{"OR":[false]}]}}
{"where":false}
return [] or throw;

Yes, I agree reduction is the way to go. And it's more than an optimization, but rather for correctness ... Will add it soon.

from zenstack.

sidharthv96 avatar sidharthv96 commented on August 25, 2024

Although the reference doc mentions a check to require login, it's not obvious how big of an issue not having it is.

    // require login
    @@deny('all', auth() == null)

From my mental model, this policy is used to check the role of the current user. So that check should never pass if the user is undefined, as user == auth() will never match because user is not an optional field.

  // space admin can update and delete
  @@allow('update,delete', members?[user == auth() && role == 'ADMIN'])

But the policy seems to behave in a fail-open mode, which is not what we expect from a security perspective.

For now, the fix is to add @@deny('all', auth() == null) to the Base model. But this is a pretty big foot gun for teams who might not know about this.

from zenstack.

ymc9 avatar ymc9 commented on August 25, 2024

Thanks for reporting and commenting @Adhil523 @sidharthv96 .

I still need to confirm, but I tend to believe this is related to this Prisma issue I reported quite a while ago:

prisma/prisma#21856

The background is that ZenStack internally uses an empty OR (OR: []) to represent a false condition, and Prisma doesn't behave consistently in different combinations.

from zenstack.

sidharthv96 avatar sidharthv96 commented on August 25, 2024

This seems like a prisma issue then. What are your thoughts on zenstack optimising queries? Is it out of scope?

{"where":{"OR":[{"OR":[{"gym":{"members":{"some":{"AND":[{"OR":[]},{"OR":[{"role":{"equals":"ADMIN"}},{"role":{"equals":"TRAINER"}}]}]}}}}]}]}}
{"where":{"OR":[{"OR":[{"gym":{"members":{"some":{"AND":[false,{"OR":[{"role":{"equals":"ADMIN"}},{"role":{"equals":"TRAINER"}}]}]}}}}]}]}}
{"where":{"OR":[{"OR":[{"gym":{"members":{"some":false}}}]}]}}
{"where":{"OR":[{"OR":[false]}]}}
{"where":false}
return [] or throw;

from zenstack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.