Commit Graph

36 Commits

Author SHA1 Message Date
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 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
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
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 6bda0a482c server: Tweak server error string format
This just tweaks the error string format introduced in #1530 to be
consistent with other error strings in OPA (e.g., topdown, ast, etc.)

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-07-03 01:43:59 +08:00
Xin Jin 8fb825a08a servers: fix comments.
Signed-off-by: Xin Jin <xin@styra.com>
2019-07-03 00:07:02 +08:00
Torin Sandall ee62afa477 server: Update server to support notes explanation
Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-05-10 10:33:40 -07:00
Patrick East 589105aff5 Add param to include bundle activation in /health response
There is a new parameter for /health REST API which will include the
Configured bundle activation in the response. Example:

GET /health?bundle=true HTTP/1.1

Without the parameter the behavior stays the same, with it the server
will respond with 500’s until the status has been updated with an
activation time.

The docs for kubernetes ready probe has been updated to show this as
it makes for a better ready check than the original behavior when
remote bundles are being used.

Fixes: #1153
Signed-off-by: Patrick East <east.patrick@gmail.com>
2019-05-02 15:28:12 -06:00
Peter W. Morreale 5c6882e176 Define 'provenance' data types
First of several commits that define a new query
parameter named 'provenance'.

This query parameter will return version/build information
in addition to the result to the caller for data REST calls.

