soma_codemode/git/
safety.rs1use crate::ToolError;
2
3pub fn validate_ref(value: &str) -> Result<(), ToolError> {
4 if value.is_empty()
5 || value.starts_with('-')
6 || value.contains("..")
7 || value.contains('\\')
8 || value.chars().any(char::is_whitespace)
9 {
10 return Err(ToolError::InvalidParam {
11 message: "unsafe git ref".to_string(),
12 param: "ref".to_string(),
13 });
14 }
15 Ok(())
16}
17
18pub fn safe_git_env() -> Vec<(&'static str, &'static str)> {
19 vec![
20 ("GIT_TERMINAL_PROMPT", "0"),
21 ("GIT_CONFIG_NOSYSTEM", "1"),
22 ("GIT_PROTOCOL_FROM_USER", "0"),
23 ]
24}