6675 Commits

Author SHA1 Message Date
Torin Sandall 5bfb8a567e Merge pull request #53 from tsandall/master
Update download links to v0.1.0-rc3
2016-06-28 14:05:23 -07:00
Torin Sandall 27936ffe7d Update download links to v0.1.0-rc3 2016-06-28 13:57:04 -07:00
Torin Sandall 9951dc4a83 Update REPL example with nested references 2016-06-27 12:48:49 -07:00
Torin Sandall 39008f708f Support nested references
Previously, nested references were not allowed. This was particularly annoying
when rules were used to define constant values because it required an
intermediate variable to store the constant value in the current scope (which
could then be used in the reference).

Now, nested references are allowed and the compiler and evaluation engine have
been updated to support them. Specifically, the evaluation engine will
recursively evaluate nested references before the outer most reference is
evaluated. The evaluation adds a binding for the nested reference to the
context so that when the containing term or expression is plugged, the nested
references are replaced with the referred value.

The compiler has been updated to include body safety, reordering, and
recursiong tests involving nested references.
2016-06-27 12:48:49 -07:00
Torin Sandall 7dbf385221 Merge pull request #51 from tsandall/repl-term-eval-match-modules
REPL Improvements
v0.1.0-rc3
2016-06-23 14:56:54 -07:00
Torin Sandall 2e9b1de8a1 Update repl.md with latest REPL behaviour 2016-06-23 12:16:19 -07:00
Torin Sandall 88f6232f13 Update lang.md with latest REPL behaviour 2016-06-23 12:16:19 -07:00
Torin Sandall 3145751c05 Add unset command to REPL
The unset command can be used to undefine rules identified by a variable in
the currently active module. This allows users to workaround the additive
nature of rule definitions.
2016-06-23 12:16:19 -07:00
Torin Sandall e3d3a15c03 Fix parsing when reading modules from files
When comprehensions were added, a post processing step was introduced to
mangle wildcards. There were two separate code paths for loading modules and
one of them was missed. Now there is only one!
2016-06-22 16:51:33 -07:00
Torin Sandall 0e29f3a873 Show term values when possible
Previously, the REPL treated all bodies as queries: the query was evaluated
and for each instance where the query was true, the variable bindings were
displayed. If there were no variables in the body, "true" was printed. If
there were no instances where the query was true, "false" was printed.

