Commit Graph

19 Commits

Author SHA1 Message Date
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 667f21d07f plugin/logs: Pass server txn to mask Eval()
We were only using it on the prepare step, but we needed to use the
passed in txn each time we eval the prepared query.

Signed-off-by: Patrick East <east.patrick@gmail.com>
2019-07-12 10:39:02 -07:00
Torin Sandall d1d4df9798 server: Pass transaction in decision log event
These changes update the server to pass the server's open transaction
to the decision logger. This prevents the same goroutine from
recursively opening a new transcation when the log masking decision is
evaluated.

Alternatively we could update the server to close it's transaction
before logging the decision however this could lead to the log masking
decision being generated from a different policy revision. Another
alternative would be extend the storage layer to support recursive
transactions however this would be quite a bit more work.

We should investigate whether we can cheaply detect recursive
transactions in the store to avoid potential deadlocks in the future.

Also, delete opa binary that was accidentally committed to the repo.

Fixes #1543

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-07-03 15:10:59 -04:00
Patrick East a1abbbf4c9 logs: console decision logging option
Add option to log decision logs locally. They'll get logged via
Logrus at info level.

To enable configure OPA with something like:

```
decision_logs:
    console: true
```

This will work alongside remote services and plugins. It will also
log the masked events in the case a masking policy is set.

Fixes: #1334
Signed-off-by: Patrick East <east.patrick@gmail.com>
2019-06-13 13:27:51 -07:00
Torin Sandall c0cc24676d logs: Update decision logger to support masking
These changes enhance the in-built decision logger to support masking
of input and result fields for cases where sensitive information is
passed to OPA (or generated by the policy.)

Also, fix rego package to avoid panic-ing on programmatically created
queriest that lack Location information.

Fixes #779

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-06-04 16:14:46 -07:00
Torin Sandall 510c5ce77e decision_logs: Update interface to return error
Previously, the decision logger interface did not allow plugin
implementations to return an error. In some cases, implementations may
prefer to make OPA fail-closed if the event cannot be emitted.

This is a backwards incompatible change to the custom decision logger
API that was added in v0.10.3 and it deprecates the old diagnostic
interface as well.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-02-22 20:47:00 -08:00
Andy Curtis 778594ec79 config: add version to labels
Adds OPA version to the config labels, so that the version
appears in status updates. Previously, decision logs had a
top-level version field. This removes that field because
version will be contained in the labels instead.

Signed-off-by: Andy Curtis <arcurtis@gmail.com>
2019-02-08 15:55:27 -08:00
Torin Sandall 1db3023d45 Update decision log events to model paths and queries
Previously paths and queries were modelled with the same
attribute. This was going to cause headaches down the road for
decision log consumers that need to be able to deal with both kinds of
policy invocations.

As part of these changes, the decision logging test in the server has
been refactored to make it a bit more maintainable.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-01-16 12:45:47 -08:00
Torin Sandall 4428a9bd31 Update server and decision logger to represent input properly
Previously the input attribute was no represented as *interface{}
which makes it impossible to differentiate between null and undefined
input. This commit changes that. Eventually we should just get rid of
server.Info in favour of the decision log event structure.

This change requires a release note.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-01-16 12:45:47 -08:00
Torin Sandall 2f5a0fe0a4 Update decision log event to include error
The error field from the server event was not being copied into the
decision log event. Also, we didn't have test cases to verify that the
error was being set correctly in the first place.

In the future, we should remove the duplication of the server event
and the decision log event (preferring the latter).

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-01-16 12:45:47 -08:00
repenno d85a3e15ca Add query metrics to decision logs
Fixes #1033

Signed-off-by: repenno <rapenno@gmail.com>
2019-01-16 12:45:47 -08:00
Torin Sandall cffc3d996d Add support for custom backends in decision logger
These changes modify the decision logger to support custom
backends. The docs now include an example of how to implement a custom
backend that writes out to stdout.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-01-10 14:52:14 -08:00
repenno 1773cf64e8 Add OPA version to decision logs
Fixes #1089

=== RUN   TestPluginStartSameInput
--- PASS: TestPluginStartSameInput (0.02s)
=== RUN   TestPluginStartChangingInputValues
--- PASS: TestPluginStartChangingInputValues (0.01s)
=== RUN   TestPluginStartChangingInputKeysAndValues
--- PASS: TestPluginStartChangingInputKeysAndValues (0.01s)
=== RUN   TestPluginRequeue
--- PASS: TestPluginRequeue (0.00s)
=== RUN   TestPluginReconfigure
time="2019-01-09T09:34:03-08:00" level=info msg="Starting decision log uploader." plugin=decision_logs
time="2019-01-09T09:34:03-08:00" level=info msg="Log upload skipped." plugin=decision_logs
time="2019-01-09T09:34:03-08:00" level=info msg="Stopping decision log uploader." plugin=decision_logs
time="2019-01-09T09:34:03-08:00" level=info msg="Decision log uploader configuration changed." plugin=decision_logs
time="2019-01-09T09:34:03-08:00" level=info msg="Log upload skipped." plugin=decision_logs
--- PASS: TestPluginReconfigure (0.00s)
PASS

Signed-off-by: repenno <rapenno@gmail.com>
2019-01-09 19:09:19 -08:00
Torin Sandall 2d425494aa Refactor discovery implementation
These changes refactor the discovery implementation a bit to improve
test coverage and remove duplication of common logic shared with the
bundle plugin.

Specifically, the downloading logic has been moved into a separate
package that is shared by bundle and discovery. Second, test coverage in
the discovery implementation is increased from ~15% to ~85%.

These changes also include a few functional improvements:

- The default decision paths can be updated dynamically
- The decision logger can be enabled dynamically
- Discovery downloading errors are reported in status updates
- Discovery bundle is evaluated with all runtime params
- Custom plugins can be created dynamically
- Status updates include both discovery and bundle status

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2018-12-08 00:45:36 +01:00
Ashutosh Narkar 2185f1eb86 Add support for configuration discovery
Previously OPA configuration for bundle downloading, status reporting, etc. had to be supplied in a configuration file on startup. With these changes, OPA can be configured to download a bundle that generates the OPA configuration. This allows OPA to boot with minimal configuration and dynamically update that configuration on-the-fly making it much easier to manage large deployments of OPAs for different use cases within the same system.

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
2018-11-29 09:19:58 -08:00
Torin Sandall c5106fa49d Remove decision log buffer limit
This change removes the default decision log buffer limit to avoid
unintentionally dropping decision logs. If users are concerned about
memory usage they can set the limit, but by default they will not be
surprised by log discards.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2018-06-18 11:32:22 -07:00
Ashutosh Narkar 1b33bf3f6f Reduce memory overhead of decision logs
Fixes #705

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
2018-06-15 09:23:01 -07:00
Torin Sandall db708b8490 Fix query to path conversion in decision logger
The decision logger was using strings.TrimLeft when it should have been
using strings.TrimPrefix. As a result, the prefix was not being trimmed
correctly--leading characters in the cutset "data." were being removed.

Fixes #783

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2018-06-13 09:17:57 -07:00
Torin Sandall 49bba1faa8 Add decision logging plugin
Previously, decision logs were kept in-memory and enabled via
diagnostics configuration. With these changes, admins can configure OPA
to log decisions to a remote HTTP endpoint.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2018-04-10 13:58:36 -07:00