Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Only make config more permissive in tests that need it#1648

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Byron merged 4 commits intogitpython-developers:mainfromEliahKagan:file-protocol
Sep 7, 2023

Conversation

EliahKagan
Copy link
Member

@EliahKaganEliahKagan commentedSep 7, 2023
edited
Loading

Closes#1544

Edit: When making this PR, I didn't notice#1647, which was recently opened (but opened before this PR;#1647 came first). That PR includes an alternative to the approach taken here. It uses a GitPython feature to setprotocol.file.allow ingit command-like arguments, while this patchesGIT_CONFIG_* environment variables. Both approaches are specific and, I believe, robust. The approach in this PR avoids using more GitPython features that are not conceptually under test in the submodule tests. But the approach in#1647 is significantly more compact, which might be considered the more important benefit. I will not mind if this is closed in preference for#1647! At this time, both#1647 and this PR also contain changes beyond those that directly address#1544, and another option, if the approach in#1647 is chosen, would be for me to narrow this PR to make only CI changes, after#1647 is accepted.

(The original description of the changes in this PR, and the rationale for them, follows.)

protocol.file.allow

This eliminates the need for users running the test suite to setprotocol.file.allow toalways in the global git configuration. Setting it globally toalways has security implications, as alluded to in#1544, and as noted in the description ingit release notes of howCVE-2022-39253 was fixed, and ingit/git@a1d4f67 where its default value was changed fromalways touser.

On CI, this was not directly a problem, because the CI runner is isolated and not being used to clone unrelated less-trusted repositories. But users are likely to be looking at the CI workflows to figure out how to overcome thefatal: transport 'file' not allowed error locally. Furthermore, by having the test suite make the change automatically and temporarily by modifying process environment variables, the needed setup is simplified for everyone.

The approach taken here is inspired by#1544 (comment) and makes use ofGIT_CONFIG_* environment variables. But it is more specific than suggested there, instead temporarily patching the environment only during the runs of the two specific tests that require it,test_list_only_valid_submodules andtest_git_submodules_and_add_sm_with_new_commit. This is done without much code duplication, so it can be applied easily to any future test cases that require it. (I think this probably won't ever be needed outsidetest_submodule.py, because Git's default value ofprotocol.file.allow isuser, notnever.)

I patchedGIT_CONFIG_* variables in such a way that existing assignments toGIT_CONFIG_* variables, if present, are still used, rather than being replaced or causing an error. I considered patchingGIT_ALLOW_PROTOCOL instead, but I decided against it because it may be useful for people running the tests to be able to change what other protocols are allowed/disallowed. PatchingGIT_ALLOW_PROTOCOL in a way that respected that would be more complicated than patchingGIT_CONFIG_* variables.

safe.directory

protocol.file.allow is one of two security-related configuration options that were set on CI. The other issafe.directory. This is not needed in thepythonpackage.yml workflow, because the cloned repository's files are always owned by the same user that is runningpytest and thusgit, so I removed it from there. Thecygwin-test.yml workflow does currently need it, and Ishell-quoted$(pwd) there, which is slightly more robust and better expresses the intent that no splitting or globbing be performed, but otherwise retained it.

I was unsure if I should include changes related tosafe.directory in this PR, or open a separate PR. Theprotocol.file.allow andsafe.directory customizations were presented as closely related in the workflows. More importantly, to decide where to put the fixture/helper used for patchingprotocol.file.allow intest_submodule.py, I checked that it would not be needed elsewhere, by verifying that no test cases inherently requiresafe.directory to be set (but that it just works around a Cygwin-specific issue). For the same reason, it seems to me that the changes may be easier toreview together than separately, as well. However, I would be pleased to make any requested changes to this PR, including splitting outsafe.directory-related changes to a separate PR if desired.

This stops setting the current directory as an explicit safedirectory on CI for non-Windows systems, where this is not neededbecause the repository has the ownership Git expects. The step nameis updated accordingly to reflect its now narrower purpose.This also adds shell quoting to $(pwd) in the Cygwin workflow. Inpractice, on CI, the path is very unlikely to contain whitespace,but double-quoting $ expansions on which splitting and globbing areunwanted is more robust and better expresses intent. This also hasthe benefit that users who use the CI workflows as a guide tocommands they run locally, where on Windows they may very well havespaces somewhere in this absolute path, will use a correct command.
Instead of setting a global git configuration.This makes no significant difference for security on CI, but it isan iterative step toward a more specific way of setting them thatwill apply on CI and locally and require less configuration.In addition, this shows an approach more similar to what users whodo not want to carefully review the security impact of changingthe global setting can use locally (and which is more secure).
Instead of setting environment variables just on CI and for thethe entire pytest command, this has the two test cases that needprotocol.file.allow to be set to "always" (instead of "user") setthem, via a shared fixture, just while those tests are running.Both on CI and for local test runs, this makes it no longernecessary to set this in a global configuration or throughenvironment variables, reducing the setup needed to run the tests.
_allow_file_protocol was effectively a _patch_git_config fixture,being no no shorter, simpler, or clearer by hard-coding thespecific name and value to patch. So this changes it to be that.As a secondary issue, it previously was called with no arguments,then that would be used as a decorator. That was unintutive and itwas easy to omit the parentheses accidentally. This resolves that.
@EliahKaganEliahKagan marked this pull request as ready for reviewSeptember 7, 2023 02:43
@ByronByron linked an issueSep 7, 2023 that may beclosed by this pull request
Copy link
Member

