Commit Graph

1873 Commits

Author SHA1 Message Date
Stan Lagun 69fbaacfde Add Prometheus metrics to the status updates
Prometheus metrics can give much of insight into OPA's health.
Run-time metrics are a natural part of the application state
so having them in status update seems like a right change
that can help server understand what's going in with the OPA
instance.

The commit also encapsulates all prometheus-related code in one package
and abstracts it with generic interface so that it would be possible
to add other metrics providers

Addresses #1606

Signed-off-by: Stan Lagun <stan@styra.com>
2019-08-15 15:08:38 -04:00
Teemu Koponen ae99b40b33 ast: Copy moduleLoader returned parsed Modules.
Signed-off-by: Teemu Koponen <koponen@styra.com>
2019-08-15 14:41:10 -04:00
Torin Sandall dd3cc6b544 travis: Build and push windows and darwin edge binaries
These changes update the travis build to produce windows/darwin
binaries in addition to the linux binary and push them to the S3
bucket holding the edge binaries. This lets users on windows/darwin
easily obtain the binary for tip of master. It also enables the live
docs build which is coming soon.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-08-15 14:38:03 -04:00
Guangming Wang ac6e42b800 cleanup: fix obvious typos in types.go
Signed-off-by: Guangming Wang <guangming.wang@daocloud.io>
2019-08-15 10:06:37 -04:00
Torin Sandall db243e70b7 Fix logo in README
Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-08-14 17:21:17 -04:00
Torin Sandall 7ef72c191b docs: Refactor admission control content into top-level section
The goal is to have the Kubernetes admission control content organized
into one section. This should make it easier to incorporate Gatekeeper
content in the future.

Since the layouts are not versioned the layout logic had to be
enhanced to filter out sections that have no content for the current
version. Doing a semantic version comparison was considered but it was
unclear how to implement that properly within the Hugo template
system. Since it's unlikely that we will want to ever display empty
sections this approach seems fine.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-08-14 16:38:09 -04:00
Torin Sandall 320df65f61 logo: Replace logo with 1024x1024 version
Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-08-14 16:38:09 -04:00
Torin Sandall 04085f29e4 Update CHANGELOG.md for v0.13.2
Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-08-14 15:17:29 -04:00
Torin Sandall bd0d89bede build: Remove the release-builder image
The release-builder image is no longer required because we only need
the base Go image to build the OPA binaries. The nodejs dependency was
only required for the docs which are handled by netlify now.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-08-14 14:03:50 -04:00
Torin Sandall b5a52d2d08 build: Use golang 1.12.8
Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-08-14 14:03:50 -04:00
Torin Sandall 789b187a76 chore: Rename design directory to proposals
Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-08-14 11:28:50 -04:00
Patrick East 8c80051cc7 rego: Fix godoc for rego.Rego() API
The documentation was updated part way through adding the Prepare
helpers on the Rego object. Later on when PrepareForEval and
PrepareForPartial helpers were added and we stopped re-using
PartialResult this was left behind and is now incorrect.

Fixes: #1619
Signed-off-by: Patrick East <east.patrick@gmail.com>
2019-08-14 10:53:45 -04:00
Stephan Renatus ebb419b075 Makefile, .travis.yml: bump Golang 1.11 -> 1.12
Signed-off-by: Stephan Renatus <srenatus@chef.io>
2019-08-14 10:53:29 -04:00
ethan 692a80c01b repl.go: command help message correction
repl.go: wording flag message to make it more understandable

Signed-off-by: Guangming Wang <guangming.wang@daocloud.io>
2019-08-13 13:43:00 -04:00
Torin Sandall 00de0208e9 docs: Add initial stab at integration guide
This is not complete (e.g., more detail on management APIs would be
great, detail on CLI invocation would be nice, detail on partial
evaluation would be very helpful, etc.) but it provides a starting
point.

