Skip to content

fix: add HTTP timeout and reject unsafe item names in clone flow#32

Open
Jaro-c wants to merge 1 commit into
newcore-network:developfrom
Jaro-c:fix/clone-hardening
Open

fix: add HTTP timeout and reject unsafe item names in clone flow#32
Jaro-c wants to merge 1 commit into
newcore-network:developfrom
Jaro-c:fix/clone-hardening

Conversation

@Jaro-c

@Jaro-c Jaro-c commented Jul 18, 2026

Copy link
Copy Markdown

Two related things I noticed in clone.go, bundled together since the fixes overlap:

  • commands/clone.go used bare http.Get everywhere with no timeout — a stalled GitHub response would hang the command indefinitely. Added a shared httpClient with a 30s timeout (matching the pattern already used correctly in internal/updater/updater.go) and switched every http.Get call in the file to it, not just the ones in the clone path — same bug, same fix, no reason to leave some of them unpatched.
  • downloadDirectory did filepath.Join(localPath, item.Name) using the GitHub API JSON item.Name with no traversal check. Low risk today since the source repo is hardcoded and trusted over HTTPS, but added isSafeItemName as defense-in-depth in case that repo or the API response is ever compromised — rejects names containing /, \, or equal to ./...

Added tests for isSafeItemName and a sanity check that httpClient has a timeout configured.

go build, go vet, gofmt -l, and go test ./... all pass.

Closes #25, closes #26.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant