Commit da779e6
Clarify Git.execute() string semantics and shell/shlex risks
Update the rewritten :param command: block from gitpython-developers#2144 in two
ways:
* Add a Windows bullet. gitpython-developers#2144 said the string is "passed as a
single executable name to subprocess.Popen" with shell=False.
That is accurate on POSIX, but on Windows subprocess.Popen
forwards the string to CreateProcessW and Windows command-line
parsing produces the program's argv. So e.g. "git version"
actually runs.
* Name the tokenization risks specifically. gitpython-developers#2144 hedged with
"possible security implications" for shlex.split and pointed at
the existing shell-parameter warning for shell=True. Be
concrete: under shell=True the shell interprets ;, |, &, $(...),
etc. as syntax, so metacharacters in interpolated values can
execute arbitrary commands; shlex.split is preferable on POSIX
but follows POSIX rules on Windows that may diverge from
Windows command-line conventions; and embedded whitespace or
quotes can shift tokenization either way. Neither is safe with
untrusted input (branch names, URLs, filenames, etc.); the
sequence form is, because each interpolated value occupies a
single argv slot.
Documentation only; behavior is unchanged.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 7b83f7a commit da779e6
1 file changed
Lines changed: 28 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1131 | 1131 | | |
1132 | 1132 | | |
1133 | 1133 | | |
1134 | | - | |
1135 | | - | |
1136 | | - | |
1137 | | - | |
1138 | | - | |
1139 | | - | |
1140 | | - | |
1141 | | - | |
1142 | | - | |
1143 | | - | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
1144 | 1162 | | |
1145 | 1163 | | |
1146 | 1164 | | |
| |||
0 commit comments