bijoutrouvaille / fireward

A concise and readable language for Firestore security rules, similar to Firebase Bolt.
MIT License
238 stars 4 forks source link

Syntax errors #11

Closed JakeHedman closed 4 years ago

JakeHedman commented 4 years ago

The following examples all work in the firestore emulator but crashes fireward:

function test (a,b) {
  return true
}

match /test/test {
  allow read: if test(true, 'asdf');
}
match /test/test {
  allow read: if data().keys().hasAll(['a', 'b', 'c']);
}
function b () {
  return "adsf"
}
match /test/{a} {
  allow read: if exists(/test/$(a)/$(b())/$(b(a)))
}
match /test/{a} {
  allow read
}
JakeHedman commented 4 years ago

Found most of these in my own security rules, but also tested a bunch of public security rules from github and most of them fail due to some of the bugs mentioned, or because of functions starting with "is".

Maybe the is-problem should be looked at to make the transition to fireward easier. Having to remove the boilerplate also seems like an unnecessary extra step.

https://github.com/search?utf8=%E2%9C%93&q=+language%3A%22Cloud+Firestore+Security+Rules%22+service+cloud.firestore+size%3A%3E5000&type=Code

bijoutrouvaille commented 4 years ago

Thanks Jake. These are serious issues and probably came from the switch to the new expression parser. Unfortunately I won’t have much internet until Monday, and won’t be able to fix until then. If your work needs it now, I can suggest interim workarounds. Lmk

JakeHedman commented 4 years ago

@bijoutrouvaille: No sweat! I can work around it for now. :) And thanks for the quick response, love the project!

bijoutrouvaille commented 4 years ago

@JakeHedman what do you mean by the "is-problem" ? I don't understand what that github search is about.

bijoutrouvaille commented 4 years ago

Never mind, I missed part of the comment. I think the is-problem was fixed with one of the recent versions. Currently the generated function names look like this is____User (with 4 underscores).

bijoutrouvaille commented 4 years ago

Issues should be fixed in v 1.1.1 available on NPM and in releases.

JakeHedman commented 4 years ago

@bijoutrouvaille Thanks! It all works now (including is-functions). I found some other problems but I'll create a new issue for those :)

bijoutrouvaille commented 4 years ago

@JakeHedman what do you mean by "having to remove the boilerplate" ? Can you please elaborate on what the boilerplate is, who needs to remove it and why?