mirror of
https://github.com/aljazceru/goose.git
synced 2025-12-19 07:04:21 +01:00
allow to use dev/null for no-session mode (#3176)
This commit is contained in:
@@ -158,6 +158,14 @@ pub fn get_path(id: Identifier) -> Result<PathBuf> {
|
|||||||
session_dir.join(format!("{}.jsonl", name))
|
session_dir.join(format!("{}.jsonl", name))
|
||||||
}
|
}
|
||||||
Identifier::Path(path) => {
|
Identifier::Path(path) => {
|
||||||
|
// Allow special paths for no-session mode
|
||||||
|
if let Some(path_str) = path.to_str() {
|
||||||
|
if path_str == "/dev/null" || path_str == "NUL" {
|
||||||
|
// These are special paths used for --no-session mode
|
||||||
|
return Ok(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// In test mode, allow temporary directory paths
|
// In test mode, allow temporary directory paths
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
{
|
{
|
||||||
@@ -190,10 +198,14 @@ pub fn get_path(id: Identifier) -> Result<PathBuf> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Additional security check for file extension
|
// Additional security check for file extension (skip for special no-session paths)
|
||||||
if let Some(ext) = path.extension() {
|
if let Some(path_str) = path.to_str() {
|
||||||
if ext != "jsonl" {
|
if path_str != "/dev/null" && path_str != "NUL" {
|
||||||
return Err(anyhow::anyhow!("Invalid file extension"));
|
if let Some(ext) = path.extension() {
|
||||||
|
if ext != "jsonl" {
|
||||||
|
return Err(anyhow::anyhow!("Invalid file extension"));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user