feat: enhance subagent context with abort flag and implement tool call timeout
This commit is contained in:
@@ -78,9 +78,20 @@ impl Session {
|
||||
|
||||
/// Load a session's metadata by id from `<base_dir>/sessions/<id>/session.json`.
|
||||
///
|
||||
/// Security: the session id is validated to prevent directory traversal
|
||||
/// (e.g. `../../etc/passwd`). Only alphanumeric, hyphens, underscores,
|
||||
/// and dots are allowed — no path separators.
|
||||
///
|
||||
/// Return: the parsed `Session`, or an `io::Error` if the file is
|
||||
/// missing or malformed.
|
||||
pub fn load(id: &str, base_dir: &Path) -> std::io::Result<Self> {
|
||||
// Reject session ids that contain path separators or parent dir refs
|
||||
if id.contains('/') || id.contains('\\') || id.contains("..") {
|
||||
return Err(std::io::Error::new(
|
||||
std::io::ErrorKind::InvalidInput,
|
||||
format!("invalid session id '{}': must not contain path separators", id),
|
||||
));
|
||||
}
|
||||
let path = base_dir.join("sessions").join(id).join("session.json");
|
||||
let data = std::fs::read_to_string(path)?;
|
||||
let session: Session = serde_json::from_str(&data)?;
|
||||
|
||||
Reference in New Issue
Block a user