Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions cortex-cli/src/run_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,19 @@ impl RunCli {
format!("Failed to read file metadata: {}", resolved_path.display())
})?;

if !metadata.is_file() && !metadata.is_dir() {
bail!(
"File is not a regular file or directory: {}",
file_path.display()
);
}

// Max file size check (e.g. 10MB) to prevent OOM
const MAX_FILE_SIZE: u64 = 10 * 1024 * 1024;
if metadata.len() > MAX_FILE_SIZE {
bail!("File too large (max 10MB): {}", file_path.display());
}

let filename = resolved_path
.file_name()
.map(|n| n.to_string_lossy().to_string())
Expand Down
Loading