/[packages]/updates/5/mercurial/current/SOURCES/hg-subrepo-bsc1071715-fix03.patch
ViewVC logotype

Contents of /updates/5/mercurial/current/SOURCES/hg-subrepo-bsc1071715-fix03.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1186276 - (show annotations) (download)
Thu Dec 28 16:04:19 2017 UTC (6 years, 3 months ago) by luigiwalser
File size: 4265 byte(s)
rediff patches from opensuse to fix CVE-2017-17458
1 # HG changeset patch
2 # User Yuya Nishihara <yuya@tcha.org>
3 # Date 1509884527 -32400
4 # Sun Nov 05 21:22:07 2017 +0900
5 # Branch stable
6 # Node ID 5e27afeddaee6754de902c5615afded32c6d87a3
7 # Parent 071cbeba421217d722a69a5d614ec934684d62d5
8 subrepo: add config option to reject any subrepo operations (SEC)
9
10 This is an alternative workaround for the issue5730.
11
12 Perhaps this is the simplest way of disabling subrepo operations. It does
13 nothing clever, but just aborts if Mercurial starts accessing to a subrepo.
14
15 I think Greg's patch is more useful since it allows us to at least check
16 out the parent repository. However, that would be confusing if the default
17 is flipped to checkout=False and subrepos are silently ignored.
18
19 I don't like the config name 'allowed', but I couldn't get any better name.
20
21 ---
22 mercurial/help/config.txt | 13 +++++++++++++
23 mercurial/subrepo.py | 19 +++++++++++++------
24 tests/test-subrepo-git.t | 20 ++++++++++++++++++++
25 tests/test-subrepo.t | 20 ++++++++++++++++++++
26 4 files changed, 66 insertions(+), 6 deletions(-)
27
28 --- a/mercurial/help/config.txt
29 +++ b/mercurial/help/config.txt
30 @@ -1488,6 +1488,19 @@ Relative subrepository paths are first m
31 rewrite rules are then applied on the full (absolute) path. The rules
32 are applied in definition order.
33
34 +``subrepos``
35 +------------
36 +
37 +This section contains options that control the behavior of the
38 +subrepositories feature. See also :hg:`help subrepos`.
39 +
40 +``allowed``
41 + Whether subrepository operation in the working directory is allowed.
42 +
43 + When disabled, any commands including :hg:`update` will fail if
44 + subrepositories are involved.
45 + (default: True)
46 +
47 ``trusted``
48 -----------
49
50 --- a/mercurial/subrepo.py
51 +++ b/mercurial/subrepo.py
52 @@ -346,6 +346,13 @@ def _auditsubrepopath(repo, path):
53 if repo.wvfs.islink(path):
54 raise util.Abort(_("subrepo '%s' traverses symbolic link") % path)
55
56 +def _checktype(ui, kind):
57 + if not ui.configbool('subrepos', 'allowed', True):
58 + raise util.Abort(_("subrepo not allowed"),
59 + hint=_("see 'hg help config.subrepos' for details"))
60 + if kind not in types:
61 + raise util.Abort(_('unknown subrepo type %s') % kind)
62 +
63 def subrepo(ctx, path):
64 """return instance of the right subrepo class for subrepo in path"""
65 # subrepo inherently violates our import layering rules
66 @@ -356,10 +363,10 @@ def subrepo(ctx, path, allowwdir=False,
67 import hg as h
68 hg = h
69
70 - _auditsubrepopath(ctx._repo, path)
71 + repo = ctx._repo
72 + _auditsubrepopath(repo, path)
73 state = ctx.substate[path]
74 - if state[2] not in types:
75 - raise util.Abort(_('unknown subrepo type %s') % state[2])
76 + _checktype(repo.ui, state[2])
77 return types[state[2]](ctx, path, state[:2])
78
79 def newcommitphase(ui, ctx):
80 --- a/tests/test-subrepo-git.t
81 +++ b/tests/test-subrepo-git.t
82 @@ -81,9 +81,29 @@ clone root
83 path s
84 source ../gitroot
85 revision 126f2a14290cd5ce061fdedc430170e8d39e1c5a
86 + $ cd ..
87 +
88 +clone with subrepo disabled (update should fail)
89 +
90 + $ hg clone t -U tc2 --config subrepos.allowed=false
91 + $ hg update -R tc2 --config subrepos.allowed=false
92 + abort: subrepo not allowed
93 + (see 'hg help config.subrepos' for details)
94 + [255]
95 + $ ls tc2
96 + a
97 +
98 + $ hg clone t tc3 --config subrepos.allowed=false
99 + updating to branch default
100 + abort: subrepo not allowed
101 + (see 'hg help config.subrepos' for details)
102 + [255]
103 + $ ls tc3
104 + a
105
106 update to previous substate
107
108 + $ cd tc
109 $ hg update 1 -q
110 $ cat s/g
111 g
112 --- a/tests/test-subrepo.t
113 +++ b/tests/test-subrepo.t
114 @@ -471,9 +471,29 @@ clone
115 path t
116 source t
117 revision 20a0db6fbf6c3d2836e6519a642ae929bfc67c0e
118 + $ cd ..
119 +
120 +clone with subrepo disabled (update should fail)
121 +
122 + $ hg clone t -U tc2 --config subrepos.allowed=false
123 + $ hg update -R tc2 --config subrepos.allowed=false
124 + abort: subrepo not allowed
125 + (see 'hg help config.subrepos' for details)
126 + [255]
127 + $ ls tc2
128 + a
129 +
130 + $ hg clone t tc3 --config subrepos.allowed=false
131 + updating to branch default
132 + abort: subrepo not allowed
133 + (see 'hg help config.subrepos' for details)
134 + [255]
135 + $ ls tc3
136 + a
137
138 push
139
140 + $ cd tc
141 $ echo bah > t/t
142 $ hg ci -m11
143 committing subrepository t

  ViewVC Help
Powered by ViewVC 1.1.30