From 80453c763ebb9de5e437bc11fc89b44f495c9c94 Mon Sep 17 00:00:00 2001 From: shadowcodex <1348053+shadowcodex@users.noreply.github.com> Date: Fri, 3 Apr 2026 00:46:19 -0500 Subject: [PATCH 1/2] Address thresher.sh findings, introduce trust flow for injectable code, remove path traversal vuln, harden workflows for supplychain attacks --- .github/workflows/homebrew.yml | 4 +- .github/workflows/lint.yml | 8 ++-- bin/git-gtr | 3 ++ lib/adapters.sh | 34 +++++++++++--- lib/args.sh | 4 +- lib/commands/init.sh | 49 +++++++++++++++---- lib/commands/trust.sh | 41 ++++++++++++++++ lib/config.sh | 4 +- lib/copy.sh | 13 +++++ lib/hooks.sh | 86 ++++++++++++++++++++++++++++++++-- lib/platform.sh | 16 +++++-- lib/ui.sh | 2 +- 12 files changed, 231 insertions(+), 33 deletions(-) create mode 100644 lib/commands/trust.sh diff --git a/.github/workflows/homebrew.yml b/.github/workflows/homebrew.yml index 9636d59..41601f8 100644 --- a/.github/workflows/homebrew.yml +++ b/.github/workflows/homebrew.yml @@ -4,13 +4,15 @@ on: release: types: [published] +permissions: read-all + jobs: homebrew: name: Bump Homebrew formula runs-on: ubuntu-latest if: ${{ !github.event.release.prerelease }} steps: - - uses: mislav/bump-homebrew-formula-action@v3 + - uses: mislav/bump-homebrew-formula-action@56a283fa15557e9abaa4bdb63b8212abc68e655c # v3 with: formula-name: git-gtr formula-path: Formula/git-gtr.rb diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8507681..7ea0886 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -6,12 +6,14 @@ on: pull_request: branches: [main] +permissions: read-all + jobs: shellcheck: name: ShellCheck runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 - name: Install ShellCheck run: sudo apt-get update && sudo apt-get install -y shellcheck @@ -24,7 +26,7 @@ jobs: name: Completions runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 - name: Verify completion files are up to date run: ./scripts/generate-completions.sh --check @@ -33,7 +35,7 @@ jobs: name: Tests runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 - name: Install BATS run: sudo apt-get update && sudo apt-get install -y bats diff --git a/bin/git-gtr b/bin/git-gtr index ef19932..9ec06f1 100755 --- a/bin/git-gtr +++ b/bin/git-gtr @@ -100,6 +100,9 @@ main() { init) cmd_init "$@" ;; + trust) + cmd_trust "$@" + ;; version|--version|-v) echo "git gtr version $GTR_VERSION" ;; diff --git a/lib/adapters.sh b/lib/adapters.sh index 91c3c08..254be2b 100644 --- a/lib/adapters.sh +++ b/lib/adapters.sh @@ -166,9 +166,10 @@ editor_open() { target="$workspace" fi - # $GTR_EDITOR_CMD may contain arguments (e.g., "code --wait") - # Using eval here is necessary to handle multi-word commands properly - eval "$GTR_EDITOR_CMD \"\$target\"" + # Split multi-word commands (e.g., "code --wait") into an array for safe execution + local _cmd_arr + read -ra _cmd_arr <<< "$GTR_EDITOR_CMD" + "${_cmd_arr[@]}" "$target" } # Globals set by load_ai_adapter: GTR_AI_CMD, GTR_AI_CMD_NAME @@ -179,9 +180,10 @@ ai_can_start() { ai_start() { local path="$1" shift - # $GTR_AI_CMD may contain arguments (e.g., "bunx @github/copilot@latest") - # Using eval here is necessary to handle multi-word commands properly - (cd "$path" && eval "$GTR_AI_CMD \"\$@\"") + # Split multi-word commands (e.g., "bunx @github/copilot@latest") into an array for safe execution + local _cmd_arr + read -ra _cmd_arr <<< "$GTR_AI_CMD" + (cd "$path" && "${_cmd_arr[@]}" "$@") } # Standard AI adapter builder — used by adapter files that follow the common pattern @@ -295,6 +297,15 @@ resolve_workspace_file() { # Usage: _load_adapter