security: tighten readable/regular file checks in CLI tools

This commit is contained in:
Dylan M. Taylor
2026-10-22 19:18:41 -04:00
parent 3a9b35c687
commit ac2d7623e3
2 changed files with 8 additions and 1 deletions
+6 -1
View File
@@ -5,10 +5,15 @@ from pathlib import Path
def _jsonl_path(arg):
"""Resolve the CLI file argument; require an existing regular file."""
"""Resolve the CLI file argument; require an existing readable regular file."""
path = Path(arg).resolve()
if not path.is_file():
sys.exit(f"not a readable file: {arg}")
try:
with path.open("rb"):
pass
except OSError:
sys.exit(f"not a readable file: {arg}")
return path
def call(method, params):