Expand description
Safe script generation for package manager operations.
This module provides the core script generation functionality that makes Santa secure by default. Instead of directly executing potentially dangerous commands, Santa generates platform-specific scripts that can be reviewed before execution.
§Architecture
ScriptGenerator: MiniJinja-based template engine for script generationExecutionMode: Safe (script generation) vs Execute (direct execution)ScriptFormat: Platform-specific script formats (Shell, PowerShell, Batch)
§Security
All user inputs are sanitized using:
- Shell escaping via
shell-escapecrate - PowerShell escaping with custom filters
- Package name validation
- Template-based command construction
§Examples
use santa::script_generator::{ScriptGenerator, ScriptFormat};
let generator = ScriptGenerator::new()?;
let packages = vec!["git".to_string(), "rust".to_string()];
// Generate a safe shell script
let script = generator.generate_install_script(
&packages,
"brew",
ScriptFormat::Shell,
"homebrew"
)?;
// Script can now be reviewed and executed manually
println!("{}", script);Structs§
- Script
Generator - Script generator using MiniJinja templates for safe script generation.
Enums§
- Execution
Mode - Execution modes for Santa - determines whether to execute directly or generate scripts.
- Script
Format - Script formats for different platforms and shells.