@ByronByron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This looks great to me, thanks a lot for the initiative and contribution!

Since this PR is complete for what it is supposed to achieve, let's merge it and deal withsafe.directory in a separate PR. Thank you.

xesf reacted with thumbs up emoji
@ByronByron merged commit11839ab intogitpython-developers:mainSep 7, 2023
@ByronByron added this to thev3.1.35 - Bugfixes milestoneSep 7, 2023
@EliahKaganEliahKagan deleted the file-protocol branchSeptember 7, 2023 15:34
@EliahKagan
Copy link
MemberAuthor

EliahKagan commentedSep 7, 2023
edited
Loading

@Byron No problem!

This PR actually had already dealt withsafe.directory, in537af83. It didn't attempt to harmonize the ownership situation incygwin-test.yml, but it did make the changes described in thesafe.directory portion of the PR description. I hope that's okay! If you'd like those changes undone or done differently, I could open a new PR for that.

@Byron
Copy link
Member

I hope that's okay!

I think it's OK as long you think the same :).

EliahKagan reacted with thumbs up emoji

renovatebot referenced this pull request in allenporter/flux-localSep 8, 2023
[![MendRenovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)This PR contains the following updates:| Package | Change | Age | Adoption | Passing | Confidence ||---|---|---|---|---|---|| [GitPython](https://togithub.com/gitpython-developers/GitPython) |`==3.1.34` -> `==3.1.35` |[![age](https://developer.mend.io/api/mc/badges/age/pypi/GitPython/3.1.35?slim=true)](https://docs.renovatebot.com/merge-confidence/)|[![adoption](https://developer.mend.io/api/mc/badges/adoption/pypi/GitPython/3.1.35?slim=true)](https://docs.renovatebot.com/merge-confidence/)|[![passing](https://developer.mend.io/api/mc/badges/compatibility/pypi/GitPython/3.1.34/3.1.35?slim=true)](https://docs.renovatebot.com/merge-confidence/)|[![confidence](https://developer.mend.io/api/mc/badges/confidence/pypi/GitPython/3.1.34/3.1.35?slim=true)](https://docs.renovatebot.com/merge-confidence/)|---### Release Notes<details><summary>gitpython-developers/GitPython (GitPython)</summary>###[`v3.1.35`](https://togithub.com/gitpython-developers/GitPython/releases/tag/3.1.35):- a fix forCVE-2023-41040[CompareSource](https://togithub.com/gitpython-developers/GitPython/compare/3.1.34...3.1.35)#### What's Changed- Bump actions/checkout from 3 to 4 by[@&#8203;dependabot](https://togithub.com/dependabot) in[https://github.com/gitpython-developers/GitPython/pull/1643](https://togithub.com/gitpython-developers/GitPython/pull/1643)- Fix 'Tree' object has no attribute '\_name' when submodule path isnormal path by [@&#8203;CosmosAtlas](https://togithub.com/CosmosAtlas)in[https://github.com/gitpython-developers/GitPython/pull/1645](https://togithub.com/gitpython-developers/GitPython/pull/1645)- FixCVE-2023-41040 by[@&#8203;facutuesca](https://togithub.com/facutuesca) in[https://github.com/gitpython-developers/GitPython/pull/1644](https://togithub.com/gitpython-developers/GitPython/pull/1644)- Only make config more permissive in tests that need it by[@&#8203;EliahKagan](https://togithub.com/EliahKagan) in[https://github.com/gitpython-developers/GitPython/pull/1648](https://togithub.com/gitpython-developers/GitPython/pull/1648)- Added test for PR[#&#8203;1645](https://togithub.com/gitpython-developers/GitPython/issues/1645)submodule path by[@&#8203;CosmosAtlas](https://togithub.com/CosmosAtlas) in[https://github.com/gitpython-developers/GitPython/pull/1647](https://togithub.com/gitpython-developers/GitPython/pull/1647)- Fix Windows environment variable upcasing bug by[@&#8203;EliahKagan](https://togithub.com/EliahKagan) in[https://github.com/gitpython-developers/GitPython/pull/1650](https://togithub.com/gitpython-developers/GitPython/pull/1650)#### New Contributors- [@&#8203;CosmosAtlas](https://togithub.com/CosmosAtlas) made theirfirst contribution in[https://github.com/gitpython-developers/GitPython/pull/1645](https://togithub.com/gitpython-developers/GitPython/pull/1645)- [@&#8203;facutuesca](https://togithub.com/facutuesca) made their firstcontribution in[https://github.com/gitpython-developers/GitPython/pull/1644](https://togithub.com/gitpython-developers/GitPython/pull/1644)**Full Changelog**:gitpython-developers/GitPython@3.1.34...3.1.35</details>---### Configuration📅 **Schedule**: Branch creation - At any time (no schedule defined),Automerge - At any time (no schedule defined).🚦 **Automerge**: Enabled.♻ **Rebasing**: Whenever PR becomes conflicted, or you tick therebase/retry checkbox.🔕 **Ignore**: Close this PR and you won't be reminded about this updateagain.---- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, checkthis box---This PR has been generated by [MendRenovate](https://www.mend.io/free-developer-tools/renovate/). Viewrepository job log[here](https://developer.mend.io/github/allenporter/flux-local).<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi44My4wIiwidXBkYXRlZEluVmVyIjoiMzYuODMuMCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
otc-zuulbot pushed a commit to opentelekomcloud-infra/eyes_on_docs that referenced this pull requestSep 11, 2023
Bump gitpython from 3.1.32 to 3.1.35Bumps gitpython from 3.1.32 to 3.1.35.Release notesSourced from gitpython's releases.3.1.35 - a fix forCVE-2023-41040What's ChangedBump actions/checkout from 3 to 4 by @​dependabot ingitpython-developers/GitPython#1643Fix 'Tree' object has no attribute '_name' when submodule path is normal path by @​CosmosAtlas ingitpython-developers/GitPython#1645FixCVE-2023-41040 by @​facutuesca ingitpython-developers/GitPython#1644Only make config more permissive in tests that need it by @​EliahKagan ingitpython-developers/GitPython#1648Added test for PR #1645 submodule path by @​CosmosAtlas ingitpython-developers/GitPython#1647Fix Windows environment variable upcasing bug by @​EliahKagan ingitpython-developers/GitPython#1650New Contributors@​CosmosAtlas made their first contribution ingitpython-developers/GitPython#1645@​facutuesca made their first contribution ingitpython-developers/GitPython#1644Full Changelog: gitpython-developers/GitPython@3.1.34...3.1.353.1.34 - fix resource leakingWhat's Changedutil: close lockfile after opening successfully by @​skshetry ingitpython-developers/GitPython#1639New Contributors@​skshetry made their first contribution ingitpython-developers/GitPython#1639Full Changelog: gitpython-developers/GitPython@3.1.33...3.1.34v3.1.33 - with security fixWhat's ChangedWIP Quick doc by @​LeoDaCoda ingitpython-developers/GitPython#1608Partial clean up wrt mypy and black by @​bodograumann ingitpython-developers/GitPython#1617Disable merge_includes in config writers by @​bodograumann ingitpython-developers/GitPython#1618feat: full typing for "progress" parameter in Repo class by @​madebylydia ingitpython-developers/GitPython#1634FixCVE-2023-40590 by @​EliahKagan ingitpython-developers/GitPython#1636#1566 Creating a lock now uses python built-in "open()" method to work arou… by @​HageMaster3108 ingitpython-developers/GitPython#1619New Contributors@​LeoDaCoda made their first contribution ingitpython-developers/GitPython#1608@​bodograumann made their first contribution ingitpython-developers/GitPython#1617@​EliahKagan made their first contribution ingitpython-developers/GitPython#1636@​HageMaster3108 made their first contribution ingitpython-developers/GitPython#1619Full Changelog: gitpython-developers/GitPython@3.1.32...3.1.33Commitsc8e303f prepare next release09e1b3d Merge pull request #1650 from EliahKagan/envcase8017421 Merge pull request #1647 from CosmosAtlas/masterfafb4f6 updated docs to better describe testing procedure with new repo9da24d4 add test for submodule path not owned by submodule caseeebdb25 Eliminate duplication of git.util.cwd logicc7fad20 Fix Windows env var upcasing regression7296e5c Make test helper script a file, for readabilityd88372a Add test for Windows env var upcasing regression11839ab Merge pull request #1648 from EliahKagan/file-protocolAdditional commits viewable in compare viewDependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting@dependabot rebase.Dependabot commands and optionsYou can trigger Dependabot actions by commenting on this PR:@dependabot rebase will rebase this PR@dependabot recreate will recreate this PR, overwriting any edits that have been made to it@dependabot merge will merge this PR after your CI passes on it@dependabot squash and merge will squash and merge this PR after your CI passes on it@dependabot cancel merge will cancel a previously requested merge and block automerging@dependabot reopen will reopen this PR if it is closed@dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually@dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency@dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)You can disable automated security fix PRs for this repo from the Security Alerts page.Reviewed-by: Vladimir Vshivkov
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@ByronByronByron approved these changes

Assignees
No one assigned
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3.1.30 & 3.1.31: failing tests Tests fail due to security vulnerability fix in git 2.38.1
2 participants
@EliahKagan@Byron

[8]ページ先頭

©2009-2025 Movatter.jp