@vybestack/llxprt-code-policy 0.10.0-nightly.260613.1adad3b34
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/dist/.last_build +0 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/src/config.d.ts +25 -0
- package/dist/src/config.js +119 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/confirmation-bus/index.d.ts +2 -0
- package/dist/src/confirmation-bus/index.js +3 -0
- package/dist/src/confirmation-bus/index.js.map +1 -0
- package/dist/src/confirmation-bus/message-bus.d.ts +29 -0
- package/dist/src/confirmation-bus/message-bus.js +143 -0
- package/dist/src/confirmation-bus/message-bus.js.map +1 -0
- package/dist/src/confirmation-bus/types.d.ts +180 -0
- package/dist/src/confirmation-bus/types.js +37 -0
- package/dist/src/confirmation-bus/types.js.map +1 -0
- package/dist/src/index.d.ts +11 -0
- package/dist/src/index.js +8 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/policies/discovered.toml +9 -0
- package/dist/src/policies/read-only.toml +96 -0
- package/dist/src/policies/write.toml +101 -0
- package/dist/src/policies/yolo.toml +10 -0
- package/dist/src/policy-engine.d.ts +72 -0
- package/dist/src/policy-engine.js +236 -0
- package/dist/src/policy-engine.js.map +1 -0
- package/dist/src/stable-stringify.d.ts +29 -0
- package/dist/src/stable-stringify.js +137 -0
- package/dist/src/stable-stringify.js.map +1 -0
- package/dist/src/toml-loader.d.ts +48 -0
- package/dist/src/toml-loader.js +453 -0
- package/dist/src/toml-loader.js.map +1 -0
- package/dist/src/types.d.ts +80 -0
- package/dist/src/types.js +18 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/utils/shell-utils.d.ts +30 -0
- package/dist/src/utils/shell-utils.js +118 -0
- package/dist/src/utils/shell-utils.js.map +1 -0
- package/dist/src/utils.d.ts +26 -0
- package/dist/src/utils.js +68 -0
- package/dist/src/utils.js.map +1 -0
- package/package.json +52 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provides deterministic JSON stringification for pattern matching in policy rules.
|
|
3
|
+
* Ensures consistent ordering of object keys and handling of special values.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Stringifies primitive values (null, undefined, boolean, number, string, function, symbol).
|
|
7
|
+
* Returns undefined if the value is not a primitive (i.e., is an object).
|
|
8
|
+
*/
|
|
9
|
+
function stringifyPrimitive(val) {
|
|
10
|
+
if (val === null)
|
|
11
|
+
return 'null';
|
|
12
|
+
if (val === undefined)
|
|
13
|
+
return 'null';
|
|
14
|
+
if (typeof val === 'boolean')
|
|
15
|
+
return String(val);
|
|
16
|
+
if (typeof val === 'number') {
|
|
17
|
+
if (!Number.isFinite(val))
|
|
18
|
+
return 'null';
|
|
19
|
+
return String(val);
|
|
20
|
+
}
|
|
21
|
+
if (typeof val === 'string') {
|
|
22
|
+
return JSON.stringify(val);
|
|
23
|
+
}
|
|
24
|
+
// Handle functions and symbols
|
|
25
|
+
if (typeof val === 'function' || typeof val === 'symbol') {
|
|
26
|
+
return 'null';
|
|
27
|
+
}
|
|
28
|
+
// Not a primitive - caller should handle as object
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Computes the indent string from a space parameter.
|
|
33
|
+
*/
|
|
34
|
+
function getIndentString(space) {
|
|
35
|
+
if (typeof space === 'number') {
|
|
36
|
+
return ' '.repeat(Math.min(10, Math.max(0, Math.floor(space))));
|
|
37
|
+
}
|
|
38
|
+
return String(space).slice(0, 10);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Stringifies an array with deterministic formatting.
|
|
42
|
+
*/
|
|
43
|
+
function stringifyArray(val, space, indent, currentDepth, stringify) {
|
|
44
|
+
const items = [];
|
|
45
|
+
const useSpace = Boolean(space);
|
|
46
|
+
const nextIndent = useSpace ? indent + getIndentString(space) : '';
|
|
47
|
+
const separator = useSpace ? '\n' : '';
|
|
48
|
+
for (let i = 0; i < val.length; i++) {
|
|
49
|
+
const item = stringify(val[i], nextIndent, currentDepth + 1);
|
|
50
|
+
items.push(useSpace ? `${nextIndent}${item}` : item);
|
|
51
|
+
}
|
|
52
|
+
if (items.length === 0) {
|
|
53
|
+
return '[]';
|
|
54
|
+
}
|
|
55
|
+
return useSpace
|
|
56
|
+
? `[${separator}${items.join(`,${separator}`)}${separator}${indent}]`
|
|
57
|
+
: `[${items.join(',')}]`;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Stringifies an object with sorted keys and deterministic formatting.
|
|
61
|
+
*/
|
|
62
|
+
function stringifyObject(val, space, indent, currentDepth, stringify) {
|
|
63
|
+
const keys = Object.keys(val).sort();
|
|
64
|
+
const pairs = [];
|
|
65
|
+
const useSpace = Boolean(space);
|
|
66
|
+
const nextIndent = useSpace ? indent + getIndentString(space) : '';
|
|
67
|
+
const separator = useSpace ? '\n' : '';
|
|
68
|
+
for (const key of keys) {
|
|
69
|
+
const value = val[key];
|
|
70
|
+
if (value !== undefined) {
|
|
71
|
+
const stringifiedKey = JSON.stringify(key);
|
|
72
|
+
const stringifiedValue = stringify(value, nextIndent, currentDepth + 1);
|
|
73
|
+
const pair = useSpace
|
|
74
|
+
? `${nextIndent}${stringifiedKey}: ${stringifiedValue}`
|
|
75
|
+
: `${stringifiedKey}:${stringifiedValue}`;
|
|
76
|
+
pairs.push(pair);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (pairs.length === 0) {
|
|
80
|
+
return '{}';
|
|
81
|
+
}
|
|
82
|
+
return useSpace
|
|
83
|
+
? `{${separator}${pairs.join(`,${separator}`)}${separator}${indent}}`
|
|
84
|
+
: `{${pairs.join(',')}}`;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Deterministically stringifies a value for use in pattern matching.
|
|
88
|
+
* - Object keys are sorted alphabetically
|
|
89
|
+
* - Arrays maintain their order
|
|
90
|
+
* - undefined values are omitted
|
|
91
|
+
* - Functions and symbols are converted to null
|
|
92
|
+
* - Circular references throw an error
|
|
93
|
+
*
|
|
94
|
+
* @param value - The value to stringify
|
|
95
|
+
* @param space - Optional spacing for readability (default: none)
|
|
96
|
+
* @returns Deterministic JSON string
|
|
97
|
+
*/
|
|
98
|
+
export function stableStringify(value, space) {
|
|
99
|
+
const seen = new WeakSet();
|
|
100
|
+
function stringify(val, indent, currentDepth) {
|
|
101
|
+
const primitive = stringifyPrimitive(val);
|
|
102
|
+
if (primitive !== undefined) {
|
|
103
|
+
return primitive;
|
|
104
|
+
}
|
|
105
|
+
// Handle objects and arrays
|
|
106
|
+
if (typeof val === 'object' && val !== null) {
|
|
107
|
+
// Circular reference check
|
|
108
|
+
if (seen.has(val)) {
|
|
109
|
+
throw new TypeError('Converting circular structure to JSON');
|
|
110
|
+
}
|
|
111
|
+
seen.add(val);
|
|
112
|
+
try {
|
|
113
|
+
if (Array.isArray(val)) {
|
|
114
|
+
return stringifyArray(val, space, indent, currentDepth, stringify);
|
|
115
|
+
}
|
|
116
|
+
return stringifyObject(val, space, indent, currentDepth, stringify);
|
|
117
|
+
}
|
|
118
|
+
finally {
|
|
119
|
+
seen.delete(val);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// Fallback for unknown types
|
|
123
|
+
return 'null';
|
|
124
|
+
}
|
|
125
|
+
return stringify(value, '', 0);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Parses a stable-stringified JSON string back into a value.
|
|
129
|
+
* This is just a wrapper around JSON.parse for consistency.
|
|
130
|
+
*
|
|
131
|
+
* @param text - The JSON string to parse
|
|
132
|
+
* @returns Parsed value
|
|
133
|
+
*/
|
|
134
|
+
export function stableParse(text) {
|
|
135
|
+
return JSON.parse(text);
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=stable-stringify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stable-stringify.js","sourceRoot":"","sources":["../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CAAC;QAC1C,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC5B,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,4BAA4B;QAC5B,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YAC5C,2BAA2B;YAC3B,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBAClB,MAAM,IAAI,SAAS,CAAC,uCAAuC,CAAC,CAAC;YAC/D,CAAC;YACD,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAEd,IAAI,CAAC;gBACH,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;oBACvB,OAAO,cAAc,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;gBACrE,CAAC;gBACD,OAAO,eAAe,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;YACtE,CAAC;oBAAS,CAAC;gBACT,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACnB,CAAC;QACH,CAAC;QAED,6BAA6B;QAC7B,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO,SAAS,CAAC,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;AACjC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAc,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Vybestack LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { type PolicyRule, type ApprovalMode } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Types of errors that can occur while loading policy files.
|
|
9
|
+
*/
|
|
10
|
+
export type PolicyFileErrorType = 'file_read' | 'toml_parse' | 'schema_validation' | 'rule_validation' | 'regex_compilation';
|
|
11
|
+
/**
|
|
12
|
+
* Detailed error information for policy file loading failures.
|
|
13
|
+
*/
|
|
14
|
+
export interface PolicyFileError {
|
|
15
|
+
filePath: string;
|
|
16
|
+
fileName: string;
|
|
17
|
+
tier: 'default' | 'user' | 'admin';
|
|
18
|
+
ruleIndex?: number;
|
|
19
|
+
errorType: PolicyFileErrorType;
|
|
20
|
+
message: string;
|
|
21
|
+
details?: string;
|
|
22
|
+
suggestion?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Result of loading policies from TOML files.
|
|
26
|
+
*/
|
|
27
|
+
export interface PolicyLoadResult {
|
|
28
|
+
rules: PolicyRule[];
|
|
29
|
+
errors: PolicyFileError[];
|
|
30
|
+
}
|
|
31
|
+
export declare function loadPoliciesFromToml(approvalMode: ApprovalMode, policyDirs: string[], getPolicyTier: (dir: string) => number): Promise<PolicyLoadResult>;
|
|
32
|
+
/**
|
|
33
|
+
* Loads policies from a single TOML file.
|
|
34
|
+
* Simplified loader for test use cases that validates priorities and throws on errors.
|
|
35
|
+
*
|
|
36
|
+
* @param filePath Path to the TOML file
|
|
37
|
+
* @param tier Optional tier (defaults to 1 for default tier)
|
|
38
|
+
* @returns Array of PolicyRule objects
|
|
39
|
+
* @throws Error if TOML parsing fails, schema validation fails, or priority is invalid
|
|
40
|
+
*/
|
|
41
|
+
export declare function loadPolicyFromToml(filePath: string, tier?: number): Promise<PolicyRule[]>;
|
|
42
|
+
/**
|
|
43
|
+
* Loads default policies from the built-in policies directory.
|
|
44
|
+
* Uses the ApprovalMode.DEFAULT mode filter.
|
|
45
|
+
*
|
|
46
|
+
* @returns Array of PolicyRule objects from all default TOML files
|
|
47
|
+
*/
|
|
48
|
+
export declare function loadDefaultPolicies(): Promise<PolicyRule[]>;
|
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Vybestack LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { PolicyDecision } from './types.js';
|
|
7
|
+
import fs from 'node:fs/promises';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import { fileURLToPath } from 'node:url';
|
|
10
|
+
import toml from '@iarna/toml';
|
|
11
|
+
import { z } from 'zod';
|
|
12
|
+
import { buildArgsPatterns, escapeRegex, validatePolicyRegex, } from './utils.js';
|
|
13
|
+
/**
|
|
14
|
+
* Schema for a single policy rule in the TOML file (before transformation).
|
|
15
|
+
*/
|
|
16
|
+
const PolicyRuleSchema = z.object({
|
|
17
|
+
toolName: z.union([z.string(), z.array(z.string())]).optional(),
|
|
18
|
+
mcpName: z.string().optional(),
|
|
19
|
+
argsPattern: z.string().optional(),
|
|
20
|
+
commandPrefix: z.union([z.string(), z.array(z.string())]).optional(),
|
|
21
|
+
commandRegex: z.string().optional(),
|
|
22
|
+
decision: z.nativeEnum(PolicyDecision),
|
|
23
|
+
// Priority must be in range [0, 999] to prevent tier overflow.
|
|
24
|
+
// With tier transformation (tier + priority/1000), this ensures:
|
|
25
|
+
// - Tier 1 (default): range [1.000, 1.999]
|
|
26
|
+
// - Tier 2 (user): range [2.000, 2.999]
|
|
27
|
+
// - Tier 3 (admin): range [3.000, 3.999]
|
|
28
|
+
priority: z
|
|
29
|
+
.number({
|
|
30
|
+
required_error: 'priority is required',
|
|
31
|
+
invalid_type_error: 'priority must be a number',
|
|
32
|
+
})
|
|
33
|
+
.int({ message: 'priority must be an integer' })
|
|
34
|
+
.min(0, { message: 'priority must be >= 0' })
|
|
35
|
+
.max(999, {
|
|
36
|
+
message: 'priority must be <= 999 to prevent tier overflow. Priorities >= 1000 would jump to the next tier.',
|
|
37
|
+
}),
|
|
38
|
+
modes: z.array(z.string()).optional(),
|
|
39
|
+
allowRedirection: z.boolean().optional(),
|
|
40
|
+
});
|
|
41
|
+
/**
|
|
42
|
+
* Schema for the entire policy TOML file.
|
|
43
|
+
*/
|
|
44
|
+
const PolicyFileSchema = z.object({
|
|
45
|
+
rule: z.array(PolicyRuleSchema),
|
|
46
|
+
});
|
|
47
|
+
/**
|
|
48
|
+
* Converts a tier number to a human-readable tier name.
|
|
49
|
+
*/
|
|
50
|
+
function getTierName(tier) {
|
|
51
|
+
if (tier === 1)
|
|
52
|
+
return 'default';
|
|
53
|
+
if (tier === 2)
|
|
54
|
+
return 'user';
|
|
55
|
+
if (tier === 3)
|
|
56
|
+
return 'admin';
|
|
57
|
+
return 'default';
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Formats a Zod validation error into a readable error message.
|
|
61
|
+
*/
|
|
62
|
+
function formatSchemaError(error, ruleIndex) {
|
|
63
|
+
const issues = error.issues
|
|
64
|
+
.map((issue) => {
|
|
65
|
+
const path = issue.path.join('.');
|
|
66
|
+
return ` - Field "${path}": ${issue.message}`;
|
|
67
|
+
})
|
|
68
|
+
.join('\n');
|
|
69
|
+
return `Invalid policy rule (rule #${ruleIndex + 1}):\n${issues}`;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Validates shell command convenience syntax rules.
|
|
73
|
+
* Returns an error message if invalid, or null if valid.
|
|
74
|
+
*/
|
|
75
|
+
function validateShellCommandSyntax(rule, ruleIndex) {
|
|
76
|
+
const hasCommandPrefix = rule.commandPrefix !== undefined;
|
|
77
|
+
const hasCommandRegex = rule.commandRegex !== undefined;
|
|
78
|
+
const hasArgsPattern = rule.argsPattern !== undefined;
|
|
79
|
+
if (hasCommandPrefix || hasCommandRegex) {
|
|
80
|
+
// Must have exactly toolName = "run_shell_command"
|
|
81
|
+
if (rule.toolName !== 'run_shell_command' || Array.isArray(rule.toolName)) {
|
|
82
|
+
return (`Rule #${ruleIndex + 1}: commandPrefix and commandRegex can only be used with toolName = "run_shell_command"\n` +
|
|
83
|
+
` Found: toolName = ${JSON.stringify(rule.toolName)}\n` +
|
|
84
|
+
` Fix: Set toolName = "run_shell_command" (not an array)`);
|
|
85
|
+
}
|
|
86
|
+
// Can't combine with argsPattern
|
|
87
|
+
if (hasArgsPattern) {
|
|
88
|
+
return (`Rule #${ruleIndex + 1}: cannot use both commandPrefix/commandRegex and argsPattern\n` +
|
|
89
|
+
` These fields are mutually exclusive\n` +
|
|
90
|
+
` Fix: Use either commandPrefix/commandRegex OR argsPattern, not both`);
|
|
91
|
+
}
|
|
92
|
+
// Can't use both commandPrefix and commandRegex
|
|
93
|
+
if (hasCommandPrefix && hasCommandRegex) {
|
|
94
|
+
return (`Rule #${ruleIndex + 1}: cannot use both commandPrefix and commandRegex\n` +
|
|
95
|
+
` These fields are mutually exclusive\n` +
|
|
96
|
+
` Fix: Use either commandPrefix OR commandRegex, not both`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Transforms a priority number based on the policy tier.
|
|
103
|
+
* Formula: tier + priority/1000
|
|
104
|
+
*
|
|
105
|
+
* @param priority The priority value from the TOML file
|
|
106
|
+
* @param tier The tier (1=default, 2=user, 3=admin)
|
|
107
|
+
* @returns The transformed priority
|
|
108
|
+
*/
|
|
109
|
+
function transformPriority(priority, tier) {
|
|
110
|
+
return tier + priority / 1000;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Loads and parses policies from TOML files in the specified directories.
|
|
114
|
+
*
|
|
115
|
+
* This function:
|
|
116
|
+
* 1. Scans directories for .toml files
|
|
117
|
+
* 2. Parses and validates each file
|
|
118
|
+
* 3. Transforms rules (commandPrefix, arrays, mcpName, priorities)
|
|
119
|
+
* 4. Filters rules by approval mode
|
|
120
|
+
* 5. Collects detailed error information for any failures
|
|
121
|
+
*
|
|
122
|
+
* @param approvalMode The current approval mode (for filtering rules by mode)
|
|
123
|
+
* @param policyDirs Array of directory paths to scan for policy files
|
|
124
|
+
* @param getPolicyTier Function to determine tier (1-3) for a directory
|
|
125
|
+
* @returns Object containing successfully parsed rules and any errors encountered
|
|
126
|
+
*/
|
|
127
|
+
/** Parses a single TOML file, validates, and returns parsed data or pushes errors. */
|
|
128
|
+
async function parseAndValidateTomlFile(filePath, file, tierName, errors) {
|
|
129
|
+
// Read file
|
|
130
|
+
const fileContent = await fs.readFile(filePath, 'utf-8');
|
|
131
|
+
// Parse TOML
|
|
132
|
+
let parsed;
|
|
133
|
+
try {
|
|
134
|
+
parsed = toml.parse(fileContent);
|
|
135
|
+
}
|
|
136
|
+
catch (e) {
|
|
137
|
+
const error = e;
|
|
138
|
+
errors.push({
|
|
139
|
+
filePath,
|
|
140
|
+
fileName: file,
|
|
141
|
+
tier: tierName,
|
|
142
|
+
errorType: 'toml_parse',
|
|
143
|
+
message: 'TOML parsing failed',
|
|
144
|
+
details: error.message,
|
|
145
|
+
suggestion: 'Check for syntax errors like missing quotes, brackets, or commas',
|
|
146
|
+
});
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
// Validate schema
|
|
150
|
+
const validationResult = PolicyFileSchema.safeParse(parsed);
|
|
151
|
+
if (!validationResult.success) {
|
|
152
|
+
errors.push({
|
|
153
|
+
filePath,
|
|
154
|
+
fileName: file,
|
|
155
|
+
tier: tierName,
|
|
156
|
+
errorType: 'schema_validation',
|
|
157
|
+
message: 'Schema validation failed',
|
|
158
|
+
details: formatSchemaError(validationResult.error, 0),
|
|
159
|
+
suggestion: 'Ensure all required fields (decision, priority) are present with correct types',
|
|
160
|
+
});
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
// Validate shell command convenience syntax
|
|
164
|
+
for (let i = 0; i < validationResult.data.rule.length; i++) {
|
|
165
|
+
const rule = validationResult.data.rule[i];
|
|
166
|
+
const validationError = validateShellCommandSyntax(rule, i);
|
|
167
|
+
if (validationError) {
|
|
168
|
+
errors.push({
|
|
169
|
+
filePath,
|
|
170
|
+
fileName: file,
|
|
171
|
+
tier: tierName,
|
|
172
|
+
ruleIndex: i,
|
|
173
|
+
errorType: 'rule_validation',
|
|
174
|
+
message: 'Invalid shell command syntax',
|
|
175
|
+
details: validationError,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return validationResult.data;
|
|
180
|
+
}
|
|
181
|
+
/** Builds a regex-compilation error entry for push into the errors array. */
|
|
182
|
+
function buildRegexError(filePath, file, tierName, patternDesc, errorMessage) {
|
|
183
|
+
return {
|
|
184
|
+
filePath,
|
|
185
|
+
fileName: file,
|
|
186
|
+
tier: tierName,
|
|
187
|
+
errorType: 'regex_compilation',
|
|
188
|
+
message: 'Invalid regex pattern',
|
|
189
|
+
details: `Pattern: ${patternDesc}\nError: ${errorMessage}`,
|
|
190
|
+
suggestion: 'Check regex syntax for errors like unmatched brackets or invalid escape sequences',
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
/** Resolves argsPattern regex and built patterns for a single rule, returning [] on error. */
|
|
194
|
+
function resolveRulePatterns(rule, filePath, file, tierName, errors) {
|
|
195
|
+
let argsPatternRegex;
|
|
196
|
+
if (rule.argsPattern) {
|
|
197
|
+
try {
|
|
198
|
+
validatePolicyRegex(rule.argsPattern);
|
|
199
|
+
argsPatternRegex = new RegExp(rule.argsPattern);
|
|
200
|
+
}
|
|
201
|
+
catch (e) {
|
|
202
|
+
const error = e;
|
|
203
|
+
errors.push(buildRegexError(filePath, file, tierName, rule.argsPattern, error.message));
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
try {
|
|
208
|
+
return buildArgsPatterns(argsPatternRegex, rule.commandPrefix, rule.commandRegex);
|
|
209
|
+
}
|
|
210
|
+
catch (e) {
|
|
211
|
+
const error = e;
|
|
212
|
+
const patternStr =
|
|
213
|
+
// eslint-disable-next-line sonarjs/expression-complexity -- Existing structure is intentionally preserved; refactoring this boundary is outside the lint slice.
|
|
214
|
+
(typeof rule.commandRegex === 'string' && rule.commandRegex !== ''
|
|
215
|
+
? rule.commandRegex
|
|
216
|
+
: '') ||
|
|
217
|
+
(typeof rule.commandPrefix === 'string' && rule.commandPrefix !== ''
|
|
218
|
+
? rule.commandPrefix
|
|
219
|
+
: '') ||
|
|
220
|
+
'unknown';
|
|
221
|
+
errors.push(buildRegexError(filePath, file, tierName, patternStr, error.message));
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
/** Expands a single validated rule into PolicyRule objects, handling toolName/mcpName arrays. */
|
|
226
|
+
function expandRuleToPolicyRules(rule, tier, tierName, file, patterns) {
|
|
227
|
+
const argsPatterns = patterns.length > 0 ? patterns : [undefined];
|
|
228
|
+
return argsPatterns.flatMap((argsPattern) => {
|
|
229
|
+
const toolNames = rule.toolName !== undefined
|
|
230
|
+
? // eslint-disable-next-line sonarjs/no-nested-conditional -- Existing structure is intentionally preserved; refactoring this boundary is outside the lint slice.
|
|
231
|
+
Array.isArray(rule.toolName)
|
|
232
|
+
? rule.toolName
|
|
233
|
+
: [rule.toolName]
|
|
234
|
+
: [undefined];
|
|
235
|
+
return toolNames.map((toolName) => {
|
|
236
|
+
const hasMcpName = rule.mcpName !== undefined && rule.mcpName !== '';
|
|
237
|
+
const hasToolName = toolName !== undefined && toolName !== '';
|
|
238
|
+
let effectiveToolName;
|
|
239
|
+
if (hasMcpName && hasToolName) {
|
|
240
|
+
effectiveToolName = `${rule.mcpName}__${toolName}`;
|
|
241
|
+
}
|
|
242
|
+
else if (hasMcpName) {
|
|
243
|
+
effectiveToolName = `${rule.mcpName}__*`;
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
effectiveToolName = toolName;
|
|
247
|
+
}
|
|
248
|
+
return {
|
|
249
|
+
toolName: effectiveToolName,
|
|
250
|
+
decision: rule.decision,
|
|
251
|
+
priority: transformPriority(rule.priority, tier),
|
|
252
|
+
argsPattern,
|
|
253
|
+
allowRedirection: rule.allowRedirection,
|
|
254
|
+
source: `${tierName.charAt(0).toUpperCase() + tierName.slice(1)}: ${file}`,
|
|
255
|
+
};
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
/** Transforms validated TOML rules into PolicyRule[], filtering by approval mode and handling errors. */
|
|
260
|
+
function transformTomlRules(data, approvalMode, tier, tierName, filePath, file, errors) {
|
|
261
|
+
return data.rule
|
|
262
|
+
.filter((rule) => {
|
|
263
|
+
if (!rule.modes || rule.modes.length === 0) {
|
|
264
|
+
return true;
|
|
265
|
+
}
|
|
266
|
+
return rule.modes.includes(approvalMode);
|
|
267
|
+
})
|
|
268
|
+
.flatMap((rule) => {
|
|
269
|
+
const patterns = resolveRulePatterns(rule, filePath, file, tierName, errors);
|
|
270
|
+
if (!patterns) {
|
|
271
|
+
return [];
|
|
272
|
+
}
|
|
273
|
+
return expandRuleToPolicyRules(rule, tier, tierName, file, patterns);
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
/** Scans a directory for .toml files, returning names or pushing a read error. */
|
|
277
|
+
async function scanTomlDir(dir, tierName, errors) {
|
|
278
|
+
try {
|
|
279
|
+
const dirEntries = await fs.readdir(dir, { withFileTypes: true });
|
|
280
|
+
return dirEntries
|
|
281
|
+
.filter((entry) => entry.isFile() && entry.name.endsWith('.toml'))
|
|
282
|
+
.map((entry) => entry.name);
|
|
283
|
+
}
|
|
284
|
+
catch (e) {
|
|
285
|
+
const error = e;
|
|
286
|
+
if (error.code === 'ENOENT') {
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
errors.push({
|
|
290
|
+
filePath: dir,
|
|
291
|
+
fileName: path.basename(dir),
|
|
292
|
+
tier: tierName,
|
|
293
|
+
errorType: 'file_read',
|
|
294
|
+
message: `Failed to read policy directory`,
|
|
295
|
+
details: error.message,
|
|
296
|
+
});
|
|
297
|
+
return null;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
/** Processes a single .toml file: parse, validate, transform, and push rules. */
|
|
301
|
+
async function processTomlFile(file, dir, approvalMode, tier, tierName, rules, errors) {
|
|
302
|
+
const filePath = path.join(dir, file);
|
|
303
|
+
try {
|
|
304
|
+
const data = await parseAndValidateTomlFile(filePath, file, tierName, errors);
|
|
305
|
+
if (!data) {
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
const parsedRules = transformTomlRules(data, approvalMode, tier, tierName, filePath, file, errors);
|
|
309
|
+
rules.push(...parsedRules);
|
|
310
|
+
}
|
|
311
|
+
catch (e) {
|
|
312
|
+
const error = e;
|
|
313
|
+
if (error.code !== 'ENOENT') {
|
|
314
|
+
errors.push({
|
|
315
|
+
filePath,
|
|
316
|
+
fileName: file,
|
|
317
|
+
tier: tierName,
|
|
318
|
+
errorType: 'file_read',
|
|
319
|
+
message: 'Failed to read policy file',
|
|
320
|
+
details: error.message,
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
export async function loadPoliciesFromToml(approvalMode, policyDirs, getPolicyTier) {
|
|
326
|
+
const rules = [];
|
|
327
|
+
const errors = [];
|
|
328
|
+
for (const dir of policyDirs) {
|
|
329
|
+
const tier = getPolicyTier(dir);
|
|
330
|
+
const tierName = getTierName(tier);
|
|
331
|
+
const filesToLoad = await scanTomlDir(dir, tierName, errors);
|
|
332
|
+
if (!filesToLoad) {
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
335
|
+
for (const file of filesToLoad) {
|
|
336
|
+
await processTomlFile(file, dir, approvalMode, tier, tierName, rules, errors);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
return { rules, errors };
|
|
340
|
+
}
|
|
341
|
+
/** Expands a single TOML rule into PolicyRule objects (command prefix/regex, toolName arrays, mcpName). */
|
|
342
|
+
function expandTomlRule(rule, tier, _tierName, filePath, _file, _errors) {
|
|
343
|
+
// Transform commandPrefix/commandRegex to argsPattern
|
|
344
|
+
let effectiveArgsPattern = rule.argsPattern;
|
|
345
|
+
const commandPrefixes = [];
|
|
346
|
+
const hasCommandPrefix = rule.commandPrefix !== undefined &&
|
|
347
|
+
(!Array.isArray(rule.commandPrefix) || rule.commandPrefix.length > 0) &&
|
|
348
|
+
rule.commandPrefix !== '';
|
|
349
|
+
const hasCommandRegex = rule.commandRegex !== undefined && rule.commandRegex !== '';
|
|
350
|
+
if (hasCommandPrefix) {
|
|
351
|
+
const prefixes = Array.isArray(rule.commandPrefix)
|
|
352
|
+
? rule.commandPrefix
|
|
353
|
+
: // eslint-disable-next-line sonarjs/no-nested-conditional -- Existing structure is intentionally preserved; refactoring this boundary is outside the lint slice.
|
|
354
|
+
rule.commandPrefix !== undefined
|
|
355
|
+
? [rule.commandPrefix]
|
|
356
|
+
: [];
|
|
357
|
+
commandPrefixes.push(...prefixes);
|
|
358
|
+
}
|
|
359
|
+
else if (hasCommandRegex) {
|
|
360
|
+
effectiveArgsPattern = `"command":"${rule.commandRegex}`;
|
|
361
|
+
}
|
|
362
|
+
// Expand command prefixes to multiple patterns
|
|
363
|
+
const argsPatterns = commandPrefixes.length > 0
|
|
364
|
+
? commandPrefixes.map((prefix) => '"command":"' + escapeRegex(prefix) + String.raw `(?:[\s"]|$)`)
|
|
365
|
+
: [effectiveArgsPattern];
|
|
366
|
+
// For each argsPattern, expand toolName arrays
|
|
367
|
+
return argsPatterns.flatMap((argsPattern) => {
|
|
368
|
+
const toolNames = rule.toolName !== undefined
|
|
369
|
+
? // eslint-disable-next-line sonarjs/no-nested-conditional -- Existing structure is intentionally preserved; refactoring this boundary is outside the lint slice.
|
|
370
|
+
Array.isArray(rule.toolName)
|
|
371
|
+
? rule.toolName
|
|
372
|
+
: [rule.toolName]
|
|
373
|
+
: [undefined];
|
|
374
|
+
// Create a policy rule for each tool name
|
|
375
|
+
return toolNames.map((toolName) => {
|
|
376
|
+
const hasMcpName = rule.mcpName !== undefined && rule.mcpName !== '';
|
|
377
|
+
const hasToolName = toolName !== undefined && toolName !== '';
|
|
378
|
+
let effectiveToolName;
|
|
379
|
+
if (hasMcpName && hasToolName) {
|
|
380
|
+
effectiveToolName = `${rule.mcpName}__${toolName}`;
|
|
381
|
+
}
|
|
382
|
+
else if (hasMcpName) {
|
|
383
|
+
effectiveToolName = `${rule.mcpName}__*`;
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
effectiveToolName = toolName;
|
|
387
|
+
}
|
|
388
|
+
const policyRule = {
|
|
389
|
+
toolName: effectiveToolName,
|
|
390
|
+
decision: rule.decision,
|
|
391
|
+
priority: transformPriority(rule.priority, tier),
|
|
392
|
+
source: `Policy: ${path.basename(filePath)}`,
|
|
393
|
+
};
|
|
394
|
+
// Compile regex pattern
|
|
395
|
+
if (argsPattern) {
|
|
396
|
+
validatePolicyRegex(argsPattern);
|
|
397
|
+
policyRule.argsPattern = new RegExp(argsPattern);
|
|
398
|
+
}
|
|
399
|
+
return policyRule;
|
|
400
|
+
});
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Loads policies from a single TOML file.
|
|
405
|
+
* Simplified loader for test use cases that validates priorities and throws on errors.
|
|
406
|
+
*
|
|
407
|
+
* @param filePath Path to the TOML file
|
|
408
|
+
* @param tier Optional tier (defaults to 1 for default tier)
|
|
409
|
+
* @returns Array of PolicyRule objects
|
|
410
|
+
* @throws Error if TOML parsing fails, schema validation fails, or priority is invalid
|
|
411
|
+
*/
|
|
412
|
+
export async function loadPolicyFromToml(filePath, tier = 1) {
|
|
413
|
+
const fileContent = await fs.readFile(filePath, 'utf-8');
|
|
414
|
+
// Parse TOML
|
|
415
|
+
const parsed = toml.parse(fileContent);
|
|
416
|
+
// Validate schema
|
|
417
|
+
const validationResult = PolicyFileSchema.safeParse(parsed);
|
|
418
|
+
if (!validationResult.success) {
|
|
419
|
+
throw new Error(formatSchemaError(validationResult.error, 0));
|
|
420
|
+
}
|
|
421
|
+
// Validate priorities are within valid range
|
|
422
|
+
for (let i = 0; i < validationResult.data.rule.length; i++) {
|
|
423
|
+
const rule = validationResult.data.rule[i];
|
|
424
|
+
// Since schema already validates 0-999, we only need to check for explicit
|
|
425
|
+
// transformed priorities that are out of range (e.g., 5.0 in raw TOML)
|
|
426
|
+
// The schema enforces priority to be an integer 0-999, so non-integer
|
|
427
|
+
// values like 5.0 or 2.0 in the test need special handling.
|
|
428
|
+
// Check if the rule's priority would result in a value outside its tier band
|
|
429
|
+
const transformedPriority = transformPriority(rule.priority, tier);
|
|
430
|
+
const maxTierPriority = tier + 0.999;
|
|
431
|
+
if (transformedPriority > maxTierPriority) {
|
|
432
|
+
throw new Error(`Invalid priority: ${rule.priority} in rule #${i + 1}. ` +
|
|
433
|
+
`Priority must be <= 999 to stay within tier ${tier} (max ${maxTierPriority.toFixed(3)}).`);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
const tierName = getTierName(tier);
|
|
437
|
+
const rules = validationResult.data.rule.flatMap((rule) => expandTomlRule(rule, tier, tierName, filePath, path.basename(filePath), []));
|
|
438
|
+
return rules;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Loads default policies from the built-in policies directory.
|
|
442
|
+
* Uses the ApprovalMode.DEFAULT mode filter.
|
|
443
|
+
*
|
|
444
|
+
* @returns Array of PolicyRule objects from all default TOML files
|
|
445
|
+
*/
|
|
446
|
+
export async function loadDefaultPolicies() {
|
|
447
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
448
|
+
const __dirname = path.dirname(__filename);
|
|
449
|
+
const policiesDir = path.join(__dirname, 'policies');
|
|
450
|
+
const { rules } = await loadPoliciesFromToml('default', [policiesDir], () => 1);
|
|
451
|
+
return rules;
|
|
452
|
+
}
|
|
453
|
+
//# sourceMappingURL=toml-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toml-loader.js","sourceRoot":"","sources":["../../src/toml-loader.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAmB,cAAc,EAAqB,MAAM,YAAY,CAAC;AAChF,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC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