Skip to main content

evaluate_path

Function evaluate_path 

Source
pub fn evaluate_path(
    rules: &RuleSet,
    kind: PathKind,
    path: &str,
    default: Decision,
) -> Decision
Expand description

Evaluate a single resolved path against rules, as either a "read" or "write" pseudo-tool (module 11’s “path rules”: read/write globs — see RuleSet’s doc comment). Falls back to default when nothing matches.

SECURITY (CRITICAL fix, guarantor audit): this function does NO normalization, canonicalization, or symlink resolution of path — it is a pure glob-match against whatever string it is handed. A caller that feeds it a raw, unvalidated model-supplied path argument directly is vulnerable to a traversal bypass: write_file path="x/../.git/config" does not literally glob-match a .git/** protected-path rule as a raw string, even though it resolves right back onto the real .git/config. Any caller evaluating a model-supplied tool path argument against rules MUST go through evaluate_path_safe instead, which resolves path (lexically AND symlink-following) against the project root before calling this function — never call evaluate_path directly on untrusted input. This function itself remains a simple, pure, single-subject matcher (used internally, multiple times, by evaluate_path_safe) — callers that already have a KNOWN-safe subject (e.g. one of evaluate_path_safe’s own resolved forms, or a test’s literal clean path) may still call it directly.