fix: add HTTP timeout and reject unsafe item names in clone flow#32
Open
Jaro-c wants to merge 1 commit into
Open
fix: add HTTP timeout and reject unsafe item names in clone flow#32Jaro-c wants to merge 1 commit into
Jaro-c wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two related things I noticed in
clone.go, bundled together since the fixes overlap:commands/clone.goused barehttp.Geteverywhere with no timeout — a stalled GitHub response would hang the command indefinitely. Added a sharedhttpClientwith a 30s timeout (matching the pattern already used correctly ininternal/updater/updater.go) and switched everyhttp.Getcall 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.downloadDirectorydidfilepath.Join(localPath, item.Name)using the GitHub API JSONitem.Namewith no traversal check. Low risk today since the source repo is hardcoded and trusted over HTTPS, but addedisSafeItemNameas defense-in-depth in case that repo or the API response is ever compromised — rejects names containing/,\, or equal to./...Added tests for
isSafeItemNameand a sanity check thathttpClienthas a timeout configured.go build,go vet,gofmt -l, andgo test ./...all pass.Closes #25, closes #26.