Skip to content

chore: use safeexec.LookPath for git in internal/config #99

@boneskull

Description

@boneskull

Description

internal/git/git.go uses safeexec.LookPath to find the git executable, caching the result via sync.Once. This prevents PATH injection attacks on Windows where the current directory is implicitly included in PATH resolution.

internal/config/config.go calls exec.Command("git", ...) directly with a bare string across all of its methods (GetTrunk, SetParent, GetPR, GetForkPoint, GetPRBase, etc.), bypassing this protection.

Suggested Fix

Either:

  1. Export resolveGitPath() (or an equivalent) from internal/git so internal/config can share the same cached, safe path, or
  2. Give internal/config its own resolveGitPath() using safeexec.LookPath + sync.Once, mirroring the pattern already in internal/git.

Option 1 is cleaner since it avoids duplicating the cache.

Context

Noticed while adding GetPRBase/SetPRBase/RemovePRBase in #95's fix. The new methods follow the same pattern as the existing ones, so this is a pre-existing inconsistency rather than a regression — but worth closing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    choreoverhead, tooling, tests, refactors, etc.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions