Coverage for src / rhiza / subprocess_utils.py: 100%
7 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-02-12 20:13 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-02-12 20:13 +0000
1"""Utilities for secure subprocess execution.
3This module provides helper functions to resolve executable paths
4to prevent PATH manipulation security vulnerabilities.
5"""
7import shutil
10def get_git_executable() -> str:
11 """Get the absolute path to the git executable.
13 This function ensures we use the full path to git to prevent
14 security issues related to PATH manipulation.
16 Returns:
17 str: Absolute path to the git executable.
19 Raises:
20 RuntimeError: If git executable is not found in PATH.
21 """
22 git_path = shutil.which("git")
23 if git_path is None:
24 msg = "git executable not found in PATH. Please ensure git is installed and available."
25 raise RuntimeError(msg)
26 return git_path