What is the name of the language used for Cloud Firestore security rules?
Asked Answered
B

3

13

I would like to know the name of the syntax used for the Cloud Firestore security rules as described at https://firebase.google.com/docs/firestore/security/get-started?authuser=0. I would like to find syntax highlighter for that syntax and maybe parsers for it.

Burdensome answered 6/10, 2017 at 7:28 Comment(0)
J
14

Firebase Security Rules is a custom DSL.

Condition expressions are JS like, and should work with one of those. The path matching framework is less common, but we're working on providing the grammar + additional tooling (syntax highlighting, parsing, type checking, evaluators) in the future.

For those interested in the history, the semantics are closely related to XACML, we just wanted to provide better (non-XML) syntax.

Jalousie answered 6/10, 2017 at 15:12 Comment(2)
Is there any updates on this since Oct 6 '17? Official VS code syntax highlighting, grammar definitions, parser?Abisia
I no longer work at Google/Firebase, but I'm pretty sure we had IntelliJ syntax highlighting at some point. VSCode is provided by a third party: github.com/toba/vsfireJalousie
C
9

You can find a syntax highlighting plugin for Visual Studio here: https://github.com/toba/vsfire

I adapted the plugin for Atom: https://github.com/jaysquared/atom-firestore-grammar

Choirmaster answered 29/10, 2017 at 23:32 Comment(6)
Do you have a plugin for Webstorm?Hayseed
Any solution for Vim?Flanigan
@choopage-JekBao FYI there's an open ticket in the Intellij backlog for this: youtrack.jetbrains.com/issue/IDEABKL-7927Extranuclear
@JohnCarter Have been following that issue. Thanks for sharing.Hayseed
@JohnCarter The link leads to a ticket about FireStorage. Do you know if the rules are similar enough with FireStore (which this entry is about)?Wayfaring
@Wayfaring I think that ticket is actually talking about Firestore (there's no such thing as FireStorage, AFAIK), but yeah Cloud Storage security rules use the same or very similar syntax.Extranuclear
W
9

For IntelliJ IDEs, I found the Set File Type Associations immensely useful for adding syntax highlighting to the .rules file.

You don't need to create an IDE plugin. Just check some boxes, mention some keywords. I chose this:

enter image description here

Tab 2: true, false

Tab 3: !==,==,&&,||

Tab 4: !,(,)

The result is a rather pleasant, imho:

enter image description here

What it does not provide is collapsing of rules, scoping of functions (autocomplete), or anything else that needs syntax awareness. But it seems way better than no syntax highlight, at all.

Edit: Unfortunately, in order to provide a tab/spaces policy for .rules files, "you have to develop your own language plugin." (source) It seems there's still need for a proper language plugin. :(

Wayfaring answered 25/3, 2020 at 12:28 Comment(1)
@choopage-JekBao You may be interested in this, if still working with WebStorm (note: I tried it on IDEA)Wayfaring

© 2022 - 2024 — McMap. All rights reserved.