From e3cf0975f9074f221974f7f7c82389786854999d Mon Sep 17 00:00:00 2001 From: Rory Prendergast Date: Tue, 2 Jan 2018 10:51:13 -0800 Subject: [PATCH] Adds whitelist for GIT_* env vars containing only GIT_SSH --- pre_commit/util.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pre_commit/util.py b/pre_commit/util.py index 10d78d99..a0eb3764 100644 --- a/pre_commit/util.py +++ b/pre_commit/util.py @@ -76,8 +76,11 @@ def no_git_env(): # while running pre-commit hooks in submodules. # GIT_DIR: Causes git clone to clone wrong thing # GIT_INDEX_FILE: Causes 'error invalid object ...' during commit + + # list of explicitly whitelisted variables + allowed_git_envs = ['GIT_SSH'] return { - k: v for k, v in os.environ.items() if not k.startswith('GIT_') + k: v for k, v in os.environ.items() if not k.startswith('GIT_') or k in allowed_git_envs }