Show More
@@ -814,6 +814,15 b" coreconfigitem('sparse', 'missingwarning" | |||
|
814 | 814 | coreconfigitem('subrepos', 'allowed', |
|
815 | 815 | default=dynamicdefault, # to make backporting simpler |
|
816 | 816 | ) |
|
817 | coreconfigitem('subrepos', 'hg:allowed', | |
|
818 | default=dynamicdefault, | |
|
819 | ) | |
|
820 | coreconfigitem('subrepos', 'git:allowed', | |
|
821 | default=dynamicdefault, | |
|
822 | ) | |
|
823 | coreconfigitem('subrepos', 'svn:allowed', | |
|
824 | default=dynamicdefault, | |
|
825 | ) | |
|
817 | 826 | coreconfigitem('templates', '.*', |
|
818 | 827 | default=None, |
|
819 | 828 | generic=True, |
@@ -1899,20 +1899,40 b' relative path alone. The rules are appli' | |||
|
1899 | 1899 | This section contains options that control the behavior of the |
|
1900 | 1900 | subrepositories feature. See also :hg:`help subrepos`. |
|
1901 | 1901 | |
|
1902 | Security note: auditing in Mercurial is known to be insufficient to | |
|
1903 | prevent clone-time code execution with carefully constructed Git | |
|
1904 | subrepos. It is unknown if a similar detect is present in Subversion | |
|
1905 | subrepos. Both Git and Subversion subrepos are disabled by default | |
|
1906 | out of security concerns. These subrepo types can be enabled using | |
|
1907 | the respective options below. | |
|
1908 | ||
|
1902 | 1909 | ``allowed`` |
|
1903 |
|
|
|
1904 | directory. | |
|
1905 | ||
|
1906 | When disallowed, any commands including :hg:`update` will fail if | |
|
1907 | subrepositories are involved. | |
|
1908 | ||
|
1909 | Security note: auditing in Mercurial is known to be insufficient | |
|
1910 | to prevent clone-time code execution with carefully constructed | |
|
1911 | Git subrepos. It is unknown if a similar defect is present in | |
|
1912 | Subversion subrepos, so both are disabled by default out of an | |
|
1913 | abundance of caution. Re-enable such subrepos via this setting | |
|
1914 | with caution. | |
|
1915 | (default: `hg`) | |
|
1910 | Whether subrepositories are allowed in the working directory. | |
|
1911 | ||
|
1912 | When false, commands involving subrepositories (like :hg:`update`) | |
|
1913 | will fail for all subrepository types. | |
|
1914 | (default: true) | |
|
1915 | ||
|
1916 | ``hg:allowed`` | |
|
1917 | Whether Mercurial subrepositories are allowed in the working | |
|
1918 | directory. This option only has an effect if ``subrepos.allowed`` | |
|
1919 | is true. | |
|
1920 | (default: true) | |
|
1921 | ||
|
1922 | ``git:allowed`` | |
|
1923 | Whether Git subrepositories are allowed in the working directory. | |
|
1924 | This option only has an effect if ``subrepos.allowed`` is true. | |
|
1925 | ||
|
1926 | See the security note above before enabling Git subrepos. | |
|
1927 | (default: false) | |
|
1928 | ||
|
1929 | ``svn:allowed`` | |
|
1930 | Whether Subversion subrepositories are allowed in the working | |
|
1931 | directory. This option only has an effect if ``subrepos.allowed`` | |
|
1932 | is true. | |
|
1933 | ||
|
1934 | See the security note above before enabling Subversion subrepos. | |
|
1935 | (default: false) | |
|
1916 | 1936 | |
|
1917 | 1937 | ``templatealias`` |
|
1918 | 1938 | ----------------- |
@@ -365,10 +365,24 b' def _auditsubrepopath(repo, path):' | |||
|
365 | 365 | if repo.wvfs.islink(path): |
|
366 | 366 | raise error.Abort(_("subrepo '%s' traverses symbolic link") % path) |
|
367 | 367 | |
|
368 | SUBREPO_ALLOWED_DEFAULTS = { | |
|
369 | 'hg': True, | |
|
370 | 'git': False, | |
|
371 | 'svn': False, | |
|
372 | } | |
|
373 | ||
|
368 | 374 | def _checktype(ui, kind): |
|
369 | if kind not in ui.configlist('subrepos', 'allowed', ['hg']): | |
|
370 | raise error.Abort(_("subrepo type %s not allowed") % kind, | |
|
375 | # subrepos.allowed is a master kill switch. If disabled, subrepos are | |
|
376 | # disabled period. | |
|
377 | if not ui.configbool('subrepos', 'allowed', True): | |
|
378 | raise error.Abort(_('subrepos not enabled'), | |
|
371 | 379 | hint=_("see 'hg help config.subrepos' for details")) |
|
380 | ||
|
381 | default = SUBREPO_ALLOWED_DEFAULTS.get(kind, False) | |
|
382 | if not ui.configbool('subrepos', '%s:allowed' % kind, default): | |
|
383 | raise error.Abort(_('%s subrepos not allowed') % kind, | |
|
384 | hint=_("see 'hg help config.subrepos' for details")) | |
|
385 | ||
|
372 | 386 | if kind not in types: |
|
373 | 387 | raise error.Abort(_('unknown subrepo type %s') % kind) |
|
374 | 388 |
@@ -8,7 +8,7 b'' | |||
|
8 | 8 | $ echo "convert=" >> $HGRCPATH |
|
9 | 9 | $ cat >> $HGRCPATH <<EOF |
|
10 | 10 | > [subrepos] |
|
11 |
> allowed = |
|
|
11 | > git:allowed = true | |
|
12 | 12 | > EOF |
|
13 | 13 | $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME |
|
14 | 14 | $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL |
@@ -6,7 +6,8 b'' | |||
|
6 | 6 | > [diff] |
|
7 | 7 | > nodates = 1 |
|
8 | 8 | > [subrepos] |
|
9 |
> allowed = |
|
|
9 | > allowed = true | |
|
10 | > svn:allowed = true | |
|
10 | 11 | > EOF |
|
11 | 12 | |
|
12 | 13 | fn to create new repository, and cd into it |
@@ -45,7 +45,7 b' add subrepo clone' | |||
|
45 | 45 | git subrepo is disabled by default |
|
46 | 46 | |
|
47 | 47 | $ hg commit -m 'new git subrepo' |
|
48 |
abort: |
|
|
48 | abort: git subrepos not allowed | |
|
49 | 49 | (see 'hg help config.subrepos' for details) |
|
50 | 50 | [255] |
|
51 | 51 | |
@@ -53,7 +53,7 b' so enable it' | |||
|
53 | 53 | |
|
54 | 54 | $ cat >> $HGRCPATH <<EOF |
|
55 | 55 | > [subrepos] |
|
56 |
> allowed = |
|
|
56 | > git:allowed = true | |
|
57 | 57 | > EOF |
|
58 | 58 | |
|
59 | 59 | $ hg commit -m 'new git subrepo' |
@@ -106,30 +106,22 b' clone root' | |||
|
106 | 106 | |
|
107 | 107 | clone with subrepo disabled (update should fail) |
|
108 | 108 | |
|
109 | $ hg clone t -U tc2 --config subrepos.allowed= | |
|
110 | $ hg update -R tc2 --config subrepos.allowed= | |
|
111 |
abort: subrepo |
|
|
109 | $ hg clone t -U tc2 --config subrepos.allowed=false | |
|
110 | $ hg update -R tc2 --config subrepos.allowed=false | |
|
111 | abort: subrepos not enabled | |
|
112 | 112 | (see 'hg help config.subrepos' for details) |
|
113 | 113 | [255] |
|
114 | 114 | $ ls tc2 |
|
115 | 115 | a |
|
116 | 116 | |
|
117 | $ hg clone t tc3 --config subrepos.allowed= | |
|
117 | $ hg clone t tc3 --config subrepos.allowed=false | |
|
118 | 118 | updating to branch default |
|
119 |
abort: subrepo |
|
|
119 | abort: subrepos not enabled | |
|
120 | 120 | (see 'hg help config.subrepos' for details) |
|
121 | 121 | [255] |
|
122 | 122 | $ ls tc3 |
|
123 | 123 | a |
|
124 | 124 | |
|
125 | $ hg clone t tc4 --config subrepos.allowed=hg | |
|
126 | updating to branch default | |
|
127 | abort: subrepo type git not allowed | |
|
128 | (see 'hg help config.subrepos' for details) | |
|
129 | [255] | |
|
130 | $ ls tc4 | |
|
131 | a | |
|
132 | ||
|
133 | 125 | update to previous substate |
|
134 | 126 | |
|
135 | 127 | $ cd tc |
@@ -61,7 +61,7 b' add first svn sub with leading whitespac' | |||
|
61 | 61 | svn subrepo is disabled by default |
|
62 | 62 | |
|
63 | 63 | $ hg ci -m1 |
|
64 |
abort: s |
|
|
64 | abort: svn subrepos not allowed | |
|
65 | 65 | (see 'hg help config.subrepos' for details) |
|
66 | 66 | [255] |
|
67 | 67 | |
@@ -69,7 +69,7 b' so enable it' | |||
|
69 | 69 | |
|
70 | 70 | $ cat >> $HGRCPATH <<EOF |
|
71 | 71 | > [subrepos] |
|
72 |
> allowed = |
|
|
72 | > svn:allowed = true | |
|
73 | 73 | > EOF |
|
74 | 74 | |
|
75 | 75 | $ hg ci -m1 |
@@ -488,30 +488,40 b' clone' | |||
|
488 | 488 | |
|
489 | 489 | clone with subrepo disabled (update should fail) |
|
490 | 490 | |
|
491 | $ hg clone t -U tc2 --config subrepos.allowed= | |
|
492 | $ hg update -R tc2 --config subrepos.allowed= | |
|
493 |
abort: subrepo |
|
|
491 | $ hg clone t -U tc2 --config subrepos.allowed=false | |
|
492 | $ hg update -R tc2 --config subrepos.allowed=false | |
|
493 | abort: subrepos not enabled | |
|
494 | 494 | (see 'hg help config.subrepos' for details) |
|
495 | 495 | [255] |
|
496 | 496 | $ ls tc2 |
|
497 | 497 | a |
|
498 | 498 | |
|
499 | $ hg clone t tc3 --config subrepos.allowed= | |
|
499 | $ hg clone t tc3 --config subrepos.allowed=false | |
|
500 | 500 | updating to branch default |
|
501 |
abort: subrepo |
|
|
501 | abort: subrepos not enabled | |
|
502 | 502 | (see 'hg help config.subrepos' for details) |
|
503 | 503 | [255] |
|
504 | 504 | $ ls tc3 |
|
505 | 505 | a |
|
506 | 506 | |
|
507 | $ hg clone t tc4 --config subrepos.allowed=git | |
|
508 | updating to branch default | |
|
509 | abort: subrepo type hg not allowed | |
|
507 | And again with just the hg type disabled | |
|
508 | ||
|
509 | $ hg clone t -U tc4 --config subrepos.hg:allowed=false | |
|
510 | $ hg update -R tc4 --config subrepos.hg:allowed=false | |
|
511 | abort: hg subrepos not allowed | |
|
510 | 512 | (see 'hg help config.subrepos' for details) |
|
511 | 513 | [255] |
|
512 | 514 | $ ls tc4 |
|
513 | 515 | a |
|
514 | 516 | |
|
517 | $ hg clone t tc5 --config subrepos.hg:allowed=false | |
|
518 | updating to branch default | |
|
519 | abort: hg subrepos not allowed | |
|
520 | (see 'hg help config.subrepos' for details) | |
|
521 | [255] | |
|
522 | $ ls tc5 | |
|
523 | a | |
|
524 | ||
|
515 | 525 | push |
|
516 | 526 | |
|
517 | 527 | $ cd tc |
General Comments 0
You need to be logged in to leave comments.
Login now