Now, the REPL treats single term expressions as a special case under the
assumption that the user wants to see the value of the term. In cases where
the term can only evaluate to a single value (e.g., it's ground), the value of
the term is serialized to JSON and printed. This is useful for initially
learning the language and eventually experimenting with references, e.g.:

> data.servers[0].name
"web"
>

In cases where the term can evaluate to multiple values (i.e., it's
non-ground), the REPL displays one row of output for each instance where the
query is true. Each row contains the bindings of non-wildcard variables as
well as a column for the value of the term itself. This is useful for quickly
evaluating references without defining an intermediate variable, e.g.:

> data.servers[x].name
0,"web"
1,"app"
...
>
2016-06-22 16:51:33 -07:00
Torin Sandall eaa61fe93a Convert <var> = <ground-term> bodies to rules 2016-06-22 09:12:02 -07:00
Torin Sandall a47ddbaa56 Print help message on startup 2016-06-21 18:19:32 -07:00
Torin Sandall 83cae9dc36 Merge pull request #49 from tsandall/master
Improve global variable support in REST API
2016-06-21 17:54:55 -07:00
Torin Sandall 9ecf7c194b Merge pull request #50 from tsandall/dev
Log server error and exit with non-zero status
2016-06-21 17:19:41 -07:00
Torin Sandall 8170e9f607 Log server error and exit with non-zero status
Previously there was no error message and the exit code was zero; this was
quite confusing.
2016-06-21 17:11:38 -07:00
Torin Sandall 7a753a958b Improve global variable support in REST API
Previously, callers were not able to query virtual docs defined by rules that
were written in terms of query inputs that in turn were defined by
references. E.g., a rule dependant on "import request" would be fine, however,
a rule dependant on "import com.example.request" would not.

Callers can now provide input values for imports defined by references. The
REST API constructs the appropriate binding for the variable in the head of
the reference. The binding value is the merged version of all the inputs that
share the same root. Conflicting values are rejected with an error (400)
response.

These changes allow policy authors to namespace their inputs in the same way
they can namespace their base and virtual docs.
2016-06-21 16:38:18 -07:00
Torin Sandall 0274bd7154 Merge pull request #48 from tsandall/master
Add query support for multiple complete docs
2016-06-21 13:08:15 -07:00
Torin Sandall 2f76a155bd Add query support for multiple complete docs
Multiple rules may share the same name while defining complete docs as
long as the docs generated by the rules at query time do not conflict. A
conflict is simply multiple values for the same document. The same applies for
object document keys.
2016-06-21 11:15:29 -07:00
Torin Sandall 386bede297 Merge pull request #47 from tsandall/comprehensions
Comprehensions
2016-06-21 09:26:36 -07:00
Torin Sandall 34b1c8628b Evaluate single, non-boolean term expressions
Previously evaluation would stop with an error if the term was not a boolean.
Now, we continue if the term is defined and not false.
2016-06-21 09:11:28 -07:00
Torin Sandall 1f94f39231 Add other simple arithmetic built-ins 2016-06-21 09:11:27 -07:00
Torin Sandall fa97fdd10a Add comprehensions to language reference 2016-06-21 09:11:27 -07:00
Torin Sandall a593a8a581 Add built-ins for basic aggregation support 2016-06-21 09:09:36 -07:00
Torin Sandall 77653b10c3 Add support for comprehensions in topdown 2016-06-21 09:09:36 -07:00
Torin Sandall 1e628e33df Resolve references within array comprehensions 2016-06-21 09:09:36 -07:00
Torin Sandall 0decd227ab Add safety check on closures/array comprehensions
This change set does away with the old way of determining which variables are
outputs. Equality is now handled with special care. Outputs that would make a
variable safe by depending on another unsafe variable are no longer included.
As a result, the occurs check in the topdown implementation is no longer
needed. This change was introduced to handle odd cases involving
comprehensions, e.g., x = y, x = [ y | y = 1 ]. In this case, without exluding
unsafe vars, the query would evaluate with x/[1]. This would violate the
semantics, because in the comprehension y/1.

Also, fix bug in reordering whereby potentially unsafe expressions were added
to the reordered body multiple times. This occurred because the expression
would be added once when the preceeding expression made it safe and then again
once the outer loop got it. With the fix, we reprocess the body each time an
expression is added to the reordered body.
2016-06-21 09:09:35 -07:00
Torin Sandall fe37cc03a8 Improve coverage of ground-ness checks 2016-06-17 16:09:29 -07:00
Torin Sandall d25f2a4c30 Add array comprehension parsing
Also, move wildcard mangling into post processing step in parser extensions.
Wildcards needs to be mangled after Parse() because otherwise the generated
variable names will reset when handling closures.
2016-06-17 16:09:29 -07:00
Torin Sandall 7a096fabb6 Refactor Term unmarshalling
This will make it easier to introduce array comprehensions.
2016-06-17 16:09:29 -07:00
Torin Sandall d198695615 Extend Body and Expr with Hash/IsGround
This will allow us to treat the Body as term which will be needed for
comprehensions.
2016-06-17 16:09:29 -07:00
Torin Sandall d9f22a1241 Merge pull request #46 from tsandall/master
Update Hello World and add REPL example
2016-06-17 16:09:09 -07:00
Torin Sandall 66e7082ab5 Add REPL example to the docs 2016-06-17 16:04:00 -07:00
Torin Sandall 0e1dad4953 Replace Hello World with Docker AuthZ example
Also, make a few tweaks to headers and download steps based on feedback.
2016-06-17 13:56:26 -07:00
Torin Sandall a6dc28ff2e Docs refactoring to prepare for new Hello World 2016-06-08 12:31:23 -07:00
Torin Sandall 49b99bb905 Merge pull request #45 from tsandall/master
Support global vars in REST API and translate topdown.Undefined
v0.1.0-rc2
2016-06-07 15:21:41 -07:00
Torin Sandall 15b9b69bf1 Handle topdown.Undefined Query result in API
If the caller GETs a completely defined virtual doc that evaluates to
undefined, the API should return an error instead of 2xx.
2016-06-06 17:06:39 -07:00
Torin Sandall 9444b16cd6 Add support for global vars in GET /v1/data/...
Callers need to be able to supply values for global values that virtual docs
depend on. These changes allow callers to supply globals via query param:

GET /v1/data/path/to/some/vdoc?global=<key>:<value>

Where <key> is the import path and <value> is a URL encoded JSON value.

For now the topdown implementation only supports ast.Var values for the key
but in future, references shall also be supported.
2016-06-06 15:43:57 -07:00
Torin Sandall c40d038e13 Merge pull request #44 from tsandall/master
Fix broken links
2016-06-06 14:43:32 -07:00
Torin Sandall 29ab710199 Fix broken links
A few of the links in the language reference were broken when switching over
to Jekyll. Also, the table formatting was broken by the switch to redcarpet.
2016-06-06 09:16:08 -07:00
Torin Sandall 3c09184bf9 Merge pull request #43 from tsandall/master
A few improvements to prepare for the initial release
v0.1.0-rc1
2016-06-03 16:30:00 -07:00
Torin Sandall 60db91d22c Revert version back to 0.1.0
A bit of extra testing identified a few changes that needed to go in before we
announce the initial release.
2016-06-03 16:24:33 -07:00
Torin Sandall 7c20f40844 Add hello world example and tweak arch.md
Also, update Jekyll configuration to use Redcarpet as Kramdown was inserting
extra spaces into code blocks. This was making the EOF line not get recognized
in the heredocs.

Also, fix missing commas in one of the arch.md policy snippets.
2016-06-03 16:15:09 -07:00
Torin Sandall 604c7de8f3 Add CONTRIBUTING.md to the repo
Provide some guidelines on contributions and link to the document from the
About page on the website.
2016-06-03 16:15:09 -07:00
Torin Sandall 4f677fe0dd Fix bug in Data API
The path handling was broken for patch objects with path = "-".

Refactored Data API test cases as well. They're more concise now and can be
extended easily.
2016-06-03 11:11:57 -07:00
Torin Sandall eee4326634 Fix downloads on front page 2016-06-02 18:21:44 -07:00
Torin Sandall 19b5e3bacb Update RELEASE.md
Fix repository URL.
2016-06-02 16:10:44 -07:00
Torin Sandall 3841867bd3 Prepare v0.2.0 development 2016-06-02 16:05:59 -07:00
Torin Sandall 12ef23e2d7 Prepare v0.1.0 release 2016-06-02 16:04:10 -07:00
Torin Sandall b878ae3718 Merge pull request #42 from tsandall/lang-output-updates
Update REPL examples in language reference
2016-06-02 15:39:53 -07:00
Torin Sandall e79f6b989a Update REPL examples in language reference
Very little changed, mostly just fixing the formatting of the REPL output.
Eventually we should have automation that runs these examples through the
REPL.
2016-06-02 15:37:35 -07:00