Skip to content

fix(guardrails): shared parser conflates --config-env values with -c values #740

Description

@kyle-sexton

Problem

hook::bash_parse_segments' git-option walk records -c, --config, and --config-env values into the same HOOK_GIT_CONFIG_VALUES array with no marker distinguishing them (hook-utils.sh:796-801).

They are not the same thing. -c alias.c=commit supplies the value commit; --config-env=alias.c=VAR supplies the name of an environment variable holding the value. A consumer reading the array cannot tell them apart, so it treats VAR as the alias expansion.

Impact

Both git guards inherit this, and both currently fail open on it:

  • block-noncanonical-commitgit --config-env=alias.z=AV z -m x (with AV=commit) is not recognized as a commit. Verified exit 0.
  • block-dangerous-git — same shape for its alias expansion path.

Neither is a correctness bug in the guards themselves; the information they need is not in the array.

Fix sketch

Tag the origin in the shared parser — e.g. a parallel HOOK_GIT_CONFIG_VALUE_KINDS array, or an env: prefix on --config-env entries — then have each consumer resolve an env-sourced value from the hook's inherited environment. An inline env-assignment prefix on the command line (AV=commit git --config-env=...) stays out of scope: the parser does not evaluate shell assignments, which is an already-documented residual.

Why not fixed in #736

It is a hook-utils.sh change shared by both guards, with its own test surface. #736 documents the residual in the new hook's header rather than half-fixing it in one consumer.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: mediumReal value, no hard deadline; normal backlog flow.status: readyTriaged, unblocked, and fully specified; eligible to pick up.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions