Skip to main content

Module sanitize

Module sanitize 

Source
Expand description

Path and input sanitization for ai-contexters.

Follows the established pattern: traversal check → canonicalize → allowlist validation.

Prevents path traversal and command injection from user-supplied inputs (CLI arguments, project names, agent names).

Vibecrafted with AI Agents by VetCoders (c)2026 VetCoders

Functions§

create_file_validated
Create or truncate a file only after validating the write path.
filter_self_echo
Filter a vec of timeline entries, removing self-echo messages.
is_self_echo
Returns true if a message is aicx operational self-echo that should be filtered from extraction to prevent feedback loops.
normalize_query
Normalize text for fuzzy matching: lowercase + strip Polish diacritics.
open_file_validated
Open a file for reading only after validating the path.
read_dir_validated
Read a directory only after validating it as an allowed directory path.
read_to_string_validated
Read a UTF-8 text file only after validating the path.
safe_agent_name
Validate an agent name against the allowlist.
safe_project_name
Sanitize a project name used in filesystem paths.
validate_dir_path
Sanitize a directory path used for reading (e.g., chunks_dir, contexts_dir).
validate_read_path
Sanitize and validate a path that must exist (for reading).
validate_write_path
Sanitize and validate a path for writing (may not exist yet).