Skip to content

Debugging

The runok check command evaluates rules and reports what action would be taken, without executing the command. This is the quickest way to test whether your rules work as expected.

Terminal window
runok check -- git status

Example output:

allow

Add --verbose to see detailed rule matching information:

Terminal window
runok check --verbose -- git status
[verbose] Evaluating command: "git status"
[verbose] Rule matched: allow 'git *' (matched tokens: ["status"])
[verbose] Evaluation result: Allow
allow

When no rule matches:

Terminal window
runok check --verbose -- rm -rf /
[verbose] Evaluating command: "rm -rf /"
[verbose] No rules matched
[verbose] No matching rule, using default behavior
no match

For compound commands (commands joined with &&, ||, ;, or |), verbose output shows each sub-command individually:

Terminal window
runok check --verbose -- 'git add . && git commit -m fix'
[verbose] Compound command detected (2 sub-commands)
[verbose] sub-command 1: "git add ."
[verbose] sub-command 2: "git commit -m 'fix'"
[verbose] Compound evaluation result: Allow
allow

You can also pipe commands via stdin:

Terminal window
echo "curl -X POST https://example.com" | runok check

The --dry-run flag on runok exec provides similar functionality, prefixed with runok: dry-run::

Terminal window
runok exec --dry-run -- curl -X POST https://example.com
runok: dry-run: command would be allowed

runok check is generally more convenient for debugging, as it is designed specifically for this purpose. Use exec --dry-run when you want to verify behavior in the exact same invocation style as production usage.

The --verbose flag also works with runok exec for debugging in production-like scenarios:

Terminal window
runok exec --verbose -- git push --force

This prints the rule matching details to stderr while also executing the command.