Commit f13df09
Refactor Git.execute() command docstring after gitpython-developers#2144
Rework :param command: as three parts:
1. Brief description: parameter type, sequence recommended, brief
platform-dependent string note. Corrects gitpython-developers#2144's claim that with
shell=False a string is "passed as a single executable name to
subprocess.Popen" -- accurate on POSIX, but on Windows
subprocess.Popen forwards the string to CreateProcessW, which
tokenizes via Windows command-line parsing.
2. Asymmetric security paragraphs:
* shell=True (or Git.USE_SHELL) runs the command through the
shell, which interprets metacharacters anywhere in it; with
untrusted input that is OS command injection. Cross-references
USE_SHELL and the shell parameter for detail.
* shlex.split runs no shell, but tokenizes by POSIX shell rules.
On Windows those rules differ from both shell=False's OS argv
parsing and shell=True's cmd.exe parsing, so untrusted
whitespace or quoting can shift token boundaries and inject
extra arguments into git's own option parser.
3. Conclusion: neither automatic-splitting approach is safe with
untrusted input; build the sequence form directly, one value
per argv slot.
Replaces gitpython-developers#2144's hedged "possible security implications" wording
with named mechanisms and keeps the asymmetry between command
injection (shell=True, catastrophic) and argument injection
(shlex.split on Windows, milder) visible. No worked examples to
keep the docstring compact; the existing USE_SHELL and shell-
parameter docstrings give the full picture for shell=True.
Documentation only; behavior is unchanged.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 7b83f7a commit f13df09
1 file changed
Lines changed: 25 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 | + | |
1144 | 1159 | | |
1145 | 1160 | | |
1146 | 1161 | | |
| |||
0 commit comments