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

change lfs.allowincompletepush default from true to false #3109

Merged
merged 3 commits into from
Jul 5, 2018

Conversation

larsxschneider
Copy link
Member

Incomplete pushes can corrupt a repository. Therefore we should not allow them and fail hard by default.

See #3105

@larsxschneider larsxschneider changed the title cahnge lfs.allowincompletepush default from true to false change lfs.allowincompletepush default from true to false Jul 5, 2018
@larsxschneider larsxschneider force-pushed the ls/check-push branch 2 times, most recently from e439315 to 4357f53 Compare July 5, 2018 18:04
Copy link
Contributor

@ttaylorr ttaylorr left a comment

Choose a reason for hiding this comment

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

@larsxschneider this looks great to me.

I am glad that you added a hint, since this will break pushes from users that did not have the objects that they were trying to push, and had not explicitly configured lfs.allowincompletepush to a true-like value.

That's a breaking change, but I'm OK with it provided that we retain this message as an easy way for a user to recover from a failed push.

I left one nit for your consideration.

@@ -289,6 +289,8 @@ func (c *uploadContext) ReportErrors() {
}

if !c.allowMissing {
Print("hint: Your push was rejected due to missing or corrupt local objects.\n" +
Copy link
Contributor

Choose a reason for hiding this comment

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

I like this message, and I think that it's good that we're only showing it once at the end of the attempted push, right before calling os.Exit.

If you don't mind, I think that we could extract this message out to a var and print it by referencing that instead of having a string constant in the code. We use this pattern in the clone and checkout commands, which have deprecation notices.

I was thinking something like:

var (
        pushMissingHint = []string{...}
)

if !c.allowMissing {
        Print(strings.Join(pushMissingHint, "\n"))
}
os.Exit(2)

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed and implemented 👍

Copy link
Contributor

@ttaylorr ttaylorr left a comment

Choose a reason for hiding this comment

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

🎉

`test-push-missing.sh` tested two error conditions (missing and corrupt)
with one `git push` exit code check. Split the test into two tests to
ensure both errors cause a `git push` error exit.

`test-push.sh` contained tests similar to `test-push-missing.sh`.
Group them all together in the new test file.
@@ -289,6 +289,11 @@ func (c *uploadContext) ReportErrors() {
}

if !c.allowMissing {
pushMissingHint := []string{
"hint: Your push was rejected due to missing or corrupt local objects.",
"hint: Overwrite the reject with `git config lfs.allowincompletepush true`.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Wording nit: Maybe something along the lines of

hint: You can disable this check using...

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed 👍
Following:

Print("Remote %q does not support the LFS locking API. Consider disabling it with:", cfg.PushRemote())

Incomplete pushes can corrupt a repository. Therefore we should not
allow them and fail hard by default.

If the situation occurs, then print a hint to the user and explain how
to overwrite the hard failure using the `lfs.allowincompletepush` config.
@ttaylorr ttaylorr merged commit 5e601f8 into master Jul 5, 2018
@ttaylorr ttaylorr deleted the ls/check-push branch July 5, 2018 21:30
ttaylorr added a commit that referenced this pull request Jul 6, 2018
In config/git_fetcher.go, we have special rules to mark certain Git
configuration keys as safe or unsafe.

Particularly, we apply these rules strictly to all values fetched from
the repository-local .lfsconfig, since it is distributed to all fetchers
of a repository and provides a widely available attack-vector.
Therefore, we only allow a tiny subset of all keys via the keyIsUnsafe
function and safeKeys slice.

The 'lfs.allowincompletepush' configuration determines whether or not a
user should be allowed to push a repository that has missing LFS objects
to a remote.

Previously, it was ignored with the following message:

    $ git push repo_clone repo_orig_master
    WARNING: These unsafe lfsconfig keys were ignored:

      lfs.allowincompletepush

In [1], Lars changed the default from 'true' to 'false'. In order to
allow users or repository maintainers to retain the prior behavior,
let's let them distribute this configuration from the repository's
.lfsconfig and thusly mark it as safe.

[1]: #3109
dhiwakarK pushed a commit to dhiwakarK/expert-octo-doodle that referenced this pull request Nov 3, 2022
In config/git_fetcher.go, we have special rules to mark certain Git
configuration keys as safe or unsafe.

Particularly, we apply these rules strictly to all values fetched from
the repository-local .lfsconfig, since it is distributed to all fetchers
of a repository and provides a widely available attack-vector.
Therefore, we only allow a tiny subset of all keys via the keyIsUnsafe
function and safeKeys slice.

The 'lfs.allowincompletepush' configuration determines whether or not a
user should be allowed to push a repository that has missing LFS objects
to a remote.

Previously, it was ignored with the following message:

    $ git push repo_clone repo_orig_master
    WARNING: These unsafe lfsconfig keys were ignored:

      lfs.allowincompletepush

In [1], Lars changed the default from 'true' to 'false'. In order to
allow users or repository maintainers to retain the prior behavior,
let's let them distribute this configuration from the repository's
.lfsconfig and thusly mark it as safe.

[1]: git-lfs/git-lfs#3109


Former-commit-id: d3564823abf16517a1b40a905c8f0e968a9ed410
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants