You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: plugins/external/opa/README.md
+8-4Lines changed: 8 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,6 +43,9 @@ plugins:
43
43
extensions:
44
44
policy: "example"
45
45
policy_endpoint: "allow"
46
+
# policy_input_data_map:
47
+
# "context.git_context": "git_context"
48
+
# "payload.args.repo_path": "repo_path"
46
49
conditions:
47
50
# Apply to specific tools/servers
48
51
- server_ids: [] # Apply to all servers
@@ -55,12 +58,13 @@ The `applied_to` key in config.yaml, has been used to selectively apply policies
55
58
Here, using this, you can provide the `name` of the tool you want to apply policy on, you can also provide
56
59
context to the tool with the prefix `global` if it needs to check the context in global context provided.
57
60
The key `opa_policy_context` is used to get context for policies and you can have multiple contexts within this key using `git_context` key.
58
-
You can also provide policy within the `extensions` key where you can provide information to the plugin
59
-
related to which policy to run and what endpoint to call for that policy.
60
-
In the `config` key in `config.yaml` file OPAPlugin consists of the following things:
61
+
62
+
Under `extensions`, you can specify which policy to run and what endpoint to call for that policy. Optionally, an input data map can be specified to transform the input passed to the OPA policy. This works by mapping (transforming) the original input data onto a new representation. In the example above, the original input data `"input":{{"payload": {..., "args": {"repo_path": ..., ...}, "context": "git_context": {...}}, ...}}` is mapped to `"input":{"repo_path": ..., "git_context": {...}}`. Observe that the policy (rego file) must accept the input schema.
63
+
64
+
In the `config` key in `config.yaml` for the OPA plugin, the following attribute must be set to configure the OPA server endpoint:
61
65
`opa_base_url` : It is the base url on which opa server is running.
62
66
63
-
3. Now suppose i have a sample policy, in `example.rego` file that allows a tool invocation only when "IBM" key word is present in the repo_path. Add the sample policy file or policy rego file that you defined, in `plugins/external/opa/opaserver/rego`.
67
+
3. Now suppose you have a sample policy in `example.rego` file that allows a tool invocation only when "IBM" key word is present in the repo_path. Add the sample policy file or policy rego file that you defined, in `plugins/external/opa/opaserver/rego`.
64
68
65
69
3. Once you have your plugin defined in `config.yaml` and policy added in the rego file, run the following commands to build your OPA Plugin external MCP server using:
66
70
* `make build`: This will build a docker image named `opapluginfilter`
0 commit comments