Fixes #372

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-08-12 17:15:30 -04:00
ethan 379b9bdf0e cleanup up fmt.go help message typo
Signed-off-by: Guangming Wang <guangming.wang@daocloud.io>
2019-08-11 13:40:57 -07:00
Jasper Van der Jeugt eec942f0db ADOPTERS.md: add Fugue
Signed-off-by: Jasper Van der Jeugt <jasper@fugue.co>
2019-08-09 09:00:46 -07:00
Torin Sandall a6e6e2d660 repl: Fix regression in interpreting statements as rules
While adding support for the some keyword in the REPL and fixing #1104
there was a regression where statements like `input = 1` would always
be interpreted as rules. We made a decision a long time ago that the
first time an expression like `input = 1` was encountered that a rule
would be declared but that subsequent similar expressions (e.g., input
= 1 or input = {"foo":"bar"} or ...) would perform a comparison. The
regression broke this for cases where the left hand side was a
reference to a global document (i.e., input or data). This commit just
fixes the regression by updating the global check to account for refs.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-08-07 14:22:45 -04:00
Torin Sandall 54c21b7c0b repl: Update to use helper to construct rule from := expression
This avoids duplicating any logic that may be required to construct
rules from := expressions. Currently the only extra bit of logic is to
set the assignment flag on the rule head. This change lets us
determine whether the rules are unset in the REPL in a more
declarative manner (i.e., if it's an assignment rule then it will
unset in all cases) and ensure that the assignment operator is not
lost in the show command output.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-08-07 14:22:45 -04:00
Torin Sandall 516461dda5 docs: Update docs to mention rules declared with :=
Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-08-07 14:22:45 -04:00
Torin Sandall 2dba8ad872 ast: Improve parser test helpers to mark themselves
Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-08-07 14:22:45 -04:00
Torin Sandall 949921c8ad format: Update formatter to preserve rule assigmemnts
Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-08-07 14:22:45 -04:00
Torin Sandall e01ada2ac4 ast: Update compiler to check rule assignments
Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-08-07 14:22:45 -04:00
Torin Sandall 557f8bb999 ast: Update parser to support rule assignments
Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-08-07 14:22:45 -04:00
Torin Sandall 81b615461d ast: Update rule head to track assignments
These changes update the AST to allow users to declare rules with the
:= operator. The compiler checks that the rule has not been declared
elsewhere in the package. These changes help bridge the gap between
the REPL and modules.

Fixes #1541

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-08-07 14:22:45 -04:00
Jasper Van der Jeugt a03588d299 Fix parsing of var-like scalars
As reported in #1582, there are some issues with parsing variables that
start with `false`, `true` or `null`.

Two possible fixes for this issue are:

 1. Reordering the `Term` rule:

        Term <- Comprehension / Composite / Scalar / Call / Ref / Var

 2. Fixing the bug in `Scalar`: e.g. `nulls` should _not_ parse as a
    scalar by ensuring these keywords are not prefixes of a variable.
    As far as I know this is a fairly common technique in grammars.

It's bikeshedding the issue a bit but I would argue that (1) is not a
great solution: it really just works around the bug by moving things
around in `Term`: the bug may pop up again when reusing `Scalar` in
other places.

In order to do (2) nicely I also refactored the parser for variables
into one for var's first and subsequent characters.

Signed-off-by: Jasper Van der Jeugt <jasper@fugue.co>
2019-08-07 12:14:15 -04:00
Torin Sandall 78f2b9d09a Prepare v0.14.0 development
Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-08-06 13:38:34 -04:00
Torin Sandall b06cfaf1d8 Prepare v0.13.0 release
Signed-off-by: Torin Sandall <torinsandall@gmail.com>
v0.13.0
2019-08-06 13:37:20 -04:00
Torin Sandall 6995cd61a3 docs: Fix bundle configuration example
The configuration was using the old 'bundle' key when it should be
using the new 'bundles' key.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-08-06 11:38:23 -04:00
Torin Sandall 4033f3d945 server: Remove deprecated diagnostic feature
This commit removes the deprecated diagnostic feature from the
server. The feature has been deprecated since November 2018 and it was
essentially unused at the time so it should be safe to
remove. Removing the diagnostic support from the server saves having
to perform an extra policy evaluation in the server.

Once the buffer is removed from the runtime.Params struct the related
issue can be closed (there is still one known user of that so it has
been left intact for backwards compatibility.)

Ref #1052

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-08-06 02:25:09 +09:00
Stan Lagun df0befd596 Monitor cancelled HTTP requests with Prometheus metrics
This commit adds `http_request_cancellations` counter to the Prometheus
metrics. Having such a counter helps identify requests that were timed
out or the client just got disconnected before the request result was
computed.

Signed-off-by: Stan Lagun <stan@styra.com>
2019-08-05 23:38:01 +09:00
Torin Sandall 6dd37dd2a7 storage: Add safety checks to in-memory store
This commit adds two checks to the in-memory store to detect improper
use of transactions:

1. Mark aborted/committed transactions as stale and error if an
operation is attempted on a stale transaction. Previously callers
could perform unsafe concurrent operations on stale transactions
without noticiing.

2. Check that supplied transactions are from the underlying store and
not another store. We could consider deprecating the store APIs and
moving them onto the transaction to prevent this kind of mistake in
the future.

With these changes the store will panic on unregister and abort
calls if any of these invariants are violated. Panicing is preferable
to failing silently.

Note, we still have the issue of recursive transactions resulting in
deadlock. Our options there are to implement more sophisticated
locking inside the in-memory store or modify the API so that the store
can update the passed context.Context with a sentinel value.

