mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
repos: git inherits only an allow-listed environment
git_env copied the whole process environment, and git consults its environment ahead of `-c`: GIT_ALLOW_PROTOCOL=file re-enabled file:// despite protocol.allow=never, and GIT_CONFIG_COUNT/KEY_*/VALUE_* could add an `insteadOf` that rewrites an approved URL to another host. Only PATH, HOME, TMPDIR, TZ and the SSL certificate paths are inherited now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
1c214f4033
commit
1a28a5900a
2 changed files with 40 additions and 2 deletions
|
|
@ -219,9 +219,16 @@ def git_command(*args, config: tuple = ()) -> tuple:
|
|||
return GIT_BIN, *safety, *args
|
||||
|
||||
|
||||
# The only parts of WROLPi's environment git may see. Anything else (GIT_ALLOW_PROTOCOL, GIT_CONFIG_COUNT and
|
||||
# GIT_CONFIG_KEY_*/VALUE_*, GIT_CONFIG_PARAMETERS, GIT_SSL_NO_VERIFY, proxies, ...) could undo `git_command`'s
|
||||
# restrictions.
|
||||
GIT_ENV_ALLOWED = ('PATH', 'HOME', 'TMPDIR', 'TZ', 'SSL_CERT_FILE', 'SSL_CERT_DIR')
|
||||
|
||||
|
||||
def git_env() -> dict:
|
||||
"""Environment for git: never prompt for credentials, ignore the user's and system's git configs."""
|
||||
env = dict(os.environ)
|
||||
"""Environment for git: never prompt for credentials, ignore the user's and system's git configs, and inherit
|
||||
nothing that changes how git connects."""
|
||||
env = {k: v for k, v in os.environ.items() if k in GIT_ENV_ALLOWED}
|
||||
env.update(
|
||||
GIT_TERMINAL_PROMPT='0',
|
||||
GIT_ASKPASS='true',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue