Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix command injection in go-getter when passing params to hg clone
The fix for this is to add -- to the arguments of each hg command, before any user-input. This indicates the end of optional arguments, only positional arguments are allowed. Test Results Before Change ``` ~> go test ./... -run=TestHg -v === RUN TestHgGetter_impl --- PASS: TestHgGetter_impl (0.00s) === RUN TestHgGetter --- PASS: TestHgGetter (0.60s) === RUN TestHgGetter_branch --- PASS: TestHgGetter_branch (0.96s) === RUN TestHgGetter_GetFile --- PASS: TestHgGetter_GetFile (0.61s) === RUN TestHgGetter_HgArgumentsNotAllowed === RUN TestHgGetter_HgArgumentsNotAllowed/arguments_allowed_in_destination get_hg_test.go:144: Expected no err, got: error running /usr/local/bin/hg: === RUN TestHgGetter_HgArgumentsNotAllowed/arguments_passed_into_rev_parameter get_hg_test.go:163: Expected no err, got: /usr/local/bin/hg exited with 1: === RUN TestHgGetter_HgArgumentsNotAllowed/arguments_passed_in_the_repository_URL get_hg_test.go:182: Expected no err, got: /usr/local/bin/hg exited with 255: hg clone: option -U not recognized alias 'clone' resolves to unknown command 'false' --- FAIL: TestHgGetter_HgArgumentsNotAllowed (1.02s) --- FAIL: TestHgGetter_HgArgumentsNotAllowed/arguments_allowed_in_destination (0.15s) --- FAIL: TestHgGetter_HgArgumentsNotAllowed/arguments_passed_into_rev_parameter (0.56s) --- FAIL: TestHgGetter_HgArgumentsNotAllowed/arguments_passed_in_the_repository_URL (0.31s) FAIL ``` Test Results After Change ``` ~> go test ./... -run=TestHg -v === RUN TestHgGetter_impl --- PASS: TestHgGetter_impl (0.00s) === RUN TestHgGetter --- PASS: TestHgGetter (0.61s) === RUN TestHgGetter_branch --- PASS: TestHgGetter_branch (0.99s) === RUN TestHgGetter_GetFile --- PASS: TestHgGetter_GetFile (0.61s) === RUN TestHgGetter_HgArgumentsNotAllowed === RUN TestHgGetter_HgArgumentsNotAllowed/arguments_allowed_in_destination === RUN TestHgGetter_HgArgumentsNotAllowed/arguments_passed_into_rev_parameter === RUN TestHgGetter_HgArgumentsNotAllowed/arguments_passed_in_the_repository_URL --- PASS: TestHgGetter_HgArgumentsNotAllowed (1.37s) --- PASS: TestHgGetter_HgArgumentsNotAllowed/arguments_allowed_in_destination (0.62s) --- PASS: TestHgGetter_HgArgumentsNotAllowed/arguments_passed_into_rev_parameter (0.61s) --- PASS: TestHgGetter_HgArgumentsNotAllowed/arguments_passed_in_the_repository_URL (0.15s) PASS ```
- Loading branch information