Skip to content

test: git_hardening fixture commits fail when commit.gpgsign=true is in user's global git config #57

Closed

Description

@thehoff

Reproducer

On a workstation where global git config has commit.gpgsign=true pointing at a GPG/SSH signing agent (e.g. 1Password, Krypton, yubikey-agent) that isn't always available, cargo test --test git_hardening fails 5/6 tests:

test git_external_diff_env_is_stripped ... FAILED
test git_config_global_env_pointing_at_evil_gitconfig_is_stripped ... FAILED
test benign_git_log_still_succeeds ... FAILED
test benign_git_status_still_succeeds ... FAILED
test git_config_count_env_injection_is_stripped ... FAILED
test c_diff_external_arg_is_rejected_with_deny_error ... ok

All failures panic at tests/git_hardening.rs:60:

git ["commit", "-q", "-m", "init"] failed: stderr=error: 1Password: agent returned an error
fatal: failed to write commit object

The one passing test (c_diff_external_arg_is_rejected_with_deny_error) is the arg-only deny path that doesn't use the make_repo() fixture.

Root cause

tests/git_hardening.rs::make_repo() runs git commit to seed a fixture repo. It explicitly sets GIT_AUTHOR_* / GIT_COMMITTER_* but inherits the user's global git config, including commit.gpgsign=true. When the signing agent isn't available, the commit fails and the entire test setup falls over.

Fix

Add -c commit.gpgsign=false -c tag.gpgsign=false -c gpg.format=openpgp to the test's git invocations (or, more aggressively, isolate the test process with GIT_CONFIG_GLOBAL=/dev/null). Either way the test should be hermetic against the user's global git config.

Scope

Not blocking any feature work — confirmed the same failures occur on contextcrawler/develop tip independent of any branch. Recommend a small standalone PR.

Observed on

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions