Skip to content

Commit 7281c19

Browse files
avargitster
authored andcommitted
transfer doc: move fetch.credentialsInUrl to "transfer" config namespace
Rename the "fetch.credentialsInUrl" configuration variable introduced in 6dcbdc0 (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 <[email protected]> Acked-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4a169da commit 7281c19

File tree

6 files changed

+53
-51
lines changed

6 files changed

+53
-51
lines changed

Documentation/RelNotes/2.37.0.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ UI, Workflows & Features
5454

5555
* Update the doctype written in gitweb output to xhtml5.
5656

57-
* The "fetch.credentialsInUrl" configuration variable controls what
57+
* The "transfer.credentialsInUrl" configuration variable controls what
5858
happens when a URL with embedded login credential is used on either
5959
"fetch" or "push". Credentials are currently only detected in
6060
`remote.<name>.url` config, not `remote.<name>.pushurl`.

Documentation/config/fetch.txt

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -96,39 +96,3 @@ fetch.writeCommitGraph::
9696
merge and the write may take longer. Having an updated commit-graph
9797
file helps performance of many Git commands, including `git merge-base`,
9898
`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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
139
transfer.fsckObjects::
240
When `fetch.fsckObjects` or `receive.fsckObjects` are
341
not set, the value of this variable is used instead.

remote.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ static void validate_remote_url(struct remote *remote)
623623
struct strbuf redacted = STRBUF_INIT;
624624
int warn_not_die;
625625

626-
if (git_config_get_string_tmp("fetch.credentialsinurl", &value))
626+
if (git_config_get_string_tmp("transfer.credentialsinurl", &value))
627627
return;
628628

629629
if (!strcmp("warn", value))
@@ -633,7 +633,7 @@ static void validate_remote_url(struct remote *remote)
633633
else if (!strcmp("allow", value))
634634
return;
635635
else
636-
die(_("unrecognized value fetch.credentialsInURL: '%s'"), value);
636+
die(_("unrecognized value transfer.credentialsInURL: '%s'"), value);
637637

638638
for (i = 0; i < remote->url_nr; i++) {
639639
struct url_info url_info = { 0 };

t/t5516-fetch-push.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,31 +1836,31 @@ test_expect_success 'refuse to push a hidden ref, and make sure do not pollute t
18361836

18371837
test_expect_success 'fetch warns or fails when using username:password' '
18381838
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 &&
18401840
! grep "$message" err &&
18411841
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 &&
18431843
grep "warning: $message" err >warnings &&
18441844
test_line_count = 3 warnings &&
18451845
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 &&
18471847
grep "fatal: $message" err >warnings &&
18481848
test_line_count = 1 warnings &&
18491849
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 &&
18511851
grep "fatal: $message" err >warnings &&
18521852
test_line_count = 1 warnings
18531853
'
18541854

18551855

18561856
test_expect_success 'push warns or fails when using username:password' '
18571857
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 &&
18591859
! grep "$message" err &&
18601860
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 &&
18621862
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 &&
18641864
grep "fatal: $message" err >warnings &&
18651865
test_line_count = 1 warnings
18661866
'

t/t5601-clone.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,24 +73,24 @@ test_expect_success 'clone respects GIT_WORK_TREE' '
7373

7474
test_expect_success 'clone warns or fails when using username:password' '
7575
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 &&
7777
! grep "$message" err &&
7878
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 &&
8080
grep "warning: $message" err >warnings &&
8181
test_line_count = 2 warnings &&
8282
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 &&
8484
grep "fatal: $message" err >warnings &&
8585
test_line_count = 1 warnings &&
8686
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 &&
8888
grep "fatal: $message" err >warnings &&
8989
test_line_count = 1 warnings
9090
'
9191

9292
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 &&
9494
! grep "uses plaintext credentials" err
9595
'
9696

0 commit comments

Comments
 (0)