safe_output_path

Function safe_output_path 

Source
pub fn safe_output_path(
    base_dir: &Path,
    name: &str,
    extension: &str,
) -> CliResult<PathBuf>
Expand description

Validates and sanitizes a filename, then constructs a safe output path.

This is a convenience function that combines sanitize_filename and validate_output_path with automatic .json extension.

§Security

This function performs all necessary security validations.

§Arguments

  • base_dir - The base directory for output files
  • name - The filename to sanitize (e.g., tool name)
  • extension - The file extension to add (e.g., “json”)

§Returns

A validated, safe output path.