@orygn/opa-mcp 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +244 -1
- package/README.md +98 -51
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1 -0
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +13 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +35 -5
- package/dist/config.js.map +1 -1
- package/dist/constants.d.ts +1 -6
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +17 -3
- package/dist/constants.js.map +1 -1
- package/dist/lib/conftest-cli.d.ts.map +1 -1
- package/dist/lib/conftest-cli.js +81 -17
- package/dist/lib/conftest-cli.js.map +1 -1
- package/dist/lib/errors.d.ts +4 -5
- package/dist/lib/errors.d.ts.map +1 -1
- package/dist/lib/errors.js +15 -3
- package/dist/lib/errors.js.map +1 -1
- package/dist/lib/inline-paths.d.ts +37 -0
- package/dist/lib/inline-paths.d.ts.map +1 -0
- package/dist/lib/inline-paths.js +162 -0
- package/dist/lib/inline-paths.js.map +1 -0
- package/dist/lib/opa-cli.d.ts +10 -0
- package/dist/lib/opa-cli.d.ts.map +1 -1
- package/dist/lib/opa-cli.js +9 -2
- package/dist/lib/opa-cli.js.map +1 -1
- package/dist/lib/opa-client.d.ts +27 -1
- package/dist/lib/opa-client.d.ts.map +1 -1
- package/dist/lib/opa-client.js +98 -14
- package/dist/lib/opa-client.js.map +1 -1
- package/dist/lib/opa-paths.d.ts +11 -1
- package/dist/lib/opa-paths.d.ts.map +1 -1
- package/dist/lib/opa-paths.js +25 -21
- package/dist/lib/opa-paths.js.map +1 -1
- package/dist/lib/output.d.ts.map +1 -1
- package/dist/lib/output.js +83 -10
- package/dist/lib/output.js.map +1 -1
- package/dist/lib/rego-ast-walker.d.ts +0 -6
- package/dist/lib/rego-ast-walker.d.ts.map +1 -1
- package/dist/lib/rego-ast-walker.js +48 -46
- package/dist/lib/rego-ast-walker.js.map +1 -1
- package/dist/lib/rego-counterexample.d.ts +14 -1
- package/dist/lib/rego-counterexample.d.ts.map +1 -1
- package/dist/lib/rego-counterexample.js +40 -10
- package/dist/lib/rego-counterexample.js.map +1 -1
- package/dist/lib/rego-input-path.d.ts +20 -0
- package/dist/lib/rego-input-path.d.ts.map +1 -0
- package/dist/lib/rego-input-path.js +70 -0
- package/dist/lib/rego-input-path.js.map +1 -0
- package/dist/lib/rego-ir.d.ts +2 -1
- package/dist/lib/rego-ir.d.ts.map +1 -1
- package/dist/lib/rego-smt-encoder.d.ts +35 -0
- package/dist/lib/rego-smt-encoder.d.ts.map +1 -1
- package/dist/lib/rego-smt-encoder.js +81 -8
- package/dist/lib/rego-smt-encoder.js.map +1 -1
- package/dist/lib/rego-type-inferencer.d.ts +26 -1
- package/dist/lib/rego-type-inferencer.d.ts.map +1 -1
- package/dist/lib/rego-type-inferencer.js +68 -0
- package/dist/lib/rego-type-inferencer.js.map +1 -1
- package/dist/lib/rego-verify-engine.d.ts.map +1 -1
- package/dist/lib/rego-verify-engine.js +171 -90
- package/dist/lib/rego-verify-engine.js.map +1 -1
- package/dist/lib/rego-z3.d.ts +56 -0
- package/dist/lib/rego-z3.d.ts.map +1 -1
- package/dist/lib/rego-z3.js +276 -7
- package/dist/lib/rego-z3.js.map +1 -1
- package/dist/lib/subprocess.d.ts +13 -0
- package/dist/lib/subprocess.d.ts.map +1 -1
- package/dist/lib/subprocess.js +153 -18
- package/dist/lib/subprocess.js.map +1 -1
- package/dist/lib/tool-helpers.d.ts +12 -25
- package/dist/lib/tool-helpers.d.ts.map +1 -1
- package/dist/lib/tool-helpers.js +66 -40
- package/dist/lib/tool-helpers.js.map +1 -1
- package/dist/prompts/index.js +2 -2
- package/dist/resources/index.js +1 -1
- package/dist/resources/index.js.map +1 -1
- package/dist/resources/patterns.d.ts +1 -1
- package/dist/resources/patterns.d.ts.map +1 -1
- package/dist/resources/patterns.js +2 -3
- package/dist/resources/patterns.js.map +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +40 -5
- package/dist/server.js.map +1 -1
- package/dist/tools/authoring/capabilities.d.ts +4 -0
- package/dist/tools/authoring/capabilities.d.ts.map +1 -1
- package/dist/tools/authoring/capabilities.js +41 -4
- package/dist/tools/authoring/capabilities.js.map +1 -1
- package/dist/tools/authoring/check-schema.d.ts +6 -0
- package/dist/tools/authoring/check-schema.d.ts.map +1 -1
- package/dist/tools/authoring/check-schema.js +56 -3
- package/dist/tools/authoring/check-schema.js.map +1 -1
- package/dist/tools/authoring/format.d.ts.map +1 -1
- package/dist/tools/authoring/format.js +2 -2
- package/dist/tools/authoring/format.js.map +1 -1
- package/dist/tools/authoring/lint.d.ts.map +1 -1
- package/dist/tools/authoring/lint.js +8 -6
- package/dist/tools/authoring/lint.js.map +1 -1
- package/dist/tools/authoring/migrate-v1.d.ts.map +1 -1
- package/dist/tools/authoring/migrate-v1.js +20 -4
- package/dist/tools/authoring/migrate-v1.js.map +1 -1
- package/dist/tools/authoring/parse.d.ts.map +1 -1
- package/dist/tools/authoring/parse.js +3 -3
- package/dist/tools/authoring/parse.js.map +1 -1
- package/dist/tools/bundles/sign.d.ts.map +1 -1
- package/dist/tools/bundles/sign.js +14 -34
- package/dist/tools/bundles/sign.js.map +1 -1
- package/dist/tools/conftest/index.d.ts +5 -0
- package/dist/tools/conftest/index.d.ts.map +1 -1
- package/dist/tools/conftest/index.js.map +1 -1
- package/dist/tools/conftest/test.d.ts.map +1 -1
- package/dist/tools/conftest/test.js +16 -17
- package/dist/tools/conftest/test.js.map +1 -1
- package/dist/tools/conftest/verify.d.ts.map +1 -1
- package/dist/tools/conftest/verify.js +14 -18
- package/dist/tools/conftest/verify.js.map +1 -1
- package/dist/tools/evaluation/_shared.js +9 -12
- package/dist/tools/evaluation/_shared.js.map +1 -1
- package/dist/tools/evaluation/bench.d.ts +20 -9
- package/dist/tools/evaluation/bench.d.ts.map +1 -1
- package/dist/tools/evaluation/bench.js +31 -12
- package/dist/tools/evaluation/bench.js.map +1 -1
- package/dist/tools/evaluation/compile.js +4 -4
- package/dist/tools/evaluation/compile.js.map +1 -1
- package/dist/tools/evaluation/eval.d.ts.map +1 -1
- package/dist/tools/evaluation/eval.js +12 -16
- package/dist/tools/evaluation/eval.js.map +1 -1
- package/dist/tools/evaluation/exec.d.ts.map +1 -1
- package/dist/tools/evaluation/exec.js +3 -4
- package/dist/tools/evaluation/exec.js.map +1 -1
- package/dist/tools/evaluation/test-multiroot.d.ts +2 -0
- package/dist/tools/evaluation/test-multiroot.d.ts.map +1 -1
- package/dist/tools/evaluation/test-multiroot.js +23 -6
- package/dist/tools/evaluation/test-multiroot.js.map +1 -1
- package/dist/tools/evaluation/test.d.ts.map +1 -1
- package/dist/tools/evaluation/test.js +8 -6
- package/dist/tools/evaluation/test.js.map +1 -1
- package/dist/tools/helpers/coverage-gaps.d.ts.map +1 -1
- package/dist/tools/helpers/coverage-gaps.js +3 -4
- package/dist/tools/helpers/coverage-gaps.js.map +1 -1
- package/dist/tools/helpers/describe-policy.d.ts.map +1 -1
- package/dist/tools/helpers/describe-policy.js +2 -2
- package/dist/tools/helpers/describe-policy.js.map +1 -1
- package/dist/tools/helpers/explain-decision.d.ts.map +1 -1
- package/dist/tools/helpers/explain-decision.js +3 -4
- package/dist/tools/helpers/explain-decision.js.map +1 -1
- package/dist/tools/helpers/explain-undefined.d.ts.map +1 -1
- package/dist/tools/helpers/explain-undefined.js +131 -22
- package/dist/tools/helpers/explain-undefined.js.map +1 -1
- package/dist/tools/helpers/fix.d.ts +11 -5
- package/dist/tools/helpers/fix.d.ts.map +1 -1
- package/dist/tools/helpers/fix.js +88 -45
- package/dist/tools/helpers/fix.js.map +1 -1
- package/dist/tools/helpers/generate-test-skeleton.d.ts.map +1 -1
- package/dist/tools/helpers/generate-test-skeleton.js +105 -21
- package/dist/tools/helpers/generate-test-skeleton.js.map +1 -1
- package/dist/tools/helpers/playground-share.d.ts +4 -2
- package/dist/tools/helpers/playground-share.d.ts.map +1 -1
- package/dist/tools/helpers/playground-share.js +13 -3
- package/dist/tools/helpers/playground-share.js.map +1 -1
- package/dist/tools/helpers/policy-diff.d.ts.map +1 -1
- package/dist/tools/helpers/policy-diff.js +3 -4
- package/dist/tools/helpers/policy-diff.js.map +1 -1
- package/dist/tools/helpers/security-audit.d.ts.map +1 -1
- package/dist/tools/helpers/security-audit.js +19 -19
- package/dist/tools/helpers/security-audit.js.map +1 -1
- package/dist/tools/meta/index.d.ts +1 -1
- package/dist/tools/server-management/_shared.d.ts.map +1 -1
- package/dist/tools/server-management/_shared.js +13 -1
- package/dist/tools/server-management/_shared.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -6,41 +6,28 @@
|
|
|
6
6
|
* the formatted MCP result. The pieces here factor out the parts every
|
|
7
7
|
* tool repeats so each tool file can stay focused on its own logic.
|
|
8
8
|
*/
|
|
9
|
-
/**
|
|
10
|
-
* Matches the temp-file paths written by OpaCli.withTempSource and
|
|
11
|
-
* RegalCli.withTempSource when handling inline source. Both now use
|
|
12
|
-
* mkdtemp which produces a private directory; the file inside is always
|
|
13
|
-
* named input.rego. Matches both Unix (/) and Windows (\) separators.
|
|
14
|
-
*/
|
|
15
|
-
export declare const INLINE_TEMP_PATH_PATTERN: RegExp;
|
|
16
|
-
/**
|
|
17
|
-
* Replace a file path that refers to one of our temp files with the
|
|
18
|
-
* sentinel string `<inline>`. Returns the original string unchanged when
|
|
19
|
-
* it does not match the pattern, so callers can unconditionally apply it
|
|
20
|
-
* to all location.file values regardless of whether inline source was used.
|
|
21
|
-
*/
|
|
22
|
-
export declare function sanitizeInlinePath(file: string): string;
|
|
23
|
-
/**
|
|
24
|
-
* Recursively rewrite every temp-file path -- in both string values and object
|
|
25
|
-
* keys -- to the `<inline>` sentinel. OPA writes inline source to a temp file,
|
|
26
|
-
* so trace (`explanation`), coverage, and profile output reference that path;
|
|
27
|
-
* this normalizes the whole structure so callers never see an absolute temp
|
|
28
|
-
* path. Only our own temp paths match the pattern, so real user file paths pass
|
|
29
|
-
* through untouched.
|
|
30
|
-
*/
|
|
31
|
-
export declare function sanitizeInlinePathsDeep(value: unknown): unknown;
|
|
32
9
|
import type { Config } from '../config.js';
|
|
33
10
|
import { type McpToolResult } from './output.js';
|
|
34
11
|
import type { SpawnResult } from './subprocess.js';
|
|
35
12
|
import type { ToolEnvelope } from '../types.js';
|
|
13
|
+
export { INLINE_TEMP_PATH_PATTERN, sanitizeInlinePath, sanitizeInlinePathsDeep, sanitizeInlineText, } from './inline-paths.js';
|
|
36
14
|
/**
|
|
37
15
|
* Convert a subprocess outcome into a structured tool error envelope
|
|
38
|
-
* for the cases that are universal across all CLI-backed tools:
|
|
39
|
-
*
|
|
16
|
+
* for the cases that are universal across all CLI-backed tools: cancelled
|
|
17
|
+
* by the client, timed out, output over the capture cap, killed by a
|
|
18
|
+
* signal from outside the server, binary missing. Returns `undefined` when the
|
|
40
19
|
* subprocess exited normally (exitCode is a number) so the caller can
|
|
41
20
|
* inspect the result.
|
|
42
21
|
*/
|
|
43
22
|
export declare function mapSubprocessFailure(result: SpawnResult, binary: 'opa' | 'regal' | 'conftest'): ToolEnvelope<never> | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Parse the last top-level JSON object in `text`, for a command that prints
|
|
25
|
+
* one document per run (`opa test --coverage --count N`). Strings are
|
|
26
|
+
* honoured, so a brace inside a file name does not end a document. Returns
|
|
27
|
+
* `undefined` when there is none. `accept` narrows it to the last object of
|
|
28
|
+
* the shape wanted, so trace text that happens to hold braces is skipped.
|
|
29
|
+
*/
|
|
30
|
+
export declare function lastJsonObject<T = unknown>(text: string, accept?: (parsed: unknown) => boolean): T | undefined;
|
|
44
31
|
/**
|
|
45
32
|
* Try to parse `text` as JSON. Returns `undefined` on failure so the
|
|
46
33
|
* caller can fall back to a textual error envelope rather than throwing.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-helpers.d.ts","sourceRoot":"","sources":["../../src/lib/tool-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH
|
|
1
|
+
{"version":3,"file":"tool-helpers.d.ts","sourceRoot":"","sources":["../../src/lib/tool-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAG3C,OAAO,EAAkB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAiB,MAAM,aAAa,CAAC;AAE/D,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,KAAK,GAAG,OAAO,GAAG,UAAU,GACnC,YAAY,CAAC,KAAK,CAAC,GAAG,SAAS,CA+DjC;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,CAAC,GAAG,OAAO,EACxC,IAAI,EAAE,MAAM,EACZ,MAAM,GAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAoB,GAChD,CAAC,GAAG,SAAS,CAkCf;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAOrE;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EAAE,EACf,MAAM,EAAE,MAAM,EACd,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,OAAO,CAAA;CAAO,GACpC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,YAAY,CAAC,KAAK,CAAC,CAAA;CAAE,CAU9E;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EACtC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GACnC,OAAO,CAAC,aAAa,CAAC,CAgBxB"}
|
package/dist/lib/tool-helpers.js
CHANGED
|
@@ -6,52 +6,16 @@
|
|
|
6
6
|
* the formatted MCP result. The pieces here factor out the parts every
|
|
7
7
|
* tool repeats so each tool file can stay focused on its own logic.
|
|
8
8
|
*/
|
|
9
|
-
/**
|
|
10
|
-
* Matches the temp-file paths written by OpaCli.withTempSource and
|
|
11
|
-
* RegalCli.withTempSource when handling inline source. Both now use
|
|
12
|
-
* mkdtemp which produces a private directory; the file inside is always
|
|
13
|
-
* named input.rego. Matches both Unix (/) and Windows (\) separators.
|
|
14
|
-
*/
|
|
15
|
-
export const INLINE_TEMP_PATH_PATTERN = /orygn-(?:opa|regal)-mcp-[^/\\]+[/\\]input\.rego$/i;
|
|
16
|
-
/**
|
|
17
|
-
* Replace a file path that refers to one of our temp files with the
|
|
18
|
-
* sentinel string `<inline>`. Returns the original string unchanged when
|
|
19
|
-
* it does not match the pattern, so callers can unconditionally apply it
|
|
20
|
-
* to all location.file values regardless of whether inline source was used.
|
|
21
|
-
*/
|
|
22
|
-
export function sanitizeInlinePath(file) {
|
|
23
|
-
return INLINE_TEMP_PATH_PATTERN.test(file) ? '<inline>' : file;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Recursively rewrite every temp-file path -- in both string values and object
|
|
27
|
-
* keys -- to the `<inline>` sentinel. OPA writes inline source to a temp file,
|
|
28
|
-
* so trace (`explanation`), coverage, and profile output reference that path;
|
|
29
|
-
* this normalizes the whole structure so callers never see an absolute temp
|
|
30
|
-
* path. Only our own temp paths match the pattern, so real user file paths pass
|
|
31
|
-
* through untouched.
|
|
32
|
-
*/
|
|
33
|
-
export function sanitizeInlinePathsDeep(value) {
|
|
34
|
-
if (typeof value === 'string')
|
|
35
|
-
return sanitizeInlinePath(value);
|
|
36
|
-
if (Array.isArray(value))
|
|
37
|
-
return value.map(sanitizeInlinePathsDeep);
|
|
38
|
-
if (value !== null && typeof value === 'object') {
|
|
39
|
-
const out = {};
|
|
40
|
-
for (const [key, val] of Object.entries(value)) {
|
|
41
|
-
out[sanitizeInlinePath(key)] = sanitizeInlinePathsDeep(val);
|
|
42
|
-
}
|
|
43
|
-
return out;
|
|
44
|
-
}
|
|
45
|
-
return value;
|
|
46
|
-
}
|
|
47
9
|
import { err } from './errors.js';
|
|
48
10
|
import { logger } from './logger.js';
|
|
49
11
|
import { formatEnvelope } from './output.js';
|
|
50
12
|
import { validatePath } from './security.js';
|
|
13
|
+
export { INLINE_TEMP_PATH_PATTERN, sanitizeInlinePath, sanitizeInlinePathsDeep, sanitizeInlineText, } from './inline-paths.js';
|
|
51
14
|
/**
|
|
52
15
|
* Convert a subprocess outcome into a structured tool error envelope
|
|
53
|
-
* for the cases that are universal across all CLI-backed tools:
|
|
54
|
-
*
|
|
16
|
+
* for the cases that are universal across all CLI-backed tools: cancelled
|
|
17
|
+
* by the client, timed out, output over the capture cap, killed by a
|
|
18
|
+
* signal from outside the server, binary missing. Returns `undefined` when the
|
|
55
19
|
* subprocess exited normally (exitCode is a number) so the caller can
|
|
56
20
|
* inspect the result.
|
|
57
21
|
*/
|
|
@@ -80,6 +44,16 @@ export function mapSubprocessFailure(result, binary) {
|
|
|
80
44
|
details: { durationMs: result.durationMs },
|
|
81
45
|
});
|
|
82
46
|
}
|
|
47
|
+
// The server's own kills are handled above. A signal that reaches here came
|
|
48
|
+
// from outside it, most often the kernel's out-of-memory killer, and the
|
|
49
|
+
// binary is installed and was running; sending the user to reinstall it
|
|
50
|
+
// would be wrong.
|
|
51
|
+
if (result.exitCode === null && result.signal) {
|
|
52
|
+
return err('SUBPROCESS_KILLED', `${binary} was terminated by ${result.signal} before it finished.`, {
|
|
53
|
+
hint: 'The process was killed from outside the server, for example by the out-of-memory killer or a container limit. Check the host memory limits and system logs.',
|
|
54
|
+
details: { signal: result.signal, durationMs: result.durationMs },
|
|
55
|
+
});
|
|
56
|
+
}
|
|
83
57
|
if (result.exitCode === null) {
|
|
84
58
|
const code = binary === 'opa'
|
|
85
59
|
? 'OPA_BINARY_NOT_FOUND'
|
|
@@ -95,6 +69,58 @@ export function mapSubprocessFailure(result, binary) {
|
|
|
95
69
|
}
|
|
96
70
|
return undefined;
|
|
97
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Parse the last top-level JSON object in `text`, for a command that prints
|
|
74
|
+
* one document per run (`opa test --coverage --count N`). Strings are
|
|
75
|
+
* honoured, so a brace inside a file name does not end a document. Returns
|
|
76
|
+
* `undefined` when there is none. `accept` narrows it to the last object of
|
|
77
|
+
* the shape wanted, so trace text that happens to hold braces is skipped.
|
|
78
|
+
*/
|
|
79
|
+
export function lastJsonObject(text, accept = () => true) {
|
|
80
|
+
let depth = 0;
|
|
81
|
+
let inString = false;
|
|
82
|
+
let escaped = false;
|
|
83
|
+
let start = -1;
|
|
84
|
+
let last;
|
|
85
|
+
for (let i = 0; i < text.length; i++) {
|
|
86
|
+
const ch = text[i];
|
|
87
|
+
if (inString) {
|
|
88
|
+
if (escaped)
|
|
89
|
+
escaped = false;
|
|
90
|
+
else if (ch === '\\')
|
|
91
|
+
escaped = true;
|
|
92
|
+
else if (ch === '"')
|
|
93
|
+
inString = false;
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (ch === '"')
|
|
97
|
+
inString = true;
|
|
98
|
+
else if (ch === '{') {
|
|
99
|
+
if (depth === 0)
|
|
100
|
+
start = i;
|
|
101
|
+
depth++;
|
|
102
|
+
}
|
|
103
|
+
else if (ch === '}') {
|
|
104
|
+
// A stray closing brace must not put every later object out of reach.
|
|
105
|
+
if (depth > 0)
|
|
106
|
+
depth--;
|
|
107
|
+
if (depth === 0 && start !== -1) {
|
|
108
|
+
const candidate = tryParseJson(text.slice(start, i + 1));
|
|
109
|
+
if (candidate !== undefined && accept(candidate))
|
|
110
|
+
last = text.slice(start, i + 1);
|
|
111
|
+
start = -1;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (last === undefined)
|
|
116
|
+
return undefined;
|
|
117
|
+
try {
|
|
118
|
+
return JSON.parse(last);
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
return undefined;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
98
124
|
/**
|
|
99
125
|
* Try to parse `text` as JSON. Returns `undefined` on failure so the
|
|
100
126
|
* caller can fall back to a textual error envelope rather than throwing.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-helpers.js","sourceRoot":"","sources":["../../src/lib/tool-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"tool-helpers.js","sourceRoot":"","sources":["../../src/lib/tool-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,cAAc,EAAsB,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAI7C,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAmB,EACnB,MAAoC;IAEpC,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,GAAG,CAAC,WAAW,EAAE,6CAA6C,EAAE;YACrE,OAAO,EAAE,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE;SAC3C,CAAC,CAAC;IACL,CAAC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AM,EAAE,CAAC;QAC7C,CAAC;QACD,IAAI,MAAM,CAAC,QAAQ,KAAK,SAAS;YAAE,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AAChC,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAAc,EACd,IAAoC;IAEpC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,IAAI,EAAE,CAAC;QAC9B,OAAO,cAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAC3D,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,OAAO,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,2BAA2B,CAAC;QAC7E,4EAA4E;QAC5E,qEAAqE;QACrE,mEAAmE;QACnE,MAAM,CAAC,KAAK,CAAC,sBAAsB,EAAE;YACnC,OAAO;YACP,KAAK,EAAE,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;SAChD,CAAC,CAAC;QACH,MAAM,OAAO,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QAC9D,OAAO,cAAc,CAAC,GAAG,CAAC,eAAe,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAC7F,CAAC;AACH,CAAC"}
|
package/dist/prompts/index.js
CHANGED
|
@@ -58,7 +58,7 @@ Apply this checklist, calling tools as needed:
|
|
|
58
58
|
concern in a policy hot path.
|
|
59
59
|
6. **Annotations.** Check that exported rules have docstrings. If
|
|
60
60
|
missing, suggest minimal \`# METADATA\` annotations.
|
|
61
|
-
7. **Shape of input.** Use \`
|
|
61
|
+
7. **Shape of input.** Use \`rego_infer_input_schema\` to enumerate input
|
|
62
62
|
refs the policy reads; confirm the documented input contract
|
|
63
63
|
matches.
|
|
64
64
|
|
|
@@ -81,7 +81,7 @@ Workflow:
|
|
|
81
81
|
Identify which rules were evaluated and which fired.
|
|
82
82
|
4. The cause is one of:
|
|
83
83
|
a. **Input mismatch** -- the policy expected a different input shape.
|
|
84
|
-
Use \`
|
|
84
|
+
Use \`rego_infer_input_schema\` to list the refs the policy reads
|
|
85
85
|
and confirm each is present in the input.
|
|
86
86
|
b. **Rule logic** -- a guard fired or didn't fire when it should
|
|
87
87
|
have. Read the trace and explain which rule's body evaluated to
|
package/dist/resources/index.js
CHANGED
|
@@ -49,7 +49,7 @@ async function buildBuiltinsResource(opa) {
|
|
|
49
49
|
.filter((n) => typeof n === 'string' && SECURITY_SENSITIVE.has(n))
|
|
50
50
|
.sort();
|
|
51
51
|
return JSON.stringify({
|
|
52
|
-
version_note: 'Derived at read time from `opa capabilities --current
|
|
52
|
+
version_note: 'Derived at read time from `opa capabilities --current` of the opa binary this server resolved: OPA_BINARY, then PATH, then the bundled copy.',
|
|
53
53
|
builtin_count: caps.builtins?.length ?? 0,
|
|
54
54
|
categories: grouped,
|
|
55
55
|
future_keywords: caps.future_keywords ?? [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/resources/index.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAazC,SAAS,kBAAkB,CAAC,IAAuB;IACjD,MAAM,OAAO,GAA6B,EAAE,CAAC;IAC7C,KAAK,MAAM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,CACF,CAAC;IAEF,MAAM,CAAC,gBAAgB,CACrB,iBAAiB,EACjB,mBAAmB,EACnB;QACE,KAAK,EAAE,kBAAkB;QACzB,WAAW,EACT,0JAA0J;QAC5J,QAAQ,EAAE,eAAe;KAC1B,EACD,CAAC,GAAG,EAAE,EAAE,CACN,OAAO,CAAC,OAAO,CAAC;QACd,QAAQ,EAAE;YACR;gBACE,GAAG,EAAE,GAAG,CAAC,IAAI;gBACb,QAAQ,EAAE,eAAe;gBACzB,IAAI,EAAE,WAAW;aAClB;SACF;KACF,CAAC,CACL,CAAC;IAEF,MAAM,CAAC,gBAAgB,CACrB,cAAc,EACd,gBAAgB,EAChB;QACE,KAAK,EAAE,sBAAsB;QAC7B,WAAW,EACT,kMAAkM;QACpM,QAAQ,EAAE,eAAe;KAC1B,EACD,CAAC,GAAG,EAAE,EAAE,CACN,OAAO,CAAC,OAAO,CAAC;QACd,QAAQ,EAAE;YACR;gBACE,GAAG,EAAE,GAAG,CAAC,IAAI;gBACb,QAAQ,EAAE,eAAe;gBACzB,IAAI,EAAE,QAAQ;aACf;SACF;KACF,CAAC,CACL,CAAC;AACJ,CAAC"}
|
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* - A test
|
|
6
6
|
* - Common pitfalls
|
|
7
7
|
*/
|
|
8
|
-
export declare const PATTERNS = "# Rego pattern library\n\nCommon Rego patterns with working examples, tests, and pitfalls. Each\npattern is self-contained -- copy, adapt, and ship.\n\n---\n\n## 1. Role-based access control (RBAC)\n\n**When to use:** the simplest authorization model. Every user has one\nor more roles; each role grants a set of actions on a set of\nresources. Sufficient for ~80% of internal applications.\n\n```rego\npackage rbac\n\nimport rego.v1\n\ndefault allow := false\n\n# Permissions table -- extend as roles evolve.\npermissions := {\n \"admin\": {\"read\", \"write\", \"delete\", \"manage_users\"},\n \"editor\": {\"read\", \"write\"},\n \"viewer\": {\"read\"},\n}\n\nallow if {\n some role in input.user.roles\n input.action in permissions[role]\n}\n\n# Why was it denied? -- useful for audit logs.\ndeny_reasons contains reason if {\n not allow\n input.user\n reason := sprintf(\n \"user %q has roles %v, none grant %q\",\n [input.user.id, input.user.roles, input.action],\n )\n}\n\ndeny_reasons contains \"anonymous request\" if {\n not allow\n not input.user\n}\n```\n\n**Test:**\n\n```rego\npackage rbac_test\n\nimport rego.v1\nimport data.rbac\n\ntest_admin_can_delete if {\n rbac.allow with input as {\n \"user\": {\"id\": \"alice\", \"roles\": [\"admin\"]},\n \"action\": \"delete\",\n }\n}\n\ntest_viewer_cannot_delete if {\n not rbac.allow with input as {\n \"user\": {\"id\": \"bob\", \"roles\": [\"viewer\"]},\n \"action\": \"delete\",\n }\n}\n\ntest_anonymous_denied if {\n not rbac.allow with input as {\"action\": \"read\"}\n reasons := rbac.deny_reasons with input as {\"action\": \"read\"}\n \"anonymous request\" in reasons\n}\n```\n\n**Pitfalls:**\n- The `permissions` table grows unbounded. Move to data files\n (`data.permissions`) once you have more than ~20 roles.\n- Roles overlap with groups in real auth systems; map at the boundary\n rather than carrying both.\n\n---\n\n## 2. Attribute-based access control (ABAC)\n\n**When to use:** when \"who\" alone isn't enough -- decisions also depend\non resource attributes (ownership, tenant, sensitivity) and context\n(time of day, source IP).\n\n```rego\npackage abac\n\nimport rego.v1\n\ndefault allow := false\n\n# Don't show \"secret\" resources to anyone outside the owner's\n# organization, even admins.\n#\n# Written as a guard the permissive rules consult. A second rule\n# assigning `allow := false` is a conflict in Rego, not an override:\n# both rules produce a value for the same document and evaluation\n# fails with eval_conflict_error. Deny wins by being a precondition,\n# not by being written last.\nhidden_from_other_org if {\n input.resource.classification == \"secret\"\n input.resource.org_id != input.user.org_id\n}\n\n# A user can read any resource they own.\nallow if {\n input.action == \"read\"\n input.resource.owner_id == input.user.id\n not hidden_from_other_org\n}\n\n# A user can read shared resources at their organization.\nallow if {\n input.action == \"read\"\n input.resource.shared\n input.resource.org_id == input.user.org_id\n not hidden_from_other_org\n}\n\n# Admins can do anything within their organization.\nallow if {\n \"admin\" in input.user.roles\n input.resource.org_id == input.user.org_id\n not hidden_from_other_org\n}\n```\n\n**Test:**\n\n```rego\npackage abac_test\n\nimport rego.v1\nimport data.abac\n\ntest_owner_reads_own if {\n abac.allow with input as {\n \"action\": \"read\",\n \"user\": {\"id\": \"u1\", \"org_id\": \"o1\"},\n \"resource\": {\"owner_id\": \"u1\", \"org_id\": \"o1\"},\n }\n}\n\ntest_admin_blocked_from_secret_in_other_org if {\n not abac.allow with input as {\n \"action\": \"read\",\n \"user\": {\"id\": \"u1\", \"org_id\": \"o1\", \"roles\": [\"admin\"]},\n \"resource\": {\n \"owner_id\": \"u2\",\n \"org_id\": \"o2\",\n \"classification\": \"secret\",\n },\n }\n}\n```\n\n**Pitfalls:**\n- Multiple `allow` rules combine with logical OR. A later rule\n cannot override an earlier one by assigning a different value:\n two rules producing different values for the same document is an\n `eval_conflict_error` and evaluation fails. Express a denial as a\n condition the permissive rules must pass, as `hidden_from_other_org`\n does above.\n- Don't compute attributes inside the policy; compute them at the\n boundary and pass via `input`.\n\n---\n\n## 3. Kubernetes admission control\n\n**When to use:** validate or mutate Kubernetes resources at admission\ntime. Run as a Gatekeeper, OPA-as-a-webhook, or Kyverno-equivalent\npolicy layer.\n\n```rego\npackage k8s.admission\n\nimport rego.v1\n\n# Reject pods without resource limits.\ndeny contains msg if {\n input.request.kind.kind == \"Pod\"\n container := input.request.object.spec.containers[_]\n not container.resources.limits.memory\n msg := sprintf(\n \"Pod %q container %q is missing resources.limits.memory\",\n [input.request.object.metadata.name, container.name],\n )\n}\n\n# Reject privileged containers in production.\ndeny contains msg if {\n input.request.kind.kind == \"Pod\"\n input.request.namespace != \"kube-system\"\n container := input.request.object.spec.containers[_]\n container.securityContext.privileged == true\n msg := sprintf(\n \"privileged containers are not allowed: %q in %q\",\n [container.name, input.request.object.metadata.name],\n )\n}\n```\n\n**Pitfalls:**\n- Use `input.request.object` for the resource being admitted; the\n envelope shape comes from Kubernetes, not your control.\n- For mutations, return a JSON Patch via the `patch` field. Test\n patches with the actual admission webhook in dry-run mode before\n enforcing.\n- Iteration order is undefined; never rely on `containers[0]` to mean\n anything specific.\n\n---\n\n## 4. Infrastructure-as-Code gates (Terraform)\n\n**When to use:** validate Terraform plans before apply. Catch overly\npermissive IAM, public S3 buckets, missing encryption.\n\n```rego\npackage terraform\n\nimport rego.v1\n\n# Reject S3 buckets without server-side encryption.\ndeny contains msg if {\n resource := input.resource_changes[_]\n resource.type == \"aws_s3_bucket\"\n after := resource.change.after\n not after.server_side_encryption_configuration\n msg := sprintf(\n \"S3 bucket %q has no server-side encryption configured\",\n [resource.address],\n )\n}\n\n# Reject IAM policies with action \"*\" on resource \"*\".\n#\n# AWS accepts either a bare string or an array for Statement, Action\n# and Resource, so each is widened to a set before the wildcard test.\n# Testing the array form alone lets the most common admin policy of\n# all, {\"Action\": \"*\", \"Resource\": \"*\"}, through untouched.\nto_set(v) := {v} if is_string(v)\n\nto_set(v) := {x | some x in v} if is_array(v)\n\nstatements(policy) := to_set(policy.Statement) if is_array(policy.Statement)\n\nstatements(policy) := {policy.Statement} if is_object(policy.Statement)\n\ndeny contains msg if {\n resource := input.resource_changes[_]\n resource.type == \"aws_iam_policy\"\n policy := json.unmarshal(resource.change.after.policy)\n some statement in statements(policy)\n statement.Effect == \"Allow\"\n \"*\" in to_set(statement.Action)\n \"*\" in to_set(statement.Resource)\n msg := sprintf(\"IAM policy %q grants Allow * on *\", [resource.address])\n}\n```\n\n**Pitfalls:**\n- Terraform plan JSON is verbose and version-specific. Pin the\n `terraform plan -json` schema you target.\n- `resource_changes[_].change.after` may be `null` for destroys --\n guard against it.\n- IAM policy documents are string-or-array in several places. Match\n both, or a policy that grants everything slips through.\n- For wide-radius changes, use `opa exec --decision` against a plan\n file in CI, not the live API.\n\n---\n\n## 5. API authorization (HTTP request gating)\n\n**When to use:** at the API gateway / reverse proxy layer, validate\neach request against the caller's identity and the requested\nendpoint.\n\n```rego\npackage api.authz\n\nimport rego.v1\n\ndefault allow := false\n\n# Public endpoints -- no auth required.\npublic_endpoints := {\n {\"method\": \"GET\", \"path\": [\"health\"]},\n {\"method\": \"GET\", \"path\": [\"version\"]},\n}\n\nallow if {\n some endpoint in public_endpoints\n matches_endpoint(endpoint)\n}\n\n# Authenticated reads on resources the user has access to.\nallow if {\n input.method == \"GET\"\n input.user\n user_can_read(input.user, input.path)\n}\n\n# Authenticated writes only with specific scopes.\nallow if {\n input.method in {\"POST\", \"PUT\", \"PATCH\", \"DELETE\"}\n input.user\n \"write\" in input.user.scopes\n user_can_write(input.user, input.path)\n}\n\nmatches_endpoint(spec) if {\n spec.method == input.method\n spec.path == input.path\n}\n\nuser_can_read(user, path) if {\n path[0] == \"users\"\n user.id == path[1]\n}\n\nuser_can_write(user, path) if {\n path[0] == \"users\"\n user.id == path[1]\n}\n```\n\n**Pitfalls:**\n- `input.path` is typically an array (`[\"users\", \"alice\"]`), not a\n string. Build it consistently at the gateway.\n- Path-prefix matching is easy; full pattern matching is not. For\n parameterized routes, decode at the gateway and pass structured\n fields.\n\n---\n\n## 6. Rate limiting (with sliding window data)\n\n**When to use:** allow N requests per principal per window. Lightweight\nlimit enforcement; for high throughput, push to a dedicated rate\nlimiter.\n\n```rego\npackage rate\n\nimport rego.v1\n\n# Configuration: 100 requests per principal per 60-second window.\nlimit := 100\nwindow_seconds := 60\n\n# input.now is a unix timestamp in nanoseconds.\n# data.requests[principal] is an array of nanosecond timestamps.\n\ncurrent_window := requests if {\n requests := [t | some t in data.requests[input.principal]; t > input.now - window_seconds * 1000000000]\n}\n\n# Do not name this rule `count`: it would shadow the built-in of the same\n# name, and the call below would resolve to the rule instead.\nrequest_count := count(current_window)\n\nallow if request_count < limit\n\ndeny_reason := sprintf(\n \"rate limit exceeded: %d requests in last %d seconds (limit %d)\",\n [request_count, window_seconds, limit],\n) if not allow\n```\n\n**Pitfalls:**\n- `data.requests` grows unbounded unless the writer prunes outside the\n window. Schedule prune on every write.\n- This pattern is *advisory* -- under load, two concurrent decisions\n can both see `count == limit - 1` and both allow. For strict\n limits, use a Lua/Redis token bucket at the gateway and have OPA\n validate the token, not count requests.\n\n---\n\n## Where these patterns came from\n\nEach is distilled from production policy code. The full Rego files,\ntests, and policy data fixtures live in this server's GitHub\nrepository under `tests/fixtures/policies/`.\n\nFor more patterns, see:\n\n- OPA Playground: https://play.openpolicyagent.org/\n- Awesome OPA: https://github.com/anderseknert/awesome-opa\n- Styra DAS pattern library: https://docs.styra.com/das/policies\n";
|
|
8
|
+
export declare const PATTERNS = "# Rego pattern library\n\nCommon Rego patterns with working examples, tests, and pitfalls. Each\npattern is self-contained -- copy, adapt, and ship.\n\n---\n\n## 1. Role-based access control (RBAC)\n\n**When to use:** the simplest authorization model. Every user has one\nor more roles; each role grants a set of actions on a set of\nresources. Sufficient for ~80% of internal applications.\n\n```rego\npackage rbac\n\nimport rego.v1\n\ndefault allow := false\n\n# Permissions table -- extend as roles evolve.\npermissions := {\n \"admin\": {\"read\", \"write\", \"delete\", \"manage_users\"},\n \"editor\": {\"read\", \"write\"},\n \"viewer\": {\"read\"},\n}\n\nallow if {\n some role in input.user.roles\n input.action in permissions[role]\n}\n\n# Why was it denied? -- useful for audit logs.\ndeny_reasons contains reason if {\n not allow\n input.user\n reason := sprintf(\n \"user %q has roles %v, none grant %q\",\n [input.user.id, input.user.roles, input.action],\n )\n}\n\ndeny_reasons contains \"anonymous request\" if {\n not allow\n not input.user\n}\n```\n\n**Test:**\n\n```rego\npackage rbac_test\n\nimport rego.v1\nimport data.rbac\n\ntest_admin_can_delete if {\n rbac.allow with input as {\n \"user\": {\"id\": \"alice\", \"roles\": [\"admin\"]},\n \"action\": \"delete\",\n }\n}\n\ntest_viewer_cannot_delete if {\n not rbac.allow with input as {\n \"user\": {\"id\": \"bob\", \"roles\": [\"viewer\"]},\n \"action\": \"delete\",\n }\n}\n\ntest_anonymous_denied if {\n not rbac.allow with input as {\"action\": \"read\"}\n reasons := rbac.deny_reasons with input as {\"action\": \"read\"}\n \"anonymous request\" in reasons\n}\n```\n\n**Pitfalls:**\n- The `permissions` table grows unbounded. Move to data files\n (`data.permissions`) once you have more than ~20 roles.\n- Roles overlap with groups in real auth systems; map at the boundary\n rather than carrying both.\n\n---\n\n## 2. Attribute-based access control (ABAC)\n\n**When to use:** when \"who\" alone isn't enough -- decisions also depend\non resource attributes (ownership, tenant, sensitivity) and context\n(time of day, source IP).\n\n```rego\npackage abac\n\nimport rego.v1\n\ndefault allow := false\n\n# Don't show \"secret\" resources to anyone outside the owner's\n# organization, even admins.\n#\n# Written as a guard the permissive rules consult. A second rule\n# assigning `allow := false` is a conflict in Rego, not an override:\n# both rules produce a value for the same document and evaluation\n# fails with eval_conflict_error. Deny wins by being a precondition,\n# not by being written last.\nhidden_from_other_org if {\n input.resource.classification == \"secret\"\n input.resource.org_id != input.user.org_id\n}\n\n# A user can read any resource they own.\nallow if {\n input.action == \"read\"\n input.resource.owner_id == input.user.id\n not hidden_from_other_org\n}\n\n# A user can read shared resources at their organization.\nallow if {\n input.action == \"read\"\n input.resource.shared\n input.resource.org_id == input.user.org_id\n not hidden_from_other_org\n}\n\n# Admins can do anything within their organization.\nallow if {\n \"admin\" in input.user.roles\n input.resource.org_id == input.user.org_id\n not hidden_from_other_org\n}\n```\n\n**Test:**\n\n```rego\npackage abac_test\n\nimport rego.v1\nimport data.abac\n\ntest_owner_reads_own if {\n abac.allow with input as {\n \"action\": \"read\",\n \"user\": {\"id\": \"u1\", \"org_id\": \"o1\"},\n \"resource\": {\"owner_id\": \"u1\", \"org_id\": \"o1\"},\n }\n}\n\ntest_admin_blocked_from_secret_in_other_org if {\n not abac.allow with input as {\n \"action\": \"read\",\n \"user\": {\"id\": \"u1\", \"org_id\": \"o1\", \"roles\": [\"admin\"]},\n \"resource\": {\n \"owner_id\": \"u2\",\n \"org_id\": \"o2\",\n \"classification\": \"secret\",\n },\n }\n}\n```\n\n**Pitfalls:**\n- Multiple `allow` rules combine with logical OR. A later rule\n cannot override an earlier one by assigning a different value:\n two rules producing different values for the same document is an\n `eval_conflict_error` and evaluation fails. Express a denial as a\n condition the permissive rules must pass, as `hidden_from_other_org`\n does above.\n- Don't compute attributes inside the policy; compute them at the\n boundary and pass via `input`.\n\n---\n\n## 3. Kubernetes admission control\n\n**When to use:** validate or mutate Kubernetes resources at admission\ntime. Run as a Gatekeeper, OPA-as-a-webhook, or Kyverno-equivalent\npolicy layer.\n\n```rego\npackage k8s.admission\n\nimport rego.v1\n\n# Reject pods without resource limits.\ndeny contains msg if {\n input.request.kind.kind == \"Pod\"\n container := input.request.object.spec.containers[_]\n not container.resources.limits.memory\n msg := sprintf(\n \"Pod %q container %q is missing resources.limits.memory\",\n [input.request.object.metadata.name, container.name],\n )\n}\n\n# Reject privileged containers in production.\ndeny contains msg if {\n input.request.kind.kind == \"Pod\"\n input.request.namespace != \"kube-system\"\n container := input.request.object.spec.containers[_]\n container.securityContext.privileged == true\n msg := sprintf(\n \"privileged containers are not allowed: %q in %q\",\n [container.name, input.request.object.metadata.name],\n )\n}\n```\n\n**Pitfalls:**\n- Use `input.request.object` for the resource being admitted; the\n envelope shape comes from Kubernetes, not your control.\n- For mutations, return a JSON Patch via the `patch` field. Test\n patches with the actual admission webhook in dry-run mode before\n enforcing.\n- Iteration order is undefined; never rely on `containers[0]` to mean\n anything specific.\n\n---\n\n## 4. Infrastructure-as-Code gates (Terraform)\n\n**When to use:** validate Terraform plans before apply. Catch overly\npermissive IAM, public S3 buckets, missing encryption.\n\n```rego\npackage terraform\n\nimport rego.v1\n\n# Reject S3 buckets without server-side encryption.\ndeny contains msg if {\n resource := input.resource_changes[_]\n resource.type == \"aws_s3_bucket\"\n after := resource.change.after\n not after.server_side_encryption_configuration\n msg := sprintf(\n \"S3 bucket %q has no server-side encryption configured\",\n [resource.address],\n )\n}\n\n# Reject IAM policies with action \"*\" on resource \"*\".\n#\n# AWS accepts either a bare string or an array for Statement, Action\n# and Resource, so each is widened to a set before the wildcard test.\n# Testing the array form alone lets the most common admin policy of\n# all, {\"Action\": \"*\", \"Resource\": \"*\"}, through untouched.\nto_set(v) := {v} if is_string(v)\n\nto_set(v) := {x | some x in v} if is_array(v)\n\nstatements(policy) := to_set(policy.Statement) if is_array(policy.Statement)\n\nstatements(policy) := {policy.Statement} if is_object(policy.Statement)\n\ndeny contains msg if {\n resource := input.resource_changes[_]\n resource.type == \"aws_iam_policy\"\n policy := json.unmarshal(resource.change.after.policy)\n some statement in statements(policy)\n statement.Effect == \"Allow\"\n \"*\" in to_set(statement.Action)\n \"*\" in to_set(statement.Resource)\n msg := sprintf(\"IAM policy %q grants Allow * on *\", [resource.address])\n}\n```\n\n**Pitfalls:**\n- Terraform plan JSON is verbose and version-specific. Pin the\n `terraform plan -json` schema you target.\n- `resource_changes[_].change.after` may be `null` for destroys --\n guard against it.\n- IAM policy documents are string-or-array in several places. Match\n both, or a policy that grants everything slips through.\n- For wide-radius changes, use `opa exec --decision` against a plan\n file in CI, not the live API.\n\n---\n\n## 5. API authorization (HTTP request gating)\n\n**When to use:** at the API gateway / reverse proxy layer, validate\neach request against the caller's identity and the requested\nendpoint.\n\n```rego\npackage api.authz\n\nimport rego.v1\n\ndefault allow := false\n\n# Public endpoints -- no auth required.\npublic_endpoints := {\n {\"method\": \"GET\", \"path\": [\"health\"]},\n {\"method\": \"GET\", \"path\": [\"version\"]},\n}\n\nallow if {\n some endpoint in public_endpoints\n matches_endpoint(endpoint)\n}\n\n# Authenticated reads on resources the user has access to.\nallow if {\n input.method == \"GET\"\n input.user\n user_can_read(input.user, input.path)\n}\n\n# Authenticated writes only with specific scopes.\nallow if {\n input.method in {\"POST\", \"PUT\", \"PATCH\", \"DELETE\"}\n input.user\n \"write\" in input.user.scopes\n user_can_write(input.user, input.path)\n}\n\nmatches_endpoint(spec) if {\n spec.method == input.method\n spec.path == input.path\n}\n\nuser_can_read(user, path) if {\n path[0] == \"users\"\n user.id == path[1]\n}\n\nuser_can_write(user, path) if {\n path[0] == \"users\"\n user.id == path[1]\n}\n```\n\n**Pitfalls:**\n- `input.path` is typically an array (`[\"users\", \"alice\"]`), not a\n string. Build it consistently at the gateway.\n- Path-prefix matching is easy; full pattern matching is not. For\n parameterized routes, decode at the gateway and pass structured\n fields.\n\n---\n\n## 6. Rate limiting (with sliding window data)\n\n**When to use:** allow N requests per principal per window. Lightweight\nlimit enforcement; for high throughput, push to a dedicated rate\nlimiter.\n\n```rego\npackage rate\n\nimport rego.v1\n\n# Configuration: 100 requests per principal per 60-second window.\nlimit := 100\nwindow_seconds := 60\n\n# input.now is a unix timestamp in nanoseconds.\n# data.requests[principal] is an array of nanosecond timestamps.\n\ncurrent_window := requests if {\n requests := [t | some t in data.requests[input.principal]; t > input.now - window_seconds * 1000000000]\n}\n\n# Do not name this rule `count`: it would shadow the built-in of the same\n# name, and the call below would resolve to the rule instead.\nrequest_count := count(current_window)\n\nallow if request_count < limit\n\ndeny_reason := sprintf(\n \"rate limit exceeded: %d requests in last %d seconds (limit %d)\",\n [request_count, window_seconds, limit],\n) if not allow\n```\n\n**Pitfalls:**\n- `data.requests` grows unbounded unless the writer prunes outside the\n window. Schedule prune on every write.\n- This pattern is *advisory* -- under load, two concurrent decisions\n can both see `count == limit - 1` and both allow. For strict\n limits, use a Lua/Redis token bucket at the gateway and have OPA\n validate the token, not count requests.\n\n---\n\n## Where these patterns came from\n\nEach is distilled from production policy code, and this server's\nintegration tests evaluate every pattern against OPA.\n\nFor more patterns, see:\n\n- OPA Playground: https://play.openpolicyagent.org/\n- Awesome OPA: https://github.com/anderseknert/awesome-opa\n- Styra DAS pattern library: https://docs.styra.com/das/policies\n";
|
|
9
9
|
//# sourceMappingURL=patterns.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patterns.d.ts","sourceRoot":"","sources":["../../src/resources/patterns.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"patterns.d.ts","sourceRoot":"","sources":["../../src/resources/patterns.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,m/VA+YpB,CAAC"}
|
|
@@ -396,9 +396,8 @@ deny_reason := sprintf(
|
|
|
396
396
|
|
|
397
397
|
## Where these patterns came from
|
|
398
398
|
|
|
399
|
-
Each is distilled from production policy code
|
|
400
|
-
tests
|
|
401
|
-
repository under \`tests/fixtures/policies/\`.
|
|
399
|
+
Each is distilled from production policy code, and this server's
|
|
400
|
+
integration tests evaluate every pattern against OPA.
|
|
402
401
|
|
|
403
402
|
For more patterns, see:
|
|
404
403
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patterns.js","sourceRoot":"","sources":["../../src/resources/patterns.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG
|
|
1
|
+
{"version":3,"file":"patterns.js","sourceRoot":"","sources":["../../src/resources/patterns.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+YvB,CAAC"}
|
package/dist/server.d.ts
CHANGED
|
@@ -11,8 +11,8 @@ export { SERVER_NAME, SERVER_VERSION };
|
|
|
11
11
|
*/
|
|
12
12
|
export declare function buildServer(config: Config): McpServer;
|
|
13
13
|
/**
|
|
14
|
-
* Probe the configured `opa` and `
|
|
15
|
-
*
|
|
14
|
+
* Probe the configured `opa`, `regal` and `conftest` binaries at startup
|
|
15
|
+
* and log a warning for each that is unreachable. Runs in the background so it
|
|
16
16
|
* doesn't delay the MCP `initialize` handshake. Most users only see
|
|
17
17
|
* the failure when they call a tool; surfacing it early in the log
|
|
18
18
|
* file gives operators a place to look when diagnosing
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAaA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+CAA+C,CAAC;AAI/E,OAAO,EAAc,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAaA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+CAA+C,CAAC;AAI/E,OAAO,EAAc,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAa7D,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC;AAiBvC;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAuBrD;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA0CvE;AAED;;;;;;;GAOG;AACH,wBAAsB,IAAI,CAAC,SAAS,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CA4DpE"}
|
package/dist/server.js
CHANGED
|
@@ -20,6 +20,9 @@ import { getInstallId } from './lib/install-id.js';
|
|
|
20
20
|
import { ConftestCli } from './lib/conftest-cli.js';
|
|
21
21
|
import { OpaCli } from './lib/opa-cli.js';
|
|
22
22
|
import { RegalCli } from './lib/regal-cli.js';
|
|
23
|
+
import { isZ3Busy, isZ3Failure, markZ3Unusable, z3RecoveriesLeft } from './lib/rego-z3.js';
|
|
24
|
+
import { redactUrlCredentials } from './lib/opa-client.js';
|
|
25
|
+
import { terminateChildren } from './lib/subprocess.js';
|
|
23
26
|
import { registerPrompts } from './prompts/index.js';
|
|
24
27
|
import { registerResources } from './resources/index.js';
|
|
25
28
|
import { registerTools } from './tools/index.js';
|
|
@@ -49,7 +52,7 @@ export function buildServer(config) {
|
|
|
49
52
|
initLogger(config.logFile, config.logLevel);
|
|
50
53
|
logger.info('starting orygn-opa-mcp', {
|
|
51
54
|
version: SERVER_VERSION,
|
|
52
|
-
opaUrl: config.opaUrl,
|
|
55
|
+
opaUrl: redactUrlCredentials(config.opaUrl),
|
|
53
56
|
opaBinary: config.opaBinary,
|
|
54
57
|
regalBinary: config.regalBinary,
|
|
55
58
|
});
|
|
@@ -62,8 +65,8 @@ export function buildServer(config) {
|
|
|
62
65
|
return server;
|
|
63
66
|
}
|
|
64
67
|
/**
|
|
65
|
-
* Probe the configured `opa` and `
|
|
66
|
-
*
|
|
68
|
+
* Probe the configured `opa`, `regal` and `conftest` binaries at startup
|
|
69
|
+
* and log a warning for each that is unreachable. Runs in the background so it
|
|
67
70
|
* doesn't delay the MCP `initialize` handshake. Most users only see
|
|
68
71
|
* the failure when they call a tool; surfacing it early in the log
|
|
69
72
|
* file gives operators a place to look when diagnosing
|
|
@@ -91,9 +94,9 @@ export async function runStartupSelfCheck(config) {
|
|
|
91
94
|
logger.info('startup self-check: opa OK', { version: opaVersion });
|
|
92
95
|
}
|
|
93
96
|
if (regalVersion === null) {
|
|
94
|
-
logger.warn('startup self-check: regal binary not reachable; rego_lint will return REGAL_NOT_FOUND', {
|
|
97
|
+
logger.warn('startup self-check: regal binary not reachable; rego_lint, rego_security_audit and rego_fix will return REGAL_NOT_FOUND', {
|
|
95
98
|
regalBinary: config.regalBinary,
|
|
96
|
-
hint: 'set REGAL_BINARY to an absolute path, or ensure regal is on PATH. Regal is optional; only rego_lint
|
|
99
|
+
hint: 'set REGAL_BINARY to an absolute path, or ensure regal is on PATH. Regal is optional; only rego_lint, rego_security_audit and rego_fix require it.',
|
|
97
100
|
});
|
|
98
101
|
}
|
|
99
102
|
else {
|
|
@@ -125,6 +128,38 @@ export async function main(transport) {
|
|
|
125
128
|
if (!transport) {
|
|
126
129
|
process.stderr.write(formatStartupBanner(config, process.stderr.isTTY === true) + '\n');
|
|
127
130
|
}
|
|
131
|
+
// A child sits in its own process group (see lib/subprocess.ts), so a
|
|
132
|
+
// signal that stops the server does not reach it by itself. Not when a
|
|
133
|
+
// test drives the server through its own transport: the runner owns the
|
|
134
|
+
// signals then.
|
|
135
|
+
if (!transport) {
|
|
136
|
+
for (const sig of ['SIGINT', 'SIGTERM']) {
|
|
137
|
+
process.once(sig, () => {
|
|
138
|
+
terminateChildren('SIGTERM');
|
|
139
|
+
process.exit(sig === 'SIGINT' ? 130 : 143);
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
// Z3 lives in a WASM heap that, exhausted, aborts outside every
|
|
143
|
+
// try/catch. Verification is the only thing on that heap, so give it up
|
|
144
|
+
// and keep the server rather than the reverse. Anything else uncaught is
|
|
145
|
+
// a bug the process must not paper over.
|
|
146
|
+
process.on('uncaughtException', (e) => {
|
|
147
|
+
const detail = e instanceof Error ? e.message : String(e);
|
|
148
|
+
// Only a WASM fault while a solve is running is Z3's; anything else
|
|
149
|
+
// that happens to land in that window is a bug of its own.
|
|
150
|
+
if (isZ3Busy() && isZ3Failure(e)) {
|
|
151
|
+
markZ3Unusable(detail);
|
|
152
|
+
logger.error(z3RecoveriesLeft() > 0
|
|
153
|
+
? 'Z3 faulted outside a try/catch; the solve in flight is retried on a fresh Z3'
|
|
154
|
+
: 'Z3 faulted outside a try/catch and no recoveries remain; rego_verify is disabled until restart', { error: detail, recoveriesLeft: z3RecoveriesLeft() });
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
logger.error('uncaught exception', {
|
|
158
|
+
error: e instanceof Error ? (e.stack ?? detail) : detail,
|
|
159
|
+
});
|
|
160
|
+
process.exit(1);
|
|
161
|
+
});
|
|
162
|
+
}
|
|
128
163
|
const connectTo = transport ?? new StdioServerTransport();
|
|
129
164
|
await server.connect(connectTo);
|
|
130
165
|
logger.info('connected to transport, ready for requests');
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AACA;;;;;;;;GAQG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAGjF,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExF,OAAO,EAAE,UAAU,EAAe,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE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C,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -2,12 +2,16 @@ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
|
2
2
|
import type { Config } from '../../config.js';
|
|
3
3
|
export interface RegoCapabilitiesOutput {
|
|
4
4
|
builtins?: unknown[];
|
|
5
|
+
/** How many of the names in a `builtins` filter were found. */
|
|
6
|
+
matched?: number;
|
|
5
7
|
builtin_names?: string[];
|
|
6
8
|
builtin_count?: number;
|
|
7
9
|
future_keywords?: unknown[];
|
|
8
10
|
features?: unknown[];
|
|
9
11
|
wasm_abi_versions?: unknown[];
|
|
10
12
|
versions?: string[];
|
|
13
|
+
/** Names asked for through `builtins` that the capabilities do not hold. */
|
|
14
|
+
missing?: string[];
|
|
11
15
|
}
|
|
12
16
|
export declare function registerRegoCapabilities(server: McpServer, config: Config): void;
|
|
13
17
|
//# sourceMappingURL=capabilities.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../../../src/tools/authoring/capabilities.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../../../src/tools/authoring/capabilities.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAkC9C,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IACrB,+DAA+D;IAC/D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,OAAO,EAAE,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IACrB,iBAAiB,CAAC,EAAE,OAAO,EAAE,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAmHhF"}
|
|
@@ -21,14 +21,19 @@ const RegoCapabilitiesInput = {
|
|
|
21
21
|
names_only: z
|
|
22
22
|
.boolean()
|
|
23
23
|
.optional()
|
|
24
|
-
.default(
|
|
25
|
-
|
|
24
|
+
.describe('When true, or omitted, return only builtin names, count, future keywords, and features. The full payload for every builtin is larger than the default response cap (OPA_MCP_MAX_RESPONSE_BYTES), so `names_only: false` on its own needs that cap raised; use `builtins` to get full records for a few names instead.'),
|
|
25
|
+
builtins: z
|
|
26
|
+
.array(z.string().min(1))
|
|
27
|
+
.min(1)
|
|
28
|
+
.max(100)
|
|
29
|
+
.optional()
|
|
30
|
+
.describe('Return the full record (type signature, documentation, metadata) for up to 100 builtin names, exact matches only. `matched` counts the records returned and names not found are listed under `missing`. When the records would not fit the response cap the tool returns OUTPUT_TOO_LARGE rather than a truncated result; ask for fewer names. Do not combine with `names_only: true`, which asks for the opposite.'),
|
|
26
31
|
};
|
|
27
32
|
export function registerRegoCapabilities(server, config) {
|
|
28
33
|
const opa = new OpaCli(config);
|
|
29
34
|
server.registerTool('rego_capabilities', {
|
|
30
35
|
title: 'OPA capabilities',
|
|
31
|
-
description: 'Return OPA capabilities -- the available builtins, future keywords, features, and WASM ABI versions. With `current: true`, returns the running OPA\'s capabilities. With `version: "v1.19.0"`, returns those of a specific version. With neither, lists available named versions. By default (`names_only: true`), returns only builtin names and count to stay within response size limits
|
|
36
|
+
description: 'Return OPA capabilities -- the available builtins, future keywords, features, and WASM ABI versions. With `current: true`, returns the running OPA\'s capabilities. With `version: "v1.19.0"`, returns those of a specific version. With neither, lists available named versions. By default (`names_only: true`), returns only builtin names and count to stay within response size limits. Pass `builtins: [...]` for the full type signatures and documentation of a few named builtins; `names_only: false` returns every full record, which needs OPA_MCP_MAX_RESPONSE_BYTES raised above its default.',
|
|
32
37
|
inputSchema: RegoCapabilitiesInput,
|
|
33
38
|
annotations: {
|
|
34
39
|
readOnlyHint: true,
|
|
@@ -36,11 +41,19 @@ export function registerRegoCapabilities(server, config) {
|
|
|
36
41
|
idempotentHint: true,
|
|
37
42
|
openWorldHint: false,
|
|
38
43
|
},
|
|
39
|
-
}, async ({ current, version, names_only }, { signal }) => {
|
|
44
|
+
}, async ({ current, version, names_only, builtins }, { signal }) => {
|
|
40
45
|
return withToolEnvelope(config, async () => {
|
|
41
46
|
if (current && version) {
|
|
42
47
|
return err('INVALID_INPUT', 'rego_capabilities accepts at most one of `current` or `version`.');
|
|
43
48
|
}
|
|
49
|
+
if (names_only === true && builtins !== undefined) {
|
|
50
|
+
return err('INVALID_INPUT', 'rego_capabilities: `names_only: true` asks for names alone and `builtins` asks for full records; pass one or the other.');
|
|
51
|
+
}
|
|
52
|
+
// The schema bounds the filter; the handler does too, before opa is
|
|
53
|
+
// run, since a unit harness may call it directly.
|
|
54
|
+
if (builtins !== undefined && (builtins.length === 0 || builtins.length > 100)) {
|
|
55
|
+
return err('INVALID_INPUT', '`builtins` takes between 1 and 100 names.');
|
|
56
|
+
}
|
|
44
57
|
const result = await opa.capabilities({ current, version }, signal);
|
|
45
58
|
const subprocessFailure = mapSubprocessFailure(result, 'opa');
|
|
46
59
|
if (subprocessFailure)
|
|
@@ -61,6 +74,30 @@ export function registerRegoCapabilities(server, config) {
|
|
|
61
74
|
details: { stdout: trimmed },
|
|
62
75
|
});
|
|
63
76
|
}
|
|
77
|
+
// A handful of full records fits the cap where the whole payload does
|
|
78
|
+
// not; this is the way to read a builtin's signature and docs.
|
|
79
|
+
if (builtins !== undefined && builtins.length > 0) {
|
|
80
|
+
const wanted = new Set(builtins);
|
|
81
|
+
const records = (parsed.builtins ?? []).filter((b) => wanted.has(b.name ?? ''));
|
|
82
|
+
const found = new Set(records.map((b) => b.name));
|
|
83
|
+
const missing = builtins.filter((n) => !found.has(n));
|
|
84
|
+
const data = {
|
|
85
|
+
builtins: records,
|
|
86
|
+
matched: records.length,
|
|
87
|
+
...(missing.length > 0 ? { missing } : {}),
|
|
88
|
+
};
|
|
89
|
+
// A count cannot promise a size: the largest records run past 2 KB
|
|
90
|
+
// each, so a hundred of those exceed the default cap. Measure the
|
|
91
|
+
// envelope as it will be sent and refuse rather than truncate.
|
|
92
|
+
const bytes = Buffer.byteLength(JSON.stringify(ok(data), null, 2), 'utf8');
|
|
93
|
+
if (bytes > config.maxResponseBytes) {
|
|
94
|
+
return err('OUTPUT_TOO_LARGE', `The full records for these ${records.length} builtins serialise to ${bytes} bytes, above the ${config.maxResponseBytes}-byte response cap.`, {
|
|
95
|
+
hint: 'Ask for fewer names, or raise OPA_MCP_MAX_RESPONSE_BYTES.',
|
|
96
|
+
details: { matched: records.length, bytes, cap: config.maxResponseBytes },
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
return ok(data);
|
|
100
|
+
}
|
|
64
101
|
// names_only defaults to true; treat undefined as true so the default
|
|
65
102
|
// applies even when the MCP SDK's schema validation is bypassed.
|
|
66
103
|
if (names_only !== false) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../../../src/tools/authoring/capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,gBA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AAE,CAAuB,CAAC,IAAI,CAAC;qBACzC,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC;gBACrD,OAAO,EAAE,CAAyB;oBAChC,aAAa;oBACb,aAAa,EAAE,aAAa,CAAC,MAAM;oBACnC,eAAe,EAAE,MAAM,CAAC,eAAe;oBACvC,QAAQ,EAAE,MAAM,CAAC,QAAQ;oBACzB,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;iBAC5C,CAAC,CAAC;YACL,CAAC;YAED,OAAO,EAAE,CAAyB,MAAM,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;IACL,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -15,6 +15,12 @@ export interface RegoCheckSchemaOutput {
|
|
|
15
15
|
/** Structured diagnostics. Empty when `valid` is true. */
|
|
16
16
|
errors: CheckErrorRecord[];
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Whether the source carries a `# METADATA` comment block with a `schemas:`
|
|
20
|
+
* entry, the one way opa reads a schema directory: each entry names a file
|
|
21
|
+
* in it for a path in `input` or `data`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function declaresSchemas(source: string): boolean;
|
|
18
24
|
export declare function registerRegoCheckSchema(server: McpServer, config: Config): void;
|
|
19
25
|
export {};
|
|
20
26
|
//# sourceMappingURL=check-schema.d.ts.map
|