docs: fix inconsistent commandRegex example in policy engine (#19027)

This commit is contained in:
N. Taylor Mullen
2026-02-13 12:02:07 -08:00
committed by GitHub
parent e844a57bfc
commit c2f62b2a2b
2 changed files with 22 additions and 2 deletions

View File

@@ -111,6 +111,24 @@ priority = 100
expect(result.errors).toHaveLength(0);
});
it('should NOT match if ^ is used in commandRegex because it matches against full JSON', async () => {
const result = await runLoadPoliciesFromToml(`
[[rule]]
toolName = "run_shell_command"
commandRegex = "^git status"
decision = "allow"
priority = 100
`);
expect(result.rules).toHaveLength(1);
// The generated pattern is "command":"^git status
// This will NOT match '{"command":"git status"}' because of the '{"' at the start.
expect(
result.rules[0].argsPattern?.test('{"command":"git status"}'),
).toBe(false);
expect(result.errors).toHaveLength(0);
});
it('should expand toolName array', async () => {
const result = await runLoadPoliciesFromToml(`
[[rule]]