Skip to content

file_utils

diapason.security.file_utils

Secure file and directory creation helpers.

All Diapason data files under ~/.diapason/ should be created through these helpers to ensure consistent, restrictive permissions.

secure_create(path, mode=384)

Ensure a file exists with restrictive permissions.

Creates the parent directory with 0o700 if needed, touches the file if it doesn't exist, and sets mode on it.

secure_mkdir(path, mode=448)

Create a directory with restrictive permissions.

Creates parent directories as needed, then sets mode on the target directory (even if it already exists).