Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: safe execute git commands without sh wrapper #606

Conversation

mrexox
Copy link
Member

@mrexox mrexox commented Jan 12, 2024

🔧 Summary

Execution of shell commands with sh wrapper can bring unexpected behavior because of arguments (branch names) that can be places into a command. For example, when a branch is named "mybranch;killall" the command for getting files for the pre-push hook will look like sh -c 'git diff --name-only HEAD mybranch;killall' and it may shoot badly.

The sh wrapper is actually needed only for the files option where user can specify something like git ls-files | grep _test. So, this behavior is kept as before + one more integrity test for it.

@mrexox mrexox marked this pull request as ready for review January 12, 2024 08:54
@mrexox mrexox merged commit 02e6f77 into evilmartians:master Jan 12, 2024
16 checks passed
@sanmai-NL
Copy link
Contributor

Are strings embedded in shell commands now sanitized in the remaining case? You can use this if not https://pkg.go.dev/github.com/alessio/shellescape

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.

2 participants