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

Add grammar for cfn-guard rulesets #65

Merged
merged 18 commits into from Oct 1, 2020
22 changes: 22 additions & 0 deletions GRAMMAR.md
@@ -0,0 +1,22 @@
# Overview
Rulesets can be described by the following BNF:

```
johnttompkins marked this conversation as resolved.
Show resolved Hide resolved
<RULESET> ::= <LINE> | <LINE> <RULESET>
<LINE> ::= <RULE_LINE> | <ASSIGNMENT> | <COMMENT>
<RULE_LINE> ::= <RULE> | <RULE> <BOOL_OPERAND> <RULE_LINE>
<RULE> ::= <BASE_RULE> <OUTPUT_MESSAGE> | <BASE_RULE>
<BASE_RULE> ::= <CHECK_RULE> | <CONDITIONAL_RULE>
<CHECK_RULE> ::= <RESOURCE_TYPE> <PROPERTY_CHECK>
<CHECK_VALUE> ::= <PRIMITIVE> | %<VARIABLE>
<PROPERTY_CHECK> ::= <PROPERTY_PATH> <OPERAND> <CHECK_VALUE>
<CONDITIONAL_RULE> ::= <RESOURCE_TYPE> WHEN <PROPERTY_CHECK> CHECK <PROPERTY_CHECK>
<VARIABLE> ::= define variable
<OPERAND> ::= ==|!=|<|>|<=|>=|IN|NOT_IN
<BOOL_OPERAND> ::= |OR| | |AND|
johnttompkins marked this conversation as resolved.
Show resolved Hide resolved
<RESOURCE_TYPE> ::= Some::Resource::Type
<PROPERTY_PATH> ::= path.to.property
<ASSIGNMENT> ::= let <VARIABLE> = <PRIMITIVE>
<PRIMITIVE> ::== some primitive value
<COMMENT> ::= # Comment
```