Skip to main content

is_valid_cache_key

Function is_valid_cache_key 

Source
pub fn is_valid_cache_key(s: &str) -> bool
Expand description

Is s a well-formed cache key: exactly 64 lowercase hex chars, matching the blake3::Hash::to_hex() output produced by cache-key recipes?

Cache keys that arrive from an untrusted source — a prefetch planner response or an S3 bucket listing — get interpolated into local filesystem paths (store_dir().join(cache_key)) and S3 object keys. An unvalidated value like ../../../home/user/.config is a path-traversal / prefix-escape primitive (PathBuf::join walks up on .. and resets on an absolute component). Callers must reject such keys, never sanitize them.