Title: Git.execute debug message has misleading Popen(shell=...) · Issue #1686 · gitpython-developers/GitPython · GitHub
Open Graph Title: Git.execute debug message has misleading Popen(shell=...) · Issue #1686 · gitpython-developers/GitPython
X Title: Git.execute debug message has misleading Popen(shell=...) · Issue #1686 · gitpython-developers/GitPython
Description: While investigating #1685, I noticed that in the debug logging Git.execute does to offer insight on the Popen call it is about to make, a user inspecting the log would reasonably infer false information about the value passed as the shel...
Open Graph Description: While investigating #1685, I noticed that in the debug logging Git.execute does to offer insight on the Popen call it is about to make, a user inspecting the log would reasonably infer false inform...
X Description: While investigating #1685, I noticed that in the debug logging Git.execute does to offer insight on the Popen call it is about to make, a user inspecting the log would reasonably infer false inform...
Opengraph URL: https://github.com/gitpython-developers/GitPython/issues/1686
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Git.execute debug message has misleading Popen(shell=...)","articleBody":"While investigating #1685, I noticed that in the debug logging `Git.execute` does to offer insight on the `Popen` call it is about to make, a user inspecting the log would reasonably infer false information about the value passed as the `shell=` keyword argument.\r\n\r\nThe log message is presented as giving information about how `Popen` is being called, not how `Git.execute` has been called: the message shows `Popen(...)`. I agree with this and I don't consider it a bug. But this means it should faithfully report what is about to be passed to `Popen` in cases where a user reading the log would otherwise be misled into thinking this is what has happened.\r\n\r\nReporting the actual `shell=` argument passed to `Popen` is also more useful to log than the argument passed to `Git.execute` (or its default value, as the case may be). Of course, logging both is possible, for example by adding more text like `[from: None]`, though I am somewhat inclined to think that is not worth doing.\r\n\r\nI am not arguing that the logged `Popen(...)` message needs to only show things as they really are in the call. It already replaces passwords to decrease leakage of sensitive information into logs, and it shows an `istream_ok` string representing the most useful information about how the `istream` argument to `Git.execute` affects what is passed as the `stdin` argument to `Popen`. (It may be that this should be logged as `stdin`, I'm not sure.) These are not misleading.\r\n\r\nIt may be that knowledge that `shell=None` is not a correct thing to pass to `Popen` mitigates this. But `Popen` accepts many arguments, and it's hard to remember what all the possible values are for all of them. Furthermore, I think there is a benefit to logging exactly what is about to be passed to `Popen` here: doing so would have revealed #1685 (assuming inspection of the log with `Git.USE_SHELL` set to `True`). The current way is more prone to error, because nontrivial logic follows the logging intended to make that logic's effect clear; so the log can show `False` even when `True` is passed.\r\n\r\n### Possible solutions\r\n\r\nCurrently, when `shell` is implicitly or explicitly `None`, the log shows lines of the form (with the `...` filled in):\r\n\r\n```python\r\nPopen(..., shell=None, ...)\r\n```\r\n\r\nI think the best approach is the simple one. This and #1685 can be fixed together by setting the `shell` variable to `self.USE_SHELL` when `shell` started out as `None`, then using `shell` both the `log.debug` and the `Popen` calls. In the log, that would give, assuming `USE_SHELL` is its default `False` value:\r\n\r\n```python\r\nPopen(..., shell=False, ...)\r\n```\r\n\r\nHowever, we could show both:\r\n\r\n```python\r\nPopen(..., shell=False [from: None], ...)\r\n```\r\n\r\nA mentioned above, I favor the former, simpler way. But I thought the latter was worth mentioning, because it is another way to show the information without misleading the user.\r\n\r\nI've opened #1687, which fixes this (along with #1685) in the first way.","author":{"url":"https://github.com/EliahKagan","@type":"Person","name":"EliahKagan"},"datePublished":"2023-10-02T09:20:52.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/1686/GitPython/issues/1686"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:91fae82a-a4b8-31dc-80fd-b8e867841d55 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BA36:1BE852:14F3E1C:1C9DE3D:69694F10 |
| html-safe-nonce | b6e8f728be2fe9973fae66cd79338df2391f666c281d34153c4ef2855f85df75 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQTM2OjFCRTg1MjoxNEYzRTFDOjFDOURFM0Q6Njk2OTRGMTAiLCJ2aXNpdG9yX2lkIjoiNjc3MTI4NDUxMjUxMjQ5NTM3NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ffea9eec5b0089d74b91e03aadb3d1a741e7928a6feed672b8142cc6d473dfc3 |
| hovercard-subject-tag | issue:1921547428 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/gitpython-developers/GitPython/1686/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e080e4bbeecc4277a69eae9ff238bd22519f64e270d522bcd7b19a9c779cab81/gitpython-developers/GitPython/issues/1686 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e080e4bbeecc4277a69eae9ff238bd22519f64e270d522bcd7b19a9c779cab81/gitpython-developers/GitPython/issues/1686 |
| og:image:alt | While investigating #1685, I noticed that in the debug logging Git.execute does to offer insight on the Popen call it is about to make, a user inspecting the log would reasonably infer false inform... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | EliahKagan |
| hostname | github.com |
| expected-hostname | github.com |
| None | 54182691a21263b584d2e600b758e081b0ff1d10ffc0d2eefa51cf754b43b51d |
| turbo-cache-control | no-preview |
| go-import | github.com/gitpython-developers/GitPython git https://github.com/gitpython-developers/GitPython.git |
| octolytics-dimension-user_id | 503709 |
| octolytics-dimension-user_login | gitpython-developers |
| octolytics-dimension-repository_id | 1126087 |
| octolytics-dimension-repository_nwo | gitpython-developers/GitPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1126087 |
| octolytics-dimension-repository_network_root_nwo | gitpython-developers/GitPython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | d69ac0477df0f87da03b8b06cebd187012d7a930 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width