Fixes #1594

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-08-05 22:38:03 +09:00
Charlie Egan 89eacaccb6 Add livenessProbe to demo deployment
I expect many install OPA following this guide (as we did). Recent PRs
have made steps to 'productionize' this (e.g.
[#1435](https://github.com/open-policy-agent/opa/pull/1435))

We had an incident involving the controller where a stuck container was
not restarted. We would have been helped if a liveness probe was
configured. We copied the docs and this is our bad but we'd like to do
our best to make sure others don't make the same mistake.

I figured it'd be ok to use the health endpoint
[here](https://github.com/open-policy-agent/opa/blob/master/docs/content/rest-api.md#health-api)

We've made this change and it seems to be working ok for us.

Signed-off-by: Charlie Egan <charlieegan3@users.noreply.github.com>
2019-08-02 12:42:46 -07:00
Patrick East 346aa964e8 Add support for multiple bundles
This change brings in support for multiple bundles to be downloaded
and activated OPA.

This is enabled by using the new config option `bundles` to define
the bundles, and deprecates the older `bundle` option.

The new `bundles` keyword and structure is propagated through to the
decision logs, status API, provenance, stored manifests, etc. Check
out the doc changes for all the updated structures.

That being said any existing configuration using `bundle` will *not*
see the new structure, everything is intended to be backwards
compatible (almost to a fault).

Fixes: #721

Signed-off-by: Patrick East <east.patrick@gmail.com>
2019-07-31 03:43:38 -04:00
Patrick East c2d2d1b7fa Remove extra character in util/close.go
Signed-off-by: Patrick East <east.patrick@gmail.com>
2019-07-31 03:43:38 -04:00
Patrick East 02ceb4f5d4 Move manifest pkg to a public location
This will allow others consuming OPA as a library to have easier
access to manage/query the bundle manifests.

Signed-off-by: Patrick East <east.patrick@gmail.com>
2019-07-31 03:43:38 -04:00
Patrick East 3aea6a0922 Add an edge tag for opa docker images
This tag will follow the current master branch and lines up with what
is in the docs as the `edge` version alias.

Signed-off-by: Patrick East <east.patrick@gmail.com>
2019-07-30 11:14:13 -07:00
Torin Sandall 221974f28a docs: Add example of merging two objects
This is answers a common question that was recently raised in #1588.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-07-30 08:54:53 -07:00
Jasper Van der Jeugt 66fb55f40e Move unsafe built-in check to compiler
This patch moves the check for unsafe built-ins from the server to the
compiler, so it can be used by the Go API as well as the HTTP API.

This was previously discussed in #1570.

Signed-off-by: Jasper Van der Jeugt <jasper@fugue.co>
2019-07-29 19:53:45 -04:00
Torin Sandall eabe7f1312 cmd: Update subcommands to support fails explanation mode
This change updates the test command to use the fail explanation mode
by default. Since the test framework expects test rules to be
defined/true failure events are usually what is required to debug test
failures (e.g., some assertion in the test rule will Fail and that
will _likely_ be based on some failure in the policy under test.)
Hopefully this makes the test output a bit less verbose and more readable.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-07-29 18:56:09 -04:00
Torin Sandall e37482d9cd repl: Update REPL to support fails explanation mode
Also, refactor how the REPL prints debug state a bit to reduce
boilerplate for each possible explanation mode.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-07-29 18:56:09 -04:00
Torin Sandall b55fc2e80d server: Update server to support fails explanations mode
Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-07-29 18:56:09 -04:00
Torin Sandall 87347dc1a5 topdown: Rename notes package to lineage and add Fail filter
These changes just rename the notes package so that it can be used
more generally. In addition, it adds another filter to show Fail
events and their lineage. The Fail filter will be exposed like the
Notes filter and will hopefully be useful in test scenarios.

This change is backwards incompatible but it's unlikely that anyone
outside of OPA was depending on the notes package. Updating
dependencies to use lineage.Notes instead of notes.Filter should be
easy enough if needed.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-07-29 18:56:09 -04:00
Torin Sandall f3d1ef4859 Update CHANGELOG.md for v0.12.2
Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-07-27 13:44:46 -04:00
Torin Sandall e7af9f8257 travis: Update install to include awscli
Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-07-26 12:33:36 -04:00
Torin Sandall c9df4da104 travis: Update build to push edge binaries to S3
These changes update the travis build to push the linux/amd64 binary
to an S3 bucket that allows public reads. This provides a simple
way for people to obtain and execute OPA locally which is useful when
Docker is not available (e.g., as is the case with Netlify.)

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-07-26 10:52:32 -04:00
Patrick East dd7cb56aab internal/version: Fixup docstring for UserAgent
Signed-off-by: Patrick East <east.patrick@gmail.com>
2019-07-24 10:41:23 -07:00
Brendan Ryan 350a74832e make path optional
Signed-off-by: Brendan Ryan <brendanjryan@github.com>
2019-07-23 14:23:54 -07:00
Brendan Ryan 57d72ae14a fixes usage of fmt command
Signed-off-by: Brendan Ryan <brendanjryan@github.com>
2019-07-23 14:23:54 -07:00
Christian Muehlhaeuser 0e5b449219 Fixed typos in code
Signed-off-by: Christian Muehlhaeuser <muesli@gmail.com>
2019-07-19 13:46:23 -07:00