Signed-off-by: Peter W. Morreale <pmorreale@statestreet.com>
2019-05-01 20:26:37 -07: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
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
NIkhil Bhatia 93542dbbec Post query (#1)
* add POST method for /query

Signed-off-by: Nikhil Bhatia <nbhatia@microsoft.com>
2018-10-23 16:16:57 -07:00
Torin Sandall 24dc8dbb0e Add handler for /v1/compile API
Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2018-06-28 08:11:45 -07:00
Torin Sandall b31412dc8e Update server to include revision in decision logs
Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2018-04-10 13:58:36 -07:00
Torin Sandall 76a3ef3c0e Add storage.MakeDir helper function
It's often useful to be able to create a hierarchical structure in one
shot in storage. Previously this functionality was implemented in the
server, but it's better off implemented in the storage package.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2018-04-10 13:58:36 -07:00
Torin Sandall 2a5192ec6c Minor changes to note support
* Check if node is non-nil to prevent panic
* Omit empty message field from API response
* Use native string type for message fields
2018-03-12 17:13:19 -07:00
Unknown dbfccf15e5 Adding test and documentation for the trace builtin 2018-03-12 16:08:54 -07:00
Torin Sandall 67022fc71a Add omitempty tag for ad-hoc query result field
Without omitempty, the server returns {"results": null} which is not
consistent with the rest of the APIs.
2018-02-24 10:16:27 -08:00
Torin Sandall 658ae9fe75 Refactor AST type name strings
Previously we had constants defined for AST type names. These were used
in error messages in various places. The original goal was to make error
messages consistent, however, this approach made it difficult to locate
the source of the error in code.
2018-02-09 16:38:34 -08:00
Torin Sandall 744316dbaa Add basic query performance instrumentation
Previously OPA only tracked query performance a high level (e.g., parse,
compile, eval latencies.) In some cases, it's necessary to instrument
lower level evaluation operations to understand performance. These
changes update the eval implementation to support instrumentation:

* Eval has been instrumented to record time taken for various core
operations like term plugging, reading from the store, rule lookup,
cache hits, etc.

* Rego package has been updated to support a simple rego.Instrument
operation that enables query instrumentation.

* REPL and server have been updated to expose simple interfaces to turn
on instrumentation.

* Diagnostic policy config "all" will enable instrumentation.

Instrumentation can be expensive (because it requires timing frequently
executed operations) so it should be treated as a debugging tool and not
enabled all of the time.
2018-02-09 09:30:27 -08:00
Torin Sandall 819be66ec7 Update server to expose partial evaluation
These changes expose the partial evaluation optimization through the
HTTP API. Clients can request the optimization by including a query
parameter and the server will lazily run partial evaluation and keep a
cache of the results for subsequent queries.
2018-01-18 07:10:31 -08:00
Tristan Swadell 582f47074d Remove lint errors detected during 'make check' 2018-01-10 15:17:10 -08:00
Torin Sandall 3ebbeede6c Refactor topdown evaluation/unification
These changes modify topdown evaluation to use a binding list that
namespaces variables. This allows topdown to propagate partially ground
ref operands into child query evaluation.

These changes also prepare topdown evaluation to support a partial
evaluation mode.

With these changes, evaluation is no longer performed in two steps
(i.e., first pass of evaluating individual terms, second pass of
evaluating built-in expressions.) Instead, evaluation assumes queries
have been rewritten to eagerly evaluate refs and comprehension. This
way, ref and comprehension bindings do not have to be maintained
separately: they are handled by the normal variable binding list.

This commit contains some breaking changes to the topdown APIs,
namely...

1. Truth explanation has been removed. This feature was not used and the
tracing changes broke it. We can revisit in future if necessary.

2. Data indexing has been removed. Data indexing can be re-added in
future if necessary however it should be handled outside of topdown to
avoid potential memory leaks.

3. Built-in functions produce at-most-one output now. Functions that
used to produce multiple outputs (e.g., io.jwt.decode) can produce a
composite value if they need to.

Fixes #131
2017-11-09 09:07:48 -08:00
Torin Sandall 05e9eb601c Refactor diagnostics support in server and runtime
- These changes update the server to always report performance metrics
  and the remote client address. The metrics are cheap to compute and
  there is no significant reason to require more complex configuration
  at this point.

- These changes update the runtime to allow callers to supply the
  diagnostics buffer implementation. This way callers can hook up their
  own sinks to the server's diagnostics.
2017-09-19 15:54:26 -07:00
Torin Sandall 2ec6770956 Add optional decision_id to server
Include an optional decision_id field in Data API responses. The
decision_id can be used for correlating application transactions with
policy decisions. The decision_id field is intended to be separate from
any kind of application tracing that OPA may eventually support.
2017-09-19 15:54:26 -07:00
Torin Sandall 4a4af6b178 Remove dead code associated with input doc errors
In b23cb4e the compiler was changed to allow queries to refer to the
input document without the input document being defined. Those changes
did not remove all of the code associated with input errors.

These changes remove the remaining (dead) code associated with input
errors and also update the server to allow Data API POST requests that
do not specify an input document.
2017-08-29 10:49:23 -07:00
Torin Sandall c45bdf9e8d Refactor Policy API responses
These changes update the Policy API responses to:

- Return empty objects for PUT/DELETE with optional support for ?metrics
- Return AST and raw/source for GET

Support for the ?source param has been removed as the raw/source version
is now included by default.
2017-08-24 11:29:26 -07:00
Matthew Mussomele b4c5f8f3fe Update server to support pretty explanations
When the `pretty` parameter was supplied with a server request that also
requested explanations, the JSON representation of the explanation was
simply indented. JSON explanations are not human readable though, so
this patch updates the server to return a human readable string
representing explanations when the `pretty` parameter is true.
2017-08-15 21:18:23 -07:00
Matthew Mussomele 41f8e6949b Implement diagnostics in the server 2017-08-08 15:45:12 -07:00
Matthew Mussomele e239309b93 Update the server to use versioned types for all query params
The server wasn't using versioned types for all the query parameters,
namely "q" and "explain". For consistency, this patch changes it to do
so.
2017-07-20 17:07:51 -07:00
Matthew Mussomele 4435880658 Implement watch API in the server 2017-07-20 17:07:51 -07:00
Torin Sandall da3eed982c Add new /v0 HTTP API
In some cases, services have existing webhook support that have
predefined request/response formats. Typically these webhooks perform an
HTTP POST against a configurable host, port, and path.

To ease integration of OPA with these services, we introduce a new API
version that represents the minimum required to perform policy
evaluation via HTTP.
2017-05-15 17:19:56 -07:00
Torin Sandall 0e5a841b9a Add basic performance metric collection 2017-05-12 09:55:14 -07:00
Torin Sandall 6d55a2818b Allow slash in policy id/path
As part of this change, the /policies/{id}/raw API has been removed in
favour of a "source" query parameter. When GET
/policies/{id}?source=true is received, the server returns the
raw/source of the policy.

Also, cleaned up handling of boolean query params.

Fixes #292
2017-03-11 11:40:46 -08:00
Torin Sandall 96aad95475 Add identifier and authorizer to server 2017-02-22 14:49:21 -08:00
Torin Sandall 68fe788626 Split server types into separate package
This will let them be re-used by other sub-packages such as the
authorizer.
2017-02-22 14:49:21 -08:00