Skip to content

lefthook guard: recognise install after valued global options, and package runners #1918

Open

Description

@potiuk

The lefthook-hooks-path agent-guard guard (added in #1895) takes the first non-option token as the lefthook subcommand. So a global option that takes its value as a separate argument hides install: in lefthook --colors off install --force, the guard reads off as the subcommand and returns no denial. It also doesn't look through package runners: npx lefthook install --force, pnpm exec, yarn exec/dlx and bunx reach the real binary with no guard. The PATH shim still covers lefthook run directly, so this is defence-in-depth, not a live bypass of the shim.

Separately, guarded_head matches the basename, so /usr/bin/git reaches the bundled guards, while git:* contributed guards still key on a literal argv[0] == "git". Normalising argv[0] once and using it in both places would make the coverage consistent.

Suggested direction: fail closed. Treat a lefthook segment as an install whenever any token equals install. Unwrap the common runners when their target is lefthook. Add tests for each shape.

Activity

  1. potiuk commented on Oct 31, 2026

    @potiuk
    MemberAuthor

    feel free

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions