Expand description
Secure file operation utilities
This module provides safe file operations that protect against common security issues like symlink attacks and hard link manipulation.
§Security Features
- Symlink attack prevention
- Hard link detection
- Path validation
- Safe file creation and opening
§Example
use atlas_common::file::{safe_create_file, safe_open_file};
use std::io::{Read, Write};
use std::path::Path;
// Safely create a file
let mut file = safe_create_file(Path::new("output.txt"), false)?;
file.write_all(b"secure data")?;
// Safely read a file
let mut file = safe_open_file(Path::new("input.txt"), false)?;
let mut contents = String::new();
file.read_to_string(&mut contents)?;
Functions§
- safe_
create_ file - Safely creates a file for writing with security checks
- safe_
file_ path - Validates that a file path is safe to use
- safe_
open_ file - Safely opens a file for reading with security checks
- safe_
open_ options - Creates
OpenOptions
for a file with security validation