file_utils
file_utils
¶
Secure file and directory creation helpers.
All OpenJarvis data files under ~/.openjarvis/ should be created
through these helpers to ensure consistent, restrictive permissions.
Functions¶
secure_mkdir
¶
Create a directory with restrictive permissions.
Creates parent directories as needed, then sets mode on the target directory (even if it already exists).
Source code in src/openjarvis/security/file_utils.py
secure_create
¶
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.
Source code in src/openjarvis/security/file_utils.py
secure_write_text
¶
Atomically replace path with owner-only text content.
The temporary file is created in the destination directory so
:func:os.replace remains atomic. Permissions are restricted before
secret bytes are written, then re-applied after replacement for platforms
whose replace semantics preserve the destination's prior mode.
Source code in src/openjarvis/security/file_utils.py
secure_write_json
¶
Atomically persist JSON with restrictive permissions.