transfer doc: move fetch.credentialsInUrl to "transfer" config namespace

Rename the "fetch.credentialsInUrl" configuration variable introduced in 6dcbdc0d661 (remote: create fetch.credentialsInUrl config, 2022-06-06) to "transfer". There are existing exceptions, but generally speaking the "<namespace>.<var>" configuration should only apply to command described in the "namespace" (and its sub-commands, so e.g. "clone.*" or "fetch.*" might also configure "git-remote-https"). But in the case of "fetch.credentialsInUrl" we've got a configuration variable that configures the behavior of all of "clone", "push" and "fetch", someone adjusting "fetch.*" configuration won't expect to have the behavior of "git push" altered, especially as we have the pre-existing "{transfer,fetch,receive}.fsckObjects", which configures different parts of the transfer dialog. So let's move this configuration variable to the "transfer" namespace before it's exposed in a release. We could add all of "{transfer,fetch,pull}.credentialsInUrl" at some other time, but once we have "fetch" configure "pull" such an arrangement would would be a confusing mess, as we'd at least need to have "fetch" configure "push" (but not the other way around), or change existing behavior. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Acked-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Jun 15, 2022 at 12:44 UTC 7281c196b1166f1c00df33948c67b0ef81ba63a9
6 files changed +53 -51
Documentation/RelNotes/2.37.0.txt
+1 -1
@@ -54,7 +54,7 @@ UI, Workflows & Features
54
55 * Update the doctype written in gitweb output to xhtml5.
56
57 - * The "fetch.credentialsInUrl" configuration variable controls what
57 + * The "transfer.credentialsInUrl" configuration variable controls what
58 happens when a URL with embedded login credential is used on either
59 "fetch" or "push". Credentials are currently only detected in
60 `remote.<name>.url` config, not `remote.<name>.pushurl`.
Documentation/config/fetch.txt
-36
@@ -96,39 +96,3 @@ fetch.writeCommitGraph::
96 merge and the write may take longer. Having an updated commit-graph
97 file helps performance of many Git commands, including `git merge-base`,
98 `git push -f`, and `git log --graph`. Defaults to false.
99 -
100 -fetch.credentialsInUrl::
101 - A configured URL can contain plaintext credentials in the form
102 - `<protocol>://<user>:<password>@<domain>/<path>`. You may want
103 - to warn or forbid the use of such configuration (in favor of
104 - using linkgit:git-credential[1]).
105 -+
106 -Note that this is currently limited to detecting credentials in
107 -`remote.<name>.url` configuration, it won't detect credentials in
108 -`remote.<name>.pushurl` configuration.
109 -+
110 -You might want to enable this to prevent inadvertent credentials
111 -exposure, e.g. because:
112 -+
113 -* The OS or system where you're running git may not provide way way or
114 - otherwise allow you to configure the permissions of the
115 - configuration file where the username and/or password are stored.
116 -* Even if it does, having such data stored "at rest" might expose you
117 - in other ways, e.g. a backup process might copy the data to another
118 - system.
119 -* The git programs will pass the full URL to one another as arguments
120 - on the command-line, meaning the credentials will be exposed to oher
121 - users on OS's or systems that allow other users to see the full
122 - process list of other users. On linux the "hidepid" setting
123 - documented in procfs(5) allows for configuring this behavior.
124 -+
125 -If such concerns don't apply to you then you probably don't need to be
126 -concerned about credentials exposure due to storing that sensitive
127 -data in git's configuration files. If you do want to use this, set
128 -`fetch.credentialsInUrl` to one of these values:
129 -+
130 -* `allow` (default): Git will proceed with its activity without warning.
131 -* `warn`: Git will write a warning message to `stderr` when parsing a URL
132 - with a plaintext credential.
133 -* `die`: Git will write a failure message to `stderr` when parsing a URL
134 - with a plaintext credential.
Documentation/config/transfer.txt
+38
@@ -1,3 +1,41 @@
1 +transfer.credentialsInUrl::
2 + A configured URL can contain plaintext credentials in the form
3 + `<protocol>://<user>:<password>@<domain>/<path>`. You may want
4 + to warn or forbid the use of such configuration (in favor of
5 + using linkgit:git-credential[1]). This will be used on
6 + linkgit:git-clone[1], linkgit:git-fetch[1], linkgit:git-push[1],
7 + and any other direct use of the configured URL.
8 ++
9 +Note that this is currently limited to detecting credentials in
10 +`remote.<name>.url` configuration, it won't detect credentials in
11 +`remote.<name>.pushurl` configuration.
12 ++
13 +You might want to enable this to prevent inadvertent credentials
14 +exposure, e.g. because:
15 ++
16 +* The OS or system where you're running git may not provide way way or
17 + otherwise allow you to configure the permissions of the
18 + configuration file where the username and/or password are stored.
19 +* Even if it does, having such data stored "at rest" might expose you
20 + in other ways, e.g. a backup process might copy the data to another
21 + system.
22 +* The git programs will pass the full URL to one another as arguments
23 + on the command-line, meaning the credentials will be exposed to oher
24 + users on OS's or systems that allow other users to see the full
25 + process list of other users. On linux the "hidepid" setting
26 + documented in procfs(5) allows for configuring this behavior.
27 ++
28 +If such concerns don't apply to you then you probably don't need to be
29 +concerned about credentials exposure due to storing that sensitive
30 +data in git's configuration files. If you do want to use this, set
31 +`transfer.credentialsInUrl` to one of these values:
32 ++
33 +* `allow` (default): Git will proceed with its activity without warning.
34 +* `warn`: Git will write a warning message to `stderr` when parsing a URL
35 + with a plaintext credential.
36 +* `die`: Git will write a failure message to `stderr` when parsing a URL
37 + with a plaintext credential.
38 +
39 transfer.fsckObjects::
40 When `fetch.fsckObjects` or `receive.fsckObjects` are
41 not set, the value of this variable is used instead.
remote.c
+2 -2
@@ -623,7 +623,7 @@ static void validate_remote_url(struct remote *remote)
623 struct strbuf redacted = STRBUF_INIT;
624 int warn_not_die;
625
626 - if (git_config_get_string_tmp("fetch.credentialsinurl", &value))
626 + if (git_config_get_string_tmp("transfer.credentialsinurl", &value))
627 return;
628
629 if (!strcmp("warn", value))
@@ -633,7 +633,7 @@ static void validate_remote_url(struct remote *remote)
633 else if (!strcmp("allow", value))
634 return;
635 else
636 - die(_("unrecognized value fetch.credentialsInURL: '%s'"), value);
636 + die(_("unrecognized value transfer.credentialsInURL: '%s'"), value);
637
638 for (i = 0; i < remote->url_nr; i++) {
639 struct url_info url_info = { 0 };
t/t5516-fetch-push.sh
+7 -7
@@ -1836,18 +1836,18 @@ test_expect_success 'refuse to push a hidden ref, and make sure do not pollute t
1836
1837 test_expect_success 'fetch warns or fails when using username:password' '
1838 message="URL '\''https://username:<redacted>@localhost/'\'' uses plaintext credentials" &&
1839 - test_must_fail git -c fetch.credentialsInUrl=allow fetch https://username:password@localhost 2>err &&
1839 + test_must_fail git -c transfer.credentialsInUrl=allow fetch https://username:password@localhost 2>err &&
1840 ! grep "$message" err &&
1841
1842 - test_must_fail git -c fetch.credentialsInUrl=warn fetch https://username:password@localhost 2>err &&
1842 + test_must_fail git -c transfer.credentialsInUrl=warn fetch https://username:password@localhost 2>err &&
1843 grep "warning: $message" err >warnings &&
1844 test_line_count = 3 warnings &&
1845
1846 - test_must_fail git -c fetch.credentialsInUrl=die fetch https://username:password@localhost 2>err &&
1846 + test_must_fail git -c transfer.credentialsInUrl=die fetch https://username:password@localhost 2>err &&
1847 grep "fatal: $message" err >warnings &&
1848 test_line_count = 1 warnings &&
1849
1850 - test_must_fail git -c fetch.credentialsInUrl=die fetch https://username:@localhost 2>err &&
1850 + test_must_fail git -c transfer.credentialsInUrl=die fetch https://username:@localhost 2>err &&
1851 grep "fatal: $message" err >warnings &&
1852 test_line_count = 1 warnings
1853 '
@@ -1855,12 +1855,12 @@ test_expect_success 'fetch warns or fails when using username:password' '
1855
1856 test_expect_success 'push warns or fails when using username:password' '
1857 message="URL '\''https://username:<redacted>@localhost/'\'' uses plaintext credentials" &&
1858 - test_must_fail git -c fetch.credentialsInUrl=allow push https://username:password@localhost 2>err &&
1858 + test_must_fail git -c transfer.credentialsInUrl=allow push https://username:password@localhost 2>err &&
1859 ! grep "$message" err &&
1860
1861 - test_must_fail git -c fetch.credentialsInUrl=warn push https://username:password@localhost 2>err &&
1861 + test_must_fail git -c transfer.credentialsInUrl=warn push https://username:password@localhost 2>err &&
1862 grep "warning: $message" err >warnings &&
1863 - test_must_fail git -c fetch.credentialsInUrl=die push https://username:password@localhost 2>err &&
1863 + test_must_fail git -c transfer.credentialsInUrl=die push https://username:password@localhost 2>err &&
1864 grep "fatal: $message" err >warnings &&
1865 test_line_count = 1 warnings
1866 '
t/t5601-clone.sh
+5 -5
@@ -73,24 +73,24 @@ test_expect_success 'clone respects GIT_WORK_TREE' '
73
74 test_expect_success 'clone warns or fails when using username:password' '
75 message="URL '\''https://username:<redacted>@localhost/'\'' uses plaintext credentials" &&
76 - test_must_fail git -c fetch.credentialsInUrl=allow clone https://username:password@localhost attempt1 2>err &&
76 + test_must_fail git -c transfer.credentialsInUrl=allow clone https://username:password@localhost attempt1 2>err &&
77 ! grep "$message" err &&
78
79 - test_must_fail git -c fetch.credentialsInUrl=warn clone https://username:password@localhost attempt2 2>err &&
79 + test_must_fail git -c transfer.credentialsInUrl=warn clone https://username:password@localhost attempt2 2>err &&
80 grep "warning: $message" err >warnings &&
81 test_line_count = 2 warnings &&
82
83 - test_must_fail git -c fetch.credentialsInUrl=die clone https://username:password@localhost attempt3 2>err &&
83 + test_must_fail git -c transfer.credentialsInUrl=die clone https://username:password@localhost attempt3 2>err &&
84 grep "fatal: $message" err >warnings &&
85 test_line_count = 1 warnings &&
86
87 - test_must_fail git -c fetch.credentialsInUrl=die clone https://username:@localhost attempt3 2>err &&
87 + test_must_fail git -c transfer.credentialsInUrl=die clone https://username:@localhost attempt3 2>err &&
88 grep "fatal: $message" err >warnings &&
89 test_line_count = 1 warnings
90 '
91
92 test_expect_success 'clone does not detect username:password when it is https://username@domain:port/' '
93 - test_must_fail git -c fetch.credentialsInUrl=warn clone https://username@localhost:8080 attempt3 2>err &&
93 + test_must_fail git -c transfer.credentialsInUrl=warn clone https://username@localhost:8080 attempt3 2>err &&
94 ! grep "uses plaintext credentials" err
95 '
96